Migrate to Asciidoctor Tabs

This commit is contained in:
Rob Winch
2023-04-20 16:21:36 -05:00
committed by rstoyanchev
parent 71154fd16b
commit 39146f9066
243 changed files with 7124 additions and 1779 deletions

View File

@@ -7,8 +7,11 @@ integration test.
The following example indicates that the `dev` profile should be active:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration
@ActiveProfiles("dev") // <1>
@@ -16,6 +19,7 @@ The following example indicates that the `dev` profile should be active:
// class body...
}
----
======
<1> Indicate that the `dev` profile should be active.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -33,8 +37,11 @@ The following example indicates that the `dev` profile should be active:
The following example indicates that both the `dev` and the `integration` profiles should
be active:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration
@ActiveProfiles({"dev", "integration"}) // <1>
@@ -42,6 +49,7 @@ be active:
// class body...
}
----
======
<1> Indicate that the `dev` and `integration` profiles should be active.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -7,14 +7,18 @@ transaction by using Spring's `@Transactional` annotation. `@AfterTransaction` m
are not required to be `public` and may be declared on Java 8-based interface default
methods.
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@AfterTransaction // <1>
void afterTransaction() {
// logic to be run after a transaction has ended
}
----
======
<1> Run this method after a transaction.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -9,14 +9,18 @@ methods.
The following example shows how to use the `@BeforeTransaction` annotation:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@BeforeTransaction // <1>
void beforeTransaction() {
// logic to be run before a transaction is started
}
----
======
<1> Run this method before a transaction.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -9,8 +9,11 @@ annotation.
The following example shows how to use the `@Commit` annotation:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@Commit // <1>
@Test
@@ -18,6 +21,7 @@ The following example shows how to use the `@Commit` annotation:
// ...
}
----
======
<1> Commit the result of the test to the database.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -15,14 +15,18 @@ xref:testing/testcontext-framework/ctx-management/javaconfig.adoc#testcontext-ct
The following example shows a `@ContextConfiguration` annotation that refers to an XML
file:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration("/test-config.xml") // <1>
class XmlApplicationContextTests {
// class body...
}
----
======
<1> Referring to an XML file.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -38,14 +42,18 @@ file:
The following example shows a `@ContextConfiguration` annotation that refers to a class:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration(classes = TestConfig.class) // <1>
class ConfigClassApplicationContextTests {
// class body...
}
----
======
<1> Referring to a class.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -63,14 +71,18 @@ As an alternative or in addition to declaring resource locations or component cl
you can use `@ContextConfiguration` to declare `ApplicationContextInitializer` classes.
The following example shows such a case:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration(initializers = CustomContextInitializer.class) // <1>
class ContextInitializerTests {
// class body...
}
----
======
<1> Declaring an initializer class.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -91,14 +103,18 @@ component `classes`.
The following example uses both a location and a loader:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration(locations = "/test-context.xml", loader = CustomContextLoader.class) // <1>
class CustomLoaderXmlApplicationContextTests {
// class body...
}
----
======
<1> Configuring both a location and a custom loader.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -8,8 +8,11 @@ defines a level in the context hierarchy. The following examples demonstrate the
`@ContextHierarchy` within a single test class (`@ContextHierarchy` can also be used
within a test class hierarchy):
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextHierarchy({
@ContextConfiguration("/parent-config.xml"),
@@ -19,8 +22,10 @@ within a test class hierarchy):
// class body...
}
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@ContextHierarchy(
ContextConfiguration("/parent-config.xml"),
@@ -29,9 +34,13 @@ within a test class hierarchy):
// class body...
}
----
======
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@WebAppConfiguration
@ContextHierarchy({
@@ -42,8 +51,10 @@ within a test class hierarchy):
// class body...
}
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@WebAppConfiguration
@ContextHierarchy(
@@ -53,6 +64,7 @@ within a test class hierarchy):
// class body...
}
----
======
If you need to merge or override the configuration for a given level of the context
hierarchy within a test class hierarchy, you must explicitly name that level by supplying

View File

@@ -20,14 +20,18 @@ configuration scenarios:
* Before the current test class, when declared on a class with class mode set to
`BEFORE_CLASS`.
+
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@DirtiesContext(classMode = BEFORE_CLASS) // <1>
class FreshContextTests {
// some tests that require a new Spring container
}
----
======
<1> Dirty the context before the current test class.
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -43,14 +47,18 @@ configuration scenarios:
* After the current test class, when declared on a class with class mode set to
`AFTER_CLASS` (i.e., the default class mode).
+
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@DirtiesContext // <1>
class ContextDirtyingTests {
// some tests that result in the Spring container being dirtied
}
----
======
<1> Dirty the context after the current test class.
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -67,14 +75,18 @@ configuration scenarios:
* Before each test method in the current test class, when declared on a class with class
mode set to `BEFORE_EACH_TEST_METHOD.`
+
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@DirtiesContext(classMode = BEFORE_EACH_TEST_METHOD) // <1>
class FreshContextTests {
// some tests that require a new Spring container
}
----
======
<1> Dirty the context before each test method.
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -91,14 +103,18 @@ mode set to `BEFORE_EACH_TEST_METHOD.`
* After each test method in the current test class, when declared on a class with class
mode set to `AFTER_EACH_TEST_METHOD.`
+
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD) // <1>
class ContextDirtyingTests {
// some tests that result in the Spring container being dirtied
}
----
======
<1> Dirty the context after each test method.
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -115,8 +131,11 @@ mode set to `AFTER_EACH_TEST_METHOD.`
* Before the current test, when declared on a method with the method mode set to
`BEFORE_METHOD`.
+
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@DirtiesContext(methodMode = BEFORE_METHOD) // <1>
@Test
@@ -124,6 +143,7 @@ mode set to `AFTER_EACH_TEST_METHOD.`
// some logic that requires a new Spring container
}
----
======
<1> Dirty the context before the current test method.
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -140,8 +160,11 @@ mode set to `AFTER_EACH_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).
+
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@DirtiesContext // <1>
@Test
@@ -149,6 +172,7 @@ mode set to `AFTER_EACH_TEST_METHOD.`
// some logic that results in the Spring container being dirtied
}
----
======
<1> Dirty the context after the current test method.
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -173,8 +197,11 @@ context are removed from the context cache and closed. If the exhaustive algorit
overkill for a particular use case, you can specify the simpler current level algorithm,
as the following example shows.
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextHierarchy({
@ContextConfiguration("/parent-config.xml"),
@@ -193,6 +220,7 @@ as the following example shows.
}
}
----
======
<1> Use the current-level algorithm.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -10,8 +10,11 @@ https://www.testcontainers.org/[Testcontainers] project.
The following example demonstrates how to register a dynamic property:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration
class MyIntegrationTests {
@@ -26,6 +29,7 @@ The following example demonstrates how to register a dynamic property:
// 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.

View File

@@ -15,8 +15,11 @@ method, potentially overriding class-level `@Rollback` or `@Commit` semantics.
The following example causes a test method's result to not be rolled back (that is, the
result is committed to the database):
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@Rollback(false) // <1>
@Test
@@ -24,6 +27,7 @@ result is committed to the database):
// ...
}
----
======
<1> Do not roll back the result.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -5,8 +5,11 @@
against a given database during integration tests. The following example shows how to use
it:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@Test
@Sql({"/test-schema.sql", "/test-user-data.sql"}) // <1>
@@ -14,6 +17,7 @@ it:
// run code that relies on the test schema and test data
}
----
======
<1> Run two scripts for this test.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -4,8 +4,11 @@
`@SqlConfig` defines metadata that is used to determine how to parse and run SQL scripts
configured with the `@Sql` annotation. The following example shows how to use it:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@Test
@Sql(
@@ -16,6 +19,7 @@ configured with the `@Sql` annotation. The following example shows how to use it
// run code that relies on the test data
}
----
======
<1> Set the comment prefix and the separator in SQL scripts.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -7,8 +7,11 @@ in conjunction with Java 8's support for repeatable annotations, where `@Sql` ca
declared several times on the same class or method, implicitly generating this container
annotation. The following example shows how to declare an SQL group:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@Test
@SqlGroup({ // <1>
@@ -19,6 +22,7 @@ annotation. The following example shows how to declare an SQL group:
// run code that uses the test schema and test data
}
----
======
<1> Declare a group of SQL scripts.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -11,8 +11,11 @@ Note that a method-level `@SqlMergeMode` declaration overrides a class-level dec
The following example shows how to use `@SqlMergeMode` at the class level.
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@SpringJUnitConfig(TestConfig.class)
@Sql("/test-schema.sql")
@@ -26,6 +29,7 @@ The following example shows how to use `@SqlMergeMode` at the class level.
}
}
----
======
<1> Set the `@Sql` merge mode to `MERGE` for all test methods in the class.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -47,8 +51,11 @@ The following example shows how to use `@SqlMergeMode` at the class level.
The following example shows how to use `@SqlMergeMode` at the method level.
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@SpringJUnitConfig(TestConfig.class)
@Sql("/test-schema.sql")
@@ -62,6 +69,7 @@ The following example shows how to use `@SqlMergeMode` at the method level.
}
}
----
======
<1> Set the `@Sql` merge mode to `MERGE` for a specific test method.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -8,8 +8,11 @@ xref:testing/testcontext-framework/tel-config.adoc[`TestExecutionListener` Confi
The following example shows how to register two `TestExecutionListener` implementations:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration
@TestExecutionListeners({CustomTestExecutionListener.class, AnotherTestExecutionListener.class}) // <1>
@@ -17,6 +20,7 @@ The following example shows how to register two `TestExecutionListener` implemen
// class body...
}
----
======
<1> Register two `TestExecutionListener` implementations.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -8,8 +8,11 @@ integration test.
The following example demonstrates how to declare a properties file from the classpath:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration
@TestPropertySource("/test.properties") // <1>
@@ -17,6 +20,7 @@ The following example demonstrates how to declare a properties file from the cla
// class body...
}
----
======
<1> Get properties from `test.properties` in the root of the classpath.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -33,8 +37,11 @@ The following example demonstrates how to declare a properties file from the cla
The following example demonstrates how to declare inlined properties:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration
@TestPropertySource(properties = { "timezone = GMT", "port: 4242" }) // <1>
@@ -42,6 +49,7 @@ The following example demonstrates how to declare inlined properties:
// class body...
}
----
======
<1> Declare `timezone` and `port` properties.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]

View File

@@ -13,8 +13,11 @@ resource base path). The resource base path is used behind the scenes to create
The following example shows how to use the `@WebAppConfiguration` annotation:
--
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration
@WebAppConfiguration // <1>
@@ -22,6 +25,7 @@ The following example shows how to use the `@WebAppConfiguration` annotation:
// class body...
}
----
======
<1> The `@WebAppConfiguration` annotation.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -43,8 +47,11 @@ supported. If no resource prefix is supplied, the path is assumed to be a file s
resource. The following example shows how to specify a classpath resource:
--
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@ContextConfiguration
@WebAppConfiguration("classpath:test-web-resources") // <1>
@@ -52,6 +59,7 @@ resource. The following example shows how to specify a classpath resource:
// class body...
}
----
======
<1> Specifying a classpath resource.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]