use of org.eclipse.jetty.server.handler.HandlerWrapper in project jetty.project by eclipse.
the class HandlerTest method testInsertWrapper.
@Test
public void testInsertWrapper() {
HandlerWrapper a = new HandlerWrapper();
HandlerWrapper b = new HandlerWrapper();
HandlerWrapper c = new HandlerWrapper();
a.insertHandler(c);
a.insertHandler(b);
assertThat(a.getHandler(), equalTo(b));
assertThat(b.getHandler(), equalTo(c));
assertThat(c.getHandler(), nullValue());
}
use of org.eclipse.jetty.server.handler.HandlerWrapper in project jetty.project by eclipse.
the class HandlerTest method testInsertWrapperBadChain.
@Test
public void testInsertWrapperBadChain() {
HandlerWrapper a = new HandlerWrapper();
HandlerWrapper b = new HandlerWrapper();
HandlerWrapper c = new HandlerWrapper();
HandlerWrapper d = new HandlerWrapper();
a.insertHandler(d);
b.insertHandler(c);
c.setHandler(new AbstractHandler() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
}
});
try {
a.insertHandler(b);
fail();
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("bad tail"));
}
}
use of org.eclipse.jetty.server.handler.HandlerWrapper in project jetty.project by eclipse.
the class HandlerTest method testWrapperDeepLoop.
@Test
public void testWrapperDeepLoop() {
HandlerWrapper a = new HandlerWrapper();
HandlerWrapper b = new HandlerWrapper();
HandlerWrapper c = new HandlerWrapper();
a.setHandler(b);
b.setHandler(c);
try {
c.setHandler(a);
fail();
} catch (IllegalStateException e) {
assertThat(e.getMessage(), containsString("loop"));
}
}
use of org.eclipse.jetty.server.handler.HandlerWrapper in project jetty.project by eclipse.
the class HandlerTest method testInsertWrapperTail.
@Test
public void testInsertWrapperTail() {
HandlerWrapper a = new HandlerWrapper();
HandlerWrapper b = new HandlerWrapper();
a.insertHandler(b);
assertThat(a.getHandler(), equalTo(b));
assertThat(b.getHandler(), nullValue());
}
use of org.eclipse.jetty.server.handler.HandlerWrapper in project jetty.project by eclipse.
the class Invoker method init.
/* ------------------------------------------------------------ */
public void init() {
ServletContext config = getServletContext();
_contextHandler = ((ContextHandler.Context) config).getContextHandler();
Handler handler = _contextHandler.getHandler();
while (handler != null && !(handler instanceof ServletHandler) && (handler instanceof HandlerWrapper)) handler = ((HandlerWrapper) handler).getHandler();
_servletHandler = (ServletHandler) handler;
Enumeration<String> e = getInitParameterNames();
while (e.hasMoreElements()) {
String param = e.nextElement();
String value = getInitParameter(param);
String lvalue = value.toLowerCase(Locale.ENGLISH);
if ("nonContextServlets".equals(param)) {
_nonContextServlets = value.length() > 0 && lvalue.startsWith("t");
}
if ("verbose".equals(param)) {
_verbose = value.length() > 0 && lvalue.startsWith("t");
} else {
if (_parameters == null)
_parameters = new HashMap<String, String>();
_parameters.put(param, value);
}
}
}
Aggregations