3
3
4
4
import com .fasterxml .jackson .core .type .TypeReference ;
5
5
import com .fasterxml .jackson .databind .ObjectMapper ;
6
+ import org .junit .jupiter .api .extension .ExtendWith ;
6
7
import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
7
8
import org .springframework .boot .test .context .SpringBootTest ;
8
9
import org .springframework .mock .web .MockHttpServletRequest ;
11
12
import org .springframework .test .annotation .DirtiesContext ;
12
13
import org .springframework .test .annotation .DirtiesContext .ClassMode ;
13
14
import org .springframework .test .context .ActiveProfiles ;
14
- import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
15
+ import org .springframework .test .context .junit .jupiter .SpringExtension ;
16
+
15
17
import org .springframework .beans .factory .annotation .Autowired ;
16
18
import org .springframework .test .web .servlet .MockMvc ;
17
19
import org .springframework .test .web .servlet .request .MockHttpServletRequestBuilder ;
18
20
import org .springframework .test .web .servlet .MvcResult ;
19
21
import org .springframework .test .web .servlet .ResultActions ;
20
22
import org .springframework .http .MediaType ;
21
- import org . junit . runner . RunWith ;
22
- import org .junit .Test ;
23
+
24
+ import org .junit .jupiter . api . Test ;
23
25
24
26
import java .util .List ;
25
27
28
+ import static org .hamcrest .MatcherAssert .assertThat ;
26
29
import static org .hamcrest .Matchers .greaterThan ;
27
30
import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
28
31
import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .post ;
29
32
import static org .springframework .test .web .servlet .result .MockMvcResultHandlers .print ;
30
33
import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
31
34
import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .content ;
32
35
import static org .hamcrest .CoreMatchers .containsString ;
33
- import static org . junit . Assert . assertThat ;
36
+
34
37
35
38
/**
36
39
* A wrapper annotation for use with integration tests.
37
40
*
38
41
* By default, assumes the integration test modifies the
39
- * {@link ApplicationContext} associated with the test/s and will therefore be
42
+ * {@link org.springframework.context. ApplicationContext} associated with the test/s and will therefore be
40
43
* closed and removed from the context cache at the end of the class.
41
44
*/
42
45
@ SpringBootTest (classes = Application .class )
43
46
@ DirtiesContext (classMode = ClassMode .AFTER_CLASS )
44
- @ RunWith (SpringJUnit4ClassRunner .class )
45
47
@ AutoConfigureMockMvc
46
48
@ ActiveProfiles ("it" )
47
- public class ExampleControllerIT {
49
+ class ExampleControllerIT {
48
50
49
51
String TOKEN_ATTR_NAME = "org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository.CSRF_TOKEN" ;
50
52
@@ -58,7 +60,7 @@ public class ExampleControllerIT {
58
60
private MockMvc mvc ;
59
61
60
62
@ Test
61
- public void exampleTest () throws Exception {
63
+ void exampleTest () throws Exception {
62
64
String greetingsId = givenAGreetingExists ();
63
65
whenWeGetTheMessageByIdThenTheMessageExists (greetingsId );
64
66
WhenWeGetAllMessagesThenAListOfMessagesIsReturned ();
0 commit comments