use of act.handler.RequestHandler in project actframework by actframework.
the class RouteTableRouterBuilderTest method verify.
private void verify(String expected, H.Method method, String url) {
H.Request req = Mockito.mock(H.Request.class);
Mockito.when(ctx.req()).thenReturn(req);
Mockito.when(ctx.attribute(anyString(), Matchers.any())).thenReturn(ctx);
Mockito.when(req.path()).thenReturn(url);
RequestHandler handler = router.getInvoker(method, url, ctx);
if (handler == AlwaysNotFound.INSTANCE) {
throw NotFound.get();
} else if (handler == AlwaysBadRequest.INSTANCE) {
throw BadRequest.get();
}
handler.handle(ctx);
controllerInvoked(expected);
}
use of act.handler.RequestHandler in project actframework by actframework.
the class RouterTest method searchBadUrl.
@Test
public void searchBadUrl() {
RequestHandler handler = router.getInvoker(GET, "/nonexists", ctx);
same(handler, AlwaysNotFound.INSTANCE);
}
use of act.handler.RequestHandler in project actframework by actframework.
the class RouterTest method doNotOverrideExistingRouting.
@Test
public void doNotOverrideExistingRouting() {
routeWithStaticDir();
router.addMapping(GET, "/public", "file:/private", ACTION_ANNOTATION);
RequestHandler handler = router.getInvoker(GET, "/public/foo/bar.txt", ctx);
yes(handler instanceof FileGetter);
yes(handler.supportPartialPath());
eq(new File(BASE, "/public"), fieldVal(handler, "base"));
}
use of act.handler.RequestHandler in project actframework by actframework.
the class RouterTest method overrideExistingRouting.
@Test
public void overrideExistingRouting() {
routeWithStaticDir();
router.addMapping(GET, "/public", "file:/private");
RequestHandler handler = router.getInvoker(GET, "/public/foo/bar.txt", ctx);
yes(handler instanceof FileGetter);
yes(handler.supportPartialPath());
eq(new File(BASE, "/private"), fieldVal(handler, "base"));
}
use of act.handler.RequestHandler in project actframework by actframework.
the class RouterTest method routeWithStaticDir.
@Test
public void routeWithStaticDir() {
router.addMapping(GET, "/public", "file:/public");
RequestHandler handler = router.getInvoker(GET, "/public/foo/bar.txt", ctx);
yes(handler instanceof FileGetter);
yes(handler.supportPartialPath());
eq(new File(BASE, "/public"), fieldVal(handler, "base"));
}
Aggregations