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
0cf1749e
Commit
0cf1749e
authored
Aug 12, 2018
by
artsiom
Committed by
Andy Wilkinson
Aug 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow properties to be configured using slice test annotations
See gh-14052
parent
29d3ee1b
Changes
33
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
1044 additions
and
20 deletions
+1044
-20
DataLdapTest.java
...ework/boot/test/autoconfigure/data/ldap/DataLdapTest.java
+10
-2
DataLdapTestContextBootstrapper.java
...oconfigure/data/ldap/DataLdapTestContextBootstrapper.java
+40
-0
DataMongoTest.java
...ork/boot/test/autoconfigure/data/mongo/DataMongoTest.java
+10
-2
DataMongoTestContextBootstrapper.java
...onfigure/data/mongo/DataMongoTestContextBootstrapper.java
+40
-0
DataNeo4jTest.java
...ork/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java
+10
-2
DataNeo4jTestContextBootstrapper.java
...onfigure/data/neo4j/DataNeo4jTestContextBootstrapper.java
+40
-0
DataRedisTest.java
...ork/boot/test/autoconfigure/data/redis/DataRedisTest.java
+10
-2
DataRedisTestContextBootstrapper.java
...onfigure/data/redis/DataRedisTestContextBootstrapper.java
+40
-0
JdbcTest.java
...pringframework/boot/test/autoconfigure/jdbc/JdbcTest.java
+10
-2
JdbcTestContextBootstrapper.java
.../test/autoconfigure/jdbc/JdbcTestContextBootstrapper.java
+40
-0
JooqTest.java
...pringframework/boot/test/autoconfigure/jooq/JooqTest.java
+10
-2
JooqTestContextBootstrapper.java
.../test/autoconfigure/jooq/JooqTestContextBootstrapper.java
+40
-0
JsonTest.java
...pringframework/boot/test/autoconfigure/json/JsonTest.java
+9
-2
JsonTestContextBootstrapper.java
.../test/autoconfigure/json/JsonTestContextBootstrapper.java
+40
-0
DataJpaTest.java
...ramework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java
+10
-2
DataJpaTestContextBootstrapper.java
...autoconfigure/orm/jpa/DataJpaTestContextBootstrapper.java
+40
-0
RestClientTest.java
...rk/boot/test/autoconfigure/web/client/RestClientTest.java
+10
-2
RestClientTestContextBootstrapper.java
...nfigure/web/client/RestClientTestContextBootstrapper.java
+40
-0
WebFluxTest.java
...ork/boot/test/autoconfigure/web/reactive/WebFluxTest.java
+9
-0
WebFluxTestContextBootstrapper.java
...onfigure/web/reactive/WebFluxTestContextBootstrapper.java
+13
-1
WebMvcTest.java
...ework/boot/test/autoconfigure/web/servlet/WebMvcTest.java
+9
-0
WebMvcTestContextBootstrapper.java
...oconfigure/web/servlet/WebMvcTestContextBootstrapper.java
+13
-1
DataLdapTestEnvironmentPropertiesTests.java
...ure/data/ldap/DataLdapTestEnvironmentPropertiesTests.java
+46
-0
DataMongoTestEnvironmentPropertiesTests.java
...e/data/mongo/DataMongoTestEnvironmentPropertiesTests.java
+46
-0
DataNeo4jTestEnvironmentPropertiesTests.java
...e/data/neo4j/DataNeo4jTestEnvironmentPropertiesTests.java
+69
-0
DataRedisTestEnvironmentPropertiesTests.java
...e/data/redis/DataRedisTestEnvironmentPropertiesTests.java
+68
-0
JdbcTestEnvironmentPropertiesTests.java
...utoconfigure/jdbc/JdbcTestEnvironmentPropertiesTests.java
+46
-0
JooqTestEnvironmentPropertiesTests.java
...utoconfigure/jooq/JooqTestEnvironmentPropertiesTests.java
+46
-0
JsonTestEnvironmentPropertiesTests.java
...utoconfigure/json/JsonTestEnvironmentPropertiesTests.java
+46
-0
DataJpaTestEnvironmentPropertiesTests.java
...figure/orm/jpa/DataJpaTestEnvironmentPropertiesTests.java
+46
-0
RestClientTestEnvironmentPropertiesTests.java
.../web/client/RestClientTestEnvironmentPropertiesTests.java
+46
-0
WebFluxTestEnvironmentPropertiesTests.java
...e/web/reactive/WebFluxTestEnvironmentPropertiesTests.java
+46
-0
WebMvcTestEnvironmentPropertiesTests.java
...ure/web/servlet/WebMvcTestEnvironmentPropertiesTests.java
+46
-0
No files found.
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java
View file @
0cf1749e
...
...
@@ -30,9 +30,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration
;
import
org.springframework.boot.test.autoconfigure.core.AutoConfigureCache
;
import
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
...
...
@@ -48,13 +48,14 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
* LDAP process (if available).
*
* @author Eddú Meléndez
* @author Artsiom Yudovin
* @since 2.0.0
*/
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@BootstrapWith
(
SpringBoot
TestContextBootstrapper
.
class
)
@BootstrapWith
(
DataLdap
TestContextBootstrapper
.
class
)
@ExtendWith
(
SpringExtension
.
class
)
@OverrideAutoConfiguration
(
enabled
=
false
)
@TypeExcludeFilters
(
DataLdapTypeExcludeFilter
.
class
)
...
...
@@ -63,6 +64,13 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@ImportAutoConfiguration
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
*/
String
[]
properties
()
default
{};
/**
* Determines if default filtering should be used with
* {@link SpringBootApplication @SpringBootApplication}. By default no beans are
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestContextBootstrapper.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
ldap
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
import
org.springframework.test.context.TestContextBootstrapper
;
/**
* {@link TestContextBootstrapper} for {@link DataLdapTest @DataLdapTest} support.
*
* @author Artsiom Yudovin
*/
public
class
DataLdapTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
DataLdapTest
annotation
=
getDataLdapTestAnnotation
(
testClass
);
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 @
0cf1749e
...
...
@@ -30,9 +30,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration
;
import
org.springframework.boot.test.autoconfigure.core.AutoConfigureCache
;
import
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
...
...
@@ -49,13 +49,14 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
*
* @author Michael Simons
* @author Stephane Nicoll
* @author Artsiom Yudovin
* @since 1.5.0
*/
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@BootstrapWith
(
SpringBoot
TestContextBootstrapper
.
class
)
@BootstrapWith
(
DataMongo
TestContextBootstrapper
.
class
)
@ExtendWith
(
SpringExtension
.
class
)
@OverrideAutoConfiguration
(
enabled
=
false
)
@TypeExcludeFilters
(
DataMongoTypeExcludeFilter
.
class
)
...
...
@@ -64,6 +65,13 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@ImportAutoConfiguration
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
*/
String
[]
properties
()
default
{};
/**
* Determines if default filtering should be used with
* {@link SpringBootApplication @SpringBootApplication}. By default no beans are
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestContextBootstrapper.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
mongo
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
import
org.springframework.test.context.TestContextBootstrapper
;
/**
* {@link TestContextBootstrapper} for {@link DataMongoTest @DataMongoTest} support.
*
* @author Artsiom Yudovin
*/
public
class
DataMongoTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
DataMongoTest
annotation
=
getDataMongoTestAnnotation
(
testClass
);
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 @
0cf1749e
...
...
@@ -30,9 +30,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration
;
import
org.springframework.boot.test.autoconfigure.core.AutoConfigureCache
;
import
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -51,13 +51,14 @@ import org.springframework.transaction.annotation.Transactional;
*
* @author Eddú Meléndez
* @author Stephane Nicoll
* @author Artsiom Yudovin
* @since 2.0.0
*/
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@BootstrapWith
(
SpringBoot
TestContextBootstrapper
.
class
)
@BootstrapWith
(
DataNeo4j
TestContextBootstrapper
.
class
)
@ExtendWith
(
SpringExtension
.
class
)
@OverrideAutoConfiguration
(
enabled
=
false
)
@TypeExcludeFilters
(
DataNeo4jTypeExcludeFilter
.
class
)
...
...
@@ -67,6 +68,13 @@ import org.springframework.transaction.annotation.Transactional;
@ImportAutoConfiguration
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
*/
String
[]
properties
()
default
{};
/**
* Determines if default filtering should be used with
* {@link SpringBootApplication @SpringBootApplication}. By default no beans are
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestContextBootstrapper.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
neo4j
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
import
org.springframework.test.context.TestContextBootstrapper
;
/**
* {@link TestContextBootstrapper} for {@link DataNeo4jTest @DataNeo4jTest} support.
*
* @author Artsiom Yudovin
*/
public
class
DataNeo4jTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
DataNeo4jTest
annotation
=
getDataNeo4jTestAnnotation
(
testClass
);
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 @
0cf1749e
...
...
@@ -30,9 +30,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration
;
import
org.springframework.boot.test.autoconfigure.core.AutoConfigureCache
;
import
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
...
...
@@ -45,13 +45,14 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
* configuration relevant to Redis tests.
*
* @author Jayaram Pradhan
* @author Artsiom Yudovin
* @since 2.0.0
*/
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@BootstrapWith
(
SpringBoot
TestContextBootstrapper
.
class
)
@BootstrapWith
(
DataRedis
TestContextBootstrapper
.
class
)
@ExtendWith
(
SpringExtension
.
class
)
@OverrideAutoConfiguration
(
enabled
=
false
)
@TypeExcludeFilters
(
DataRedisTypeExcludeFilter
.
class
)
...
...
@@ -60,6 +61,13 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@ImportAutoConfiguration
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
*/
String
[]
properties
()
default
{};
/**
* Determines if default filtering should be used with
* {@link SpringBootApplication @SpringBootApplication}. By default no beans are
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestContextBootstrapper.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
redis
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
import
org.springframework.test.context.TestContextBootstrapper
;
/**
* {@link TestContextBootstrapper} for {@link DataRedisTest @DataRedisTest} support.
*
* @author Artsiom Yudovin
*/
public
class
DataRedisTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
DataRedisTest
annotation
=
getDataRedisTestAnnotation
(
testClass
);
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 @
0cf1749e
...
...
@@ -31,9 +31,9 @@ import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration;
import
org.springframework.boot.test.autoconfigure.core.AutoConfigureCache
;
import
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -57,6 +57,7 @@ import org.springframework.transaction.annotation.Transactional;
* annotation.
*
* @author Stephane Nicoll
* @author Artsiom Yudovin
* @see AutoConfigureJdbc
* @see AutoConfigureTestDatabase
* @see AutoConfigureCache
...
...
@@ -65,7 +66,7 @@ import org.springframework.transaction.annotation.Transactional;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@BootstrapWith
(
SpringBoot
TestContextBootstrapper
.
class
)
@BootstrapWith
(
Jdbc
TestContextBootstrapper
.
class
)
@ExtendWith
(
SpringExtension
.
class
)
@OverrideAutoConfiguration
(
enabled
=
false
)
@TypeExcludeFilters
(
JdbcTypeExcludeFilter
.
class
)
...
...
@@ -76,6 +77,13 @@ import org.springframework.transaction.annotation.Transactional;
@ImportAutoConfiguration
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
*/
String
[]
properties
()
default
{};
/**
* Determines if default filtering should be used with
* {@link SpringBootApplication @SpringBootApplication}. By default no beans are
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestContextBootstrapper.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
jdbc
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
import
org.springframework.test.context.TestContextBootstrapper
;
/**
* {@link TestContextBootstrapper} for {@link JdbcTest @JdbcTest} support.
*
* @author Artsiom Yudovin
*/
public
class
JdbcTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
JdbcTest
annotation
=
getJdbcAnnotation
(
testClass
);
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 @
0cf1749e
...
...
@@ -30,9 +30,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration
;
import
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters
;
import
org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -52,13 +52,14 @@ import org.springframework.transaction.annotation.Transactional;
*
* @author Michael Simons
* @author Stephane Nicoll
* @author Artsiom Yudovin
* @since 2.0.0
*/
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@BootstrapWith
(
SpringBoot
TestContextBootstrapper
.
class
)
@BootstrapWith
(
Jooq
TestContextBootstrapper
.
class
)
@ExtendWith
(
SpringExtension
.
class
)
@OverrideAutoConfiguration
(
enabled
=
false
)
@TypeExcludeFilters
(
JooqTypeExcludeFilter
.
class
)
...
...
@@ -67,6 +68,13 @@ import org.springframework.transaction.annotation.Transactional;
@ImportAutoConfiguration
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
*/
String
[]
properties
()
default
{};
/**
* Determines if default filtering should be used with
* {@link SpringBootApplication @SpringBootApplication}. By default no beans are
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestContextBootstrapper.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
jooq
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
import
org.springframework.test.context.TestContextBootstrapper
;
/**
* {@link TestContextBootstrapper} for {@link JooqTest @JooqTest} support.
*
* @author Artsiom Yudovin
*/
public
class
JooqTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
JooqTest
annotation
=
getJooqTestAnnotation
(
testClass
);
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 @
0cf1749e
...
...
@@ -28,12 +28,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration
;
import
org.springframework.boot.test.autoconfigure.core.AutoConfigureCache
;
import
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.boot.test.json.GsonTester
;
import
org.springframework.boot.test.json.JacksonTester
;
import
org.springframework.boot.test.json.JsonbTester
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.BootstrapWith
;
/**
...
...
@@ -60,7 +60,7 @@ import org.springframework.test.context.BootstrapWith;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@BootstrapWith
(
SpringBoot
TestContextBootstrapper
.
class
)
@BootstrapWith
(
Json
TestContextBootstrapper
.
class
)
@OverrideAutoConfiguration
(
enabled
=
false
)
@TypeExcludeFilters
(
JsonExcludeFilter
.
class
)
@AutoConfigureCache
...
...
@@ -69,6 +69,13 @@ import org.springframework.test.context.BootstrapWith;
@ImportAutoConfiguration
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
*/
String
[]
properties
()
default
{};
/**
* Determines if default filtering should be used with
* {@link SpringBootApplication @SpringBootApplication}. By default only
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestContextBootstrapper.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
json
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
import
org.springframework.test.context.TestContextBootstrapper
;
/**
* {@link TestContextBootstrapper} for {@link JsonTest @JsonTest} support.
*
* @author Artsiom Yudovin
*/
public
class
JsonTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
JsonTest
annotation
=
getJsonTestAnnotation
(
testClass
);
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 @
0cf1749e
...
...
@@ -33,9 +33,9 @@ import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters;
import
org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase
;
import
org.springframework.boot.test.autoconfigure.properties.PropertyMapping
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -59,6 +59,7 @@ import org.springframework.transaction.annotation.Transactional;
* annotation.
*
* @author Phillip Webb
* @author Artsiom Yudovin
* @see AutoConfigureDataJpa
* @see AutoConfigureTestDatabase
* @see AutoConfigureTestEntityManager
...
...
@@ -68,7 +69,7 @@ import org.springframework.transaction.annotation.Transactional;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@BootstrapWith
(
SpringBoot
TestContextBootstrapper
.
class
)
@BootstrapWith
(
DataJpa
TestContextBootstrapper
.
class
)
@ExtendWith
(
SpringExtension
.
class
)
@OverrideAutoConfiguration
(
enabled
=
false
)
@TypeExcludeFilters
(
DataJpaTypeExcludeFilter
.
class
)
...
...
@@ -80,6 +81,13 @@ import org.springframework.transaction.annotation.Transactional;
@ImportAutoConfiguration
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
*/
String
[]
properties
()
default
{};
/**
* If SQL output should be logged.
* @return if SQL is logged
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestContextBootstrapper.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
orm
.
jpa
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
import
org.springframework.test.context.TestContextBootstrapper
;
/**
* {@link TestContextBootstrapper} for {@link DataJpaTest @DataJpaTest} support.
*
* @author Artsiom Yudovin
*/
public
class
DataJpaTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
DataJpaTest
annotation
=
getDataJpaAnnotation
(
testClass
);
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 @
0cf1749e
...
...
@@ -30,10 +30,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration
;
import
org.springframework.boot.test.autoconfigure.core.AutoConfigureCache
;
import
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Component
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
...
...
@@ -60,13 +60,14 @@ import org.springframework.web.client.RestTemplate;
*
* @author Stephane Nicoll
* @author Phillip Webb
* @author Artsiom Yudovin
* @since 1.4.0
*/
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@BootstrapWith
(
SpringBoo
tTestContextBootstrapper
.
class
)
@BootstrapWith
(
RestClien
tTestContextBootstrapper
.
class
)
@ExtendWith
(
SpringExtension
.
class
)
@OverrideAutoConfiguration
(
enabled
=
false
)
@TypeExcludeFilters
(
RestClientExcludeFilter
.
class
)
...
...
@@ -76,6 +77,13 @@ import org.springframework.web.client.RestTemplate;
@ImportAutoConfiguration
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
*/
String
[]
properties
()
default
{};
/**
* Specifies the components to test. This is an alias of {@link #components()} which
* can be used for brevity if no other attributes are defined. See
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestContextBootstrapper.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
web
.
client
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
import
org.springframework.test.context.TestContextBootstrapper
;
/**
* {@link TestContextBootstrapper} for {@link RestClientTest @RestClientTest} support.
*
* @author Artsiom Yudovin
*/
public
class
RestClientTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
RestClientTest
annotation
=
getRestClientAnnotation
(
testClass
);
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 @
0cf1749e
...
...
@@ -35,6 +35,7 @@ import org.springframework.boot.test.mock.mockito.MockBean;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
import
org.springframework.test.web.reactive.server.WebTestClient
;
...
...
@@ -64,6 +65,7 @@ import org.springframework.test.web.reactive.server.WebTestClient;
* annotation.
*
* @author Stephane Nicoll
* @author Artsiom Yudovin
* @since 2.0.0
* @see AutoConfigureWebFlux
* @see AutoConfigureWebTestClient
...
...
@@ -82,6 +84,13 @@ import org.springframework.test.web.reactive.server.WebTestClient;
@ImportAutoConfiguration
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
*/
String
[]
properties
()
default
{};
/**
* Specifies the controllers to test. This is an alias of {@link #controllers()} which
* can be used for brevity if no other attributes are defined. See
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestContextBootstrapper.java
View file @
0cf1749e
...
...
@@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.web.reactive;
import
org.springframework.boot.test.context.ReactiveWebMergedContextConfiguration
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
import
org.springframework.test.context.MergedContextConfiguration
;
import
org.springframework.test.context.TestContextBootstrapper
;
...
...
@@ -25,8 +26,9 @@ import org.springframework.test.context.TestContextBootstrapper;
* {@link TestContextBootstrapper} for {@link WebFluxTest @WebFluxTest} support.
*
* @author Stephane Nicoll
* @author Artsiom Yudovin
*/
class
WebFluxTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
public
class
WebFluxTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
MergedContextConfiguration
processMergedContextConfiguration
(
...
...
@@ -35,4 +37,14 @@ class WebFluxTestContextBootstrapper extends SpringBootTestContextBootstrapper {
super
.
processMergedContextConfiguration
(
mergedConfig
));
}
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
WebFluxTest
annotation
=
getWebFluxTestAnnotation
(
testClass
);
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 @
0cf1749e
...
...
@@ -35,6 +35,7 @@ import org.springframework.boot.test.mock.mockito.MockBean;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.core.annotation.AliasFor
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
import
org.springframework.test.web.servlet.MockMvc
;
...
...
@@ -65,6 +66,7 @@ import org.springframework.test.web.servlet.MockMvc;
* {@link AutoConfigureMockMvc @AutoConfigureMockMvc} rather than this annotation.
*
* @author Phillip Webb
* @author Artsiom Yudovin
* @see AutoConfigureWebMvc
* @see AutoConfigureMockMvc
* @see AutoConfigureCache
...
...
@@ -84,6 +86,13 @@ import org.springframework.test.web.servlet.MockMvc;
@ImportAutoConfiguration
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
*/
String
[]
properties
()
default
{};
/**
* Specifies the controllers to test. This is an alias of {@link #controllers()} which
* can be used for brevity if no other attributes are defined. See
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestContextBootstrapper.java
View file @
0cf1749e
...
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
web
.
servlet
;
import
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
import
org.springframework.test.context.MergedContextConfiguration
;
import
org.springframework.test.context.TestContextBootstrapper
;
import
org.springframework.test.context.web.WebMergedContextConfiguration
;
...
...
@@ -25,8 +26,9 @@ import org.springframework.test.context.web.WebMergedContextConfiguration;
* {@link TestContextBootstrapper} for {@link WebMvcTest @WebMvcTest} support.
*
* @author Phillip Webb
* @author Artsiom Yudovin
*/
class
WebMvcTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
public
class
WebMvcTestContextBootstrapper
extends
SpringBootTestContextBootstrapper
{
@Override
protected
MergedContextConfiguration
processMergedContextConfiguration
(
...
...
@@ -35,4 +37,14 @@ class WebMvcTestContextBootstrapper extends SpringBootTestContextBootstrapper {
super
.
processMergedContextConfiguration
(
mergedConfig
),
""
);
}
@Override
protected
String
[]
getProperties
(
Class
<?>
testClass
)
{
WebMvcTest
annotation
=
getWebMvcTestAnnotation
(
testClass
);
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/DataLdapTestEnvironmentPropertiesTests.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
ldap
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link DataLdapTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@DataLdapTest
(
properties
=
"spring.profiles.active=test"
)
public
class
DataLdapTestEnvironmentPropertiesTests
{
@Autowired
private
Environment
environment
;
@Test
public
void
environmentWitNewProfile
()
{
String
profile
=
this
.
environment
.
getActiveProfiles
()[
0
];
assertThat
(
profile
).
isEqualTo
(
"test"
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestEnvironmentPropertiesTests.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
mongo
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link DataMongoTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@DataMongoTest
(
properties
=
"spring.profiles.active=test"
)
public
class
DataMongoTestEnvironmentPropertiesTests
{
@Autowired
private
Environment
environment
;
@Test
public
void
environmentWitNewProfile
()
{
String
profile
=
this
.
environment
.
getActiveProfiles
()[
0
];
assertThat
(
profile
).
isEqualTo
(
"test"
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestEnvironmentPropertiesTests.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
neo4j
;
import
org.junit.ClassRule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.testsupport.testcontainers.Neo4jContainer
;
import
org.springframework.context.ApplicationContextInitializer
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link DataNeo4jTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@ContextConfiguration
(
initializers
=
DataNeo4jTestEnvironmentPropertiesTests
.
Initializer
.
class
)
@DataNeo4jTest
(
properties
=
"spring.profiles.active=test"
)
public
class
DataNeo4jTestEnvironmentPropertiesTests
{
@ClassRule
public
static
Neo4jContainer
neo4j
=
new
Neo4jContainer
();
@Autowired
private
Environment
environment
;
@Test
public
void
environmentWitNewProfile
()
{
String
profile
=
this
.
environment
.
getActiveProfiles
()[
0
];
assertThat
(
profile
).
isEqualTo
(
"test"
);
}
static
class
Initializer
implements
ApplicationContextInitializer
<
ConfigurableApplicationContext
>
{
@Override
public
void
initialize
(
ConfigurableApplicationContext
configurableApplicationContext
)
{
TestPropertyValues
.
of
(
"spring.data.neo4j.uri=bolt://localhost:"
+
neo4j
.
getMappedPort
())
.
applyTo
(
configurableApplicationContext
.
getEnvironment
());
}
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestEnvironmentPropertiesTests.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
redis
;
import
org.junit.ClassRule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.testsupport.testcontainers.RedisContainer
;
import
org.springframework.context.ApplicationContextInitializer
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link DataRedisTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@ContextConfiguration
(
initializers
=
DataRedisTestEnvironmentPropertiesTests
.
Initializer
.
class
)
@DataRedisTest
(
properties
=
"spring.profiles.active=test"
)
public
class
DataRedisTestEnvironmentPropertiesTests
{
@ClassRule
public
static
RedisContainer
redis
=
new
RedisContainer
();
@Autowired
private
Environment
environment
;
@Test
public
void
environmentWitNewProfile
()
{
String
profile
=
this
.
environment
.
getActiveProfiles
()[
0
];
assertThat
(
profile
).
isEqualTo
(
"test"
);
}
static
class
Initializer
implements
ApplicationContextInitializer
<
ConfigurableApplicationContext
>
{
@Override
public
void
initialize
(
ConfigurableApplicationContext
configurableApplicationContext
)
{
TestPropertyValues
.
of
(
"spring.redis.port="
+
redis
.
getMappedPort
())
.
applyTo
(
configurableApplicationContext
.
getEnvironment
());
}
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestEnvironmentPropertiesTests.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
jdbc
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link JdbcTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@JdbcTest
(
properties
=
"spring.profiles.active=test"
)
public
class
JdbcTestEnvironmentPropertiesTests
{
@Autowired
private
Environment
environment
;
@Test
public
void
environmentWitNewProfile
()
{
String
profile
=
this
.
environment
.
getActiveProfiles
()[
0
];
assertThat
(
profile
).
isEqualTo
(
"test"
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestEnvironmentPropertiesTests.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
jooq
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link JooqTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@JooqTest
(
properties
=
"spring.profiles.active=test"
)
public
class
JooqTestEnvironmentPropertiesTests
{
@Autowired
private
Environment
environment
;
@Test
public
void
environmentWitNewProfile
()
{
String
profile
=
this
.
environment
.
getActiveProfiles
()[
0
];
assertThat
(
profile
).
isEqualTo
(
"test"
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestEnvironmentPropertiesTests.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
json
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link JsonTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@JsonTest
(
properties
=
"spring.profiles.active=test"
)
public
class
JsonTestEnvironmentPropertiesTests
{
@Autowired
private
Environment
environment
;
@Test
public
void
environmentWitNewProfile
()
{
String
profile
=
this
.
environment
.
getActiveProfiles
()[
0
];
assertThat
(
profile
).
isEqualTo
(
"test"
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestEnvironmentPropertiesTests.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
orm
.
jpa
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link DataJpaTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@DataJpaTest
(
properties
=
"spring.profiles.active=test"
)
public
class
DataJpaTestEnvironmentPropertiesTests
{
@Autowired
private
Environment
environment
;
@Test
public
void
environmentWitNewProfile
()
{
String
profile
=
this
.
environment
.
getActiveProfiles
()[
0
];
assertThat
(
profile
).
isEqualTo
(
"test"
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestEnvironmentPropertiesTests.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
web
.
client
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link RestClientTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@RestClientTest
(
properties
=
"spring.profiles.active=test"
)
public
class
RestClientTestEnvironmentPropertiesTests
{
@Autowired
private
Environment
environment
;
@Test
public
void
environmentWitNewProfile
()
{
String
profile
=
this
.
environment
.
getActiveProfiles
()[
0
];
assertThat
(
profile
).
isEqualTo
(
"test"
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestEnvironmentPropertiesTests.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
web
.
reactive
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link WebFluxTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@WebFluxTest
(
properties
=
"spring.profiles.active=test"
)
public
class
WebFluxTestEnvironmentPropertiesTests
{
@Autowired
private
Environment
environment
;
@Test
public
void
environmentWitNewProfile
()
{
String
profile
=
this
.
environment
.
getActiveProfiles
()[
0
];
assertThat
(
profile
).
isEqualTo
(
"test"
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestEnvironmentPropertiesTests.java
0 → 100644
View file @
0cf1749e
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
web
.
servlet
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Add properties to {@link Environment} via {@link WebMvcTest}.
*
* @author Artsiom Yudovin
*/
@RunWith
(
SpringRunner
.
class
)
@WebMvcTest
(
properties
=
"spring.profiles.active=test"
)
public
class
WebMvcTestEnvironmentPropertiesTests
{
@Autowired
private
Environment
environment
;
@Test
public
void
environmentWitNewProfile
()
{
String
profile
=
this
.
environment
.
getActiveProfiles
()[
0
];
assertThat
(
profile
).
isEqualTo
(
"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