Use StandardCharsets

See gh-29408
This commit is contained in:
Kulwant Singh 2022-10-31 22:49:29 +01:00 committed by Sam Brannen
parent c091bbdeaa
commit bd57d860d2
1 changed files with 6 additions and 4 deletions

View File

@ -26,6 +26,8 @@ import org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSes
import org.springframework.web.socket.sockjs.transport.session.StubSockJsServiceConfig;
import org.springframework.web.socket.sockjs.transport.session.TestHttpSockJsSession;
import java.nio.charset.StandardCharsets;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@ -44,7 +46,7 @@ public class HttpReceivingTransportHandlerTests extends AbstractHttpRequestTests
@Test
public void readMessagesXhr() throws Exception {
this.servletRequest.setContent("[\"x\"]".getBytes("UTF-8"));
this.servletRequest.setContent("[\"x\"]".getBytes(StandardCharsets.UTF_8));
handleRequest(new XhrReceivingTransportHandler());
assertThat(this.servletResponse.getStatus()).isEqualTo(204);
@ -52,10 +54,10 @@ public class HttpReceivingTransportHandlerTests extends AbstractHttpRequestTests
@Test
public void readMessagesBadContent() throws Exception {
this.servletRequest.setContent("".getBytes("UTF-8"));
this.servletRequest.setContent("".getBytes(StandardCharsets.UTF_8));
handleRequestAndExpectFailure();
this.servletRequest.setContent("[\"x]".getBytes("UTF-8"));
this.servletRequest.setContent("[\"x]".getBytes(StandardCharsets.UTF_8));
handleRequestAndExpectFailure();
}
@ -69,7 +71,7 @@ public class HttpReceivingTransportHandlerTests extends AbstractHttpRequestTests
@Test
public void delegateMessageException() throws Exception {
StubSockJsServiceConfig sockJsConfig = new StubSockJsServiceConfig();
this.servletRequest.setContent("[\"x\"]".getBytes("UTF-8"));
this.servletRequest.setContent("[\"x\"]".getBytes(StandardCharsets.UTF_8));
WebSocketHandler wsHandler = mock(WebSocketHandler.class);
TestHttpSockJsSession session = new TestHttpSockJsSession("1", sockJsConfig, wsHandler, null);