@@ -446,8 +446,8 @@ used within a test class hierarchy.
446446[subs="verbatim,quotes"]
447447----
448448 @ContextHierarchy({
449- @ContextConfiguration("/parent-config.xml"),
450- @ContextConfiguration("/child-config.xml")
449+ @ContextConfiguration(locations = "/parent-config.xml"),
450+ @ContextConfiguration(locations = "/child-config.xml")
451451 })
452452 public class ContextHierarchyTests {
453453 // class body...
@@ -673,8 +673,8 @@ specified instead, as seen below.
673673[subs="verbatim,quotes"]
674674----
675675 @ContextHierarchy({
676- @ContextConfiguration("/parent-config.xml"),
677- @ContextConfiguration("/child-config.xml")
676+ @ContextConfiguration(locations = "/parent-config.xml"),
677+ @ContextConfiguration(locations = "/child-config.xml")
678678 })
679679 public class BaseTests {
680680 // class body...
@@ -829,7 +829,7 @@ container annotation.
829829 @Test
830830 **@SqlGroup**({
831831 @Sql(scripts = "/test-schema.sql", config = @SqlConfig(commentPrefix = "`")),
832- @Sql("/test-user-data.sql")
832+ @Sql(scripts = "/test-user-data.sql")
833833 )}
834834 public void userTest {
835835 // execute code that uses the test schema and test data
@@ -1009,14 +1009,14 @@ across our JUnit 4 based test suite...
10091009[subs="verbatim,quotes"]
10101010----
10111011 @RunWith(SpringRunner.class)
1012- @ContextConfiguration({ "/app-config.xml", "/test-data-access-config.xml"})
1013- @ActiveProfiles("dev")
1012+ @ContextConfiguration(locations = " "/app-config.xml", "/test-data-access-config.xml"})
1013+ @ActiveProfiles(profiles = "dev")
10141014 @Transactional
10151015 public class OrderRepositoryTests { }
10161016
10171017 @RunWith(SpringRunner.class)
1018- @ContextConfiguration({ "/app-config.xml", "/test-data-access-config.xml"})
1019- @ActiveProfiles("dev")
1018+ @ContextConfiguration(locations = " "/app-config.xml", "/test-data-access-config.xml"})
1019+ @ActiveProfiles(profiles = "dev")
10201020 @Transactional
10211021 public class UserRepositoryTests { }
10221022----
@@ -1029,8 +1029,8 @@ that centralizes the common test configuration like this:
10291029----
10301030 @Target(ElementType.TYPE)
10311031 @Retention(RetentionPolicy.RUNTIME)
1032- @ContextConfiguration({ "/app-config.xml", "/test-data-access-config.xml"})
1033- @ActiveProfiles("dev")
1032+ @ContextConfiguration(locations = " "/app-config.xml", "/test-data-access-config.xml"})
1033+ @ActiveProfiles(profiles = "dev")
10341034 @Transactional
10351035 public @interface TransactionalDevTest { }
10361036----
@@ -1406,7 +1406,7 @@ demonstrated in the following example.
14061406[subs="verbatim,quotes"]
14071407----
14081408 @RunWith(SpringRunner.class)
1409- **@ContextConfiguration({ "/app-config.xml", "/test-config.xml"})**
1409+ **@ContextConfiguration(locations = " "/app-config.xml", "/test-config.xml"})**
14101410 public class MyTest {
14111411 // class body...
14121412 }
@@ -1457,7 +1457,7 @@ TestContext Framework is enabled automatically if Groovy is on the classpath.
14571457 @RunWith(SpringRunner.class)
14581458 // ApplicationContext will be loaded from "/AppConfig.groovy" and
14591459 // "/TestConfig.groovy" in the root of the classpath
1460- **@ContextConfiguration({ "/AppConfig.groovy", "/TestConfig.Groovy"})**
1460+ **@ContextConfiguration(locations = " "/AppConfig.groovy", "/TestConfig.Groovy"})**
14611461 public class MyTest {
14621462 // class body...
14631463 }
@@ -1500,7 +1500,7 @@ The following listing demonstrates how to combine both in an integration test.
15001500 @RunWith(SpringRunner.class)
15011501 // ApplicationContext will be loaded from
15021502 // "/app-config.xml" and "/TestConfig.groovy"
1503- @ContextConfiguration({ "/app-config.xml", "/TestConfig.groovy" })
1503+ @ContextConfiguration(locations = " "/app-config.xml", "/TestConfig.groovy" })
15041504 public class MyTest {
15051505 // class body...
15061506 }
@@ -1691,14 +1691,14 @@ therefore __override__ (i.e., replace) those defined in __"base-config.xml"__.
16911691 @RunWith(SpringRunner.class)
16921692 // ApplicationContext will be loaded from "/base-config.xml"
16931693 // in the root of the classpath
1694- **@ContextConfiguration("/base-config.xml")**
1694+ **@ContextConfiguration(locations = "/base-config.xml")**
16951695 public class BaseTest {
16961696 // class body...
16971697 }
16981698
16991699 // ApplicationContext will be loaded from "/base-config.xml" and
17001700 // "/extended-config.xml" in the root of the classpath
1701- **@ContextConfiguration("/extended-config.xml")**
1701+ **@ContextConfiguration(locations = "/extended-config.xml")**
17021702 public class ExtendedTest extends BaseTest {
17031703 // class body...
17041704 }
@@ -1822,8 +1822,8 @@ Let's take a look at some examples with XML configuration and `@Configuration` c
18221822
18231823 @RunWith(SpringRunner.class)
18241824 // ApplicationContext will be loaded from "classpath:/app-config.xml"
1825- @ContextConfiguration("/app-config.xml")
1826- @ActiveProfiles("dev")
1825+ @ContextConfiguration(locations = "/app-config.xml")
1826+ @ActiveProfiles(profiles = "dev")
18271827 public class TransferServiceTest {
18281828
18291829 @Autowired
@@ -1843,7 +1843,7 @@ When `TransferServiceTest` is run, its `ApplicationContext` will be loaded from
18431843`dataSource` is defined three times: in the __production__ profile, the
18441844__dev__ profile, and the __default__ profile.
18451845
1846- By annotating `TransferServiceTest` with `@ActiveProfiles("dev")` we instruct the Spring
1846+ By annotating `TransferServiceTest` with `@ActiveProfiles(profiles = "dev")` we instruct the Spring
18471847TestContext Framework to load the `ApplicationContext` with the active profiles set to
18481848`{"dev"}`. As a result, an embedded database will be created and populated with test data,
18491849and the `accountRepository` bean will be wired with a reference to the development
@@ -1945,7 +1945,7 @@ integration test but using `@Configuration` classes instead of XML.
19451945 StandaloneDataConfig.class,
19461946 JndiDataConfig.class,
19471947 DefaultDataConfig.class})
1948- @ActiveProfiles("dev")
1948+ @ActiveProfiles(profiles = "dev")
19491949 public class TransferServiceTest {
19501950
19511951 @Autowired
@@ -1971,7 +1971,7 @@ In this variation, we have split the XML configuration into four independent
19711971 no profile is active
19721972
19731973As with the XML-based configuration example, we still annotate `TransferServiceTest`
1974- with `@ActiveProfiles("dev")`, but this time we specify all four configuration classes
1974+ with `@ActiveProfiles(profiles = "dev")`, but this time we specify all four configuration classes
19751975via the `@ContextConfiguration` annotation. The body of the test class itself remains
19761976completely unchanged.
19771977
@@ -1993,7 +1993,7 @@ annotations) has been moved to an abstract superclass, `AbstractIntegrationTest`
19931993 StandaloneDataConfig.class,
19941994 JndiDataConfig.class,
19951995 DefaultDataConfig.class})
1996- @ActiveProfiles("dev")
1996+ @ActiveProfiles(profiles = "dev")
19971997 public abstract class AbstractIntegrationTest {
19981998 }
19991999----
@@ -2121,7 +2121,7 @@ be loaded using the specified resource protocol. Resource location wildcards (e.
21212121[subs="verbatim,quotes"]
21222122----
21232123 @ContextConfiguration
2124- @TestPropertySource("/test.properties")
2124+ @TestPropertySource(locations = "/test.properties")
21252125 public class MyIntegrationTests {
21262126 // class body...
21272127 }
@@ -2211,13 +2211,13 @@ only the `"base.properties"` file as a test property source. In contrast, the
22112211[source,java,indent=0]
22122212[subs="verbatim,quotes"]
22132213----
2214- @TestPropertySource("base.properties")
2214+ @TestPropertySource(locations = "base.properties")
22152215 @ContextConfiguration
22162216 public class BaseTest {
22172217 // ...
22182218 }
22192219
2220- @TestPropertySource("extended.properties")
2220+ @TestPropertySource(locations = "extended.properties")
22212221 @ContextConfiguration
22222222 public class ExtendedTest extends BaseTest {
22232223 // ...
@@ -2311,7 +2311,7 @@ nested `@Configuration` classes).
23112311 @WebAppConfiguration("webapp")
23122312
23132313 // classpath resource
2314- @ContextConfiguration("/spring/test-servlet-config.xml")
2314+ @ContextConfiguration(locations = "/spring/test-servlet-config.xml")
23152315
23162316 public class WacTests {
23172317 //...
@@ -2334,7 +2334,7 @@ whereas, `@ContextConfiguration` resource locations are classpath based.
23342334 @WebAppConfiguration("classpath:test-web-resources")
23352335
23362336 // file system resource
2337- @ContextConfiguration("file:src/main/webapp/WEB-INF/servlet-config.xml")
2337+ @ContextConfiguration(locations = "file:src/main/webapp/WEB-INF/servlet-config.xml")
23382338
23392339 public class WacTests {
23402340 //...
@@ -2554,13 +2554,13 @@ for the concrete subclasses.
25542554----
25552555 @RunWith(SpringRunner.class)
25562556 @WebAppConfiguration
2557- @ContextConfiguration("file:src/main/webapp/WEB-INF/applicationContext.xml")
2557+ @ContextConfiguration(locations = "file:src/main/webapp/WEB-INF/applicationContext.xml")
25582558 public abstract class AbstractWebTests {}
25592559
2560- @ContextHierarchy(@ContextConfiguration("/spring/soap-ws-config.xml")
2560+ @ContextHierarchy(@ContextConfiguration(locations = "/spring/soap-ws-config.xml")
25612561 public class SoapWebServiceTests extends AbstractWebTests {}
25622562
2563- @ContextHierarchy(@ContextConfiguration("/spring/rest-ws-config.xml")
2563+ @ContextHierarchy(@ContextConfiguration(locations = "/spring/rest-ws-config.xml")
25642564 public class RestWebServiceTests extends AbstractWebTests {}
25652565----
25662566--
@@ -2693,7 +2693,7 @@ The first code listing shows a JUnit 4 based implementation of the test class th
26932693----
26942694 @RunWith(SpringRunner.class)
26952695 // specifies the Spring configuration to load for this test fixture
2696- **@ContextConfiguration(" repository-config.xml")**
2696+ **@ContextConfiguration(locations= " repository-config.xml")**
26972697 public class HibernateTitleRepositoryTests {
26982698
26992699 // this instance will be dependency injected by type
@@ -2716,7 +2716,7 @@ seen below.
27162716----
27172717 @RunWith(SpringRunner.class)
27182718 // specifies the Spring configuration to load for this test fixture
2719- **@ContextConfiguration(" repository-config.xml")**
2719+ **@ContextConfiguration(locations= " repository-config.xml")**
27202720 public class HibernateTitleRepositoryTests {
27212721
27222722 // this instance will be dependency injected by type
@@ -3097,7 +3097,7 @@ to run within a transaction.
30973097`TransactionalTestExecutionListener` expects a `PlatformTransactionManager` bean to be
30983098defined in the Spring `ApplicationContext` for the test. In case there are multiple
30993099instances of `PlatformTransactionManager` within the test's `ApplicationContext`, a
3100- _qualifier_ may be declared via `@Transactional("myTxMgr")` or
3100+ _qualifier_ may be declared via `@Transactional(transactionManager = "myTxMgr")` or
31013101`@Transactional(transactionManager = "myTxMgr")`, or `TransactionManagementConfigurer`
31023102can be implemented by an `@Configuration` class. Consult the javadocs for
31033103`TestContextTransactionUtils.retrieveTransactionManager()` for details on the algorithm
@@ -3320,7 +3320,7 @@ level within a JUnit 4 based integration test class.
33203320----
33213321 @RunWith(SpringRunner.class)
33223322 @ContextConfiguration
3323- @Sql("/test-schema.sql")
3323+ @Sql(scripts = "/test-schema.sql")
33243324 public class DatabaseTests {
33253325
33263326 @Test
@@ -3329,7 +3329,7 @@ level within a JUnit 4 based integration test class.
33293329 }
33303330
33313331 @Test
3332- @Sql({ "/test-schema.sql", "/test-user-data.sql"})
3332+ @Sql(scripts = " "/test-schema.sql", "/test-user-data.sql"})
33333333 public void userTest {
33343334 // execute code that uses the test schema and test data
33353335 }
@@ -3366,7 +3366,7 @@ single-line comments.
33663366----
33673367 @Test
33683368 @Sql(scripts = "/test-schema.sql", config = @SqlConfig(commentPrefix = "`"))
3369- @Sql("/test-user-data.sql")
3369+ @Sql(scripts = "/test-user-data.sql")
33703370 public void userTest {
33713371 // execute code that uses the test schema and test data
33723372 }
@@ -3381,7 +3381,7 @@ grouped together within `@SqlGroup` for compatibility with Java 6 and Java 7.
33813381 @Test
33823382 @SqlGroup({
33833383 @Sql(scripts = "/test-schema.sql", config = @SqlConfig(commentPrefix = "`")),
3384- @Sql("/test-user-data.sql")
3384+ @Sql(scripts = "/test-user-data.sql")
33853385 )}
33863386 public void userTest {
33873387 // execute code that uses the test schema and test data
@@ -3482,7 +3482,7 @@ be automatically rolled back by the `TransactionalTestExecutionListener` (see
34823482 }
34833483
34843484 @Test
3485- @Sql("/test-data.sql")
3485+ @Sql(scripts = "/test-data.sql")
34863486 public void usersTest() {
34873487 // verify state in test database:
34883488 assertNumUsers(2);
@@ -3719,7 +3719,7 @@ JUnit 4 based example of using Spring MVC Test:
37193719
37203720 @RunWith(SpringRunner.class)
37213721 @WebAppConfiguration
3722- @ContextConfiguration(" test-servlet-context.xml")
3722+ @ContextConfiguration(locations= " test-servlet-context.xml")
37233723 public class ExampleTests {
37243724
37253725 @Autowired
@@ -3779,7 +3779,7 @@ into the test to use to build a `MockMvc` instance:
37793779----
37803780 @RunWith(SpringRunner.class)
37813781 @WebAppConfiguration
3782- @ContextConfiguration(" my-servlet-context.xml")
3782+ @ContextConfiguration(locations= " my-servlet-context.xml")
37833783 public class MyWebTests {
37843784
37853785 @Autowired
@@ -3844,7 +3844,7 @@ expectations:
38443844----
38453845 @RunWith(SpringRunner.class)
38463846 @WebAppConfiguration
3847- @ContextConfiguration(" test-servlet-context.xml")
3847+ @ContextConfiguration(locations= " test-servlet-context.xml")
38483848 public class AccountTests {
38493849
38503850 @Autowired
0 commit comments