Package org.springframework.http.client

Examples of org.springframework.http.client.ClientHttpRequestExecution


  private void assertThatInterceptorWritesAuthorizationHeader(OAuth2RequestInterceptor interceptor, final String expected) throws Exception {
    byte[] body = "status=Hello+there".getBytes();
    MockHttpServletRequest request = new MockHttpServletRequest(HttpMethod.POST.name(), "https://api.someprovider.com/status/update");
    request.setContentType(MediaType.APPLICATION_FORM_URLENCODED.toString());
    ClientHttpRequestExecution execution = new ClientHttpRequestExecution() {
      public ClientHttpResponse execute(HttpRequest request, byte[] body) throws IOException {
        String authorizationHeader = request.getHeaders().getFirst("Authorization");
        assertEquals(expected, authorizationHeader);
        assertEquals(MediaType.APPLICATION_FORM_URLENCODED, request.getHeaders().getContentType());
        return null;
View Full Code Here


  private void assertThatInterceptorAddsTokenParameter(OAuth2TokenParameterRequestInterceptor interceptor) throws Exception {
    byte[] body = "status=Hello+there".getBytes();
    MockHttpServletRequest originalRequest = new MockHttpServletRequest(HttpMethod.POST.name(), "/status/update");
    originalRequest.setServerName("api.someprovider.com");
    originalRequest.setContentType(MediaType.APPLICATION_FORM_URLENCODED.toString());
    ClientHttpRequestExecution execution = new ClientHttpRequestExecution() {
      public ClientHttpResponse execute(HttpRequest request, byte[] body) throws IOException {
        assertEquals(MediaType.APPLICATION_FORM_URLENCODED, request.getHeaders().getContentType());
        assertEquals("access_token=SOMETOKEN", request.getURI().getQuery());
        return null;
      }
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest(HttpMethod.POST.name(), "/status/update");
    request.setRemoteHost("api.someprovider.com");
    request.setSecure(true);
    request.setContentType(MediaType.APPLICATION_FORM_URLENCODED.toString());

    ClientHttpRequestExecution execution = new ClientHttpRequestExecution() {
      public ClientHttpResponse execute(HttpRequest request, byte[] body) throws IOException {
        String authorizationHeader = request.getHeaders().getFirst("Authorization");
        Map<String, String> headerParameters = extractHeaderParameters(authorizationHeader);
        // TODO: Figure out how to test this more precisely with a fixed nonce and timestamp (and thus a fixed signature)
        assertEquals("1.0", headerParameters.get("oauth_version"));
View Full Code Here

TOP

Related Classes of org.springframework.http.client.ClientHttpRequestExecution

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.