Package ch.ralscha.extdirectspring.bean

Examples of ch.ralscha.extdirectspring.bean.ExtDirectResponse


    parameters.put("extAction", "remoteProviderSimple");
    parameters.put("extMethod", "method1");
    parameters.put("extType", "rpc");
    MvcResult result = ControllerUtil.performRouterRequest(mockMvc, null, parameters,
        null, null, false);
    ExtDirectResponse edsResponse = ControllerUtil.readDirectResponse(result
        .getResponse().getContentAsByteArray());

    assertThat(edsResponse.getType()).isEqualTo("exception");
    assertThat(edsResponse.getMessage()).isEqualTo("something wrong");
    assertThat(edsResponse.getWhere()).isEqualTo(
        "Bean or Method 'remoteProviderSimple.method1' not found");

    assertThat(edsResponse.getTid()).isEqualTo(12);
    assertThat(edsResponse.getAction()).isEqualTo("remoteProviderSimple");
    assertThat(edsResponse.getMethod()).isEqualTo("method1");

    ReflectionTestUtils.setField(configurationService, "configuration",
        new Configuration());
    configurationService.afterPropertiesSet();
  }
View Full Code Here


    parameters.put("salary", "12.3");
    parameters.put("result", "theResult");

    MvcResult resultMvc = ControllerUtil.performRouterRequest(mockMvc, null,
        parameters, null, null, false);
    ExtDirectResponse edsResponse = ControllerUtil.readDirectResponse(resultMvc
        .getResponse().getContentAsByteArray());

    assertThat(edsResponse.getType()).isEqualTo("rpc");
    assertThat(edsResponse.getMessage()).isNull();
    assertThat(edsResponse.getWhere()).isNull();
    assertThat(edsResponse.getTid()).isEqualTo(12);
    assertThat(edsResponse.getAction()).isEqualTo("formInfoController");
    assertThat(edsResponse.getMethod()).isEqualTo("updateInfoDirect");

    @SuppressWarnings("unchecked")
    Map<String, Object> result = (Map<String, Object>) edsResponse.getResult();
    assertThat(result).hasSize(6).contains(entry("name", "RALPH"), entry("age", 30),
        entry("admin", Boolean.FALSE), entry("salary", 1012.3),
        entry("result", "theResultRESULT"), entry("success", Boolean.TRUE));
  }
View Full Code Here

    String prefix = "<html><body><textarea>";
    String suffix = "</textarea></body></html>";
    assertThat(response).startsWith(prefix).endsWith(suffix);
    String json = response.substring(prefix.length(), response.indexOf(suffix));

    ExtDirectResponse edsResponse = ControllerUtil.readDirectResponse(json
        .getBytes(ExtDirectSpringUtil.UTF8_CHARSET));

    assertThat(edsResponse.getType()).isEqualTo("rpc");
    assertThat(edsResponse.getMessage()).isNull();
    assertThat(edsResponse.getWhere()).isNull();
    assertThat(edsResponse.getTid()).isEqualTo(1);
    assertThat(edsResponse.getAction()).isEqualTo("uploadService");
    assertThat(edsResponse.getMethod()).isEqualTo("upload");

    Map<String, Object> result = (Map<String, Object>) edsResponse.getResult();
    assertThat(result).hasSize(8);
    assertThat(result).contains(entry("e-mail", null), entry("age", 20),
        entry("name", "Ralph"), entry("fileName", ""),
        entry("fileContents", "the content of the file"),
        entry("firstName", null), entry("success", Boolean.TRUE));
View Full Code Here

    MvcResult result = ControllerUtil.performRouterRequest(mockMvc, edRequest);
    List<ExtDirectResponse> responses = ControllerUtil.readDirectResponses(result
        .getResponse().getContentAsByteArray());

    assertThat(responses).hasSize(1);
    ExtDirectResponse resp = responses.get(0);
    assertThat(resp.getAction()).isEqualTo("remoteProviderSimple");
    assertThat(resp.getMethod()).isEqualTo("method4b");
    assertThat(resp.getType()).isEqualTo("exception");
    assertThat(resp.getTid()).isEqualTo(2);
    assertThat(resp.getMessage()).isEqualTo("there is something wrong");
    assertThat(resp.getResult()).isNull();
    assertThat(resp.getWhere()).startsWith(
        "java.lang.NumberFormatException: For input string: \"xxx\"");
  }
View Full Code Here

    MvcResult result = ControllerUtil.performRouterRequest(mockMvc, edRequest);
    List<ExtDirectResponse> responses = ControllerUtil.readDirectResponses(result
        .getResponse().getContentAsByteArray());

    assertThat(responses).hasSize(1);
    ExtDirectResponse resp = responses.get(0);
    assertThat(resp.getAction()).isEqualTo("remoteProviderSimple2");
    assertThat(resp.getMethod()).isEqualTo("method4");
    assertThat(resp.getType()).isEqualTo("exception");
    assertThat(resp.getTid()).isEqualTo(2);
    assertThat(resp.getMessage()).isEqualTo("Panic!!!");
    assertThat(resp.getResult()).isNull();
    assertThat(resp.getWhere()).startsWith(
        "Bean or Method 'remoteProviderSimple2.method4' not found");

  }
View Full Code Here

    MvcResult result = ControllerUtil.performRouterRequest(mockMvc, edRequest);
    List<ExtDirectResponse> responses = ControllerUtil.readDirectResponses(result
        .getResponse().getContentAsByteArray());

    assertThat(responses).hasSize(1);
    ExtDirectResponse resp = responses.get(0);
    assertThat(resp.getAction()).isEqualTo("remoteProviderSimple");
    assertThat(resp.getMethod()).isEqualTo("method11b");
    assertThat(resp.getType()).isEqualTo("exception");
    assertThat(resp.getTid()).isEqualTo(3);
    assertThat(resp.getMessage()).isEqualTo("not supported");
    assertThat(resp.getResult()).isNull();
    assertThat(resp.getWhere()).startsWith("java.lang.UnsupportedOperationException");
  }
View Full Code Here

    MvcResult result = ControllerUtil.performRouterRequest(mockMvc, edRequest);
    List<ExtDirectResponse> responses = ControllerUtil.readDirectResponses(result
        .getResponse().getContentAsByteArray());

    assertThat(responses).hasSize(1);
    ExtDirectResponse resp = responses.get(0);
    assertThat(resp.getAction()).isEqualTo("remoteProviderSimple");
    assertThat(resp.getMethod()).isEqualTo("method11");
    assertThat(resp.getType()).isEqualTo("exception");
    assertThat(resp.getTid()).isEqualTo(3);
    assertThat(resp.getMessage()).isEqualTo("Panic!!!");
    assertThat(resp.getResult()).isNull();
    assertThat(resp.getWhere()).startsWith("java.lang.NullPointerException");

  }
View Full Code Here

    mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
  }

  @Test
  public void testDefault() throws Exception {
    ExtDirectResponse resp = runTest(new Configuration());
    assertThat(resp.getMessage()).isEqualTo("Server Error");
    assertThat(resp.getWhere()).isNull();
  }
View Full Code Here

  @Test
  public void testDefaultExceptionMessage() throws Exception {
    Configuration configuration = new Configuration();
    configuration.setDefaultExceptionMessage("an error occured");
    ExtDirectResponse resp = runTest(configuration);
    assertThat(resp.getMessage()).isEqualTo("an error occured");
    assertThat(resp.getWhere()).isNull();
  }
View Full Code Here

    MvcResult result = ControllerUtil.performRouterRequest(mockMvc, sb.toString());
    List<ExtDirectResponse> responses = ControllerUtil.readDirectResponses(result
        .getResponse().getContentAsByteArray());

    assertThat(responses).hasSize(6);
    ExtDirectResponse resp = responses.get(0);
    assertThat(resp.getAction()).isEqualTo("remoteProvider");
    assertThat(resp.getMethod()).isEqualTo("method1");
    assertThat(resp.getType()).isEqualTo("exception");
    assertThat(resp.getTid()).isEqualTo(1);
    assertThat(resp.getResult()).isNull();
    assertThat(resp.getMessage()).isEqualTo("Server Error");
    assertThat(resp.getWhere()).isNull();
    checkMethodNotFoundResponse(responses.get(1));
    checkNoParametersResponse(responses.get(2), 3);

    checkFormLoadResult(responses.get(3), 1.1, 4);
    checkFormLoadResult(responses.get(4), 2.2, 5);
View Full Code Here

TOP

Related Classes of ch.ralscha.extdirectspring.bean.ExtDirectResponse

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.