Package jodd.madvoc.component

Examples of jodd.madvoc.component.ActionsManager$ActionConfigSetComparator


      throw new MadvocException("Madvoc interceptors manager not found");
    }
    webapp.initInterceptors(interceptorsManager);

    // actions
    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    if (actionsManager == null) {
      throw new MadvocException("Madvoc actions manager not found");
    }
    webapp.initActions(actionsManager);
View Full Code Here


  public void testManualAction() {
    Madvoc madvoc = new Madvoc();
    madvoc.setMadvocConfiguratorClass(ManualRegistration.class);
    madvoc.startNewWebApplication(null);

    ActionsManager actionsManager = madvoc.getWebApplication().getComponent(ActionsManager.class);

    assertEquals(2, actionsManager.getActionsCount());

    ActionConfig actionConfig = actionsManager.lookup("/hello", "GET");
    assertNotNull(actionConfig);
    assertEquals(BooAction.class, actionConfig.getActionClass());
    assertEquals("foo1", actionConfig.actionClassMethod.getName());

    actionConfig = actionsManager.lookup("/world", "GET");
    assertNotNull(actionConfig);
    assertEquals(BooAction.class, actionConfig.getActionClass());
    assertEquals("foo2", actionConfig.actionClassMethod.getName());
  }
View Full Code Here

  @Test
  public void testAlias() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();

    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    actionsManager.register(BooAction.class, "foo5");
    actionsManager.registerPathAlias("ok", "xxx.jsp");
    actionsManager.registerPathAlias("sok", "zzz");

    ResultMapper resultMapper = webapp.getComponent(ResultMapper.class);

    String path = "/boo.foo.html";
View Full Code Here

  @Test
  public void testAlias2() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();

    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    actionsManager.register(BooAction.class, "foo2");
    actionsManager.registerPathAlias("/boo.foo2.xxx", "/aliased");

    ResultMapper resultMapper = webapp.getComponent(ResultMapper.class);
    ActionMethodParser actionMethodParser = webapp.getComponent(ActionMethodParser.class);

    ActionConfig cfg = parse(actionMethodParser, "tst.BooAction#foo2");
View Full Code Here

  @Test
  public void testAlias3() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();

    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    actionsManager.register(BooAction.class, "foo2");

    assertEquals("/boo.foo2.xxx", actionsManager.lookup(BooAction.class.getName() + "#foo2").actionPath);
  }
View Full Code Here

    cfg = parse(actionMethodParser, "tst.BooAction#foo5");
    assertEquals("/xxx.html", cfg.actionPath);
    assertEquals("POST", cfg.actionMethod);

    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    assertEquals("/xxx.html", actionsManager.lookupPathAlias("dude"));
  }
View Full Code Here

  @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());
  }
View Full Code Here

  @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());
  }
View Full Code Here

  @Test
  public void testMacrosDups() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);

    MadvocConfig madvocConfig = webapp.getComponent(MadvocConfig.class);
    madvocConfig.getRootPackages().addRootPackageOf(this.getClass());
    madvocConfig.setPathMacroClass(RegExpPathMacros.class);

    actionsManager.register(ReAction.class, "duplo1");
    actionsManager.register(ReAction.class, "duplo2");

    ActionConfig cfg = actionsManager.lookup("/re/duplo/123", "GET");
    assertNotNull(cfg);
    ActionConfigSet set = cfg.getActionConfigSet();
    assertEquals(ReAction.class, cfg.actionClass);
    assertEquals("/re/duplo/${id:^[0-9]+}", cfg.actionPath);
    assertEquals(3, set.deep);
    assertEquals(1, set.actionPathMacros.getMacrosCount());
    assertEquals("id", set.actionPathMacros.getNames()[0]);

    cfg = actionsManager.lookup("/re/duplo/aaa", "GET");
    assertNotNull(cfg);
    set = cfg.getActionConfigSet();
    assertEquals(ReAction.class, cfg.actionClass);
    assertEquals("/re/duplo/${sid}", cfg.actionPath);
    assertEquals(3, set.deep);
    assertEquals(1, set.actionPathMacros.getMacrosCount());
    assertEquals("sid", set.actionPathMacros.getNames()[0]);

    assertEquals(2, actionsManager.getActionsCount());
  }
View Full Code Here

  @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());
  }
View Full Code Here

TOP

Related Classes of jodd.madvoc.component.ActionsManager$ActionConfigSetComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.