Package juzu.test.protocol.mock

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


  @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

  @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

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

    //
    MockClient client = app.client();
    MockViewBridge render = client.render();
    TemplateExecutionException te = render.assertFailure(TemplateExecutionException.class);
    assertInstanceOf(ConcurrentModificationException.class, te.getCause());
  }
View Full Code Here

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

    //
    MockClient client = app.client();
    MockViewBridge render = client.render();
    render.assertFailure(UnknownError.class);
  }
View Full Code Here

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

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

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

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

  @Test
  public void testResolveBean() throws Exception {
    MockApplication<?> app = application(di, "plugin.template.ambiguous.app1").init();

    //
    MockClient client = app.client();
    MockViewBridge render = client.render();
    assertEquals("app1", render.assertStringResponse());
  }
View Full Code Here

TOP

Related Classes of juzu.test.protocol.mock.MockClient

Copyright © 2018 www.massapicom. 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.