@Test public void testSimple() throws Exception { // We only use CDI for its capability to discover beans automatically MockApplication<?> application = application(InjectorProvider.WELD, "plugin.controller.contextual.simple"); application.init(); MockClient client = application.client(); MockViewBridge request = client.render(); Assert.assertEquals("__foo__", request.assertStringResponse()); }
@Test public void testRender() throws Exception { MockApplication<?> app = application("plugin.controller.action.render").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockActionBridge action = (MockActionBridge)client.invoke(render.assertStringResponse()); action.assertRender("render", Collections.singletonMap("arg", "arg_value")); } }
@Test public void testConstructorChecked() throws Exception { MockApplication<?> app = application("plugin.controller.constructor.throwable.checked").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); render.assertFailure(AuthenticationException.class); }
@Test public void testConstructorRuntime() throws Exception { MockApplication<?> app = application("plugin.controller.constructor.throwable.runtime").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); render.assertFailure(ConcurrentModificationException.class); }
@Test public void testUnresolvedContext() throws Exception { MockApplication<?> app = application("plugin.controller.method.parameters.context.unresolved").init(); // MockClient client = app.client(); // MockViewBridge render = client.render("index"); assertTrue(WAS_NULL); // MockRenderBridge mv = (MockRenderBridge)client.invoke(render.assertStringResult()); }
@Test public void testRenderRuntime() throws Exception { MockApplication<?> app = application("plugin.controller.view.throwable.runtime").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); render.assertFailure(ConcurrentModificationException.class); }
@Test public void testRenderError() throws Exception { MockApplication<?> app = application("plugin.controller.view.throwable.error").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); render.assertFailure(UnknownError.class); }
@Test public void testInclude() throws Exception { MockApplication<?> app = application("plugin.template.tag.include").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); String out = render.assertStringResponse(); assertEquals("foo", out); }
@Test public void testResolveBean() throws Exception { MockApplication<?> app = application("plugin.template.el").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals("A", render.assertStringResponse()); } }
@Test public void testQualifiedProvider() throws Exception { MockApplication<?> app = application("plugin.binding.provider.qualified").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals("pass", render.assertStringResponse()); } }
@Test public void testCreate() throws Exception { MockApplication<?> app = application("plugin.binding.implementation.create").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals("pass", render.assertStringResponse()); } }
@Test public void testTyped() throws Exception { MockApplication<?> app = application("plugin.template.typed").init(); MockClient client = app.client(); assertEquals("typed_template", client.render().assertStringResponse()); }
@Test public void testBasic() throws Exception { MockApplication<?> app = application("basic").init(); MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals("foo", render.assertStringResponse()); }
@Test public void testBasic() throws Exception { MockApplication<?> app = application("basic").init(); MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals("foo", render.assertStringResponse()); }
@Test public void testRedirect() throws Exception { MockApplication<?> app = application("plugin.controller.action.redirect").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockActionBridge action = (MockActionBridge)client.invoke(render.assertStringResponse()); action.assertRedirect("http://www.julienviet.com"); }
@Test public void testActionRuntime() throws Exception { MockApplication<?> app = application("plugin.controller.action.throwable.runtime").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockRequestBridge request = client.invoke(render.assertStringResponse()); request.assertFailure(ConcurrentModificationException.class); }
@Test public void testParameterDeclaration() throws Exception { if (getDI() != InjectorProvider.GUICE) { MockApplication<?> app = application("parameterdeclaration").init(); MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals("bar", render.assertStringResponse()); } } }
@Test public void testRedirect() throws Exception { MockApplication<?> app = application("plugin.controller.action.redirect").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockActionBridge action = (MockActionBridge)client.invoke(render.assertStringResponse()); action.assertRedirect("http://www.julienviet.com"); }
@Test public void testResourceError() throws Exception { MockApplication<?> app = application("plugin.controller.resource.throwable.error").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockRequestBridge request = client.invoke(render.assertStringResponse()); request.assertFailure(UnknownError.class); } }
@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")); }