Package juzu.test.protocol.mock

Examples of juzu.test.protocol.mock.MockClient


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

    //
    MockClient client = app.client();
    MockViewBridge render = client.render();
    assertEquals("render_phase", render.assertStringResponse());

    //
    String url = render.getTitle();
    MockActionBridge action = (MockActionBridge)client.invoke(url);
    //
//      client.
//      client.invoke();
//      assertNull(Registry.get("car"));
View Full Code Here


  }

  @Test
  public void testValidation() throws Exception {
    MockApplication app = application("juzu.simple").init();
    MockClient client = app.client();
    MockViewBridge render = client.render();
    ValidationError va = assertInstanceOf(ValidationError.class, render.getResponse());
    Set<ConstraintViolation<Object>> violations = va.getViolations();
    assertEquals(1, violations.size());
    ConstraintViolation<Object> violation = violations.iterator().next();
    assertEquals("may not be null", violation.getMessage());
View Full Code Here

  }

  @Test
  public void testLifeCycle() throws Exception {
    MockApplication app = application("juzu.lifecycle").init();
    MockClient client = app.client();
    o = null;
    client.render();
    ValidationError error = assertInstanceOf(ValidationError.class, o);
    Set<ConstraintViolation<Object>> violations = error.getViolations();
    assertEquals(1, violations.size());
  }
View Full Code Here

  @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

  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

  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

  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

  @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

  @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

  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

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.