40
40
import jakarta .servlet .ServletResponse ;
41
41
import jakarta .servlet .http .HttpServletRequest ;
42
42
import org .assertj .core .api .Assertions ;
43
- import org .jetbrains .annotations .NotNull ;
44
43
import org .junit .jupiter .api .Test ;
45
44
import org .junit .jupiter .api .extension .ExtendWith ;
46
45
154
153
@ ExtendWith (OutputCaptureExtension .class )
155
154
public class ServerMvcIntegrationTests {
156
155
157
- public static final MediaType FORM_URL_ENCODED_CONTENT_TYPE = new MediaType (APPLICATION_FORM_URLENCODED ,
158
- StandardCharsets .UTF_8 );
159
-
160
156
static {
161
157
// if set type to autodetect above
162
158
System .setProperty ("sun.net.http.allowRestrictedHeaders" , "true" );
@@ -171,12 +167,6 @@ public class ServerMvcIntegrationTests {
171
167
@ Autowired
172
168
TestRestClient restClient ;
173
169
174
- private static boolean isPNG (byte [] bytes ) {
175
- byte [] pngSignature = { (byte ) 0x89 , 0x50 , 0x4E , 0x47 , 0x0D , 0x0A , 0x1A , 0x0A };
176
- byte [] header = Arrays .copyOf (bytes , pngSignature .length );
177
- return Arrays .equals (pngSignature , header );
178
- }
179
-
180
170
@ Test
181
171
public void nonGatewayRouterFunctionWorks () {
182
172
restClient .get ().uri ("/hello" ).exchange ().expectStatus ().isOk ().expectBody (String .class ).isEqualTo ("Hello" );
@@ -603,6 +593,9 @@ public void requestHeaderSizeWorks() {
603
593
.isOk ();
604
594
}
605
595
596
+ public static final MediaType FORM_URL_ENCODED_CONTENT_TYPE = new MediaType (APPLICATION_FORM_URLENCODED ,
597
+ StandardCharsets .UTF_8 );
598
+
606
599
@ Test
607
600
void formUrlencodedWorks () {
608
601
LinkedMultiValueMap <String , String > formData = new LinkedMultiValueMap <>();
@@ -683,6 +676,12 @@ private void assertMultipartData(Map responseBody) {
683
676
}
684
677
}
685
678
679
+ private static boolean isPNG (byte [] bytes ) {
680
+ byte [] pngSignature = { (byte ) 0x89 , 0x50 , 0x4E , 0x47 , 0x0D , 0x0A , 0x1A , 0x0A };
681
+ byte [] header = Arrays .copyOf (bytes , pngSignature .length );
682
+ return Arrays .equals (pngSignature , header );
683
+ }
684
+
686
685
@ Test
687
686
public void removeRequestHeaderWorks () {
688
687
restClient .get ()
@@ -1056,10 +1055,10 @@ EventController eventController() {
1056
1055
@ Bean
1057
1056
@ Lazy
1058
1057
@ Override
1059
- public @ NotNull HandlerMappingIntrospector mvcHandlerMappingIntrospector () {
1058
+ public HandlerMappingIntrospector mvcHandlerMappingIntrospector () {
1060
1059
return new HandlerMappingIntrospector () {
1061
1060
@ Override
1062
- public @ NotNull Filter createCacheFilter () {
1061
+ public Filter createCacheFilter () {
1063
1062
return (request , response , chain ) -> {
1064
1063
chain .doFilter (request , response );
1065
1064
};
@@ -1691,12 +1690,6 @@ public String toString() {
1691
1690
1692
1691
private static class MyFilter implements Filter , Ordered {
1693
1692
1694
- static boolean isFormPost (HttpServletRequest request ) {
1695
- String contentType = request .getContentType ();
1696
- return (contentType != null && contentType .contains (MediaType .APPLICATION_FORM_URLENCODED_VALUE )
1697
- && HttpMethod .POST .matches (request .getMethod ()));
1698
- }
1699
-
1700
1693
@ Override
1701
1694
public int getOrder () {
1702
1695
return FormFilter .FORM_FILTER_ORDER - 1 ;
@@ -1719,6 +1712,12 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
1719
1712
}
1720
1713
}
1721
1714
1715
+ static boolean isFormPost (HttpServletRequest request ) {
1716
+ String contentType = request .getContentType ();
1717
+ return (contentType != null && contentType .contains (MediaType .APPLICATION_FORM_URLENCODED_VALUE )
1718
+ && HttpMethod .POST .matches (request .getMethod ()));
1719
+ }
1720
+
1722
1721
}
1723
1722
1724
1723
protected record Hello (String message ) {
0 commit comments