Example usage for org.springframework.http RequestEntity get

List of usage examples for org.springframework.http RequestEntity get

Introduction

In this page you can find the example usage for org.springframework.http RequestEntity get.

Prototype

public static HeadersBuilder<?> get(URI url) 

Source Link

Document

Create an HTTP GET builder with the given url.

Usage

From source file:org.zalando.stups.oauth2.spring.server.TokenInfoResourceServerTokenServicesTest.java

@Test
public void buildRequest() {

    RequestEntity<Void> entity = DefaultTokenInfoRequestExecutor.buildRequestEntity(URI.create(TOKENINFO_URL),
            "0123456789");

    Assertions.assertThat(entity).isNotNull();

    Assertions.assertThat(entity.getMethod()).isEqualTo(HttpMethod.GET);
    Assertions.assertThat(entity.getUrl()).isEqualTo(URI.create(TOKENINFO_URL));

    Assertions.assertThat(entity.getHeaders()).containsKey(HttpHeaders.AUTHORIZATION);
    List<String> authorizationHeader = entity.getHeaders().get(HttpHeaders.AUTHORIZATION);
    Assertions.assertThat(authorizationHeader).containsExactly("Bearer 0123456789");

    Assertions.assertThat(entity.getHeaders()).containsKey(HttpHeaders.ACCEPT);
    Assertions.assertThat(entity.getHeaders().getAccept()).contains(MediaType.APPLICATION_JSON);
}

From source file:com.github.harti2006.Neo4jServerIT.java

@Test
public void testNeo4jServerIsRunning() throws Exception {
    final RestTemplate restTemplate = new RestTemplate();
    final RequestEntity<Void> request = RequestEntity.get(create(System.getProperty("neo4j-server.url")))
            .accept(APPLICATION_JSON).build();
    final ResponseEntity<String> responseEntity = restTemplate.exchange(request, String.class);

    assertEquals(OK, responseEntity.getStatusCode());
    System.out.println(responseEntity);
}

From source file:com.github.wnameless.spring.papertrail.test.jpa.JpaPaperTrailGetTest.java

@Test
public void testGet() throws Exception {
    long records = repo.count();

    RequestEntity<Void> req = RequestEntity.get(new URI(host + "/get")).header("Authorization", encodedAuth)
            .build();//from   w  w  w  . j  a v a 2  s. c om
    template.exchange(req, String.class);

    assertEquals(records, repo.count());
}

From source file:io.spring.initializr.stub.ClientApplicationTests.java

@Test
public void testCurrentMetadata() {
    RequestEntity<Void> request = RequestEntity.get(createUri("/"))
            .accept(MediaType.valueOf("application/vnd.initializr.v2.1+json")).build();

    ResponseEntity<String> response = this.restTemplate.exchange(request, String.class);
    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
    // other assertions here
}

From source file:io.spring.initializr.service.InitializrServiceSmokeTests.java

@Test
public void metadataCanBeSerialized() throws URISyntaxException, IOException {
    RequestEntity<Void> request = RequestEntity.get(new URI("/"))
            .accept(MediaType.parseMediaType("application/vnd.initializr.v2.1+json")).build();
    ResponseEntity<String> response = this.restTemplate.exchange(request, String.class);
    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
    new ObjectMapper().readTree(response.getBody());
}

From source file:at.ac.tuwien.dsg.cloud.utilities.gateway.registry.UserController.java

@PostConstruct
public void init() {
    RequestEntity<Void> req = RequestEntity.get(URI.create(this.kongUris.getKongConsumersUri())).build();

    try {/*from ww w  .  j  a v a  2  s . c o  m*/
        ResponseEntity<KongUserList> resp = restUtilities.simpleRestExchange(req, KongUserList.class);
        this.kongUsers = resp.getBody();
    } catch (ResourceAccessException ex) {
        this.kongUsers = new KongUserList();
    }
}

From source file:io.spring.initializr.service.InitializrServiceSmokeTests.java

@Test
public void configurationCanBeSerialized() throws URISyntaxException {
    RequestEntity<Void> request = RequestEntity.get(new URI("/metadata/config"))
            .accept(MediaType.APPLICATION_JSON).build();
    ResponseEntity<String> response = this.restTemplate.exchange(request, String.class);
    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
    InitializrMetadata actual = InitializrMetadataBuilder.create()
            .withInitializrMetadata(new ByteArrayResource(response.getBody().getBytes())).build();
    assertThat(actual).isNotNull();/*  w  w  w. j av  a2 s  .  c o m*/
    InitializrMetadata expected = this.metadataProvider.get();
    assertThat(actual.getDependencies().getAll().size()).isEqualTo(expected.getDependencies().getAll().size());
    assertThat(actual.getConfiguration().getEnv().getBoms().size())
            .isEqualTo(expected.getConfiguration().getEnv().getBoms().size());
}

From source file:com.test.RestApplicationTests.java

@Test
public void wordsSSE() throws Exception {
    assertThat(rest.exchange(RequestEntity.get(new URI("/words")).accept(EVENT_STREAM).build(), String.class)
            .getBody()).isEqualTo(sse("foo", "bar"));
}

From source file:com.test.RestApplicationTests.java

@Test
public void wordsJson() throws Exception {
    assertThat(rest.exchange(RequestEntity.get(new URI("/words")).accept(MediaType.APPLICATION_JSON).build(),
            String.class).getBody()).isEqualTo("[\"foo\",\"bar\"]");
}

From source file:org.zalando.github.spring.UsersTemplate.java

@Override
public List<PubKey> listPublicKeys(String username) {
    Map<String, Object> uriVariabels = new HashMap<String, Object>(0);
    uriVariabels.put("username", username);

    RequestEntity<Void> reqEntity = RequestEntity.get(buildUri("/users/{username}/keys", uriVariabels)).build();

    return getRestOperations().exchange(reqEntity, pubKeyListTypeRef).getBody();
}