11/*
2- * Copyright 2002-2019 the original author or authors.
2+ * Copyright 2002-2021 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -45,20 +45,20 @@ public class ServletServerHttpRequestTests {
4545
4646
4747 @ BeforeEach
48- public void create () {
48+ void create () {
4949 mockRequest = new MockHttpServletRequest ();
5050 request = new ServletServerHttpRequest (mockRequest );
5151 }
5252
5353
5454 @ Test
55- public void getMethod () {
55+ void getMethod () {
5656 mockRequest .setMethod ("POST" );
5757 assertThat (request .getMethod ()).as ("Invalid method" ).isEqualTo (HttpMethod .POST );
5858 }
5959
6060 @ Test
61- public void getUriForSimplePath () throws URISyntaxException {
61+ void getUriForSimplePath () throws URISyntaxException {
6262 URI uri = new URI ("https://example.com/path" );
6363 mockRequest .setScheme (uri .getScheme ());
6464 mockRequest .setServerName (uri .getHost ());
@@ -69,7 +69,7 @@ public void getUriForSimplePath() throws URISyntaxException {
6969 }
7070
7171 @ Test
72- public void getUriWithQueryString () throws URISyntaxException {
72+ void getUriWithQueryString () throws URISyntaxException {
7373 URI uri = new URI ("https://example.com/path?query" );
7474 mockRequest .setScheme (uri .getScheme ());
7575 mockRequest .setServerName (uri .getHost ());
@@ -80,7 +80,7 @@ public void getUriWithQueryString() throws URISyntaxException {
8080 }
8181
8282 @ Test // SPR-16414
83- public void getUriWithQueryParam () throws URISyntaxException {
83+ void getUriWithQueryParam () throws URISyntaxException {
8484 mockRequest .setScheme ("https" );
8585 mockRequest .setServerPort (443 );
8686 mockRequest .setServerName ("example.com" );
@@ -90,7 +90,7 @@ public void getUriWithQueryParam() throws URISyntaxException {
9090 }
9191
9292 @ Test // SPR-16414
93- public void getUriWithMalformedQueryParam () throws URISyntaxException {
93+ void getUriWithMalformedQueryParam () throws URISyntaxException {
9494 mockRequest .setScheme ("https" );
9595 mockRequest .setServerPort (443 );
9696 mockRequest .setServerName ("example.com" );
@@ -100,7 +100,7 @@ public void getUriWithMalformedQueryParam() throws URISyntaxException {
100100 }
101101
102102 @ Test // SPR-13876
103- public void getUriWithEncoding () throws URISyntaxException {
103+ void getUriWithEncoding () throws URISyntaxException {
104104 URI uri = new URI ("https://example.com/%E4%B8%AD%E6%96%87" +
105105 "?redirect=https%3A%2F%2Fgithub.202132.xyz%2Fspring-projects%2Fspring-framework" );
106106 mockRequest .setScheme (uri .getScheme ());
@@ -112,7 +112,7 @@ public void getUriWithEncoding() throws URISyntaxException {
112112 }
113113
114114 @ Test
115- public void getHeaders () {
115+ void getHeaders () {
116116 String headerName = "MyHeader" ;
117117 String headerValue1 = "value1" ;
118118 String headerValue2 = "value2" ;
@@ -132,7 +132,7 @@ public void getHeaders() {
132132 }
133133
134134 @ Test
135- public void getHeadersWithEmptyContentTypeAndEncoding () {
135+ void getHeadersWithEmptyContentTypeAndEncoding () {
136136 String headerName = "MyHeader" ;
137137 String headerValue1 = "value1" ;
138138 String headerValue2 = "value2" ;
@@ -152,25 +152,26 @@ public void getHeadersWithEmptyContentTypeAndEncoding() {
152152 }
153153
154154 @ Test
155- public void getBody () throws IOException {
156- byte [] content = "Hello World" .getBytes ("UTF-8" );
155+ void getBody () throws IOException {
156+ byte [] content = "Hello World" .getBytes (StandardCharsets . UTF_8 );
157157 mockRequest .setContent (content );
158158
159159 byte [] result = FileCopyUtils .copyToByteArray (request .getBody ());
160160 assertThat (result ).as ("Invalid content returned" ).isEqualTo (content );
161161 }
162162
163163 @ Test
164- public void getFormBody () throws IOException {
164+ void getFormBody () throws IOException {
165165 // Charset (SPR-8676)
166166 mockRequest .setContentType ("application/x-www-form-urlencoded; charset=UTF-8" );
167167 mockRequest .setMethod ("POST" );
168168 mockRequest .addParameter ("name 1" , "value 1" );
169- mockRequest .addParameter ("name 2" , new String [] { "value 2+1" , "value 2+2" } );
169+ mockRequest .addParameter ("name 2" , "value 2+1" , "value 2+2" );
170170 mockRequest .addParameter ("name 3" , (String ) null );
171171
172172 byte [] result = FileCopyUtils .copyToByteArray (request .getBody ());
173- byte [] content = "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3" .getBytes ("UTF-8" );
173+ byte [] content = "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3" .getBytes (
174+ StandardCharsets .UTF_8 );
174175 assertThat (result ).as ("Invalid content returned" ).isEqualTo (content );
175176 }
176177
0 commit comments