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);
}
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());
}
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);
}
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());
}
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());
}
Aggregations