Commit e3f203a8 authored by Phillip Webb's avatar Phillip Webb

Polish

parent 441beee2
...@@ -477,6 +477,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord ...@@ -477,6 +477,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
} }
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override @Override
public void customize(Connector connector) { public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler(); ProtocolHandler handler = connector.getProtocolHandler();
...@@ -489,14 +490,15 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord ...@@ -489,14 +490,15 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
} }
private String coerceCompression(String compression) { private String coerceCompression(String compression) {
if (Boolean.toString(true).equals(compression)) { if ("true".equalsIgnoreCase(compression)) {
return "on"; return "on";
} }
else if (Boolean.toString(false).equals(compression)) { if ("false".equalsIgnoreCase(compression)) {
return "off"; return "off";
} }
return compression; return compression;
} }
}); });
if (this.accessLogEnabled) { if (this.accessLogEnabled) {
......
...@@ -205,13 +205,13 @@ public class ServerPropertiesTests { ...@@ -205,13 +205,13 @@ public class ServerPropertiesTests {
@Test @Test
public void disableTomcatCompressionWithYaml() throws Exception { public void disableTomcatCompressionWithYaml() throws Exception {
// YAML interprets "off" as false, check that it's mapped back to off // YAML interprets "off" as false, check that it's mapped back to off
assertThat("off", is(equalTo(configureCompression("false")))); assertThat("off", is(equalTo(configureCompression("faLSe"))));
} }
@Test @Test
public void enableTomcatCompressionWithYaml() throws Exception { public void enableTomcatCompressionWithYaml() throws Exception {
// YAML interprets "on" as true, check that it's mapped back to on // YAML interprets "on" as true, check that it's mapped back to on
assertThat("on", is(equalTo(configureCompression("true")))); assertThat("on", is(equalTo(configureCompression("trUE"))));
} }
@Test @Test
......
...@@ -325,9 +325,7 @@ public class ErrorPageFilterTests { ...@@ -325,9 +325,7 @@ public class ErrorPageFilterTests {
@Test @Test
public void responseIsNotCommitedWhenRequestIsAsync() throws Exception { public void responseIsNotCommitedWhenRequestIsAsync() throws Exception {
this.request.setAsyncStarted(true); this.request.setAsyncStarted(true);
this.filter.doFilter(this.request, this.response, this.chain); this.filter.doFilter(this.request, this.response, this.chain);
assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request)); assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request));
assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(), assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(),
equalTo((ServletResponse) this.response)); equalTo((ServletResponse) this.response));
...@@ -347,9 +345,7 @@ public class ErrorPageFilterTests { ...@@ -347,9 +345,7 @@ public class ErrorPageFilterTests {
throw new RuntimeException("BAD"); throw new RuntimeException("BAD");
} }
}; };
this.filter.doFilter(this.request, this.response, this.chain); this.filter.doFilter(this.request, this.response, this.chain);
assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request)); assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request));
assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(), assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(),
equalTo((ServletResponse) this.response)); equalTo((ServletResponse) this.response));
...@@ -368,9 +364,7 @@ public class ErrorPageFilterTests { ...@@ -368,9 +364,7 @@ public class ErrorPageFilterTests {
((HttpServletResponse) response).sendError(400, "BAD"); ((HttpServletResponse) response).sendError(400, "BAD");
} }
}; };
this.filter.doFilter(this.request, this.response, this.chain); this.filter.doFilter(this.request, this.response, this.chain);
assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request)); assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request));
assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(), assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(),
equalTo((ServletResponse) this.response)); equalTo((ServletResponse) this.response));
...@@ -380,9 +374,7 @@ public class ErrorPageFilterTests { ...@@ -380,9 +374,7 @@ public class ErrorPageFilterTests {
@Test @Test
public void responseIsNotCommitedDuringAsyncDispatch() throws Exception { public void responseIsNotCommitedDuringAsyncDispatch() throws Exception {
setUpAsyncDispatch(); setUpAsyncDispatch();
this.filter.doFilter(this.request, this.response, this.chain); this.filter.doFilter(this.request, this.response, this.chain);
assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request)); assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request));
assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(), assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(),
equalTo((ServletResponse) this.response)); equalTo((ServletResponse) this.response));
...@@ -402,9 +394,7 @@ public class ErrorPageFilterTests { ...@@ -402,9 +394,7 @@ public class ErrorPageFilterTests {
throw new RuntimeException("BAD"); throw new RuntimeException("BAD");
} }
}; };
this.filter.doFilter(this.request, this.response, this.chain); this.filter.doFilter(this.request, this.response, this.chain);
assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request)); assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request));
assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(), assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(),
equalTo((ServletResponse) this.response)); equalTo((ServletResponse) this.response));
...@@ -424,9 +414,7 @@ public class ErrorPageFilterTests { ...@@ -424,9 +414,7 @@ public class ErrorPageFilterTests {
((HttpServletResponse) response).sendError(400, "BAD"); ((HttpServletResponse) response).sendError(400, "BAD");
} }
}; };
this.filter.doFilter(this.request, this.response, this.chain); this.filter.doFilter(this.request, this.response, this.chain);
assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request)); assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request));
assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(), assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getResponse(),
equalTo((ServletResponse) this.response)); equalTo((ServletResponse) this.response));
...@@ -439,9 +427,7 @@ public class ErrorPageFilterTests { ...@@ -439,9 +427,7 @@ public class ErrorPageFilterTests {
HttpServletResponse committedResponse = mock(HttpServletResponse.class); HttpServletResponse committedResponse = mock(HttpServletResponse.class);
given(committedResponse.isCommitted()).willReturn(true); given(committedResponse.isCommitted()).willReturn(true);
given(committedResponse.getStatus()).willReturn(200); given(committedResponse.getStatus()).willReturn(200);
this.filter.doFilter(this.request, committedResponse, this.chain); this.filter.doFilter(this.request, committedResponse, this.chain);
verify(committedResponse, times(0)).flushBuffer(); verify(committedResponse, times(0)).flushBuffer();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment