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