From 4e1de48ba6dd1bc4620ab48f204746ca30ad7f64 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 27 Feb 2015 13:54:41 +1100 Subject: [PATCH] Simplified Gzip test --- .../handler/gzip/GzipContentLengthTest.java | 48 ++++++------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/server/handler/gzip/GzipContentLengthTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/server/handler/gzip/GzipContentLengthTest.java index ef66c5b6ef3..333a74e2bff 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/server/handler/gzip/GzipContentLengthTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/server/handler/gzip/GzipContentLengthTest.java @@ -68,28 +68,19 @@ public class GzipContentLengthTest private static final int TINY = GzipHandler.DEFAULT_MIN_GZIP_SIZE / 2; private static final boolean EXPECT_COMPRESSED = true; - @Parameters(name = "{0} bytes - {1} - compressed({2}) - type({3}) - filter({4})") + @Parameters(name = "{0} bytes - {1} - compressed({2})") public static List data() { List ret = new ArrayList(); - - String compressionTypes[] = new String[] { GzipHandler.GZIP, GzipHandler.DEFLATE }; - Class gzipFilters[] = new Class[] { GzipFilter.class, AsyncGzipFilter.class }; - - for(String compressionType: compressionTypes) - { - for(Class gzipFilter: gzipFilters) - { - ret.add(new Object[] { 0, "empty.txt", !EXPECT_COMPRESSED, compressionType, gzipFilter }); - ret.add(new Object[] { TINY, "file-tiny.txt", !EXPECT_COMPRESSED, compressionType, gzipFilter }); - ret.add(new Object[] { SMALL, "file-small.txt", EXPECT_COMPRESSED, compressionType, gzipFilter }); - ret.add(new Object[] { SMALL, "file-small.mp3", !EXPECT_COMPRESSED, compressionType, gzipFilter }); - ret.add(new Object[] { MEDIUM, "file-med.txt", EXPECT_COMPRESSED, compressionType, gzipFilter }); - ret.add(new Object[] { MEDIUM, "file-medium.mp3", !EXPECT_COMPRESSED, compressionType, gzipFilter }); - ret.add(new Object[] { LARGE, "file-large.txt", EXPECT_COMPRESSED, compressionType, gzipFilter }); - ret.add(new Object[] { LARGE, "file-large.mp3", !EXPECT_COMPRESSED, compressionType, gzipFilter }); - } - } + + ret.add(new Object[] { 0, "empty.txt", !EXPECT_COMPRESSED}); + ret.add(new Object[] { TINY, "file-tiny.txt", !EXPECT_COMPRESSED}); + ret.add(new Object[] { SMALL, "file-small.txt", EXPECT_COMPRESSED}); + ret.add(new Object[] { SMALL, "file-small.mp3", !EXPECT_COMPRESSED}); + ret.add(new Object[] { MEDIUM, "file-med.txt", EXPECT_COMPRESSED}); + ret.add(new Object[] { MEDIUM, "file-medium.mp3", !EXPECT_COMPRESSED}); + ret.add(new Object[] { LARGE, "file-large.txt", EXPECT_COMPRESSED}); + ret.add(new Object[] { LARGE, "file-large.mp3", !EXPECT_COMPRESSED}); return ret; } @@ -100,28 +91,21 @@ public class GzipContentLengthTest public String fileName; @Parameter(2) public boolean expectCompressed; - @Parameter(3) - public String compressionType; - @Parameter(4) - public Class gzipFilterClass; private void testWithGzip(Class contentServlet) throws Exception { GzipTester tester = new GzipTester(testingdir, GzipHandler.GZIP); - // Add AsyncGzip Filter - FilterHolder gzipHolder = new FilterHolder(gzipFilterClass); - gzipHolder.setAsyncSupported(true); - tester.addFilter(gzipHolder,"*.txt",EnumSet.of(DispatcherType.REQUEST,DispatcherType.ASYNC)); - tester.addFilter(gzipHolder,"*.mp3",EnumSet.of(DispatcherType.REQUEST,DispatcherType.ASYNC)); - gzipHolder.setInitParameter("mimeTypes","text/plain"); + // Add AsyncGzip Configuration + tester.getGzipHandler().setIncludedMimeTypes("text/plain"); + tester.getGzipHandler().setIncludedPaths("*.txt","*.mp3"); // Add content servlet tester.setContentServlet(contentServlet); try { - String testFilename = String.format("%s-%s-%s", gzipFilterClass.getSimpleName(), contentServlet.getSimpleName(), fileName); + String testFilename = String.format("%s-%s", contentServlet.getSimpleName(), fileName); File testFile = tester.prepareServerFile(testFilename,fileSize); tester.start(); @@ -159,8 +143,6 @@ public class GzipContentLengthTest @Test public void testAsyncTimeoutCompleteWrite_Default() throws Exception { - if (expectCompressed && gzipFilterClass==GzipFilter.class) - return; // Default startAsync will never work with GzipFilter, which needs wrapping testWithGzip(AsyncTimeoutCompleteWrite.Default.class); } @@ -334,8 +316,6 @@ public class GzipContentLengthTest @Test public void testHttpOutputWrite() throws Exception { - if (gzipFilterClass == GzipFilter.class) - return; // Can't downcaste output stream when wrapper is used testWithGzip(TestServletBufferTypeLengthWrite.class); } }