use of jodd.madvoc.config.ActionRuntime in project jodd by oblac.
the class ActionMethodParserTest method testMethodWithPackage.
@Test
void testMethodWithPackage() {
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.tst.BooAction#foo");
assertNotNull(cfg);
assertEquals(BooAction.class, cfg.getActionClass());
assertEquals("/fixtures/tst/boo.foo", cfg.getActionPath());
cfg = parse(actionMethodParser, "fixtures.tst.BooAction#foo1");
assertEquals("/fixtures/tst/boo.xxx", cfg.getActionPath());
cfg = parse(actionMethodParser, "fixtures.tst.BooAction#foo2");
assertEquals("/fixtures/tst/boo.foo2.xxx", cfg.getActionPath());
cfg = parse(actionMethodParser, "fixtures.tst.BooAction#foo3");
assertEquals("/fixtures/tst/boo", cfg.getActionPath());
cfg = parse(actionMethodParser, "fixtures.tst.BooAction#foo4");
assertEquals("/xxx", cfg.getActionPath());
assertNull(cfg.getActionMethod());
cfg = parse(actionMethodParser, "fixtures.tst.BooAction#foo41");
assertEquals("/xxx", cfg.getActionPath());
assertEquals("DELETE", cfg.getActionMethod());
cfg = parse(actionMethodParser, "fixtures.tst.BooAction#foo5");
assertEquals("/xxx.html", cfg.getActionPath());
assertEquals("POST", cfg.getActionMethod());
cfg = parse(actionMethodParser, "fixtures.tst.BooAction#foo6");
assertEquals("/fixtures/tst/boo.qfoo62", cfg.getActionPath());
cfg = parse(actionMethodParser, "fixtures.tst.BooAction#foo7");
assertEquals("/foo7.html", cfg.getActionPath());
}
use of jodd.madvoc.config.ActionRuntime in project jodd by oblac.
the class ActionResultTest method testAlias2.
@Test
void testAlias2() {
WebApp webapp = new WebApp();
webapp.start();
ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class);
actionsManager.registerAction(BooAction.class, "foo2", null);
actionsManager.registerPathAlias("/boo.foo2.xxx", "/aliased");
ResultMapper resultMapper = webapp.madvocContainer().lookupComponent(ResultMapper.class);
ActionMethodParser actionMethodParser = webapp.madvocContainer().lookupComponent(ActionMethodParser.class);
ActionRuntime cfg = parse(actionMethodParser, "fixtures.tst.BooAction#foo2");
String path = cfg.getActionPath();
String resultPath = resultMapper.resolveResultPathString(path, null);
assertEquals("/aliased", resultPath);
}
use of jodd.madvoc.config.ActionRuntime in project jodd by oblac.
the class AnnArgTest method testDefaultMethods.
@Test
void testDefaultMethods() {
WebApp webapp = new WebApp();
webapp.start();
ActionMethodParser actionMethodParser = webapp.madvocContainer().lookupComponent(ActionMethodParser.class);
ActionRuntime cfg = parse(actionMethodParser, "fixtures.tst.SuperAction#add");
assertNotNull(cfg);
}
use of jodd.madvoc.config.ActionRuntime in project jodd by oblac.
the class ManualRegistrationTest method testManualAction_asComponent.
@Test
void testManualAction_asComponent() {
WebApp webApp = WebApp.createWebApp().registerComponent(ManualRegistration.class).start();
ActionsManager actionsManager = webApp.madvocContainer().requestComponent(ActionsManager.class);
assertEquals(2, actionsManager.getActionsCount());
ActionRuntime actionRuntime = actionsManager.lookup("GET", MadvocUtil.splitPathToChunks("/hello"));
assertNotNull(actionRuntime);
assertEquals(BooAction.class, actionRuntime.getActionClass());
assertEquals("foo1", actionRuntime.getActionClassMethod().getName());
actionRuntime = actionsManager.lookup("GET", MadvocUtil.splitPathToChunks("/world"));
assertNotNull(actionRuntime);
assertEquals(BooAction.class, actionRuntime.getActionClass());
assertEquals("foo2", actionRuntime.getActionClassMethod().getName());
}
use of jodd.madvoc.config.ActionRuntime in project jodd by oblac.
the class ActionsManagerTest method testActionPathMacrosRegexp.
@Test
void testActionPathMacrosRegexp() {
WebApp webapp = new WebApp();
webapp.start();
ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class);
actionsManager.setPathMacroClass(RegExpPathMacros.class);
actionsManager.registerAction(FooAction.class, "one", new ActionDefinition("/{one:[ab]+}"));
ActionRuntime actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/a"));
assertNotNull(actionRuntime);
actionRuntime = actionsManager.routes.lookup(null, MadvocUtil.splitPathToChunks("/ac"));
assertNull(actionRuntime);
}
Aggregations