1
1
package com .baeldung .web .controller ;
2
2
3
- import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
4
- import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .header ;
5
- import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
6
-
7
3
import org .junit .jupiter .api .Test ;
8
4
import org .springframework .beans .factory .annotation .Autowired ;
9
5
import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
12
8
import org .springframework .http .MediaType ;
13
9
import org .springframework .test .web .servlet .MockMvc ;
14
10
11
+ import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
12
+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .header ;
13
+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
14
+
15
15
@ SpringBootTest
16
16
@ AutoConfigureMockMvc
17
17
public class EmployeeControllerContentNegotiationIntegrationTest {
@@ -23,7 +23,7 @@ public class EmployeeControllerContentNegotiationIntegrationTest {
23
23
public void whenEndpointUsingJsonSuffixCalled_thenJsonResponseObtained () throws Exception {
24
24
this .mockMvc .perform (get ("/employee/1.json" ))
25
25
.andExpect (status ().isOk ())
26
- .andExpect (header ().string (HttpHeaders .CONTENT_TYPE , MediaType .APPLICATION_JSON_UTF8_VALUE ));
26
+ .andExpect (header ().string (HttpHeaders .CONTENT_TYPE , MediaType .APPLICATION_JSON_VALUE ));
27
27
}
28
28
29
29
@ Test
@@ -37,7 +37,7 @@ public void whenEndpointUsingXmlSuffixCalled_thenXmlResponseObtained() throws Ex
37
37
public void whenEndpointUsingJsonParameterCalled_thenJsonResponseObtained () throws Exception {
38
38
this .mockMvc .perform (get ("/employee/1?mediaType=json" ))
39
39
.andExpect (status ().isOk ())
40
- .andExpect (header ().string (HttpHeaders .CONTENT_TYPE , MediaType .APPLICATION_JSON_UTF8_VALUE ));
40
+ .andExpect (header ().string (HttpHeaders .CONTENT_TYPE , MediaType .APPLICATION_JSON_VALUE ));
41
41
}
42
42
43
43
@ Test
@@ -51,7 +51,7 @@ public void whenEndpointUsingXmlParameterCalled_thenXmlResponseObtained() throws
51
51
public void whenEndpointUsingJsonAcceptHeaderCalled_thenJsonResponseObtained () throws Exception {
52
52
this .mockMvc .perform (get ("/employee/1" ).header (HttpHeaders .ACCEPT , MediaType .APPLICATION_JSON_VALUE ))
53
53
.andExpect (status ().isOk ())
54
- .andExpect (header ().string (HttpHeaders .CONTENT_TYPE , MediaType .APPLICATION_JSON_UTF8_VALUE ));
54
+ .andExpect (header ().string (HttpHeaders .CONTENT_TYPE , MediaType .APPLICATION_JSON_VALUE ));
55
55
}
56
56
57
57
@ Test
0 commit comments