Fix migration to asciidoctor tabs

The automation to asciidoctor tabs did not migrate properly for all
cases this commit fixes the migration.

See gh-30435
This commit is contained in:
Rob Winch
2023-05-05 20:19:47 -05:00
committed by rstoyanchev
parent 6930d4d531
commit 3a0a19cff8
72 changed files with 448 additions and 300 deletions

View File

@@ -36,11 +36,11 @@ Java::
// class body...
}
----
======
<1> Specify the configuration class.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@SpringJUnitConfig(TestConfig::class) // <1>
class ConfigurationClassJUnitJupiterSpringTests {
@@ -48,6 +48,7 @@ Java::
}
----
<1> Specify the configuration class.
======
The following example shows how to use the `@SpringJUnitConfig` annotation to specify the
@@ -64,11 +65,11 @@ Java::
// class body...
}
----
======
<1> Specify the location of a configuration file.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@SpringJUnitConfig(locations = ["/test-config.xml"]) // <1>
class XmlJUnitJupiterSpringTests {
@@ -76,6 +77,7 @@ Java::
}
----
<1> Specify the location of a configuration file.
======
See xref:testing/testcontext-framework/ctx-management.adoc[Context Management] as well as the javadoc for
@@ -109,11 +111,11 @@ Java::
// class body...
}
----
======
<1> Specify the configuration class.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@SpringJUnitWebConfig(TestConfig::class) // <1>
class ConfigurationClassJUnitJupiterSpringWebTests {
@@ -121,6 +123,7 @@ Java::
}
----
<1> Specify the configuration class.
======
The following example shows how to use the `@SpringJUnitWebConfig` annotation to specify the
@@ -137,11 +140,11 @@ Java::
// class body...
}
----
======
<1> Specify the location of a configuration file.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@SpringJUnitWebConfig(locations = ["/test-config.xml"]) // <1>
class XmlJUnitJupiterSpringWebTests {
@@ -149,6 +152,7 @@ Java::
}
----
<1> Specify the location of a configuration file.
======
See xref:testing/testcontext-framework/ctx-management.adoc[Context Management] as well as the javadoc for

View File

@@ -39,11 +39,11 @@ Java::
// some logic that should run only on Java VMs from Oracle Corporation
}
----
======
<1> Run this test only when the Java vendor is "Oracle Corporation".
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@IfProfileValue(name="java.vendor", value="Oracle Corporation") // <1>
@Test
@@ -52,6 +52,7 @@ Java::
}
----
<1> Run this test only when the Java vendor is "Oracle Corporation".
======
Alternatively, you can configure `@IfProfileValue` with a list of `values` (with `OR`
@@ -70,11 +71,11 @@ Java::
// some logic that should run only for unit and integration test groups
}
----
======
<1> Run this test for unit tests and integration tests.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@IfProfileValue(name="test-groups", values=["unit-tests", "integration-tests"]) // <1>
@Test
@@ -83,6 +84,7 @@ Java::
}
----
<1> Run this test for unit tests and integration tests.
======
[[integration-testing-annotations-junit4-profilevaluesourceconfiguration]]
@@ -105,11 +107,11 @@ Java::
// class body...
}
----
======
<1> Use a custom profile value source.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ProfileValueSourceConfiguration(CustomProfileValueSource::class) // <1>
class CustomProfileValueSourceTests {
@@ -117,6 +119,7 @@ Java::
}
----
<1> Use a custom profile value source.
======
[[integration-testing-annotations-junit4-timed]]
@@ -141,11 +144,11 @@ Java::
// some logic that should not take longer than 1 second to run
}
----
======
<1> Set the time period for the test to one second.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Timed(millis = 1000) // <1>
fun testProcessWithOneSecondTimeout() {
@@ -153,6 +156,7 @@ Java::
}
----
<1> Set the time period for the test to one second.
======
Spring's `@Timed` annotation has different semantics than JUnit 4's `@Test(timeout=...)`
@@ -186,11 +190,11 @@ Java::
// ...
}
----
======
<1> Repeat this test ten times.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Repeat(10) // <1>
@Test
@@ -199,6 +203,7 @@ Java::
}
----
<1> Repeat this test ten times.
======

View File

@@ -19,11 +19,11 @@ Java::
// class body...
}
----
======
<1> Indicate that the `dev` profile should be active.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration
@ActiveProfiles("dev") // <1>
@@ -32,6 +32,7 @@ Java::
}
----
<1> Indicate that the `dev` profile should be active.
======
The following example indicates that both the `dev` and the `integration` profiles should
@@ -49,11 +50,11 @@ Java::
// class body...
}
----
======
<1> Indicate that the `dev` and `integration` profiles should be active.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration
@ActiveProfiles(["dev", "integration"]) // <1>
@@ -62,6 +63,7 @@ Java::
}
----
<1> Indicate that the `dev` and `integration` profiles should be active.
======
NOTE: `@ActiveProfiles` provides support for inheriting active bean definition profiles

View File

@@ -18,11 +18,11 @@ Java::
// logic to be run after a transaction has ended
}
----
======
<1> Run this method after a transaction.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@AfterTransaction // <1>
fun afterTransaction() {
@@ -30,5 +30,6 @@ Java::
}
----
<1> Run this method after a transaction.
======

View File

@@ -20,11 +20,11 @@ Java::
// logic to be run before a transaction is started
}
----
======
<1> Run this method before a transaction.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@BeforeTransaction // <1>
fun beforeTransaction() {
@@ -32,5 +32,6 @@ Java::
}
----
<1> Run this method before a transaction.
======

View File

@@ -21,11 +21,11 @@ Java::
// ...
}
----
======
<1> Commit the result of the test to the database.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Commit // <1>
@Test
@@ -34,5 +34,6 @@ Java::
}
----
<1> Commit the result of the test to the database.
======

View File

@@ -26,11 +26,11 @@ Java::
// class body...
}
----
======
<1> Referring to an XML file.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration("/test-config.xml") // <1>
class XmlApplicationContextTests {
@@ -38,6 +38,7 @@ Java::
}
----
<1> Referring to an XML file.
======
The following example shows a `@ContextConfiguration` annotation that refers to a class:
@@ -53,11 +54,11 @@ Java::
// class body...
}
----
======
<1> Referring to a class.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration(classes = [TestConfig::class]) // <1>
class ConfigClassApplicationContextTests {
@@ -65,6 +66,7 @@ Java::
}
----
<1> Referring to a class.
======
As an alternative or in addition to declaring resource locations or component classes,
@@ -82,11 +84,11 @@ Java::
// class body...
}
----
======
<1> Declaring an initializer class.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration(initializers = [CustomContextInitializer::class]) // <1>
class ContextInitializerTests {
@@ -94,6 +96,7 @@ Java::
}
----
<1> Declaring an initializer class.
======
You can optionally use `@ContextConfiguration` to declare the `ContextLoader` strategy as
@@ -114,11 +117,11 @@ Java::
// class body...
}
----
======
<1> Configuring both a location and a custom loader.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration("/test-context.xml", loader = CustomContextLoader::class) // <1>
class CustomLoaderXmlApplicationContextTests {
@@ -126,6 +129,7 @@ Java::
}
----
<1> Configuring both a location and a custom loader.
======
NOTE: `@ContextConfiguration` provides support for inheriting resource locations or

View File

@@ -31,11 +31,11 @@ Java::
// some tests that require a new Spring container
}
----
======
<1> Dirty the context before the current test class.
+
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@DirtiesContext(classMode = BEFORE_CLASS) // <1>
class FreshContextTests {
@@ -43,6 +43,7 @@ Java::
}
----
<1> Dirty the context before the current test class.
======
* After the current test class, when declared on a class with class mode set to
`AFTER_CLASS` (i.e., the default class mode).
@@ -58,11 +59,11 @@ Java::
// some tests that result in the Spring container being dirtied
}
----
======
<1> Dirty the context after the current test class.
+
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@DirtiesContext // <1>
class ContextDirtyingTests {
@@ -70,6 +71,7 @@ Java::
}
----
<1> Dirty the context after the current test class.
======
* Before each test method in the current test class, when declared on a class with class
@@ -86,11 +88,11 @@ Java::
// some tests that require a new Spring container
}
----
======
<1> Dirty the context before each test method.
+
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@DirtiesContext(classMode = BEFORE_EACH_TEST_METHOD) // <1>
class FreshContextTests {
@@ -98,6 +100,7 @@ Java::
}
----
<1> Dirty the context before each test method.
======
* After each test method in the current test class, when declared on a class with class
@@ -114,11 +117,11 @@ Java::
// some tests that result in the Spring container being dirtied
}
----
======
<1> Dirty the context after each test method.
+
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD) // <1>
class ContextDirtyingTests {
@@ -126,6 +129,7 @@ Java::
}
----
<1> Dirty the context after each test method.
======
* Before the current test, when declared on a method with the method mode set to
@@ -143,11 +147,11 @@ Java::
// some logic that requires a new Spring container
}
----
======
<1> Dirty the context before the current test method.
+
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@DirtiesContext(methodMode = BEFORE_METHOD) // <1>
@Test
@@ -156,6 +160,7 @@ Java::
}
----
<1> Dirty the context before the current test method.
======
* After the current test, when declared on a method with the method mode set to
`AFTER_METHOD` (i.e., the default method mode).
@@ -172,11 +177,11 @@ Java::
// some logic that results in the Spring container being dirtied
}
----
======
<1> Dirty the context after the current test method.
+
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@DirtiesContext // <1>
@Test
@@ -185,6 +190,7 @@ Java::
}
----
<1> Dirty the context after the current test method.
======
If you use `@DirtiesContext` in a test whose context is configured as part of a context
@@ -220,11 +226,11 @@ Java::
}
}
----
======
<1> Use the current-level algorithm.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextHierarchy(
ContextConfiguration("/parent-config.xml"),
@@ -243,6 +249,7 @@ Java::
}
----
<1> Use the current-level algorithm.
======
For further details regarding the `EXHAUSTIVE` and `CURRENT_LEVEL` algorithms, see the

View File

@@ -29,13 +29,13 @@ Java::
// tests ...
}
----
======
<1> Annotate a `static` method with `@DynamicPropertySource`.
<2> Accept a `DynamicPropertyRegistry` as an argument.
<3> Register a dynamic `server.port` property to be retrieved lazily from the server.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration
class MyIntegrationTests {
@@ -58,6 +58,7 @@ Java::
<1> Annotate a `static` method with `@DynamicPropertySource`.
<2> Accept a `DynamicPropertyRegistry` as an argument.
<3> Register a dynamic `server.port` property to be retrieved lazily from the server.
======
See xref:testing/testcontext-framework/ctx-management/dynamic-property-sources.adoc[Context Configuration with Dynamic Property Sources] for further details.

View File

@@ -27,11 +27,11 @@ Java::
// ...
}
----
======
<1> Do not roll back the result.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Rollback(false) // <1>
@Test
@@ -40,5 +40,6 @@ Java::
}
----
<1> Do not roll back the result.
======

View File

@@ -17,11 +17,11 @@ Java::
// run code that relies on the test schema and test data
}
----
======
<1> Run two scripts for this test.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Test
@Sql("/test-schema.sql", "/test-user-data.sql") // <1>
@@ -30,6 +30,7 @@ Java::
}
----
<1> Run two scripts for this test.
======
See xref:testing/testcontext-framework/executing-sql.adoc#testcontext-executing-sql-declaratively[Executing SQL scripts declaratively with @Sql] for further details.

View File

@@ -19,11 +19,11 @@ Java::
// run code that relies on the test data
}
----
======
<1> Set the comment prefix and the separator in SQL scripts.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Test
@Sql("/test-user-data.sql", config = SqlConfig(commentPrefix = "`", separator = "@@")) // <1>
@@ -32,4 +32,5 @@ Java::
}
----
<1> Set the comment prefix and the separator in SQL scripts.
======

View File

@@ -22,11 +22,11 @@ Java::
// run code that uses the test schema and test data
}
----
======
<1> Declare a group of SQL scripts.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Test
@SqlGroup( // <1>
@@ -37,6 +37,7 @@ Java::
}
----
<1> Declare a group of SQL scripts.
======

View File

@@ -29,11 +29,11 @@ Java::
}
}
----
======
<1> Set the `@Sql` merge mode to `MERGE` for all test methods in the class.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@SpringJUnitConfig(TestConfig::class)
@Sql("/test-schema.sql")
@@ -48,6 +48,7 @@ Java::
}
----
<1> Set the `@Sql` merge mode to `MERGE` for all test methods in the class.
======
The following example shows how to use `@SqlMergeMode` at the method level.
@@ -69,11 +70,11 @@ Java::
}
}
----
======
<1> Set the `@Sql` merge mode to `MERGE` for a specific test method.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@SpringJUnitConfig(TestConfig::class)
@Sql("/test-schema.sql")
@@ -88,5 +89,6 @@ Java::
}
----
<1> Set the `@Sql` merge mode to `MERGE` for a specific test method.
======

View File

@@ -20,11 +20,11 @@ Java::
// class body...
}
----
======
<1> Register two `TestExecutionListener` implementations.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration
@TestExecutionListeners(CustomTestExecutionListener::class, AnotherTestExecutionListener::class) // <1>
@@ -33,11 +33,12 @@ Java::
}
----
<1> Register two `TestExecutionListener` implementations.
======
By default, `@TestExecutionListeners` provides support for inheriting listeners from
superclasses or enclosing classes. See
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration] and the
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration] and the
{api-spring-framework}/test/context/TestExecutionListeners.html[`@TestExecutionListeners`
javadoc] for an example and further details. If you discover that you need to switch
back to using the default `TestExecutionListener` implementations, see the note

View File

@@ -20,11 +20,11 @@ Java::
// class body...
}
----
======
<1> Get properties from `test.properties` in the root of the classpath.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration
@TestPropertySource("/test.properties") // <1>
@@ -33,6 +33,7 @@ Java::
}
----
<1> Get properties from `test.properties` in the root of the classpath.
======
The following example demonstrates how to declare inlined properties:
@@ -49,11 +50,11 @@ Java::
// class body...
}
----
======
<1> Declare `timezone` and `port` properties.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration
@TestPropertySource(properties = ["timezone = GMT", "port: 4242"]) // <1>
@@ -62,6 +63,7 @@ Java::
}
----
<1> Declare `timezone` and `port` properties.
======
See xref:testing/testcontext-framework/ctx-management/property-sources.adoc[Context Configuration with Test Property Sources] for examples and further details.

View File

@@ -25,11 +25,11 @@ Java::
// class body...
}
----
======
<1> The `@WebAppConfiguration` annotation.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration
@WebAppConfiguration // <1>
@@ -38,6 +38,7 @@ Java::
}
----
<1> The `@WebAppConfiguration` annotation.
======
--
@@ -59,11 +60,11 @@ Java::
// class body...
}
----
======
<1> Specifying a classpath resource.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration
@WebAppConfiguration("classpath:test-web-resources") // <1>
@@ -72,6 +73,7 @@ Java::
}
----
<1> Specifying a classpath resource.
======
--

View File

@@ -37,15 +37,15 @@ Java::
.andExpect(content().string("body"));
}
----
======
<1> Check response status is still unchanged
<2> Async processing must have started
<3> Wait and assert the async result
<4> Manually perform an ASYNC dispatch (as there is no running container)
<5> Verify the final response
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Test
fun test() {
@@ -69,5 +69,6 @@ Java::
<3> Wait and assert the async result
<4> Manually perform an ASYNC dispatch (as there is no running container)
<5> Verify the final response
======

View File

@@ -298,7 +298,6 @@ Java::
}
}
----
======
<1> `CreateMessagePage` extends the `AbstractPage`. We do not go over the details of
`AbstractPage`, but, in summary, it contains common functionality for all of our pages.
For example, if our application has a navigational bar, global error messages, and other
@@ -316,8 +315,9 @@ https://github.com/SeleniumHQ/selenium/wiki/PageFactory#making-the-example-work-
to override the default lookup behavior. Our example shows how to use the `@FindBy`
annotation to look up our submit button with a `css` selector (`input[type=submit]`).
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
class CreateMessagePage(private val driver: WebDriver) : AbstractPage(driver) { // <1>
@@ -358,6 +358,7 @@ by the `id` or `name` of the element within the HTML page.
https://github.com/SeleniumHQ/selenium/wiki/PageFactory#making-the-example-work-using-annotations[`@FindBy` annotation]
to override the default lookup behavior. Our example shows how to use the `@FindBy`
annotation to look up our submit button with a `css` selector (*input[type=submit]*).
======
--
Finally, we can verify that a new message was created successfully. The following

View File

@@ -54,14 +54,13 @@ Java::
}
}
----
======
<1> Annotate the test class with `@RecordApplicationEvents`.
<2> Inject the `ApplicationEvents` instance for the current test.
<3> Use the `ApplicationEvents` API to count how many `OrderSubmitted` events were published.
// Don't use "quotes" in the "subs" section because of the asterisks in /* ... */
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
.Kotlin
----
@SpringJUnitConfig(/* ... */)
@RecordApplicationEvents // <1>
@@ -86,6 +85,7 @@ Java::
<1> Annotate the test class with `@RecordApplicationEvents`.
<2> Inject the `ApplicationEvents` instance for the current test.
<3> Use the `ApplicationEvents` API to count how many `OrderSubmitted` events were published.
======
See the
{api-spring-framework}/test/context/event/ApplicationEvents.html[`ApplicationEvents`

View File

@@ -31,11 +31,11 @@ Java::
// class body...
}
----
======
<1> Injecting the `ApplicationContext`.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@SpringJUnitConfig
class MyTest {
@@ -47,6 +47,7 @@ Java::
}
----
<1> Injecting the `ApplicationContext`.
======
Similarly, if your test is configured to load a `WebApplicationContext`, you can inject
@@ -67,12 +68,12 @@ Java::
// class body...
}
----
======
<1> Configuring the `WebApplicationContext`.
<2> Injecting the `WebApplicationContext`.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@SpringJUnitWebConfig // <1>
class MyWebAppTest {
@@ -84,6 +85,7 @@ Java::
----
<1> Configuring the `WebApplicationContext`.
<2> Injecting the `WebApplicationContext`.
======
Dependency injection by using `@Autowired` is provided by the

View File

@@ -28,11 +28,11 @@ Java::
// class body...
}
----
======
<1> Specifying the location of Groovy configuration files.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ExtendWith(SpringExtension::class)
// ApplicationContext will be loaded from "/AppConfig.groovy" and
@@ -43,6 +43,7 @@ Java::
}
----
<1> Specifying the location of Groovy configuration files.
======
If you omit both the `locations` and `value` attributes from the `@ContextConfiguration`
@@ -67,11 +68,11 @@ Java::
// class body...
}
----
======
<1> Loading configuration from the default location.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ExtendWith(SpringExtension::class)
// ApplicationContext will be loaded from
@@ -82,6 +83,7 @@ Java::
}
----
<1> Loading configuration from the default location.
======
.Declaring XML configuration and Groovy scripts simultaneously

View File

@@ -47,12 +47,12 @@ Java::
// class body...
}
----
======
<1> Configuration file defined in the superclass.
<2> Configuration file defined in the subclass.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ExtendWith(SpringExtension::class)
// ApplicationContext will be loaded from "/base-config.xml"
@@ -71,6 +71,7 @@ Java::
----
<1> Configuration file defined in the superclass.
<2> Configuration file defined in the subclass.
======
Similarly, in the next example, which uses component classes, the `ApplicationContext`
@@ -97,12 +98,12 @@ Java::
// class body...
}
----
======
<1> Configuration class defined in the superclass.
<2> Configuration class defined in the subclass.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
// ApplicationContext will be loaded from BaseConfig
@SpringJUnitConfig(BaseConfig::class) // <1>
@@ -118,6 +119,7 @@ Java::
----
<1> Configuration class defined in the superclass.
<2> Configuration class defined in the subclass.
======
In the next example, which uses context initializers, the `ApplicationContext` for
@@ -146,12 +148,12 @@ Java::
// class body...
}
----
======
<1> Initializer defined in the superclass.
<2> Initializer defined in the subclass.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
// ApplicationContext will be initialized by BaseInitializer
@SpringJUnitConfig(initializers = [BaseInitializer::class]) // <1>
@@ -168,5 +170,6 @@ Java::
----
<1> Initializer defined in the superclass.
<2> Initializer defined in the subclass.
======

View File

@@ -29,11 +29,11 @@ Java::
// class body...
}
----
======
<1> Specifying configuration by using a configuration class and an initializer.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ExtendWith(SpringExtension::class)
// ApplicationContext will be loaded from TestConfig
@@ -46,6 +46,7 @@ Java::
}
----
<1> Specifying configuration by using a configuration class and an initializer.
======
You can also omit the declaration of XML configuration files, Groovy scripts, or
@@ -68,11 +69,11 @@ Java::
// class body...
}
----
======
<1> Specifying configuration by using only an initializer.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ExtendWith(SpringExtension::class)
// ApplicationContext will be initialized by EntireAppInitializer
@@ -83,5 +84,6 @@ Java::
}
----
<1> Specifying configuration by using only an initializer.
======

View File

@@ -19,11 +19,11 @@ Java::
// class body...
}
----
======
<1> Specifying component classes.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ExtendWith(SpringExtension::class)
// ApplicationContext will be loaded from AppConfig and TestConfig
@@ -33,6 +33,7 @@ Java::
}
----
<1> Specifying component classes.
======
[[testcontext-ctx-management-javaconfig-component-classes]]
@@ -100,11 +101,11 @@ Java::
}
----
======
<1> Loading configuration information from the nested `Config` class.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@SpringJUnitConfig <1>
// ApplicationContext will be loaded from the nested Config class
@@ -131,5 +132,6 @@ Java::
}
----
<1> Loading configuration information from the nested `Config` class.
======

View File

@@ -52,11 +52,11 @@ Java::
// class body...
}
----
======
<1> Specifying a properties file with an absolute path.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration
@TestPropertySource("/test.properties") // <1>
@@ -65,6 +65,7 @@ Java::
}
----
<1> Specifying a properties file with an absolute path.
======
You can configure inlined properties in the form of key-value pairs by using the
@@ -93,11 +94,11 @@ Java::
// class body...
}
----
======
<1> Setting two properties by using two variations of the key-value syntax.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextConfiguration
@TestPropertySource(properties = ["timezone = GMT", "port: 4242"]) // <1>
@@ -106,6 +107,7 @@ Java::
}
----
<1> Setting two properties by using two variations of the key-value syntax.
======
[NOTE]
====

View File

@@ -24,11 +24,11 @@ Java::
// class body...
}
----
======
<1> Setting the locations attribute to a list of XML files.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ExtendWith(SpringExtension::class)
// ApplicationContext will be loaded from "/app-config.xml" and
@@ -39,6 +39,7 @@ Java::
}
----
<1> Setting the locations attribute to a list of XML files.
======
`@ContextConfiguration` supports an alias for the `locations` attribute through the
@@ -59,11 +60,11 @@ Java::
// class body...
}
----
======
<1> Specifying XML files without using the `locations` attribute.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ExtendWith(SpringExtension::class)
@ContextConfiguration("/app-config.xml", "/test-config.xml") // <1>
@@ -72,6 +73,7 @@ Java::
}
----
<1> Specifying XML files without using the `locations` attribute.
======
If you omit both the `locations` and the `value` attributes from the
@@ -96,11 +98,11 @@ Java::
// class body...
}
----
======
<1> Loading configuration from the default location.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ExtendWith(SpringExtension::class)
// ApplicationContext will be loaded from
@@ -111,5 +113,6 @@ Java::
}
----
<1> Loading configuration from the default location.
======

View File

@@ -105,13 +105,13 @@ Java::
}
}
----
======
<1> Specify the configuration to load
<2> Inject the configuration
<3> Create the `WebTestClient`
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@SpringJUnitConfig(WebConfig::class) // <1>
class MyTests {
@@ -127,6 +127,7 @@ Java::
<1> Specify the configuration to load
<2> Inject the configuration
<3> Create the `WebTestClient`
======
For Spring MVC, use the following where the Spring `ApplicationContext` is passed to
{api-spring-framework}/test/web/servlet/setup/MockMvcBuilders.html#webAppContextSetup-org.springframework.web.context.WebApplicationContext-[MockMvcBuilders.webAppContextSetup]
@@ -158,13 +159,13 @@ Java::
}
}
----
======
<1> Specify the configuration to load
<2> Inject the configuration
<3> Create the `WebTestClient`
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ExtendWith(SpringExtension.class)
@WebAppConfiguration("classpath:META-INF/web-resources") // <1>
@@ -188,6 +189,7 @@ Java::
<1> Specify the configuration to load
<2> Inject the configuration
<3> Create the `WebTestClient`
======