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
075a745e
Commit
075a745e
authored
Aug 16, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Allow properties to be configured using slice test annotations"
Closes gh-14052
parent
0cf1749e
Changes
34
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
107 additions
and
115 deletions
+107
-115
spring-boot-features.adoc
...ing-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+4
-2
DataLdapTest.java
...ework/boot/test/autoconfigure/data/ldap/DataLdapTest.java
+1
-0
DataLdapTestContextBootstrapper.java
...oconfigure/data/ldap/DataLdapTestContextBootstrapper.java
+4
-7
DataMongoTest.java
...ork/boot/test/autoconfigure/data/mongo/DataMongoTest.java
+1
-0
DataMongoTestContextBootstrapper.java
...onfigure/data/mongo/DataMongoTestContextBootstrapper.java
+4
-7
DataNeo4jTest.java
...ork/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java
+1
-0
DataNeo4jTestContextBootstrapper.java
...onfigure/data/neo4j/DataNeo4jTestContextBootstrapper.java
+4
-7
DataRedisTest.java
...ork/boot/test/autoconfigure/data/redis/DataRedisTest.java
+1
-0
DataRedisTestContextBootstrapper.java
...onfigure/data/redis/DataRedisTestContextBootstrapper.java
+4
-7
JdbcTest.java
...pringframework/boot/test/autoconfigure/jdbc/JdbcTest.java
+1
-0
JdbcTestContextBootstrapper.java
.../test/autoconfigure/jdbc/JdbcTestContextBootstrapper.java
+4
-7
JooqTest.java
...pringframework/boot/test/autoconfigure/jooq/JooqTest.java
+1
-0
JooqTestContextBootstrapper.java
.../test/autoconfigure/jooq/JooqTestContextBootstrapper.java
+4
-7
JsonTest.java
...pringframework/boot/test/autoconfigure/json/JsonTest.java
+3
-1
JsonTestContextBootstrapper.java
.../test/autoconfigure/json/JsonTestContextBootstrapper.java
+4
-7
DataJpaTest.java
...ramework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java
+1
-0
DataJpaTestContextBootstrapper.java
...autoconfigure/orm/jpa/DataJpaTestContextBootstrapper.java
+4
-7
RestClientTest.java
...rk/boot/test/autoconfigure/web/client/RestClientTest.java
+1
-0
RestClientTestContextBootstrapper.java
...nfigure/web/client/RestClientTestContextBootstrapper.java
+4
-7
WebFluxTest.java
...ork/boot/test/autoconfigure/web/reactive/WebFluxTest.java
+1
-0
WebFluxTestContextBootstrapper.java
...onfigure/web/reactive/WebFluxTestContextBootstrapper.java
+4
-7
WebMvcTest.java
...ework/boot/test/autoconfigure/web/servlet/WebMvcTest.java
+1
-0
WebMvcTestContextBootstrapper.java
...oconfigure/web/servlet/WebMvcTestContextBootstrapper.java
+4
-7
DataLdapTestPropertiesIntegrationTests.java
...ure/data/ldap/DataLdapTestPropertiesIntegrationTests.java
+4
-3
DataMongoTestPropertiesIntegrationTests.java
...e/data/mongo/DataMongoTestPropertiesIntegrationTests.java
+4
-3
DataNeo4jTestPropertiesIntegrationTests.java
...e/data/neo4j/DataNeo4jTestPropertiesIntegrationTests.java
+5
-4
DataRedisTestPropertiesIntegrationTests.java
...e/data/redis/DataRedisTestPropertiesIntegrationTests.java
+5
-4
JdbcTestPropertiesIntegrationTests.java
...utoconfigure/jdbc/JdbcTestPropertiesIntegrationTests.java
+4
-3
JooqTestPropertiesIntegrationTests.java
...utoconfigure/jooq/JooqTestPropertiesIntegrationTests.java
+4
-3
JsonTestPropertiesIntegrationTests.java
...utoconfigure/json/JsonTestPropertiesIntegrationTests.java
+4
-3
DataJpaTestPropertiesIntegrationTests.java
...figure/orm/jpa/DataJpaTestPropertiesIntegrationTests.java
+4
-3
RestClientTestPropertiesIntegrationTests.java
.../web/client/RestClientTestPropertiesIntegrationTests.java
+4
-3
WebFluxTestPropertiesIntegrationTests.java
...e/web/reactive/WebFluxTestPropertiesIntegrationTests.java
+4
-3
WebMvcTestPropertiesIntegrationTests.java
...ure/web/servlet/WebMvcTestPropertiesIntegrationTests.java
+4
-3
No files found.
spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
075a745e
...
...
@@ -403,8 +403,10 @@ sensible overriding of values. Properties are considered in the following order:
on your home directory (`~/.spring-boot-devtools.properties` when devtools is active).
. {spring-javadoc}/test/context/TestPropertySource.{dc-ext}[`@TestPropertySource`]
annotations on your tests.
. {dc-spring-boot-test}/context/SpringBootTest.{dc-ext}[`@SpringBootTest#properties`]
annotation attribute on your tests.
. `properties` attribute on your tests. Available on
{dc-spring-boot-test}/context/SpringBootTest.{dc-ext}[`@SpringBootTest`] and the
<<boot-features-testing-spring-boot-applications-testing-autoconfigured-tests,test
annotations for testing a particular slice of your application>>.
. Command line arguments.
. Properties from `SPRING_APPLICATION_JSON` (inline JSON embedded in an environment
variable or system property).
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java
View file @
075a745e
...
...
@@ -68,6 +68,7 @@ public @interface DataLdapTest {
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
* @return the properties to add
* @since 2.1.0
*/
String
[]
properties
()
default
{};
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestContextBootstrapper.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,16 +25,13 @@ import org.springframework.test.context.TestContextBootstrapper;
*
* @author Artsiom Yudovin
*/
public
class
DataLdapTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
class
DataLdapTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
DataLdapTest
annotation
=
getDataLdapTestAnnotation
(
testClass
);
DataLdapTest
annotation
=
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
DataLdapTest
.
class
);
return
(
annotation
!=
null
)
?
annotation
.
properties
()
:
null
;
}
private
DataLdapTest
getDataLdapTestAnnotation
(
Class
<?>
testClass
)
{
return
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
DataLdapTest
.
class
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java
View file @
075a745e
...
...
@@ -69,6 +69,7 @@ public @interface DataMongoTest {
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
* @return the properties to add
* @since 2.1.0
*/
String
[]
properties
()
default
{};
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestContextBootstrapper.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,16 +25,13 @@ import org.springframework.test.context.TestContextBootstrapper;
*
* @author Artsiom Yudovin
*/
public
class
DataMongoTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
class
DataMongoTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
DataMongoTest
annotation
=
getDataMongoTestAnnotation
(
testClass
);
DataMongoTest
annotation
=
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
DataMongoTest
.
class
);
return
(
annotation
!=
null
)
?
annotation
.
properties
()
:
null
;
}
private
DataMongoTest
getDataMongoTestAnnotation
(
Class
<?>
testClass
)
{
return
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
DataMongoTest
.
class
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java
View file @
075a745e
...
...
@@ -72,6 +72,7 @@ public @interface DataNeo4jTest {
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
* @return the properties to add
* @since 2.1.0
*/
String
[]
properties
()
default
{};
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestContextBootstrapper.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,16 +25,13 @@ import org.springframework.test.context.TestContextBootstrapper;
*
* @author Artsiom Yudovin
*/
public
class
DataNeo4jTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
class
DataNeo4jTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
DataNeo4jTest
annotation
=
getDataNeo4jTestAnnotation
(
testClass
);
DataNeo4jTest
annotation
=
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
DataNeo4jTest
.
class
);
return
(
annotation
!=
null
)
?
annotation
.
properties
()
:
null
;
}
private
DataNeo4jTest
getDataNeo4jTestAnnotation
(
Class
<?>
testClass
)
{
return
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
DataNeo4jTest
.
class
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java
View file @
075a745e
...
...
@@ -65,6 +65,7 @@ public @interface DataRedisTest {
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
* @return the properties to add
* @since 2.1.0
*/
String
[]
properties
()
default
{};
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestContextBootstrapper.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,16 +25,13 @@ import org.springframework.test.context.TestContextBootstrapper;
*
* @author Artsiom Yudovin
*/
public
class
DataRedisTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
class
DataRedisTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
DataRedisTest
annotation
=
getDataRedisTestAnnotation
(
testClass
);
DataRedisTest
annotation
=
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
DataRedisTest
.
class
);
return
(
annotation
!=
null
)
?
annotation
.
properties
()
:
null
;
}
private
DataRedisTest
getDataRedisTestAnnotation
(
Class
<?>
testClass
)
{
return
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
DataRedisTest
.
class
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java
View file @
075a745e
...
...
@@ -81,6 +81,7 @@ public @interface JdbcTest {
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
* @return the properties to add
* @since 2.1.0
*/
String
[]
properties
()
default
{};
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestContextBootstrapper.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,16 +25,13 @@ import org.springframework.test.context.TestContextBootstrapper;
*
* @author Artsiom Yudovin
*/
public
class
JdbcTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
class
JdbcTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
JdbcTest
annotation
=
getJdbcAnnotation
(
testClass
);
JdbcTest
annotation
=
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
JdbcTest
.
class
);
return
(
annotation
!=
null
)
?
annotation
.
properties
()
:
null
;
}
private
JdbcTest
getJdbcAnnotation
(
Class
<?>
testClass
)
{
return
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
JdbcTest
.
class
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java
View file @
075a745e
...
...
@@ -72,6 +72,7 @@ public @interface JooqTest {
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
* @return the properties to add
* @since 2.1.0
*/
String
[]
properties
()
default
{};
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestContextBootstrapper.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,16 +25,13 @@ import org.springframework.test.context.TestContextBootstrapper;
*
* @author Artsiom Yudovin
*/
public
class
JooqTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
class
JooqTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
JooqTest
annotation
=
getJooqTestAnnotation
(
testClass
);
JooqTest
annotation
=
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
JooqTest
.
class
);
return
(
annotation
!=
null
)
?
annotation
.
properties
()
:
null
;
}
private
JooqTest
getJooqTestAnnotation
(
Class
<?>
testClass
)
{
return
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
JooqTest
.
class
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -51,6 +51,7 @@ import org.springframework.test.context.BootstrapWith;
* {@link AutoConfigureJsonTesters @AutoConfigureJsonTesters} annotation.
*
* @author Phillip Webb
* @author Artsiom Yudovin
* @see AutoConfigureJson
* @see AutoConfigureJsonTesters
* @see AutoConfigureCache
...
...
@@ -73,6 +74,7 @@ public @interface JsonTest {
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
* @return the properties to add
* @since 2.1.0
*/
String
[]
properties
()
default
{};
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestContextBootstrapper.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,16 +25,13 @@ import org.springframework.test.context.TestContextBootstrapper;
*
* @author Artsiom Yudovin
*/
public
class
JsonTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
class
JsonTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
JsonTest
annotation
=
getJsonTestAnnotation
(
testClass
);
JsonTest
annotation
=
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
JsonTest
.
class
);
return
(
annotation
!=
null
)
?
annotation
.
properties
()
:
null
;
}
private
JsonTest
getJsonTestAnnotation
(
Class
<?>
testClass
)
{
return
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
JsonTest
.
class
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java
View file @
075a745e
...
...
@@ -85,6 +85,7 @@ public @interface DataJpaTest {
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
* @return the properties to add
* @since 2.1.0
*/
String
[]
properties
()
default
{};
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestContextBootstrapper.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,16 +25,13 @@ import org.springframework.test.context.TestContextBootstrapper;
*
* @author Artsiom Yudovin
*/
public
class
DataJpaTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
class
DataJpaTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
DataJpaTest
annotation
=
getDataJpaAnnotation
(
testClass
);
DataJpaTest
annotation
=
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
DataJpaTest
.
class
);
return
(
annotation
!=
null
)
?
annotation
.
properties
()
:
null
;
}
private
DataJpaTest
getDataJpaAnnotation
(
Class
<?>
testClass
)
{
return
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
DataJpaTest
.
class
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java
View file @
075a745e
...
...
@@ -81,6 +81,7 @@ public @interface RestClientTest {
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
* @return the properties to add
* @since 2.1.0
*/
String
[]
properties
()
default
{};
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestContextBootstrapper.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,16 +25,13 @@ import org.springframework.test.context.TestContextBootstrapper;
*
* @author Artsiom Yudovin
*/
public
class
RestClientTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
class
RestClientTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
RestClientTest
annotation
=
getRestClientAnnotation
(
testClass
);
RestClientTest
annotation
=
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
RestClientTest
.
class
);
return
(
annotation
!=
null
)
?
annotation
.
properties
()
:
null
;
}
private
RestClientTest
getRestClientAnnotation
(
Class
<?>
testClass
)
{
return
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
RestClientTest
.
class
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java
View file @
075a745e
...
...
@@ -88,6 +88,7 @@ public @interface WebFluxTest {
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
* @return the properties to add
* @since 2.1.0
*/
String
[]
properties
()
default
{};
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestContextBootstrapper.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -28,7 +28,7 @@ import org.springframework.test.context.TestContextBootstrapper;
* @author Stephane Nicoll
* @author Artsiom Yudovin
*/
public
class
WebFluxTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
class
WebFluxTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
MergedContextConfiguration
processMergedContextConfiguration
(
...
...
@@ -39,12 +39,9 @@ public class WebFluxTestContextBootstrapper extends SpringBootTestContextBootstr
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
WebFluxTest
annotation
=
getWebFluxTestAnnotation
(
testClass
);
WebFluxTest
annotation
=
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
WebFluxTest
.
class
);
return
(
annotation
!=
null
)
?
annotation
.
properties
()
:
null
;
}
private
WebFluxTest
getWebFluxTestAnnotation
(
Class
<?>
testClass
)
{
return
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
WebFluxTest
.
class
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java
View file @
075a745e
...
...
@@ -90,6 +90,7 @@ public @interface WebMvcTest {
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
* @return the properties to add
* @since 2.1.0
*/
String
[]
properties
()
default
{};
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestContextBootstrapper.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -28,7 +28,7 @@ import org.springframework.test.context.web.WebMergedContextConfiguration;
* @author Phillip Webb
* @author Artsiom Yudovin
*/
public
class
WebMvcTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
class
WebMvcTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
MergedContextConfiguration
processMergedContextConfiguration
(
...
...
@@ -39,12 +39,9 @@ public class WebMvcTestContextBootstrapper extends SpringBootTestContextBootstra
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
WebMvcTest
annotation
=
getWebMvcTestAnnotation
(
testClass
);
WebMvcTest
annotation
=
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
WebMvcTest
.
class
);
return
(
annotation
!=
null
)
?
annotation
.
properties
()
:
null
;
}
private
WebMvcTest
getWebMvcTestAnnotation
(
Class
<?>
testClass
)
{
return
AnnotatedElementUtils
.
getMergedAnnotation
(
testClass
,
WebMvcTest
.
class
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest
EnvironmentProperties
Tests.java
→
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest
PropertiesIntegration
Tests.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -26,13 +26,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link DataLdapTest}.
* Tests for the {@link DataLdapTest#properties properties} attribute of
* {@link DataLdapTest @DataLdapTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@DataLdapTest
(
properties
=
"spring.profiles.active=test"
)
public
class
DataLdapTest
EnvironmentProperties
Tests
{
public
class
DataLdapTest
PropertiesIntegration
Tests
{
@Autowired
private
Environment
environment
;
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest
EnvironmentProperties
Tests.java
→
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest
PropertiesIntegration
Tests.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -26,13 +26,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link DataMongoTest}.
* Tests for the {@link DataMongoTest#properties properties} attribute of
* {@link DataMongoTest @DataMongoTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@DataMongoTest
(
properties
=
"spring.profiles.active=test"
)
public
class
DataMongoTest
EnvironmentProperties
Tests
{
public
class
DataMongoTest
PropertiesIntegration
Tests
{
@Autowired
private
Environment
environment
;
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest
EnvironmentProperties
Tests.java
→
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest
PropertiesIntegration
Tests.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -32,14 +32,15 @@ import org.springframework.test.context.junit4.SpringRunner;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link DataNeo4jTest}.
* Tests for the {@link DataNeo4jTest#properties properties} attribute of
* {@link DataNeo4jTest @DataNeo4jTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@ContextConfiguration
(
initializers
=
DataNeo4jTest
EnvironmentProperties
Tests
.
Initializer
.
class
)
@ContextConfiguration
(
initializers
=
DataNeo4jTest
PropertiesIntegration
Tests
.
Initializer
.
class
)
@DataNeo4jTest
(
properties
=
"spring.profiles.active=test"
)
public
class
DataNeo4jTest
EnvironmentProperties
Tests
{
public
class
DataNeo4jTest
PropertiesIntegration
Tests
{
@ClassRule
public
static
Neo4jContainer
neo4j
=
new
Neo4jContainer
();
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest
EnvironmentProperties
Tests.java
→
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest
PropertiesIntegration
Tests.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -32,14 +32,15 @@ import org.springframework.test.context.junit4.SpringRunner;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link DataRedisTest}.
* Tests for the {@link DataRedisTest#properties properties} attribute of
* {@link DataRedisTest @DataRedisTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@ContextConfiguration
(
initializers
=
DataRedisTest
EnvironmentProperties
Tests
.
Initializer
.
class
)
@ContextConfiguration
(
initializers
=
DataRedisTest
PropertiesIntegration
Tests
.
Initializer
.
class
)
@DataRedisTest
(
properties
=
"spring.profiles.active=test"
)
public
class
DataRedisTest
EnvironmentProperties
Tests
{
public
class
DataRedisTest
PropertiesIntegration
Tests
{
@ClassRule
public
static
RedisContainer
redis
=
new
RedisContainer
();
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest
EnvironmentProperties
Tests.java
→
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest
PropertiesIntegration
Tests.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -26,13 +26,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link JdbcTest}.
* Tests for the {@link JdbcTest#properties properties} attribute of
* {@link JdbcTest @JdbcTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@JdbcTest
(
properties
=
"spring.profiles.active=test"
)
public
class
JdbcTest
EnvironmentProperties
Tests
{
public
class
JdbcTest
PropertiesIntegration
Tests
{
@Autowired
private
Environment
environment
;
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest
EnvironmentProperties
Tests.java
→
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest
PropertiesIntegration
Tests.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -26,13 +26,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link JooqTest}.
* Tests for the {@link JooqTest#properties properties} attribute of
* {@link JooqTest @JooqTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@JooqTest
(
properties
=
"spring.profiles.active=test"
)
public
class
JooqTest
EnvironmentProperties
Tests
{
public
class
JooqTest
PropertiesIntegration
Tests
{
@Autowired
private
Environment
environment
;
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTest
EnvironmentProperties
Tests.java
→
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTest
PropertiesIntegration
Tests.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -26,13 +26,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link JsonTest}.
* Tests for the {@link JsonTest#properties properties} attribute of
* {@link JsonTest @JsonTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@JsonTest
(
properties
=
"spring.profiles.active=test"
)
public
class
JsonTest
EnvironmentProperties
Tests
{
public
class
JsonTest
PropertiesIntegration
Tests
{
@Autowired
private
Environment
environment
;
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest
EnvironmentProperties
Tests.java
→
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest
PropertiesIntegration
Tests.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -26,13 +26,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link DataJpaTest}.
* Tests for the {@link DataJpaTest#properties properties} attribute of
* {@link DataJpaTest @DataJpaTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@DataJpaTest
(
properties
=
"spring.profiles.active=test"
)
public
class
DataJpaTest
EnvironmentProperties
Tests
{
public
class
DataJpaTest
PropertiesIntegration
Tests
{
@Autowired
private
Environment
environment
;
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest
EnvironmentProperties
Tests.java
→
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest
PropertiesIntegration
Tests.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -26,13 +26,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link RestClientTest}.
* Tests for the {@link RestClientTest#properties properties} attribute of
* {@link RestClientTest @RestClientTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@RestClientTest
(
properties
=
"spring.profiles.active=test"
)
public
class
RestClientTest
EnvironmentProperties
Tests
{
public
class
RestClientTest
PropertiesIntegration
Tests
{
@Autowired
private
Environment
environment
;
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest
EnvironmentProperties
Tests.java
→
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest
PropertiesIntegration
Tests.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -26,13 +26,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link WebFluxTest}.
* Tests for the {@link WebFluxTest#properties properties} attribute of
* {@link WebFluxTest @WebFluxTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@WebFluxTest
(
properties
=
"spring.profiles.active=test"
)
public
class
WebFluxTest
EnvironmentProperties
Tests
{
public
class
WebFluxTest
PropertiesIntegration
Tests
{
@Autowired
private
Environment
environment
;
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest
EnvironmentProperties
Tests.java
→
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest
PropertiesIntegration
Tests.java
View file @
075a745e
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -26,13 +26,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link WebMvcTest}.
* Tests for the {@link WebMvcTest#properties properties} attribute of
* {@link WebMvcTest @WebMvcTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@WebMvcTest
(
properties
=
"spring.profiles.active=test"
)
public
class
WebMvcTest
EnvironmentProperties
Tests
{
public
class
WebMvcTest
PropertiesIntegration
Tests
{
@Autowired
private
Environment
environment
;
...
...
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