Search in sources :

Example 6 with WebApplication

use of jodd.madvoc.WebApplication in project jodd by oblac.

the class ActionsManagerTest method testActionPathMacrosWildcard.

@Test
public void testActionPathMacrosWildcard() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    MadvocConfig madvocConfig = webapp.getComponent(MadvocConfig.class);
    madvocConfig.setPathMacroClass(WildcardPathMacros.class);
    actionsManager.register(FooAction.class, "one", new ActionDef("/${one:a?a}"));
    ActionConfig actionConfig = actionsManager.lookup("/aaa", null);
    assertNotNull(actionConfig);
    actionConfig = actionsManager.lookup("/aab", null);
    assertNull(actionConfig);
}
Also used : ActionConfig(jodd.madvoc.ActionConfig) WebApplication(jodd.madvoc.WebApplication) ActionDef(jodd.madvoc.ActionDef) Test(org.junit.Test)

Example 7 with WebApplication

use of jodd.madvoc.WebApplication in project jodd by oblac.

the class ActionsManagerTest method testActionPathMacros2.

@Test
public void testActionPathMacros2() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    actionsManager.register(FooAction.class, "one", new ActionDef("/${one}"));
    actionsManager.register(FooAction.class, "two", new ActionDef("/xxx-${two}"));
    ActionConfig actionConfig = actionsManager.lookup("/foo", null);
    assertEquals("one", actionConfig.actionClassMethod.getName());
    actionConfig = actionsManager.lookup("/foo/boo", null);
    assertNull(actionConfig);
    actionConfig = actionsManager.lookup("/xxx-foo", null);
    // best match!
    assertEquals("two", actionConfig.actionClassMethod.getName());
}
Also used : ActionConfig(jodd.madvoc.ActionConfig) WebApplication(jodd.madvoc.WebApplication) ActionDef(jodd.madvoc.ActionDef) Test(org.junit.Test)

Example 8 with WebApplication

use of jodd.madvoc.WebApplication in project jodd by oblac.

the class ActionsManagerTest method testActionPathMacros1.

@Test
public void testActionPathMacros1() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    actionsManager.register(FooAction.class, "one", new ActionDef("/${one}"));
    ActionConfig actionConfig = actionsManager.lookup("/foo", null);
    assertNotNull(actionConfig);
    actionConfig = actionsManager.lookup("/foo/boo", null);
    assertNull(actionConfig);
    actionConfig = actionsManager.lookup("/foo/boo/zoo", null);
    assertNull(actionConfig);
}
Also used : ActionConfig(jodd.madvoc.ActionConfig) WebApplication(jodd.madvoc.WebApplication) ActionDef(jodd.madvoc.ActionDef) Test(org.junit.Test)

Aggregations

WebApplication (jodd.madvoc.WebApplication)8 Test (org.junit.Test)8 ActionConfig (jodd.madvoc.ActionConfig)6 ActionDef (jodd.madvoc.ActionDef)6 ArrayList (java.util.ArrayList)1 ActionRequest (jodd.madvoc.ActionRequest)1 MadvocConfig (jodd.madvoc.component.MadvocConfig)1 ResultMapper (jodd.madvoc.component.ResultMapper)1 PetiteContainer (jodd.petite.PetiteContainer)1