Search in sources :

Example 26 with ActionRuntime

use of jodd.madvoc.config.ActionRuntime 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);
}
Also used : ActionRuntime(jodd.madvoc.config.ActionRuntime) ActionDefinition(jodd.madvoc.config.ActionDefinition)

Example 27 with ActionRuntime

use of jodd.madvoc.config.ActionRuntime in project jodd by oblac.

the class ManualRegistrationTest method testManualAction_asArgument.

@Test
void testManualAction_asArgument() {
    WebApp webApp = WebApp.createWebApp().start(madvoc -> madvoc.route().path("/hello").mapTo(BooAction.class, "foo1").bind().route().path("/world").mapTo(BooAction.class, "foo2").interceptBy(EchoInterceptor.class).bind().interceptor(EchoInterceptor.class, i -> i.setPrefixIn("====> ")));
    ActionsManager actionsManager = webApp.madvocContainer().requestComponent(ActionsManager.class);
    assertEquals(2, actionsManager.getActionsCount());
    ActionRuntime actionRuntime = actionsManager.lookup("GET", MadvocUtil.splitPathToChunks("/hello"));
    assertNotNull(actionRuntime);
    assertEquals(BooAction.class, actionRuntime.getActionClass());
    assertEquals("foo1", actionRuntime.getActionClassMethod().getName());
    actionRuntime = actionsManager.lookup("GET", MadvocUtil.splitPathToChunks("/world"));
    assertNotNull(actionRuntime);
    assertEquals(BooAction.class, actionRuntime.getActionClass());
    assertEquals("foo2", actionRuntime.getActionClassMethod().getName());
}
Also used : ActionRuntime(jodd.madvoc.config.ActionRuntime) Test(org.junit.jupiter.api.Test) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) BooAction(jodd.madvoc.fixtures.tst.BooAction) ActionsManager(jodd.madvoc.component.ActionsManager) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) EchoInterceptor(jodd.madvoc.interceptor.EchoInterceptor) ActionsManager(jodd.madvoc.component.ActionsManager) EchoInterceptor(jodd.madvoc.interceptor.EchoInterceptor) ActionRuntime(jodd.madvoc.config.ActionRuntime) Test(org.junit.jupiter.api.Test)

Example 28 with ActionRuntime

use of jodd.madvoc.config.ActionRuntime 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);
}
Also used : ActionRuntime(jodd.madvoc.config.ActionRuntime) ActionDefinition(jodd.madvoc.config.ActionDefinition) WebApp(jodd.madvoc.WebApp) Test(org.junit.jupiter.api.Test)

Example 29 with ActionRuntime

use of jodd.madvoc.config.ActionRuntime 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);
}
Also used : ActionRuntime(jodd.madvoc.config.ActionRuntime) ActionDefinition(jodd.madvoc.config.ActionDefinition) WebApp(jodd.madvoc.WebApp) Test(org.junit.jupiter.api.Test)

Example 30 with ActionRuntime

use of jodd.madvoc.config.ActionRuntime 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);
}
Also used : ActionRuntime(jodd.madvoc.config.ActionRuntime) ActionDefinition(jodd.madvoc.config.ActionDefinition) WebApp(jodd.madvoc.WebApp) Test(org.junit.jupiter.api.Test)

Aggregations

ActionRuntime (jodd.madvoc.config.ActionRuntime)32 Test (org.junit.jupiter.api.Test)24 ActionMethodParser (jodd.madvoc.component.ActionMethodParser)11 RootPackages (jodd.madvoc.component.RootPackages)10 ActionDefinition (jodd.madvoc.config.ActionDefinition)10 ActionsManager (jodd.madvoc.component.ActionsManager)9 WebApp (jodd.madvoc.WebApp)7 RouteChunk (jodd.madvoc.config.RouteChunk)5 Map (java.util.Map)2 ActionRequest (jodd.madvoc.ActionRequest)2 MadvocException (jodd.madvoc.MadvocException)2 Annotation (java.lang.annotation.Annotation)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ServletContext (javax.servlet.ServletContext)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 HttpSession (javax.servlet.http.HttpSession)1