4040import jakarta .servlet .ServletResponse ;
4141import jakarta .servlet .http .HttpServletRequest ;
4242import org .assertj .core .api .Assertions ;
43- import org .jetbrains .annotations .NotNull ;
4443import org .junit .jupiter .api .Test ;
4544import org .junit .jupiter .api .extension .ExtendWith ;
4645
154153@ ExtendWith (OutputCaptureExtension .class )
155154public class ServerMvcIntegrationTests {
156155
157- public static final MediaType FORM_URL_ENCODED_CONTENT_TYPE = new MediaType (APPLICATION_FORM_URLENCODED ,
158- StandardCharsets .UTF_8 );
159-
160156 static {
161157 // if set type to autodetect above
162158 System .setProperty ("sun.net.http.allowRestrictedHeaders" , "true" );
@@ -171,12 +167,6 @@ public class ServerMvcIntegrationTests {
171167 @ Autowired
172168 TestRestClient restClient ;
173169
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-
180170 @ Test
181171 public void nonGatewayRouterFunctionWorks () {
182172 restClient .get ().uri ("/hello" ).exchange ().expectStatus ().isOk ().expectBody (String .class ).isEqualTo ("Hello" );
@@ -603,6 +593,9 @@ public void requestHeaderSizeWorks() {
603593 .isOk ();
604594 }
605595
596+ private static final MediaType FORM_URL_ENCODED_CONTENT_TYPE = new MediaType (APPLICATION_FORM_URLENCODED ,
597+ StandardCharsets .UTF_8 );
598+
606599 @ Test
607600 void formUrlencodedWorks () {
608601 LinkedMultiValueMap <String , String > formData = new LinkedMultiValueMap <>();
@@ -683,6 +676,12 @@ private void assertMultipartData(Map responseBody) {
683676 }
684677 }
685678
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+
686685 @ Test
687686 public void removeRequestHeaderWorks () {
688687 restClient .get ()
@@ -1056,10 +1055,10 @@ EventController eventController() {
10561055 @ Bean
10571056 @ Lazy
10581057 @ Override
1059- public @ NotNull HandlerMappingIntrospector mvcHandlerMappingIntrospector () {
1058+ public HandlerMappingIntrospector mvcHandlerMappingIntrospector () {
10601059 return new HandlerMappingIntrospector () {
10611060 @ Override
1062- public @ NotNull Filter createCacheFilter () {
1061+ public Filter createCacheFilter () {
10631062 return (request , response , chain ) -> {
10641063 chain .doFilter (request , response );
10651064 };
@@ -1691,12 +1690,6 @@ public String toString() {
16911690
16921691 private static class MyFilter implements Filter , Ordered {
16931692
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-
17001693 @ Override
17011694 public int getOrder () {
17021695 return FormFilter .FORM_FILTER_ORDER - 1 ;
@@ -1719,6 +1712,12 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
17191712 }
17201713 }
17211714
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+
17221721 }
17231722
17241723 protected record Hello (String message ) {
0 commit comments