File tree Expand file tree Collapse file tree 6 files changed +12
-12
lines changed
complete/src/test/java/com/example/testingweb
initial/src/test/java/com/example/testingweb Expand file tree Collapse file tree 6 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 1111import static org .assertj .core .api .Assertions .assertThat ;
1212
1313@ SpringBootTest (webEnvironment = WebEnvironment .RANDOM_PORT )
14- public class HttpRequestTest {
14+ class HttpRequestTest {
1515
1616 @ Value (value ="${local.server.port}" )
1717 private int port ;
@@ -20,7 +20,7 @@ public class HttpRequestTest {
2020 private TestRestTemplate restTemplate ;
2121
2222 @ Test
23- public void greetingShouldReturnDefaultMessage () throws Exception {
23+ void greetingShouldReturnDefaultMessage () throws Exception {
2424 assertThat (this .restTemplate .getForObject ("http://localhost:" + port + "/" ,
2525 String .class )).contains ("Hello, World" );
2626 }
Original file line number Diff line number Diff line change 88import org .springframework .boot .test .context .SpringBootTest ;
99
1010@ SpringBootTest
11- public class SmokeTest {
11+ class SmokeTest {
1212
1313 @ Autowired
1414 private HomeController controller ;
1515
1616 @ Test
17- public void contextLoads () throws Exception {
17+ void contextLoads () throws Exception {
1818 assertThat (controller ).isNotNull ();
1919 }
2020}
Original file line number Diff line number Diff line change 1515
1616@ SpringBootTest
1717@ AutoConfigureMockMvc
18- public class TestingWebApplicationTest {
18+ class TestingWebApplicationTest {
1919
2020 @ Autowired
2121 private MockMvc mockMvc ;
2222
2323 @ Test
24- public void shouldReturnDefaultMessage () throws Exception {
24+ void shouldReturnDefaultMessage () throws Exception {
2525 this .mockMvc .perform (get ("/" )).andDo (print ()).andExpect (status ().isOk ())
2626 .andExpect (content ().string (containsString ("Hello, World" )));
2727 }
Original file line number Diff line number Diff line change 1414
1515@ WebMvcTest (HomeController .class )
1616//tag::test[]
17- public class WebLayerTest {
17+ class WebLayerTest {
1818
1919 @ Autowired
2020 private MockMvc mockMvc ;
2121
2222 @ Test
23- public void shouldReturnDefaultMessage () throws Exception {
23+ void shouldReturnDefaultMessage () throws Exception {
2424 this .mockMvc .perform (get ("/" )).andDo (print ()).andExpect (status ().isOk ())
2525 .andExpect (content ().string (containsString ("Hello, World" )));
2626 }
Original file line number Diff line number Diff line change 1515import org .springframework .test .web .servlet .MockMvc ;
1616
1717@ WebMvcTest (GreetingController .class )
18- public class WebMockTest {
18+ class WebMockTest {
1919
2020 @ Autowired
2121 private MockMvc mockMvc ;
@@ -24,7 +24,7 @@ public class WebMockTest {
2424 private GreetingService service ;
2525
2626 @ Test
27- public void greetingShouldReturnMessageFromService () throws Exception {
27+ void greetingShouldReturnMessageFromService () throws Exception {
2828 when (service .greet ()).thenReturn ("Hello, Mock" );
2929 this .mockMvc .perform (get ("/greeting" )).andDo (print ()).andExpect (status ().isOk ())
3030 .andExpect (content ().string (containsString ("Hello, Mock" )));
Original file line number Diff line number Diff line change 55import org .springframework .boot .test .context .SpringBootTest ;
66
77@ SpringBootTest
8- public class TestingWebApplicationTests {
8+ class TestingWebApplicationTests {
99
1010 @ Test
11- public void contextLoads () {
11+ void contextLoads () {
1212 }
1313
1414}
You can’t perform that action at this time.
0 commit comments