public MockClient(MockApplication<?> application) { LinkedList<Locale> locales = new LinkedList<Locale>(); locales.add(Locale.ENGLISH); ControllerService controllerPlugin = application.getLifeCycle().resolveBean(ControllerService.class); // this.application = application; this.session = new ServletScopedContext(Logger.SYSTEM); this.flash = null; this.flashHistory = new LinkedList<List<Scoped>>(); this.controllerPlugin = controllerPlugin; this.locales = locales; this.roles = new HashSet<String>(); }
public MockClient(MockApplication<?> application) { LinkedList<Locale> locales = new LinkedList<Locale>(); locales.add(Locale.ENGLISH); ControllerService controllerPlugin = application.getLifeCycle().resolveBean(ControllerService.class); // this.application = application; this.session = new ServletScopedContext(Logger.SYSTEM); this.flash = null; this.flashHistory = new LinkedList<List<Scoped>>(); this.controllerPlugin = controllerPlugin; this.locales = locales; this.roles = new HashSet<String>(); }
public MockViewBridge render(String methodId) { MethodHandle handle = null; ControllerHandler handler = null; if (methodId != null) { handler = controllerPlugin.getDescriptor().getMethodById(methodId); } else { handler = controllerPlugin.getDescriptor().getResolver().resolve(Phase.VIEW, Collections.<String>emptySet()); } if (handler != null) { handle = handler.getHandle(); } MockViewBridge render = new MockViewBridge(application.getLifeCycle(), this, handle, new HashMap<String, String[]>()); invoke(render); return render; }
@Test public void testLifeCycle() throws Exception { events.clear(); MockApplication<?> app = application("plugin.controller.executionfilter.lifecycle").init(); Tools.list(app.getLifeCycle().resolveBeans(RequestFilter.class)); MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals((Object)Arrays.asList("execute", "onCommand", "beforeRun", "run", "afterRun", "hello"), events); }
public MockViewBridge render(String methodId) { MethodHandle handle = null; ControllerHandler handler = null; if (methodId != null) { handler = controllerPlugin.getDescriptor().getMethodById(methodId); } else { handler = controllerPlugin.getDescriptor().getResolver().resolve(Phase.VIEW, Collections.<String>emptySet()); } if (handler != null) { handle = handler.getHandle(); } MockViewBridge render = new MockViewBridge(application.getLifeCycle(), this, handle, new HashMap<String, String[]>()); invoke(render); return render; }
@Test public void testLifeCycle() throws Exception { events.clear(); MockApplication<?> app = application("plugin.controller.executionfilter.lifecycle").init(); Tools.list(app.getLifeCycle().resolveBeans(RequestFilter.class)); MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals((Object)Arrays.asList("execute", "onCommand", "beforeRun", "run", "afterRun", "hello"), events); }
request = new MockActionBridge(application.getLifeCycle(), this, handler.getHandle(), parameters); } else if (handler.getPhase() == Phase.VIEW) { request = new MockViewBridge(application.getLifeCycle(), this, handler.getHandle(), parameters); } else if (handler.getPhase() == Phase.RESOURCE) { request = new MockResourceBridge(application.getLifeCycle(), this, handler.getHandle(), parameters); } else { throw new AssertionError(); request = new MockViewBridge(application.getLifeCycle(), this, null, parameters);
request = new MockActionBridge(application.getLifeCycle(), this, handler.getHandle(), parameters); } else if (handler.getPhase() == Phase.VIEW) { request = new MockViewBridge(application.getLifeCycle(), this, handler.getHandle(), parameters); } else if (handler.getPhase() == Phase.RESOURCE) { request = new MockResourceBridge(application.getLifeCycle(), this, handler.getHandle(), parameters); } else { throw new AssertionError(); request = new MockViewBridge(application.getLifeCycle(), this, null, parameters);
TemplateDescriptor desc = app.getLifeCycle().resolveBean(TemplateService.class).getDescriptor().getTemplate("/plugin/template/tag/decorate/templates/index.gtmpl"); assertNotNull(desc); TemplateModel<?> foo = new TemplateModel<ASTNode.Template>(
TemplateDescriptor desc = app.getLifeCycle().resolveBean(TemplateService.class).getDescriptor().getTemplate("/plugin/template/tag/decorate/templates/index.gtmpl"); assertNotNull(desc); TemplateModel<?> foo = new TemplateModel<ASTNode.Template>(
@Test public void testLifeCycle() throws Exception { Registry.unset("request.filter.lifecycle"); MockApplication<?> app = application("plugin.controller.requestfilter.lifecycle").init(); Tools.list(app.getLifeCycle().resolveBeans(RequestFilter.class)); assertEquals("created", Registry.get("request.filter.lifecycle")); MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals("after", Registry.get("request.filter.lifecycle")); }
@Test public void testLifeCycle() throws Exception { Registry.unset("request.filter.lifecycle"); MockApplication<?> app = application("plugin.controller.requestfilter.lifecycle").init(); Tools.list(app.getLifeCycle().resolveBeans(RequestFilter.class)); assertEquals("created", Registry.get("request.filter.lifecycle")); MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals("after", Registry.get("request.filter.lifecycle")); }