Fix tests and checkstyle violations

See gh-29408
This commit is contained in:
Kulwant Singh 2022-11-01 18:03:14 +01:00 committed by Sam Brannen
parent 20d0becbc6
commit 5245327962
4 changed files with 24 additions and 24 deletions

View File

@ -618,17 +618,17 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script>
document.domain = document.domain;
_sockjs_onload = function(){SockJS.bootstrap_iframe();};
</script>
<script src="%s"></script>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script>
document.domain = document.domain;
_sockjs_onload = function(){SockJS.bootstrap_iframe();};
</script>
<script src="%s"></script>
</head>
<body>
<h2>Don't panic!</h2>
<p>This is a SockJS hidden iframe. It's used for cross domain magic.</p>
<h2>Don't panic!</h2>
<p>This is a SockJS hidden iframe. It's used for cross domain magic.</p>
</body>
</html>""";

View File

@ -61,18 +61,18 @@ public class HtmlFileTransportHandler extends AbstractHttpSendingTransportHandle
static {
StringBuilder sb = new StringBuilder(
"""
<!doctype html>
<!DOCTYPE html>
<html><head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head><body><h2>Don't panic!</h2>
<script>
document.domain = document.domain;
var c = parent.%s;
c.start();
function p(d) {c.message(d);};
window.onload = function() {c.stop();};
</script>"""
<script>
document.domain = document.domain;
var c = parent.%s;
c.start();
function p(d) {c.message(d);};
window.onload = function() {c.stop();};
</script>"""
);
while (sb.length() < MINIMUM_PARTIAL_HTML_CONTENT_LENGTH) {

View File

@ -238,14 +238,14 @@ public class SockJsServiceTests extends AbstractHttpRequestTests {
assertThat(this.servletResponse.getContentType()).isEqualTo("text/html;charset=UTF-8");
assertThat(this.servletResponse.getContentAsString().startsWith("<!DOCTYPE html>\n")).isTrue();
assertThat(this.servletResponse.getContentLength()).isEqualTo(490);
assertThat(this.servletResponse.getContentLength()).isEqualTo(479);
assertThat(this.response.getHeaders().getCacheControl()).isEqualTo("no-store, no-cache, must-revalidate, max-age=0");
assertThat(this.response.getHeaders().getETag()).isEqualTo("\"0096cbd37f2a5218c33bb0826a7c74cbf\"");
assertThat(this.response.getHeaders().getETag()).isEqualTo("\"096aaf2482e2a85effc0ab65a61993ae0\"");
}
@Test
public void handleIframeRequestNotModified() {
this.servletRequest.addHeader("If-None-Match", "\"0096cbd37f2a5218c33bb0826a7c74cbf\"");
this.servletRequest.addHeader("If-None-Match", "\"096aaf2482e2a85effc0ab65a61993ae0\"");
resetResponseAndHandleRequest("GET", "/echo/iframe.html", HttpStatus.NOT_MODIFIED);
}

View File

@ -16,6 +16,8 @@
package org.springframework.web.socket.sockjs.transport.handler;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.Test;
import org.springframework.web.socket.AbstractHttpRequestTests;
@ -26,8 +28,6 @@ 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;