use of jodd.madvoc.config.ActionDefinition in project jodd by oblac.
the class ActionsManagerTest method testActionPathMacrosRegexp.
@Test
void testActionPathMacrosRegexp() {
WebApp webapp = new WebApp();
webapp.start();
ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class);
actionsManager.setPathMacroClass(RegExpPathMacros.class);
actionsManager.registerAction(FooAction.class, "one", new ActionDefinition("/{one:[ab]+}"));
ActionRuntime actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/a"));
assertNotNull(actionRuntime);
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/ac"));
assertNull(actionRuntime);
}
use of jodd.madvoc.config.ActionDefinition in project jodd by oblac.
the class ActionsManagerTest method testActionPathMacros3.
@Test
void testActionPathMacros3() {
WebApp webapp = new WebApp();
webapp.start();
ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class);
actionsManager.registerAction(FooAction.class, "one", new ActionDefinition("/yyy-{one}"));
actionsManager.registerAction(FooAction.class, "two", new ActionDefinition("/xxx-{two}"));
assertEquals(2, actionsManager.getActionsCount());
ActionRuntime actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/foo"));
assertNull(actionRuntime);
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/yyy-111"));
assertEquals("one", actionRuntime.getActionClassMethod().getName());
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/xxx-222"));
assertEquals("two", actionRuntime.getActionClassMethod().getName());
try {
actionsManager.registerAction(FooAction.class, "two", new ActionDefinition("/xxx-{two}"));
fail("error");
} catch (Exception ex) {
// ignore
}
}
use of jodd.madvoc.config.ActionDefinition in project jodd by oblac.
the class ActionsManagerTest method testActionPathMacros4.
@Test
void testActionPathMacros4() {
WebApp webapp = new WebApp();
webapp.start();
ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class);
// no macro
actionsManager.registerAction(FooAction.class, "one", new ActionDefinition("/dummy"));
actionsManager.registerAction(FooAction.class, "one", new ActionDefinition("/{one}"));
actionsManager.registerAction(FooAction.class, "three", new ActionDefinition("/life/{three}"));
actionsManager.registerAction(FooAction.class, "two", new ActionDefinition("/{two}/{three}"));
ActionRuntime actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/foo"));
assertEquals("one", actionRuntime.getActionClassMethod().getName());
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/scott/ramonna"));
assertEquals("two", actionRuntime.getActionClassMethod().getName());
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/life/universe"));
assertEquals("three", actionRuntime.getActionClassMethod().getName());
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/scott/ramonna/envy"));
assertNull(actionRuntime);
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/life/universe/else"));
assertNull(actionRuntime);
}
use of jodd.madvoc.config.ActionDefinition in project jodd by oblac.
the class ActionRequestRecursionTest method createMyActionRequest.
private MyActionRequest createMyActionRequest(ActionFilter[] actionFilters, ActionInterceptor[] actionInterceptors) {
SimpleMadvocController madvocController = new SimpleMadvocController();
Action action = new Action();
ActionRuntime actionRuntime = new ActionRuntime(null, Action.class, ClassUtil.findMethod(Action.class, "view"), actionFilters, actionInterceptors, new ActionDefinition("path", "method"), ServletDispatcherActionResult.class, null, false, false, null, null);
return new MyActionRequest(madvocController, "actionPath", actionRuntime, action, null, null);
}
use of jodd.madvoc.config.ActionDefinition in project jodd by oblac.
the class ActionsManagerTest method testActionPathMacros_679.
@Test
void testActionPathMacros_679() {
WebApp webapp = new WebApp();
webapp.start();
ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class);
actionsManager.setPathMacroClass(RegExpPathMacros.class);
ActionRuntime a1 = actionsManager.registerAction(FooAction.class, "one", new ActionDefinition("/hello/{id}"));
ActionRuntime a2 = actionsManager.registerAction(FooAction.class, "two", new ActionDefinition("/hello/default"));
ActionRuntime actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/hello/123"));
assertSame(a1, actionRuntime);
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/hello/default"));
assertSame(a2, actionRuntime);
}
Aggregations