Issue #4765 - Review GzipHandler inside ServletContextHandler.

Fixed test failures.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2020-04-13 23:54:31 +02:00
parent 1a234dcf4c
commit e17d0f4e98
3 changed files with 13 additions and 9 deletions

View File

@ -673,7 +673,7 @@ public class GzipDefaultTest
GzipTester tester = new GzipTester(testingdir.getEmptyPathDir(), compressionType); GzipTester tester = new GzipTester(testingdir.getEmptyPathDir(), compressionType);
// Configure Gzip Handler // Configure Gzip Handler
tester.getGzipHandler().setExcludedPaths("/bad.txt"); tester.getGzipHandler().setExcludedPaths(tester.getContextPath() + "/bad.txt");
tester.getGzipHandler().setIncludedPaths("*.txt"); tester.getGzipHandler().setIncludedPaths("*.txt");
// Prepare server file // Prepare server file

View File

@ -44,7 +44,6 @@ import org.eclipse.jetty.http.tools.HttpTester;
import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.handler.gzip.GzipHandler; import org.eclipse.jetty.server.handler.gzip.GzipHandler;
import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlet.ServletTester; import org.eclipse.jetty.servlet.ServletTester;
import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.FS;
@ -82,28 +81,33 @@ public class GzipTester
private String encoding = "ISO8859_1"; private String encoding = "ISO8859_1";
private String userAgent = null; private String userAgent = null;
private final ServletTester tester = new ServletTester("/context", ServletContextHandler.GZIP); private final GzipHandler gzipHandler = new GzipHandler();
private final ServletTester tester = new ServletTester("/context");
private Path testdir; private Path testdir;
private String accept; private String accept;
private String compressionType; private String compressionType;
public GzipTester(Path testingdir, String compressionType)
{
this(testingdir, compressionType, compressionType);
}
public GzipTester(Path testingdir, String compressionType, String accept) public GzipTester(Path testingdir, String compressionType, String accept)
{ {
this.testdir = testingdir; this.testdir = testingdir;
this.compressionType = compressionType; this.compressionType = compressionType;
this.accept = accept; this.accept = accept;
this.tester.getServer().insertHandler(gzipHandler);
} }
public GzipTester(Path testingdir, String compressionType) public String getContextPath()
{ {
this.testdir = testingdir; return tester.getContextPath();
this.compressionType = compressionType;
this.accept = compressionType;
} }
public GzipHandler getGzipHandler() public GzipHandler getGzipHandler()
{ {
return tester.getContext().getGzipHandler(); return gzipHandler;
} }
public int getOutputBufferSize() public int getOutputBufferSize()

View File

@ -90,7 +90,7 @@ public class IncludedGzipTest
GzipHandler gzipHandler = new GzipHandler(); GzipHandler gzipHandler = new GzipHandler();
gzipHandler.setMinGzipSize(16); gzipHandler.setMinGzipSize(16);
tester.getContext().insertHandler(gzipHandler); tester.getServer().insertHandler(gzipHandler);
tester.start(); tester.start();
} }