Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2014-10-23 21:17:05 +0000
committerGreg Wilkins2014-10-23 21:17:05 +0000
commit738c47bc553d7e90a0d074b99aff5e666d26a7c2 (patch)
tree60f24d19794e3c33dc0b1f4c6c9cfaa1d0c9db95 /jetty-servlet/src/test
parentb65aed7d1052bb91647dc281092f2fce2314b67f (diff)
downloadorg.eclipse.jetty.project-738c47bc553d7e90a0d074b99aff5e666d26a7c2.tar.gz
org.eclipse.jetty.project-738c47bc553d7e90a0d074b99aff5e666d26a7c2.tar.xz
org.eclipse.jetty.project-738c47bc553d7e90a0d074b99aff5e666d26a7c2.zip
447515 Remove GzipFilter
Moved all usages of GzipFilter to GzipHandler added support to ServerContextHandler to create a GzipHandler
Diffstat (limited to 'jetty-servlet/src/test')
-rw-r--r--jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java53
1 files changed, 52 insertions, 1 deletions
diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java
index cde72a5e95..e3f0a2f8b2 100644
--- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java
+++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java
@@ -48,7 +48,9 @@ import org.eclipse.jetty.server.handler.AbstractHandlerContainer;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.HandlerList;
+import org.eclipse.jetty.server.handler.HandlerWrapper;
import org.eclipse.jetty.server.handler.ResourceHandler;
+import org.eclipse.jetty.server.handler.gzip.GzipHandler;
import org.eclipse.jetty.server.session.SessionHandler;
import org.hamcrest.Matchers;
import org.junit.After;
@@ -172,6 +174,55 @@ public class ServletContextHandlerTest
response = _connector.getResponses(request.toString());
assertResponseContains("Hello World", response);
}
+
+ @Test
+ public void testHandlerBeforeServletHandler() throws Exception
+ {
+ ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
+
+ HandlerWrapper extra = new HandlerWrapper();
+
+ context.getSessionHandler().insertHandler(extra);
+
+ context.addServlet(TestServlet.class,"/test");
+ context.setContextPath("/");
+ _server.setHandler(context);
+ _server.start();
+
+ StringBuffer request = new StringBuffer();
+ request.append("GET /test HTTP/1.0\n");
+ request.append("Host: localhost\n");
+ request.append("\n");
+
+ String response = _connector.getResponses(request.toString());
+ assertResponseContains("Test", response);
+
+ assertEquals(extra,context.getSessionHandler().getHandler());
+ }
+
+ @Test
+ public void testGzipHandlerOption() throws Exception
+ {
+ ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS|ServletContextHandler.GZIP);
+ GzipHandler gzip = context.getGzipHandler();
+ _server.start();
+ assertEquals(context.getSessionHandler(),context.getHandler());
+ assertEquals(gzip,context.getSessionHandler().getHandler());
+ assertEquals(context.getServletHandler(),gzip.getHandler());
+ }
+
+ @Test
+ public void testGzipHandlerSet() throws Exception
+ {
+ ServletContextHandler context = new ServletContextHandler();
+ context.setSessionHandler(new SessionHandler());
+ context.setGzipHandler(new GzipHandler());
+ GzipHandler gzip = context.getGzipHandler();
+ _server.start();
+ assertEquals(context.getSessionHandler(),context.getHandler());
+ assertEquals(gzip,context.getSessionHandler().getHandler());
+ assertEquals(context.getServletHandler(),gzip.getHandler());
+ }
@Test
public void testReplaceServletHandlerWithServlet() throws Exception
@@ -268,7 +319,7 @@ public class ServletContextHandlerTest
ResourceHandler rh = new ResourceHandler();
- servletContextHandler.setHandler(rh);
+ servletContextHandler.insertHandler(rh);
assertEquals(shandler, servletContextHandler.getServletHandler());
assertEquals(rh, servletContextHandler.getHandler());
assertEquals(rh.getHandler(), shandler);

Back to the top