use of jodd.madvoc.config.ActionRuntime in project jodd by oblac.
the class ActionsManagerTest method testActionPathMacros2.
@Test
void testActionPathMacros2() {
WebApp webapp = new WebApp();
webapp.start();
ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class);
actionsManager.registerAction(FooAction.class, "two", new ActionDefinition("/xxx-{two}"));
actionsManager.registerAction(FooAction.class, "one", new ActionDefinition("/{one}"));
ActionRuntime actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/foo"));
assertEquals("one", actionRuntime.getActionClassMethod().getName());
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/foo/boo"));
assertNull(actionRuntime);
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/xxx-foo"));
// best match!
assertEquals("two", actionRuntime.getActionClassMethod().getName());
}
use of jodd.madvoc.config.ActionRuntime in project jodd by oblac.
the class ServletDispatcherResultTest method createActionRequest.
protected ActionRequest createActionRequest(String actionPath) {
HttpServletRequest servletRequest = mock(HttpServletRequest.class);
HttpServletResponse servletResponse = mock(HttpServletResponse.class);
HttpSession httpSession = mock(HttpSession.class);
ServletContext servletContext = mock(ServletContext.class);
when(servletRequest.getSession()).thenReturn(httpSession);
when(httpSession.getServletContext()).thenReturn(servletContext);
MadvocController madvocController = new MadvocController();
Object action = new Object();
ActionRuntime actionRuntime = new ActionRuntime(null, Action.class, ClassUtil.findMethod(Action.class, "view"), null, null, new ActionDefinition(actionPath, "GET"), ServletDispatcherActionResult.class, null, false, false, null, null);
return new ActionRequest(madvocController, actionRuntime.getActionPath(), MadvocUtil.splitPathToChunks(actionRuntime.getActionPath()), actionRuntime, action, servletRequest, servletResponse);
}
Aggregations