use of jodd.madvoc.config.ActionDefinition in project jodd by oblac.
the class ActionsManagerTest method testActionPathMacrosWildcard.
@Test
void testActionPathMacrosWildcard() {
WebApp webapp = new WebApp();
webapp.start();
ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class);
actionsManager.setPathMacroClass(WildcardPathMacros.class);
actionsManager.registerAction(FooAction.class, "one", new ActionDefinition("/{one:a?a}"));
ActionRuntime actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/aaa"));
assertNotNull(actionRuntime);
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/aab"));
assertNull(actionRuntime);
}
use of jodd.madvoc.config.ActionDefinition in project jodd by oblac.
the class ActionsManagerTest method testActionPathMacros1.
@Test
void testActionPathMacros1() {
WebApp webapp = new WebApp();
webapp.start();
ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class);
actionsManager.registerAction(FooAction.class, "one", new ActionDefinition("/{one}"));
ActionRuntime actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/foo"));
assertNotNull(actionRuntime);
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/foo/boo"));
assertNull(actionRuntime);
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/foo/boo/zoo"));
assertNull(actionRuntime);
}
use of jodd.madvoc.config.ActionDefinition 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.ActionDefinition 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