public MockRequestBridge invoke(String url) { MockRequestBridge request = create(url); invoke(request); return request; }
private void assertBean(MockClient client, String name, Object expected) throws Exception { MockViewBridge render = client.render(name); String url = render.assertStringResponse(); MockViewBridge m = (MockViewBridge)client.invoke(url); assertEquals(expected, m.assertStringResponse()); render = client.render(name + "Action"); url = render.assertStringResponse(); MockActionBridge action = (MockActionBridge)client.invoke(url); MockViewBridge m2 = (MockViewBridge)client.invoke(action.assertUpdate()); assertEquals(expected, m2.assertStringResponse()); }
private void assertBean(MockClient client, String name, Object expected) throws Exception { MockViewBridge render = client.render(name); String url = render.assertStringResponse(); MockViewBridge m = (MockViewBridge)client.invoke(url); assertEquals(expected, m.assertStringResponse()); render = client.render(name + "Action"); url = render.assertStringResponse(); MockActionBridge action = (MockActionBridge)client.invoke(url); MockViewBridge m2 = (MockViewBridge)client.invoke(action.assertUpdate()); assertEquals(expected, m2.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 testUpdate() throws Exception { MockApplication<?> app = application("plugin.controller.view.update").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); String result = render.assertStringResponse(); MockActionBridge action = (MockActionBridge)client.invoke(result); action.assertRender("A.done", Collections.<String, String>emptyMap()); } }
@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 testActionError() throws Exception { MockApplication<?> app = application("plugin.controller.action.throwable.error").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockRequestBridge request = client.invoke(render.assertStringResponse()); request.assertFailure(UnknownError.class); }
@Test public void testResourceRuntime() throws Exception { MockApplication<?> app = application("plugin.controller.resource.throwable.runtime").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockRequestBridge request = client.invoke(render.assertStringResponse()); request.assertFailure(ConcurrentModificationException.class); }
@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 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 testBinary() throws Exception { MockApplication<?> app = application("plugin.controller.resource.binary").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockResourceBridge resource = (MockResourceBridge)client.invoke(render.assertStringResponse()); assertEquals("hello", new String(resource.assertBinaryResponse(), "UTF-8")); assertEquals("application/octet-stream", resource.getMimeType()); } }
private void runSuccess(String pkg) throws Exception { MockApplication<File> application = application(InjectorProvider.GUICE, pkg); MockApplication<?> app = application.init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockViewBridge action = (MockViewBridge)client.invoke(render.assertStringResponse()); String result = action.assertStringResponse(); assertEquals("pass", result); }
@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 testNoOp() throws Exception { MockApplication<?> app = application("plugin.controller.action.noop").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockActionBridge action = (MockActionBridge)client.invoke(render.assertStringResponse()); action.assertNoResponse(); }
@Test public void testActionError() throws Exception { MockApplication<?> app = application("plugin.controller.action.throwable.error").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockRequestBridge request = client.invoke(render.assertStringResponse()); request.assertFailure(UnknownError.class); }
@Test public void testResourceChecked() throws Exception { MockApplication<?> app = application("plugin.controller.resource.throwable.checked").init(); // MockClient client = app.client(); MockViewBridge render = client.render(); MockRequestBridge request = client.invoke(render.assertStringResponse()); request.assertFailure(AuthenticationException.class); }
@Test public void testContextutal() throws Exception { MockApplication<?> app = application(InjectorProvider.WELD, "plugin.template.url.contextual").init(); MockClient client = app.client(); String url = client.render().assertStringResponse(); assertEquals("pass", ((MockViewBridge)client.invoke(url)).assertStringResponse()); } }
@Test public void testContextutal() throws Exception { MockApplication<?> app = application(InjectorProvider.WELD, "plugin.template.url.contextual").init(); MockClient client = app.client(); String url = client.render().assertStringResponse(); assertEquals("pass", ((MockViewBridge)client.invoke(url)).assertStringResponse()); } }