Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
4eab9476
Commit
4eab9476
authored
May 17, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Detect use of spring.profiles.include as a YAML list"
See gh-26205
parent
80ad6385
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
ConfigDataEnvironmentTests.java
...ework/boot/context/config/ConfigDataEnvironmentTests.java
+8
-9
No files found.
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentTests.java
View file @
4eab9476
...
@@ -47,7 +47,6 @@ import org.springframework.mock.env.MockPropertySource;
...
@@ -47,7 +47,6 @@ import org.springframework.mock.env.MockPropertySource;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatExceptionOfType
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatExceptionOfType
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatNoException
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
/**
...
@@ -221,7 +220,7 @@ class ConfigDataEnvironmentTests {
...
@@ -221,7 +220,7 @@ class ConfigDataEnvironmentTests {
@ParameterizedTest
@ParameterizedTest
@CsvSource
({
"include"
,
"include[0]"
})
@CsvSource
({
"include"
,
"include[0]"
})
void
processAndApply
ThrowExceptionWhenActivateProfileWithProfileInclude
(
String
property
,
TestInfo
info
)
{
void
processAndApply
WhenHasProfileIncludeInProfileSpecificDocumentThrowsException
(
String
property
,
TestInfo
info
)
{
this
.
environment
.
setProperty
(
"spring.config.location"
,
getConfigLocation
(
info
));
this
.
environment
.
setProperty
(
"spring.config.location"
,
getConfigLocation
(
info
));
ConfigDataEnvironment
configDataEnvironment
=
new
ConfigDataEnvironment
(
this
.
logFactory
,
this
.
bootstrapContext
,
ConfigDataEnvironment
configDataEnvironment
=
new
ConfigDataEnvironment
(
this
.
logFactory
,
this
.
bootstrapContext
,
this
.
environment
,
this
.
resourceLoader
,
this
.
additionalProfiles
,
null
)
{
this
.
environment
,
this
.
resourceLoader
,
this
.
additionalProfiles
,
null
)
{
...
@@ -237,16 +236,15 @@ class ConfigDataEnvironmentTests {
...
@@ -237,16 +236,15 @@ class ConfigDataEnvironmentTests {
mock
(
ConfigDataResource
.
class
),
false
,
data
,
0
));
mock
(
ConfigDataResource
.
class
),
false
,
data
,
0
));
return
super
.
createContributors
(
contributors
);
return
super
.
createContributors
(
contributors
);
}
}
};
};
assertThatExceptionOfType
(
InactiveConfigDataAccessException
.
class
)
assertThatExceptionOfType
(
InactiveConfigDataAccessException
.
class
)
.
isThrownBy
(
configDataEnvironment:
:
processAndApply
);
.
isThrownBy
(
configDataEnvironment:
:
processAndApply
);
}
}
@ParameterizedTest
@ParameterizedTest
@CsvSource
({
"spring.config.activate.on-profile"
,
"spring.profiles.include"
,
"spring.profiles.include[0]"
})
@CsvSource
({
"spring.profiles.include"
,
"spring.profiles.include[0]"
})
void
processAndApplyDoseNotThrowExceptionWhenUsingEitherActivateProfileOrProfileInclude
(
String
property
,
void
processAndApplyIncludesProfilesFromSpringProfilesInclude
(
String
property
,
TestInfo
info
)
{
TestInfo
info
)
{
this
.
environment
.
setProperty
(
"spring.config.location"
,
getConfigLocation
(
info
));
this
.
environment
.
setProperty
(
"spring.config.location"
,
getConfigLocation
(
info
));
ConfigDataEnvironment
configDataEnvironment
=
new
ConfigDataEnvironment
(
this
.
logFactory
,
this
.
bootstrapContext
,
ConfigDataEnvironment
configDataEnvironment
=
new
ConfigDataEnvironment
(
this
.
logFactory
,
this
.
bootstrapContext
,
this
.
environment
,
this
.
resourceLoader
,
this
.
additionalProfiles
,
null
)
{
this
.
environment
,
this
.
resourceLoader
,
this
.
additionalProfiles
,
null
)
{
...
@@ -255,15 +253,16 @@ class ConfigDataEnvironmentTests {
...
@@ -255,15 +253,16 @@ class ConfigDataEnvironmentTests {
protected
ConfigDataEnvironmentContributors
createContributors
(
protected
ConfigDataEnvironmentContributors
createContributors
(
List
<
ConfigDataEnvironmentContributor
>
contributors
)
{
List
<
ConfigDataEnvironmentContributor
>
contributors
)
{
Map
<
String
,
Object
>
source
=
new
LinkedHashMap
<>();
Map
<
String
,
Object
>
source
=
new
LinkedHashMap
<>();
source
.
put
(
property
,
"
only
"
);
source
.
put
(
property
,
"
included
"
);
ConfigData
data
=
new
ConfigData
(
Collections
.
singleton
(
new
MapPropertySource
(
"test"
,
source
)));
ConfigData
data
=
new
ConfigData
(
Collections
.
singleton
(
new
MapPropertySource
(
"test"
,
source
)));
contributors
.
add
(
ConfigDataEnvironmentContributor
.
ofUnboundImport
(
ConfigDataLocation
.
of
(
"test"
),
contributors
.
add
(
ConfigDataEnvironmentContributor
.
ofUnboundImport
(
ConfigDataLocation
.
of
(
"test"
),
mock
(
ConfigDataResource
.
class
),
false
,
data
,
0
));
mock
(
ConfigDataResource
.
class
),
false
,
data
,
0
));
return
super
.
createContributors
(
contributors
);
return
super
.
createContributors
(
contributors
);
}
}
};
assertThatNoException
().
isThrownBy
(
configDataEnvironment:
:
processAndApply
);
};
configDataEnvironment
.
processAndApply
();
assertThat
(
this
.
environment
.
getActiveProfiles
()).
containsExactly
(
"included"
);
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment