Search in sources :

Example 6 with MadvocConfig

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

the class ActionMethodParserTest method testClassesWithoutPackage.

@Test
public void testClassesWithoutPackage() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ActionMethodParser actionMethodParser = webapp.getComponent(ActionMethodParser.class);
    MadvocConfig madvocConfig = webapp.getComponent(MadvocConfig.class);
    madvocConfig.getRootPackages().addRootPackageOf(this.getClass());
    ActionConfig cfg = parse(actionMethodParser, "tst.Boo3Action#foo");
    assertNotNull(cfg);
    assertEquals(Boo3Action.class, cfg.actionClass);
    assertEquals("/bbb.foo.html", cfg.actionPath);
    cfg = parse(actionMethodParser, "tst.Boo3Action#foo1");
    assertEquals("/bbb.xxx.html", cfg.actionPath);
    cfg = parse(actionMethodParser, "tst.Boo3Action#foo2");
    assertEquals("/bbb.foo2.xxx", cfg.actionPath);
    cfg = parse(actionMethodParser, "tst.Boo3Action#foo3");
    assertEquals("/bbb.html", cfg.actionPath);
}
Also used : MadvocConfig(jodd.madvoc.component.MadvocConfig) ActionMethodParser(jodd.madvoc.component.ActionMethodParser) Test(org.junit.Test)

Example 7 with MadvocConfig

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

the class ActionMethodParserTest method testZqq.

@Test
public void testZqq() {
    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, "zqq1");
    actionsManager.register(ReAction.class, "zqq2");
    ActionConfig cfg = actionsManager.lookup("/config/dba.delete_multi", "GET");
    assertNotNull(cfg);
    assertEquals("/${entityName}/dba.delete_multi", cfg.getActionPath());
}
Also used : ActionsManager(jodd.madvoc.component.ActionsManager) MadvocConfig(jodd.madvoc.component.MadvocConfig) Test(org.junit.Test)

Example 8 with MadvocConfig

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

the class ActionMethodParserTest method testClassesWithPackage.

@Test
public void testClassesWithPackage() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ActionMethodParser actionMethodParser = webapp.getComponent(ActionMethodParser.class);
    MadvocConfig madvocConfig = webapp.getComponent(MadvocConfig.class);
    madvocConfig.getRootPackages().addRootPackageOf(this.getClass());
    ActionConfig cfg = parse(actionMethodParser, "tst.Boo1Action#foo");
    assertNotNull(cfg);
    assertEquals(Boo1Action.class, cfg.actionClass);
    assertEquals("/tst/boo1.foo.html", cfg.actionPath);
    cfg = parse(actionMethodParser, "tst.Boo2Action#foo");
    assertNotNull(cfg);
    assertEquals(Boo2Action.class, cfg.actionClass);
    assertEquals("/tst/bbb.foo.html", cfg.actionPath);
    cfg = parse(actionMethodParser, "tst.Boo2Action#foo1");
    assertEquals("/tst/bbb.xxx.html", cfg.actionPath);
    cfg = parse(actionMethodParser, "tst.Boo2Action#foo2");
    assertEquals("/tst/bbb.foo2.xxx", cfg.actionPath);
    cfg = parse(actionMethodParser, "tst.Boo2Action#foo3");
    assertEquals("/tst/bbb.html", cfg.actionPath);
}
Also used : MadvocConfig(jodd.madvoc.component.MadvocConfig) ActionMethodParser(jodd.madvoc.component.ActionMethodParser) Test(org.junit.Test)

Example 9 with MadvocConfig

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

the class MadvocParamsInjectorTest method testInjection.

@Test
public void testInjection() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    PetiteContainer madpc = (PetiteContainer) webapp.getComponent(WebApplication.MADVOC_CONTAINER_NAME);
    MadvocConfig madvocConfig = new MadvocConfig();
    String baseName = FooBean.class.getName();
    madpc.defineParameter("foo", "1");
    madpc.defineParameter(baseName + ".integer", "173");
    madpc.defineParameter(baseName + ".string", "jodd");
    madpc.defineParameter(baseName, "huh");
    MadvocParamsInjector madvocParamsInjector = new MadvocParamsInjector(madvocConfig);
    FooBean fooBean = new FooBean();
    madvocParamsInjector.injectContext(new Target(fooBean), null, madpc);
    assertEquals(173, fooBean.getInteger().intValue());
    assertEquals("jodd", fooBean.getString());
}
Also used : WebApplication(jodd.madvoc.WebApplication) PetiteContainer(jodd.petite.PetiteContainer) MadvocConfig(jodd.madvoc.component.MadvocConfig) Test(org.junit.Test)

Example 10 with MadvocConfig

use of jodd.madvoc.component.MadvocConfig 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)

Aggregations

MadvocConfig (jodd.madvoc.component.MadvocConfig)14 Test (org.junit.Test)13 ActionMethodParser (jodd.madvoc.component.ActionMethodParser)7 ActionsManager (jodd.madvoc.component.ActionsManager)5 WebApplication (jodd.madvoc.WebApplication)1 FiltersManager (jodd.madvoc.component.FiltersManager)1 InterceptorsManager (jodd.madvoc.component.InterceptorsManager)1 MadvocController (jodd.madvoc.component.MadvocController)1 ResultMapper (jodd.madvoc.component.ResultMapper)1 ResultsManager (jodd.madvoc.component.ResultsManager)1 AutomagicMadvocConfigurator (jodd.madvoc.config.AutomagicMadvocConfigurator)1 MadvocConfigurator (jodd.madvoc.config.MadvocConfigurator)1 PetiteContainer (jodd.petite.PetiteContainer)1 Props (jodd.props.Props)1