Package juzu.test.protocol.mock

Examples of juzu.test.protocol.mock.MockClient


    assertEquals("plugin.controller.error.inject.A", ret.getClass().getName());
  }

  private Object invokeErrorHandler(String pkg) throws Exception {
    MockApplication app = application(pkg).init();
    MockClient client = app.client();
    shared = null;
    MockViewBridge render = client.render();
    render.assertOk();
    render.assertStringResponse("hello");
    assertNotNull(shared);
    return shared;
  }
View Full Code Here


  }

  @Test
  public void testMimeType() throws Exception {
    MockApplication app = application("plugin.controller.mimetype.html").init();
    MockClient client = app.client();
    MockViewBridge render = client.render();
    render.assertStringResponse("HELLO");
    Iterable<String> mimeType = render.getResponse().getProperties().getValues(PropertyType.MIME_TYPE);
    assertNotNull(mimeType);
    Iterator<String> iterator = mimeType.iterator();
    assertTrue(iterator.hasNext());
View Full Code Here

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

  @Test
  public void testRequest() throws Exception {
    MockApplication<?> application = application(InjectorProvider.GUICE, "plugin.controller.contextual.request");
    application.init();
    MockClient client = application.client();
    MockViewBridge request = client.render();
    Assert.assertEquals("pass", request.assertStringResponse());
  }
View Full Code Here

  @Test
  public void testStringArray() throws Exception {
    MockApplication<?> app = application("plugin.controller.method.parameters.string.array").init();

    //
    MockClient client = app.client();

    //
    MockViewBridge render = client.render("none");
    MockViewBridge mv = (MockViewBridge)client.invoke(render.assertStringResponse());
    assertEquals("", mv.assertStringResponse());

    //
    render = client.render("0");
    mv = (MockViewBridge)client.invoke(render.assertStringResponse());
    assertEquals("", mv.assertStringResponse());

    //
    render = client.render("1");
    mv = (MockViewBridge)client.invoke(render.assertStringResponse());
    assertEquals(Arrays.asList("bar").toString(), mv.assertStringResponse());

    //
    render = client.render("2");
    mv = (MockViewBridge)client.invoke(render.assertStringResponse());
    assertEquals(Arrays.asList("bar_1", "bar_2").toString(), mv.assertStringResponse());
  }
View Full Code Here

  @Test
  public void testStringList() throws Exception {
    MockApplication<?> app = application("plugin.controller.method.parameters.string.list").init();

    //
    MockClient client = app.client();

    //
    MockViewBridge render = client.render("none");
    MockViewBridge mv = (MockViewBridge)client.invoke(render.assertStringResponse());
    assertEquals("", mv.assertStringResponse());

    //
    render = client.render("0");
    mv = (MockViewBridge)client.invoke(render.assertStringResponse());
    assertEquals("", mv.assertStringResponse());

    //
    render = client.render("1");
    mv = (MockViewBridge)client.invoke(render.assertStringResponse());
    assertEquals(Arrays.asList("bar").toString(), mv.assertStringResponse());

    //
    render = client.render("2");
    mv = (MockViewBridge)client.invoke(render.assertStringResponse());
    assertEquals(Arrays.asList("bar_1", "bar_2").toString(), mv.assertStringResponse());
  }
View Full Code Here

  @Test
  public void testBean() throws Exception {
    MockApplication<?> app = application("plugin.controller.method.parameters.bean").init();

    //
    MockClient client = app.client();

    //
    assertBean(client, "a", "v");
    assertBean(client, "b", Arrays.asList("v1", "v2").toString());
    assertBean(client, "c", Arrays.asList("v1", "v2").toString());
View Full Code Here

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

  public void testSimple() throws Exception {
    MockApplication<?> app = application("plugin.controller.url.simple");
    app.init();

    //
    MockClient client = app.client();
    MockViewBridge render = client.render();
    JSON url = (JSON)JSON.parse(render.assertStringResponse());
    assertFalse(url.getJSON("properties").contains(PropertyType.ESCAPE_XML.getClass().getName()));
  }
View Full Code Here

  public void testEscapeXML() throws Exception {
    MockApplication<?> app = application("plugin.controller.url.escapexml");
    app.init();

    //
    MockClient client = app.client();
    MockViewBridge render = client.render();
    JSON url = (JSON)JSON.parse(render.assertStringResponse());
    assertEquals(Boolean.TRUE, url.getJSON("properties").get(PropertyType.ESCAPE_XML.getClass().getName()));
  }
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.