Search in sources :

Example 6 with ActionsManager

use of jodd.madvoc.component.ActionsManager in project jodd by oblac.

the class ActionResultTest method testAlias3.

@Test
public void testAlias3() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    actionsManager.register(BooAction.class, "foo2");
    assertEquals("/boo.foo2.xxx", actionsManager.lookup(BooAction.class.getName() + "#foo2").actionPath);
}
Also used : ActionsManager(jodd.madvoc.component.ActionsManager) Test(org.junit.Test)

Example 7 with ActionsManager

use of jodd.madvoc.component.ActionsManager in project jodd by oblac.

the class ManualRegistrationTest method testManualAction.

@Test
public void testManualAction() {
    Madvoc madvoc = new Madvoc();
    madvoc.setMadvocConfiguratorClass(ManualRegistration.class);
    madvoc.startNewWebApplication(null);
    ActionsManager actionsManager = madvoc.getWebApplication().getComponent(ActionsManager.class);
    assertEquals(2, actionsManager.getActionsCount());
    ActionConfig actionConfig = actionsManager.lookup("/hello", "GET");
    assertNotNull(actionConfig);
    assertEquals(BooAction.class, actionConfig.getActionClass());
    assertEquals("foo1", actionConfig.actionClassMethod.getName());
    actionConfig = actionsManager.lookup("/world", "GET");
    assertNotNull(actionConfig);
    assertEquals(BooAction.class, actionConfig.getActionClass());
    assertEquals("foo2", actionConfig.actionClassMethod.getName());
}
Also used : ActionsManager(jodd.madvoc.component.ActionsManager) Test(org.junit.Test)

Example 8 with ActionsManager

use of jodd.madvoc.component.ActionsManager in project jodd by oblac.

the class ActionMethodParserTest method testMacros.

@Test
public void testMacros() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    MadvocConfig madvocConfig = webapp.getComponent(MadvocConfig.class);
    madvocConfig.getRootPackages().addRootPackageOf(this.getClass());
    actionsManager.register(ReAction.class, "macro");
    ActionConfig cfg = actionsManager.lookup("/re/user/173/macro.html", "GET");
    assertNotNull(cfg);
    ActionConfigSet set = cfg.getActionConfigSet();
    assertEquals(ReAction.class, cfg.actionClass);
    assertEquals("/re/user/${id}/macro.html", cfg.actionPath);
    assertEquals(4, set.deep);
    assertEquals(1, set.actionPathMacros.getMacrosCount());
    assertEquals("id", set.actionPathMacros.getNames()[0]);
    assertNull(set.actionPathMacros.getPatterns()[0]);
    actionsManager.register(ReAction.class, "macro2");
    cfg = actionsManager.lookup("/re/user/image/173/png/macro2.html", "GET");
    assertNotNull(cfg);
    set = cfg.getActionConfigSet();
    assertEquals(ReAction.class, cfg.actionClass);
    assertEquals("/re/user/image/${id}/${fmt}/macro2.html", cfg.actionPath);
    assertEquals(6, set.deep);
    assertEquals(2, set.actionPathMacros.getMacrosCount());
    assertEquals("id", set.actionPathMacros.getNames()[0]);
    assertEquals("fmt", set.actionPathMacros.getNames()[1]);
    actionsManager.register(ReAction.class, "macro3");
    cfg = actionsManager.lookup("/re/users/173/macro3", "POST");
    assertNotNull(cfg);
    set = cfg.getActionConfigSet();
    assertEquals(ReAction.class, cfg.actionClass);
    assertEquals("/re/users/${id}/macro3", cfg.actionPath);
    assertEquals("POST", cfg.actionMethod);
    assertEquals(4, set.deep);
    assertEquals(1, set.actionPathMacros.getMacrosCount());
    assertEquals("id", set.actionPathMacros.getNames()[0]);
    cfg = actionsManager.lookup("/re/user/index.html", "GET");
    assertNull(cfg);
    cfg = actionsManager.lookup("/re/user/index/reindex/macro.html", "GET");
    assertNull(cfg);
    cfg = actionsManager.lookup("/re/users/173/macro3", "GET");
    assertNull(cfg);
    assertEquals(3, actionsManager.getActionsCount());
}
Also used : ActionsManager(jodd.madvoc.component.ActionsManager) MadvocConfig(jodd.madvoc.component.MadvocConfig) Test(org.junit.Test)

Example 9 with ActionsManager

use of jodd.madvoc.component.ActionsManager in project jodd by oblac.

the class ActionMethodParserTest method testMacrosWildcards.

@Test
public void testMacrosWildcards() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    MadvocConfig madvocConfig = webapp.getComponent(MadvocConfig.class);
    madvocConfig.getRootPackages().addRootPackageOf(this.getClass());
    actionsManager.register(ReAction.class, "wild1");
    actionsManager.register(ReAction.class, "wild2");
    ActionConfig cfg = actionsManager.lookup("/re/ild123cat", "GET");
    assertNull(cfg);
    cfg = actionsManager.lookup("/re/wild123cat", "GET");
    assertNull(cfg);
    cfg = actionsManager.lookup("/re/wild123cat.html", "GET");
    assertNotNull(cfg);
    ActionConfigSet set = cfg.getActionConfigSet();
    assertEquals(ReAction.class, cfg.actionClass);
    assertEquals("/re/wild${id}cat.html", cfg.actionPath);
    assertEquals(2, set.deep);
    assertEquals(1, set.actionPathMacros.getMacrosCount());
    assertEquals("id", set.actionPathMacros.getNames()[0]);
    cfg = actionsManager.lookup("/re/wild123dog.html", "GET");
    assertNull(cfg);
    cfg = actionsManager.lookup("/re/wild123dog.html", "POST");
    assertNotNull(cfg);
    set = cfg.getActionConfigSet();
    assertEquals(ReAction.class, cfg.actionClass);
    assertEquals("/re/wild${id}dog.html", cfg.actionPath);
    assertEquals("POST", cfg.actionMethod);
    assertEquals(2, set.deep);
    assertEquals(1, set.actionPathMacros.getMacrosCount());
    assertEquals("id", set.actionPathMacros.getNames()[0]);
    assertEquals(2, actionsManager.getActionsCount());
}
Also used : ActionsManager(jodd.madvoc.component.ActionsManager) MadvocConfig(jodd.madvoc.component.MadvocConfig) Test(org.junit.Test)

Example 10 with ActionsManager

use of jodd.madvoc.component.ActionsManager in project jodd by oblac.

the class ActionMethodParserTest method testMethod.

@Test
public void testMethod() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ActionMethodParser actionMethodParser = webapp.getComponent(ActionMethodParser.class);
    ActionConfig cfg = parse(actionMethodParser, "tst.BooAction#foo");
    assertNotNull(cfg);
    assertEquals(BooAction.class, cfg.actionClass);
    assertEquals("/boo.foo.html", cfg.actionPath);
    cfg = parse(actionMethodParser, "tst.BooAction#foo1");
    assertEquals("/boo.xxx.html", cfg.actionPath);
    cfg = parse(actionMethodParser, "tst.BooAction#foo2");
    assertEquals("/boo.foo2.xxx", cfg.actionPath);
    cfg = parse(actionMethodParser, "tst.BooAction#foo3");
    assertEquals("/boo.html", cfg.actionPath);
    cfg = parse(actionMethodParser, "tst.BooAction#foo4");
    assertEquals("/xxx", cfg.actionPath);
    assertNull(cfg.actionMethod);
    cfg = parse(actionMethodParser, "tst.BooAction#foo41");
    assertEquals("/xxx", cfg.actionPath);
    assertEquals("DELETE", cfg.actionMethod);
    cfg = parse(actionMethodParser, "tst.BooAction#foo5");
    assertEquals("/xxx.html", cfg.actionPath);
    assertEquals("POST", cfg.actionMethod);
    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    assertEquals("/xxx.html", actionsManager.lookupPathAlias("dude"));
}
Also used : ActionsManager(jodd.madvoc.component.ActionsManager) ActionMethodParser(jodd.madvoc.component.ActionMethodParser) Test(org.junit.Test)

Aggregations

ActionsManager (jodd.madvoc.component.ActionsManager)10 Test (org.junit.Test)9 MadvocConfig (jodd.madvoc.component.MadvocConfig)5 ActionMethodParser (jodd.madvoc.component.ActionMethodParser)2 ResultMapper (jodd.madvoc.component.ResultMapper)2 FiltersManager (jodd.madvoc.component.FiltersManager)1 InterceptorsManager (jodd.madvoc.component.InterceptorsManager)1 MadvocController (jodd.madvoc.component.MadvocController)1 ResultsManager (jodd.madvoc.component.ResultsManager)1 AutomagicMadvocConfigurator (jodd.madvoc.config.AutomagicMadvocConfigurator)1 MadvocConfigurator (jodd.madvoc.config.MadvocConfigurator)1 Props (jodd.props.Props)1