Skip to content

Commit

Permalink
Update documentation to use JUnit Jupiter
Browse files Browse the repository at this point in the history
  • Loading branch information
wonwoo authored and snicoll committed Jul 16, 2019
1 parent e5b596c commit 93bcc3d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 27 deletions.
Expand Up @@ -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 { ... }
----


Expand Down Expand Up @@ -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() {
...
}
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -7636,10 +7635,9 @@ following example:

[source,java,indent=0]
----
@RunWith(SpringRunner.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace=Replace.NONE)
public class ExampleRepositoryTests {
class ExampleRepositoryTests {
// ...
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
}
----
Expand All @@ -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;
Expand All @@ -7835,7 +7833,7 @@ as follows:
@DataNeo4jTest
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public class ExampleNonTransactionalTests {
class ExampleNonTransactionalTests {
}
----
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -7912,7 +7910,7 @@ following example:
import org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest;
@DataLdapTest(excludeAutoConfiguration = EmbeddedLdapAutoConfiguration.class)
public class ExampleDataLdapNonEmbeddedTests {
class ExampleDataLdapNonEmbeddedTests {
}
----
Expand All @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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 {
}
----
Expand Down
Expand Up @@ -18,20 +18,17 @@

// 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;
Expand Down
Expand Up @@ -20,6 +20,7 @@

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;
Expand All @@ -33,7 +34,7 @@
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"));
}

Expand Down
Expand Up @@ -26,7 +26,7 @@
import org.springframework.test.web.reactive.server.WebTestClient;

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class RandomPortWebTestClientExampleTests {
class RandomPortWebTestClientExampleTests {

@Test
void exampleTest(@Autowired WebTestClient webClient) {
Expand Down
Expand Up @@ -19,7 +19,6 @@
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;
Expand All @@ -29,7 +28,6 @@
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;

Expand All @@ -39,7 +37,6 @@
* @author Stephane Nicoll
*/
// tag::test[]
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
class SampleWebClientTests {

Expand Down

0 comments on commit 93bcc3d

Please sign in to comment.