use of jodd.madvoc.component.MadvocConfig in project jodd by oblac.
the class ActionMethodParserTest method testNoPackage.
@Test
public void testNoPackage() {
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, "tst2.Boo5Action#foo");
assertNotNull(cfg);
assertEquals(Boo5Action.class, cfg.actionClass);
assertEquals("/www.foo.html", cfg.actionPath);
cfg = parse(actionMethodParser, "tst2.Boo5Action#foo1");
assertEquals("/www.xxx.html", cfg.actionPath);
cfg = parse(actionMethodParser, "tst2.Boo5Action#foo2");
assertEquals("/www.foo2.xxx", cfg.actionPath);
cfg = parse(actionMethodParser, "tst2.Boo5Action#foo3");
assertEquals("/www.html", cfg.actionPath);
}
use of jodd.madvoc.component.MadvocConfig 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());
}
use of jodd.madvoc.component.MadvocConfig in project jodd by oblac.
the class ActionResultTest method testMethodWithPrefix.
@Test
public void testMethodWithPrefix() {
WebApplication webapp = new WebApplication(true);
webapp.registerMadvocComponents();
ResultMapper resultMapper = webapp.getComponent(ResultMapper.class);
MadvocConfig madvocConfig = webapp.getComponent(MadvocConfig.class);
madvocConfig.setResultPathPrefix("/WEB-INF");
String path = "/boo.foo";
ResultPath resultPath = resultMapper.resolveResultPath(path, "ok");
assertEquals("/WEB-INF/boo.foo.ok", resultPath.getPathValue());
resultPath = resultMapper.resolveResultPath(path, "doo.ok");
assertEquals("/WEB-INF/boo.foo.doo.ok", resultPath.getPathValue());
resultPath = resultMapper.resolveResultPath(path, "#ok");
assertEquals("/WEB-INF/boo.ok", resultPath.getPathValue());
resultPath = resultMapper.resolveResultPath(path, "#");
assertEquals("/WEB-INF/boo", resultPath.getPathValue());
resultPath = resultMapper.resolveResultPath(path, "#doo.ok");
assertEquals("/WEB-INF/boo.doo.ok", resultPath.getPathValue());
resultPath = resultMapper.resolveResultPath(path, null);
assertEquals("/WEB-INF/boo.foo", resultPath.getPathValue());
resultPath = resultMapper.resolveResultPath(path, "/xxx");
assertEquals("/xxx", resultPath.getPathValue());
resultPath = resultMapper.resolveResultPath(path, "/xxx.ext");
assertEquals("/xxx.ext", resultPath.getPathValue());
}
use of jodd.madvoc.component.MadvocConfig in project jodd by oblac.
the class ActionMethodParserTest method testMarkerClass.
@Test
public void testMarkerClass() {
WebApplication webapp = new WebApplication(true);
webapp.registerMadvocComponents();
ActionMethodParser actionMethodParser = webapp.getComponent(ActionMethodParser.class);
MadvocConfig madvocConfig = webapp.getComponent(MadvocConfig.class);
RootPackages rootPackages = madvocConfig.getRootPackages();
String thisPackageName = this.getClass().getPackage().getName();
assertNull(rootPackages.getPackageActionPath(thisPackageName + ".tst3"));
ActionConfig cfg = parse(actionMethodParser, "tst3.JohnAction#hello");
assertEquals("/root", rootPackages.getPackageActionPath(thisPackageName + ".tst3"));
assertEquals("/root/john.hello.html", cfg.actionPath);
cfg = parse(actionMethodParser, "tst3.JimAction#hello");
assertEquals("/my-root/jim.my-hello.html", cfg.actionPath);
assertNull(rootPackages.getPackageActionPath(thisPackageName + ".tst3.lvl1"));
cfg = parse(actionMethodParser, "tst3.lvl1.EmaAction#hello");
assertEquals("/root/lvl1/ema.hello.html", cfg.actionPath);
assertEquals("/root/lvl1", rootPackages.getPackageActionPath(thisPackageName + ".tst3.lvl1"));
assertNull(rootPackages.getPackageActionPath(thisPackageName + ".tst3.lvl2"));
cfg = parse(actionMethodParser, "tst3.lvl2.DidyAction#hello");
assertEquals("/gig/didy.hello.html", cfg.actionPath);
assertEquals("/gig", rootPackages.getPackageActionPath(thisPackageName + ".tst3.lvl2"));
}
Aggregations