diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java index 61f73663ebe..b63816c4492 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java @@ -502,16 +502,25 @@ public class GzipFilterDefaultTest public void testIsNotGzipCompressedHttpStatus() throws Exception { GzipTester tester = new GzipTester(testingdir, compressionType); - tester.setGzipFilterClass(testFilter); + + // Add Gzip Filter first + FilterHolder gzipHolder = new FilterHolder(testFilter); + gzipHolder.setAsyncSupported(true); + tester.addFilter(gzipHolder,"/*",EnumSet.of(DispatcherType.REQUEST,DispatcherType.ASYNC)); + gzipHolder.setInitParameter("mimeTypes","text/plain"); // Test error code 204 - FilterHolder holder = tester.setContentServlet(HttpStatusServlet.class); - holder.setInitParameter("mimeTypes","text/plain"); + tester.setContentServlet(HttpStatusServlet.class); try { tester.start(); - tester.assertIsResponseNotGzipCompressed("GET",-1, 204); + + HttpTester.Response response = tester.executeRequest("GET","/context/",2,TimeUnit.SECONDS); + + assertThat("Response status", response.getStatus(), is(HttpStatus.NO_CONTENT_204)); + + assertThat("Content-Encoding",response.get("Content-Encoding"),not(containsString(GzipFilter.GZIP))); } finally { @@ -541,6 +550,7 @@ public class GzipFilterDefaultTest HttpTester.Response response = tester.executeRequest("GET","/context/",2,TimeUnit.SECONDS); assertThat("Response status", response.getStatus(), is(HttpStatus.BAD_REQUEST_400)); + assertThat("Content-Encoding",response.get("Content-Encoding"),not(containsString(GzipFilter.GZIP))); String content = tester.readResponse(response); assertThat("Response content", content, is("error message")); diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java index a504cb54dfc..aff0c441351 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java @@ -461,22 +461,6 @@ public class GzipTester return response; } - /** - * Asserts that the request results in a properly structured GzipFilter response, where the content is not compressed, and the content-length is returned - * appropriately. - * - * @param expectedFilesize - * the expected filesize to be specified on the Content-Length portion of the response headers. (note: passing -1 will disable the Content-Length - * assertion) - * @throws Exception - */ - public void assertIsResponseNotGzipCompressed(String method, int expectedFilesize, int status) throws Exception - { - String uri = "/context/"; - HttpTester.Response response = executeRequest(method,uri); - assertResponseHeaders(expectedFilesize,status,response); - } - private void assertResponseHeaders(int expectedFilesize, int status, HttpTester.Response response) { Assert.assertThat("Response.status",response.getStatus(),is(status));