Examples of exchange()


Examples of org.springframework.web.client.RestTemplate.exchange()

        final HttpHeaders headers = new HttpHeadersBuilder().acceptJSON().acceptUTF8().build();
        final HttpEntity<String> entity = new HttpEntity<String>( headers );

        try
        {
            final ResponseEntity<String> response = template.exchange( "http://localhost:8080/echo/time", HttpMethod.GET, entity, String.class );
            assertThat( response, is( notNullValue() ) );
            assertThat( response.getStatusCode(), is( notNullValue() ) );
            assertThat( response.getStatusCode(), is( equalTo( HttpStatus.OK ) ) );
            assertThat( response.hasBody(), is( equalTo( true ) ) );
            System.out.println( response.getBody() );
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.exchange()

        final HttpHeaders headers = new HttpHeadersBuilder().acceptJSON().acceptUTF8().build();
        final HttpEntity<String> entity = new HttpEntity<String>( headers );

        try
        {
            final ResponseEntity<Object> response = template.exchange( "http://localhost:8080/echo/person", HttpMethod.GET, entity, Object.class );
            System.out.println( response.getBody() );
        }
        catch( HttpStatusCodeException e )
        {
            System.err.println( "Status Code: " + e.getStatusCode() );
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.exchange()

        final RestTemplate restTemplate = new RestTemplate(requestFactory);

        // credentialsProvider.setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user1", "user1Pass"));

        final String uri = "http://localhost:8080/spring-security-rest-digest-auth/api/foos/1";
        final ResponseEntity<Foo> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, null, Foo.class);

        System.out.println(responseEntity.getStatusCode());
    }

    @Test
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.exchange()

        final RestTemplate restTemplate = new RestTemplate(requestFactory);

        // credentialsProvider.setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user1", "user1Pass"));

        final String uri = "http://localhost:8080/spring-security-rest-digest-auth/api/foos/1";
        final ResponseEntity<Foo> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, null, Foo.class);

        System.out.println(responseEntity.getStatusCode());
    }

    // UTIL
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.exchange()

        final HttpHeaders headers = new HttpHeaders();
        headers.setAccept(Arrays.asList(MediaType.APPLICATION_XML));
        final HttpEntity<String> entity = new HttpEntity<String>(headers);

        final ResponseEntity<Foo> response = restTemplate.exchange(URI, HttpMethod.GET, entity, Foo.class, "1");
        final Foo resource = response.getBody();

        assertThat(resource, notNullValue());
    }
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.exchange()

        final HttpHeaders headers = new HttpHeaders();
        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
        final HttpEntity<String> entity = new HttpEntity<String>(headers);

        final ResponseEntity<Foo> response = restTemplate.exchange(URI, HttpMethod.GET, entity, Foo.class, "1");
        final Foo resource = response.getBody();

        assertThat(resource, notNullValue());
    }
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.exchange()

        final HttpHeaders headers = new HttpHeaders();
        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
        headers.setContentType((MediaType.APPLICATION_XML));
        final HttpEntity<Foo> entity = new HttpEntity<Foo>(resource, headers);

        final ResponseEntity<Foo> response = restTemplate.exchange(URI, HttpMethod.PUT, entity, Foo.class, resource.getId());
        final Foo fooResponse = response.getBody();

        Assert.assertEquals(resource.getId(), fooResponse.getId());
    }
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.exchange()

      HttpEntity<String> request = new HttpEntity<String>( headers );

      String url = uri.build().toUriString();
      LOG.debug( "calling oauth2 token endpoint {}", url );

      ResponseEntity<Map> response = template.exchange( url, HttpMethod.GET, request, Map.class );
      body = response.getBody();

      if ( response.getStatusCode() != HttpStatus.OK ) {
        throw new RuntimeException(
            "Fetching OAuth2 token failed with status code: " + response.getStatusCode() );
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.