Examples of andExpect()


Examples of org.springframework.test.web.client.ResponseActions.andExpect()

    MockRestServiceServer mockServer = MockRestServiceServer.createServer(oauthTemplate.getRestTemplate());
    ResponseActions responseActions = mockServer.expect(requestTo(ACCESS_TOKEN_URL))
        .andExpect(method(POST))
        .andExpect(content().string(expectedClientParams + "code=code&redirect_uri=http%3A%2F%2Fwww.someclient.com%2Fcallback&grant_type=authorization_code"));
    if (expectedAuthorizationHeader != null) {
      responseActions.andExpect(header("Authorization", expectedAuthorizationHeader));
    }
    responseActions.andRespond(withSuccess(new ClassPathResource(responseFile, getClass()), MediaType.APPLICATION_JSON));
    return oauthTemplate.exchangeForAccess("code", "http://www.someclient.com/callback", null);
  }
 
View Full Code Here

Examples of org.springframework.test.web.client.ResponseActions.andExpect()

    MockRestServiceServer mockServer = MockRestServiceServer.createServer(oauthTemplate.getRestTemplate());
    ResponseActions responseActions = mockServer.expect(requestTo(ACCESS_TOKEN_URL))
        .andExpect(method(POST))
        .andExpect(content().string(expectedClientParams + "username=habuma&password=letmein01&grant_type=password&scope=read%2Cwrite"));
    if (expectedAuthorizationHeader != null) {
      responseActions.andExpect(header("Authorization", expectedAuthorizationHeader));
    }
    responseActions.andRespond(withSuccess(new ClassPathResource(responseFile, getClass()), MediaType.APPLICATION_JSON));
    OAuth2Parameters parameters = new OAuth2Parameters();
    parameters.setScope("read,write");
    return oauthTemplate.exchangeCredentialsForAccess("habuma", "letmein01", parameters);
View Full Code Here

Examples of org.springframework.test.web.client.ResponseActions.andExpect()

    MockRestServiceServer mockServer = MockRestServiceServer.createServer(oauthTemplate.getRestTemplate());
    ResponseActions responseActions = mockServer.expect(requestTo(ACCESS_TOKEN_URL))
        .andExpect(method(POST))
        .andExpect(content().string(expectedClientParams + "grant_type=client_credentials&scope=read%2Cwrite"));
    if (expectedAuthorizationHeader != null) {
      responseActions.andExpect(header("Authorization", expectedAuthorizationHeader));
    }
    responseActions.andRespond(withSuccess(new ClassPathResource(responseFile, getClass()), MediaType.APPLICATION_JSON));
    OAuth2Parameters parameters = new OAuth2Parameters();
    parameters.setScope("read,write");
    return oauthTemplate.authenticateClient("read,write");
View Full Code Here

Examples of org.springframework.test.web.client.ResponseActions.andExpect()

    MockRestServiceServer mockServer = MockRestServiceServer.createServer(oauthTemplate.getRestTemplate());
    ResponseActions responseActions = mockServer.expect(requestTo(ACCESS_TOKEN_URL))
        .andExpect(method(POST))
        .andExpect(content().string(expectedClientParams + "refresh_token=r3fr35h_t0k3n&grant_type=refresh_token"));
    if (expectedAuthorizationHeader != null) {
      responseActions.andExpect(header("Authorization", expectedAuthorizationHeader));
    }
    responseActions.andRespond(withSuccess(new ClassPathResource(responseFile, getClass()), MediaType.APPLICATION_JSON));
    return oauthTemplate.refreshAccess("r3fr35h_t0k3n", null);
  }
View Full Code Here

Examples of org.springframework.test.web.servlet.ResultActions.andExpect()

   
    @Test
    public void getVisitsXml() throws Exception {
        ResultActions actions = this.mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML));
        actions.andDo(print()); // action is logged into the console
        actions.andExpect(status().isOk());
        actions.andExpect(content().contentType("application/xml"));
        actions.andExpect(xpath("/vets/vetList[id=1]/firstName").string(containsString("James")));

    }
}
View Full Code Here

Examples of org.springframework.test.web.servlet.ResultActions.andExpect()

    @Test
    public void getVisitsXml() throws Exception {
        ResultActions actions = this.mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML));
        actions.andDo(print()); // action is logged into the console
        actions.andExpect(status().isOk());
        actions.andExpect(content().contentType("application/xml"));
        actions.andExpect(xpath("/vets/vetList[id=1]/firstName").string(containsString("James")));

    }
}
View Full Code Here

Examples of org.springframework.test.web.servlet.ResultActions.andExpect()

    public void getVisitsXml() throws Exception {
        ResultActions actions = this.mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML));
        actions.andDo(print()); // action is logged into the console
        actions.andExpect(status().isOk());
        actions.andExpect(content().contentType("application/xml"));
        actions.andExpect(xpath("/vets/vetList[id=1]/firstName").string(containsString("James")));

    }
}
View Full Code Here

Examples of org.springframework.test.web.servlet.ResultActions.andExpect()

        // WHEN - circuit viewed
        ResultActions result = mockMvc.perform(get("/circuit/{id}", id));

        // THEN - circuit should be in the model
        result.andExpect(status().isOk()).andExpect(model().attribute("receivedId", is(id)));

    }

    @Test
    public void voidTestEncodingInTestCase() throws Exception {
View Full Code Here

Examples of org.springframework.test.web.servlet.ResultActions.andExpect()

        // WHEN - circuit viewed
        ResultActions result = mockMvc.perform(get("/circuit/{id}", id));

        // THEN - circuit should be in the model
        result.andExpect(status().isOk()).andExpect(model().attribute("receivedId", is("a/b")));

    }

}
View Full Code Here

Examples of org.springframework.test.web.servlet.ResultActions.andExpect()

  public void exposesRootResource() throws Exception {

    ResultActions actions = mvc.perform(get("/").accept(DEFAULT_MEDIA_TYPE)).andExpect(status().isOk());

    for (String rel : expectedRootLinkRels()) {
      actions.andExpect(hasLinkWithRel(rel));
    }
  }

  /**
   * @see DATAREST-113
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.