Package org.springframework.test.web.servlet

Examples of org.springframework.test.web.servlet.MvcResult


    }

    @Test
    public void shouldGetPageWithPasswordFormatError() throws Exception {
        // when
        MvcResult mvcResult = mockMvc.perform(
                post("/updatePassword")
                        .secure(true)
                        .session(session)
                        .contentType(MediaType.APPLICATION_FORM_URLENCODED)
                        .param("email", expectedUser.getEmail())
                        .param("oneTimeToken", expectedUser.getOneTimeToken())
                        .param("password", "password")
                        .param("passwordConfirm", "password")
                        .param((csrfToken != null ? csrfToken.getParameterName() : "_csrf"), (csrfToken != null ? csrfToken.getToken() : ""))
        )

                // then
                .andExpect(status().isOk())
                .andExpect(content().contentType("text/html;charset=UTF-8"))
                .andReturn();

        UpdatePasswordPage updatePasswordPage = new UpdatePasswordPage(mvcResult.getResponse().getContentAsString());
        updatePasswordPage.hasErrors("Please provide a password of 8 or more characters with at least 1 digit and 1 letter");
    }
View Full Code Here


    }

    @Test
    public void shouldGetPageWithPasswordMatchingError() throws Exception {
        // when
        MvcResult mvcResult = mockMvc.perform(
                post("/updatePassword")
                        .secure(true)
                        .session(session)
                        .contentType(MediaType.APPLICATION_FORM_URLENCODED)
                        .param("email", expectedUser.getEmail())
                        .param("oneTimeToken", expectedUser.getOneTimeToken())
                        .param("password", "NewPassword123")
                        .param("passwordConfirm", "Password123")
                        .param((csrfToken != null ? csrfToken.getParameterName() : "_csrf"), (csrfToken != null ? csrfToken.getToken() : ""))
        )

                // then
                .andExpect(status().isOk())
                .andExpect(content().contentType("text/html;charset=UTF-8"))
                .andReturn();

        UpdatePasswordPage updatePasswordPage = new UpdatePasswordPage(mvcResult.getResponse().getContentAsString());
        updatePasswordPage.hasErrors("The second password field does not match the first password field");
    }
View Full Code Here

public class LoginPageControllerIntegrationTest extends BaseIntegrationTest {

    @Test
    public void testShouldReturnLoginPageForGetRequest() throws Exception {
        // when
        MvcResult mvcResult = mockMvc.perform(
                get("/login")
                        .secure(true)
                        .session(session)
                        .accept(MediaType.TEXT_HTML)
                        .param((csrfToken != null ? csrfToken.getParameterName() : "_csrf"), (csrfToken != null ? csrfToken.getToken() : ""))
        )
                // then
                .andExpect(status().isOk())
                .andExpect(content().contentType("text/html;charset=UTF-8"))
                .andReturn();

        LoginPage loginPage = new LoginPage(mvcResult.getResponse().getContentAsString());
        loginPage.shouldHaveCorrectFields();
    }
View Full Code Here

    parameters.put("extTID", "11");
    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("Server Error");
    assertThat(edsResponse.getWhere()).isNull();
View Full Code Here

    Map<String, String> parameters = new LinkedHashMap<String, String>();
    parameters.put("extTID", "12");
    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(
View Full Code Here

    parameters.put("age", "20");
    parameters.put("admin", "true");
    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();
View Full Code Here

    request.param("salary", "12.3");
    request.param("result", "theResult");

    request.file("fileUpload", "the content of the file".getBytes());

    MvcResult resultMvc = mockMvc.perform(request).andExpect(status().isOk())
        .andExpect(content().contentType("text/html;charset=UTF-8"))
        .andExpect(content().encoding("UTF-8")).andReturn();

    String response = resultMvc.getResponse().getContentAsString();
    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));
View Full Code Here

  @Test
  public void testExceptionInMapping() throws Exception {

    String edRequest = ControllerUtil.createEdsRequest("remoteProviderSimple",
        "method4b", 2, new Object[] { 3, "xxx", "string.param" });
    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");
View Full Code Here

  public void testBeanOrMethodNotFound() throws Exception {

    String edRequest = ControllerUtil.createEdsRequest("remoteProviderSimple2",
        "method4", 2, new Object[] { 3, 2.5, "string.param" });

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

  @Test
  public void testExceptionInMappingWithNullValue() throws Exception {
    String edRequest = ControllerUtil.createEdsRequest("remoteProviderSimple",
        "method11b", 3, null);

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

TOP

Related Classes of org.springframework.test.web.servlet.MvcResult

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.