parent
e5b596c162
commit
93bcc3dcf5
|
@ -7023,9 +7023,8 @@ property:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = "spring.main.web-application-type=reactive")
|
||||
public class MyWebFluxTests { ... }
|
||||
class MyWebFluxTests { ... }
|
||||
----
|
||||
|
||||
|
||||
|
@ -7088,10 +7087,10 @@ that class explicitly where it is required, as shown in the following example:
|
|||
----
|
||||
@SpringBootTest
|
||||
@Import(MyTestsConfiguration.class)
|
||||
public class MyTests {
|
||||
class MyTests {
|
||||
|
||||
@Test
|
||||
public void exampleTest() {
|
||||
void exampleTest() {
|
||||
...
|
||||
}
|
||||
|
||||
|
@ -7345,7 +7344,7 @@ Strings respectively. Any helper fields on the test class can be `@Autowired` wh
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDeserialize() throws Exception {
|
||||
void testDeserialize() throws Exception {
|
||||
String content = "{\"make\":\"Ford\",\"model\":\"Focus\"}";
|
||||
assertThat(this.json.parse(content))
|
||||
.isEqualTo(new VehicleDetails("Ford", "Focus"));
|
||||
|
@ -7636,10 +7635,9 @@ following example:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
@RunWith(SpringRunner.class)
|
||||
@DataJpaTest
|
||||
@AutoConfigureTestDatabase(replace=Replace.NONE)
|
||||
public class ExampleRepositoryTests {
|
||||
class ExampleRepositoryTests {
|
||||
|
||||
// ...
|
||||
|
||||
|
@ -7765,7 +7763,7 @@ The following class shows the `@DataMongoTest` annotation in use:
|
|||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
||||
@DataMongoTest
|
||||
public class ExampleDataMongoTests {
|
||||
class ExampleDataMongoTests {
|
||||
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
@ -7785,7 +7783,7 @@ the following example:
|
|||
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
|
||||
|
||||
@DataMongoTest(excludeAutoConfiguration = EmbeddedMongoAutoConfiguration.class)
|
||||
public class ExampleDataMongoNonEmbeddedTests {
|
||||
class ExampleDataMongoNonEmbeddedTests {
|
||||
|
||||
}
|
||||
----
|
||||
|
@ -7812,7 +7810,7 @@ The following example shows a typical setup for using Neo4J tests in Spring Boot
|
|||
import org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest;
|
||||
|
||||
@DataNeo4jTest
|
||||
public class ExampleDataNeo4jTests {
|
||||
class ExampleDataNeo4jTests {
|
||||
|
||||
@Autowired
|
||||
private YourRepository repository;
|
||||
|
@ -7835,7 +7833,7 @@ as follows:
|
|||
|
||||
@DataNeo4jTest
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public class ExampleNonTransactionalTests {
|
||||
class ExampleNonTransactionalTests {
|
||||
|
||||
}
|
||||
----
|
||||
|
@ -7861,7 +7859,7 @@ The following example shows the `@DataRedisTest` annotation in use:
|
|||
import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest;
|
||||
|
||||
@DataRedisTest
|
||||
public class ExampleDataRedisTests {
|
||||
class ExampleDataRedisTests {
|
||||
|
||||
@Autowired
|
||||
private YourRepository repository;
|
||||
|
@ -7892,7 +7890,7 @@ The following example shows the `@DataLdapTest` annotation in use:
|
|||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
@DataLdapTest
|
||||
public class ExampleDataLdapTests {
|
||||
class ExampleDataLdapTests {
|
||||
|
||||
@Autowired
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
@ -7912,7 +7910,7 @@ following example:
|
|||
import org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest;
|
||||
|
||||
@DataLdapTest(excludeAutoConfiguration = EmbeddedLdapAutoConfiguration.class)
|
||||
public class ExampleDataLdapNonEmbeddedTests {
|
||||
class ExampleDataLdapNonEmbeddedTests {
|
||||
|
||||
}
|
||||
----
|
||||
|
@ -7935,7 +7933,7 @@ The specific beans that you want to test should be specified by using the `value
|
|||
[source,java,indent=0]
|
||||
----
|
||||
@RestClientTest(RemoteVehicleDetailsService.class)
|
||||
public class ExampleRestClientTest {
|
||||
class ExampleRestClientTest {
|
||||
|
||||
@Autowired
|
||||
private RemoteVehicleDetailsService service;
|
||||
|
@ -7944,7 +7942,7 @@ The specific beans that you want to test should be specified by using the `value
|
|||
private MockRestServiceServer server;
|
||||
|
||||
@Test
|
||||
public void getVehicleDetailsWhenResultIsSuccessShouldReturnDetails()
|
||||
void getVehicleDetailsWhenResultIsSuccessShouldReturnDetails()
|
||||
throws Exception {
|
||||
this.server.expect(requestTo("/greet/details"))
|
||||
.andRespond(withSuccess("hello", MediaType.TEXT_PLAIN));
|
||||
|
@ -8099,10 +8097,9 @@ simply by adding `@ImportAutoConfiguration` to the test as shown in the followin
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
@RunWith(SpringRunner.class)
|
||||
@JdbcTest
|
||||
@ImportAutoConfiguration(IntegrationAutoConfiguration.class)
|
||||
public class ExampleJdbcTests {
|
||||
class ExampleJdbcTests {
|
||||
|
||||
}
|
||||
----
|
||||
|
|
|
@ -18,20 +18,17 @@ package org.springframework.boot.docs.test.autoconfigure.restdocs.webclient;
|
|||
|
||||
// tag::source[]
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs;
|
||||
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@WebFluxTest
|
||||
@AutoConfigureRestDocs
|
||||
public class UsersDocumentationTests {
|
||||
class UsersDocumentationTests {
|
||||
|
||||
@Autowired
|
||||
private WebTestClient webTestClient;
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.springframework.boot.docs.test.web;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
@ -33,7 +34,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
class MockMvcExampleTests {
|
||||
|
||||
@Test
|
||||
void exampleTest(MockMvc mvc) throws Exception {
|
||||
void exampleTest(@Autowired MockMvc mvc) throws Exception {
|
||||
mvc.perform(get("/")).andExpect(status().isOk()).andExpect(content().string("Hello World"));
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
|||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class RandomPortWebTestClientExampleTests {
|
||||
class RandomPortWebTestClientExampleTests {
|
||||
|
||||
@Test
|
||||
void exampleTest(@Autowired WebTestClient webClient) {
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.springframework.boot.docs.web.client;
|
|||
import java.time.Duration;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
@ -29,7 +28,6 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
|
|||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
@ -39,7 +37,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* @author Stephane Nicoll
|
||||
*/
|
||||
// tag::test[]
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
class SampleWebClientTests {
|
||||
|
||||
|
|
Loading…
Reference in New Issue