Examples of MockClient


Examples of juzu.test.protocol.mock.MockClient

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

Examples of juzu.test.protocol.mock.MockClient

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

Examples of juzu.test.protocol.mock.MockClient

  private <T extends Throwable> T  runParseError(String pkg, Class<T> expected) 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());
    return action.assertFailure(expected);
  }
View Full Code Here

Examples of juzu.test.protocol.mock.MockClient

  private void runMissing(String pkg) throws Exception {
    MockApplication<File> application = application(InjectorProvider.GUICE, pkg);
    MockApplication<?> app = application.init();

    //
    MockClient client = app.client();
    MockViewBridge render = client.render();
    String url = render.assertStringResponse();
    JSON json = (JSON)JSON.parse(url);
    json.set("parameters", new JSON());
    MockViewBridge action = (MockViewBridge)client.invoke(json.toString());
    String result = action.assertStringResponse();
    assertEquals("pass", result);
  }
View Full Code Here

Examples of juzu.test.protocol.mock.MockClient

  @Test
  public void testNotFound() throws Exception {
    MockApplication<?> app = application("plugin.controller.resource.notfound").init();

    //
    MockClient client = app.client();
    MockViewBridge render = client.render();
    MockResourceBridge resource = (MockResourceBridge)client.invoke(render.assertStringResponse());
    resource.assertNotFound();
  }
View Full Code Here

Examples of juzu.test.protocol.mock.MockClient

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

Examples of juzu.test.protocol.mock.MockClient

  public void testRenderPhase() throws Exception {
    if (getDI() == InjectorProvider.WELD) {
      MockApplication<?> app = application("plugin.controller.predestroy").init();

      //
      MockClient client = app.client();
      client.render();
      Integer count = Registry.get("count");
      assertEquals((Integer)1, count);
    }
  }
View Full Code Here

Examples of juzu.test.protocol.mock.MockClient

  @Test
  public void testFlashScope() throws Exception {
    MockApplication<?> app = application("plugin.controller.scope.flash").init();

    //
    MockClient client = app.client();

    //
    client.render();
    long id1 = Registry.<Long>unset("car");
    int status = Registry.<Integer>unset("status");
    assertEquals(Identifiable.MANAGED, status);
    assertEquals(1, client.getFlashHistory(1).size());
    Identifiable car1 = (Identifiable)client.getFlashHistory(1).iterator().next().get();
    assertEquals(car1.getIdentityHashCode(), id1);
    assertEquals(Identifiable.DESTROYED, car1.getStatus());

    //
    client.invoke(Registry.<String>unset("action"));
    long id2 = Registry.<Long>unset("car");
    status = Registry.<Integer>unset("status");
    assertEquals(Identifiable.MANAGED, status);
    assertNotSame(id1, id2);
    assertEquals(1, client.getFlashHistory(0).size());
    Identifiable car2 = (Identifiable)client.getFlashHistory(0).iterator().next().get();
    assertNotSame(car1, car2);
    assertEquals(Identifiable.MANAGED, car2.getStatus());

    //
    client.render();
    long id3 = Registry.<Long>unset("car");
    status = Registry.<Integer>unset("status");
    assertEquals(Identifiable.MANAGED, status);
    assertEquals(id2, id3);
    assertEquals(1, client.getFlashHistory(1).size());
    Identifiable car3 = (Identifiable)client.getFlashHistory(1).iterator().next().get();
    assertSame(car2, car3);
    assertEquals(Identifiable.DESTROYED, car2.getStatus());
  }
View Full Code Here

Examples of juzu.test.protocol.mock.MockClient

  @Test
  public void testSessionScope() throws Exception {
    MockApplication<?> app = application("plugin.controller.scope.session").init();

    //
    MockClient client = app.client();

    //
    client.render();
    long id1 = Registry.<Long>unset("car");
    int status = Registry.<Integer>unset("status");
    assertEquals(Identifiable.MANAGED, status);
    assertEquals(1, client.getSession().size());
    Identifiable car1 = (Identifiable)client.getSession().iterator().next().get();
    assertEquals(car1.getIdentityHashCode(), id1);
    assertEquals(Identifiable.MANAGED, car1.getStatus());

    //
    client.invoke(Registry.<String>unset("action"));
    long id2 = Registry.<Long>unset("car");
    status = Registry.<Integer>unset("status");
    assertEquals(Identifiable.MANAGED, status);
    assertNotSame(id1, id2);
    assertEquals(1, client.getSession().size());
    Identifiable car2 = (Identifiable)client.getSession().iterator().next().get();
    assertSame(car1, car2);
    assertEquals(Identifiable.MANAGED, car2.getStatus());

    //
    client.render();
    long id3 = Registry.<Long>unset("car");
    status = Registry.<Integer>unset("status");
    assertEquals(Identifiable.MANAGED, status);
    assertEquals(id2, id3);
    assertEquals(1, client.getSession().size());
    Identifiable car3 = (Identifiable)client.getSession().iterator().next().get();
    assertSame(car2, car3);
    assertEquals(Identifiable.MANAGED, car2.getStatus());
  }
View Full Code Here

Examples of juzu.test.protocol.mock.MockClient

  @Test
  public void testChecked() throws Exception {
    MockApplication<?> app = application("plugin.template.throwable.checked").init();

    //
    MockClient client = app.client();
    MockViewBridge render = client.render();
    TemplateExecutionException te = render.assertFailure(TemplateExecutionException.class);
    assertInstanceOf(AuthenticationException.class, te.getCause());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.