Search in sources :

Example 6 with ActionRuntime

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

the class ActionMethodParserTest method testMacrosDups.

@Test
void testMacrosDups() {
    WebApp webapp = new WebApp();
    webapp.start();
    ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class);
    webapp.madvocContainer().lookupComponent(RootPackages.class).addRootPackageOf(this.getClass());
    actionsManager.setPathMacroClass(RegExpPathMacros.class);
    actionsManager.registerAction(ReAction.class, "duplo2", null);
    actionsManager.registerAction(ReAction.class, "duplo1", null);
    ActionRuntime cfg = actionsManager.lookup("GET", MadvocUtil.splitPathToChunks("/re/duplo/123"));
    assertNotNull(cfg);
    assertEquals(ReAction.class, cfg.getActionClass());
    assertEquals("/re/duplo/{id:^[0-9]+}", cfg.getActionPath());
    RouteChunk chunk = cfg.getRouteChunk();
    assertEquals(1, chunk.pathMacros().macrosCount());
    assertEquals("id", chunk.pathMacros().names()[0]);
    cfg = actionsManager.lookup("GET", MadvocUtil.splitPathToChunks("/re/duplo/aaa"));
    assertNotNull(cfg);
    assertEquals(ReAction.class, cfg.getActionClass());
    assertEquals("/re/duplo/{sid}", cfg.getActionPath());
    chunk = cfg.getRouteChunk();
    assertEquals(1, chunk.pathMacros().macrosCount());
    assertEquals("sid", chunk.pathMacros().names()[0]);
    assertEquals(2, actionsManager.getActionsCount());
}
Also used : ActionsManager(jodd.madvoc.component.ActionsManager) RootPackages(jodd.madvoc.component.RootPackages) ActionRuntime(jodd.madvoc.config.ActionRuntime) RouteChunk(jodd.madvoc.config.RouteChunk) Test(org.junit.jupiter.api.Test)

Example 7 with ActionRuntime

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

the class ActionMethodParserTest method testDefaultMethods.

@Test
void testDefaultMethods() {
    WebApp webapp = new WebApp();
    webapp.start();
    ActionMethodParser actionMethodParser = webapp.madvocContainer().lookupComponent(ActionMethodParser.class);
    ActionRuntime cfg = parse(actionMethodParser, "fixtures.tst.BooAction#foo");
    assertEquals("/boo.foo", cfg.getActionPath());
    cfg = parse(actionMethodParser, "fixtures.tst.BooAction#view");
    assertEquals("/boo", cfg.getActionPath());
    cfg = parse(actionMethodParser, "fixtures.tst.BooAction#execute");
    assertEquals("/boo", cfg.getActionPath());
}
Also used : ActionRuntime(jodd.madvoc.config.ActionRuntime) ActionMethodParser(jodd.madvoc.component.ActionMethodParser) Test(org.junit.jupiter.api.Test)

Example 8 with ActionRuntime

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

the class ActionMethodParserTest method testZqq.

@Test
void testZqq() {
    WebApp webapp = new WebApp();
    webapp.start();
    ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class);
    RootPackages rootPackages = webapp.madvocContainer().lookupComponent(RootPackages.class);
    rootPackages.addRootPackageOf(this.getClass());
    actionsManager.registerAction(ReAction.class, "zqq1", null);
    actionsManager.registerAction(ReAction.class, "zqq2", null);
    ActionRuntime cfg = actionsManager.lookup("GET", MadvocUtil.splitPathToChunks("/config/dba.delete_multi.do"));
    assertNotNull(cfg);
    assertEquals("/{entityName}/dba.delete_multi.do", cfg.getActionPath());
}
Also used : ActionsManager(jodd.madvoc.component.ActionsManager) RootPackages(jodd.madvoc.component.RootPackages) ActionRuntime(jodd.madvoc.config.ActionRuntime) Test(org.junit.jupiter.api.Test)

Example 9 with ActionRuntime

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

the class ActionMethodParserTest method testClasses.

@Test
void testClasses() {
    WebApp webapp = new WebApp();
    webapp.start();
    ActionMethodParser actionMethodParser = webapp.madvocContainer().lookupComponent(ActionMethodParser.class);
    ActionRuntime cfg = parse(actionMethodParser, "fixtures.tst.Boo1Action#foo");
    assertNotNull(cfg);
    assertEquals(Boo1Action.class, cfg.getActionClass());
    assertEquals("/boo1.foo", cfg.getActionPath());
    cfg = parse(actionMethodParser, "fixtures.tst.Boo2Action#foo");
    assertNotNull(cfg);
    assertEquals(Boo2Action.class, cfg.getActionClass());
    assertEquals("/bbb.foo", cfg.getActionPath());
    cfg = parse(actionMethodParser, "fixtures.tst.Boo2Action#foo1");
    assertEquals("/bbb.xxx", cfg.getActionPath());
    cfg = parse(actionMethodParser, "fixtures.tst.Boo2Action#foo2");
    assertEquals("/bbb.foo2.xxx", cfg.getActionPath());
    cfg = parse(actionMethodParser, "fixtures.tst.Boo2Action#foo3");
    assertEquals("/bbb", cfg.getActionPath());
}
Also used : ActionRuntime(jodd.madvoc.config.ActionRuntime) ActionMethodParser(jodd.madvoc.component.ActionMethodParser) Test(org.junit.jupiter.api.Test)

Example 10 with ActionRuntime

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

the class ActionMethodParserTest method testPackage.

@Test
void testPackage() {
    WebApp webapp = new WebApp();
    webapp.start();
    ActionMethodParser actionMethodParser = webapp.madvocContainer().lookupComponent(ActionMethodParser.class);
    RootPackages rootPackages = webapp.madvocContainer().lookupComponent(RootPackages.class);
    rootPackages.addRootPackageOf(this.getClass());
    ActionRuntime cfg = parse(actionMethodParser, "fixtures.tst2.Boo4Action#foo");
    assertNotNull(cfg);
    assertEquals(Boo4Action.class, cfg.getActionClass());
    assertEquals("/ttt/www.foo", cfg.getActionPath());
    cfg = parse(actionMethodParser, "fixtures.tst2.Boo4Action#foo1");
    assertEquals("/ttt/www.xxx", cfg.getActionPath());
    cfg = parse(actionMethodParser, "fixtures.tst2.Boo4Action#foo2");
    assertEquals("/ttt/www.foo2.xxx", cfg.getActionPath());
    cfg = parse(actionMethodParser, "fixtures.tst2.Boo4Action#foo3");
    assertEquals("/ttt/www", cfg.getActionPath());
}
Also used : RootPackages(jodd.madvoc.component.RootPackages) ActionRuntime(jodd.madvoc.config.ActionRuntime) ActionMethodParser(jodd.madvoc.component.ActionMethodParser) 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