Package org.springframework.boot.test

Examples of org.springframework.boot.test.TestRestTemplate$CustomHttpComponentsClientHttpRequestFactory


    Map<String, String> form = new LinkedHashMap<String, String>();
    form.put("client_id", "my-trusted-client");
    form.put("redirect_uri", "http://foo.com");
    form.put("response_type", "token");
    form.put("scope", "read");
    ResponseEntity<Void> response = new TestRestTemplate("user", "password")
        .getForEntity(
            http.getUrl("/oauth/authorize?client_id={client_id}&redirect_uri={redirect_uri}&response_type={response_type}&scope={scope}"),
            Void.class, form);
    assertEquals(HttpStatus.FOUND, response.getStatusCode());
    assertTrue(response.getHeaders().getLocation().toString().contains("access_token"));
View Full Code Here


  public void testCheckToken() throws Exception {
    OAuth2AccessToken token = context.getAccessToken();
    HttpHeaders headers = new HttpHeaders();
    headers.set("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> response = new TestRestTemplate("my-client-with-secret", "secret").exchange(http
        .getUrl(checkTokenPath()), HttpMethod.POST,
        new HttpEntity<String>("token=" + token.getValue(), headers), Map.class);
    assertEquals(HttpStatus.OK, response.getStatusCode());
    @SuppressWarnings("unchecked")
    Map<String, Object> map = (Map<String, Object>) response.getBody();
View Full Code Here

  }

  @Test
  public void testTokenKey() throws Exception {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> response = new TestRestTemplate("my-client-with-secret", "secret").getForEntity(
        http.getUrl(tokenKeyPath()), Map.class);
    // This app has no token key.
    assertEquals(HttpStatus.FORBIDDEN, response.getStatusCode());
  }
View Full Code Here

public class ServletPathClientCredentialsProviderTests extends AbstractClientCredentialsProviderTests {
 
  @Test
  public void testTokenKey() throws Exception {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> response = new TestRestTemplate("my-client-with-secret", "secret").getForEntity(
        http.getUrl(tokenKeyPath()), Map.class);
    // This app has no token key.
    assertEquals(HttpStatus.FORBIDDEN, response.getStatusCode());
  }
View Full Code Here

  public RestOperations getRestTemplate() {
    return client;
  }

  public RestOperations createRestTemplate() {
    RestTemplate client = new TestRestTemplate();
    return client;
  }
View Full Code Here

  public void testCheckToken() throws Exception {
    OAuth2AccessToken token = context.getAccessToken();
    HttpHeaders headers = new HttpHeaders();
    headers.set("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> response = new TestRestTemplate("my-client-with-secret", "secret").exchange(http
        .getUrl(checkTokenPath()), HttpMethod.POST, new HttpEntity<String>("token=" + token.getValue(),
        headers), Map.class);
    assertEquals(HttpStatus.OK, response.getStatusCode());
    @SuppressWarnings("unchecked")
    Map<String, Object> map = (Map<String, Object>) response.getBody();
View Full Code Here

  public void testCheckToken() throws Exception {
    OAuth2AccessToken token = context.getAccessToken();
    HttpHeaders headers = new HttpHeaders();
    headers.set("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> response = new TestRestTemplate("my-client-with-secret", "secret").exchange(http
        .getUrl(checkTokenPath()), HttpMethod.POST,
        new HttpEntity<String>("token=" + token.getValue(), headers), Map.class);
    assertEquals(HttpStatus.OK, response.getStatusCode());
    @SuppressWarnings("unchecked")
    Map<String, Object> map = (Map<String, Object>) response.getBody();
View Full Code Here

  }

  @Test
  public void testTokenKey() throws Exception {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> response = new TestRestTemplate("my-client-with-secret", "secret").getForEntity(
        http.getUrl(tokenKeyPath()), Map.class);
    assertEquals(HttpStatus.OK, response.getStatusCode());
    @SuppressWarnings("unchecked")
    Map<String, Object> map = (Map<String, Object>) response.getBody();
    assertTrue(map.containsKey("alg"));
View Full Code Here

  private RestTemplate restTemplate;
  private String resourceUrl;

  @Before
  public void setup() {
    restTemplate = new TestRestTemplate();
    resourceUrl = "http://localhost:" + port + "/task";
  }
View Full Code Here

  private int port;

  @Test
  public void testHome() throws Exception {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
        "http://localhost:" + port, Map.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    @SuppressWarnings("unchecked")
    Map<String, Object> body = entity.getBody();
    assertEquals("Hello Daniel", body.get("message"));
View Full Code Here

TOP

Related Classes of org.springframework.boot.test.TestRestTemplate$CustomHttpComponentsClientHttpRequestFactory

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.