Example usage for org.springframework.http HttpMethod GET

List of usage examples for org.springframework.http HttpMethod GET

Introduction

In this page you can find the example usage for org.springframework.http HttpMethod GET.

Prototype

HttpMethod GET

To view the source code for org.springframework.http HttpMethod GET.

Click Source Link

Usage

From source file:demo.RestServiceIntegrationTests.java

@Test
public void findAll() {
    TestRestTemplate template = new TestRestTemplate();
    ResponseEntity<Resource<List<ServiceLocation>>> result = template.exchange(
            "http://localhost:" + this.port + "/serviceLocations", HttpMethod.GET,
            new HttpEntity<Void>((Void) null),
            new ParameterizedTypeReference<Resource<List<ServiceLocation>>>() {
            });//  w  ww.j  a v  a2 s.  com
    assertEquals(HttpStatus.OK, result.getStatusCode());
}

From source file:com.tce.oauth2.spring.client.services.TodoService.java

public List<Todo> findByUsername(String accessToken, String username) {
    HttpHeaders headers = new HttpHeaders();
    headers.add("Authorization", "Bearer " + accessToken);
    HttpEntity<String> entity = new HttpEntity<String>(headers);
    ResponseEntity<Todo[]> response = restTemplate.exchange(
            OAUTH_RESOURCE_SERVER_URL + "/rest/todos/" + username, HttpMethod.GET, entity, Todo[].class);
    Todo[] todos = response.getBody();/*from   w  w  w.jav  a 2  s .c om*/

    return Arrays.asList(todos);
}

From source file:com.joseph.california.test.restapi.ClubRestControllerTest.java

public void testreadClubByNameName() {
    String clubName = "Chess";
    HttpEntity<?> requestEntity = getHttpEntity();
    ResponseEntity<Club> responseEntity = restTemplate.exchange(URL + "api/club/name/" + clubName,
            HttpMethod.GET, requestEntity, Club.class);
    Club club = responseEntity.getBody();

    Assert.assertNotNull(club);/*w w w.  j a v  a 2  s.c o m*/

}

From source file:com.onedrive.api.resource.support.AsyncOperationStatus.java

public AsyncOperationStatus status() {
    Assert.notNull(monitorUrl, "[monitorUrl] is required");
    URI uri = null;/*from  w w  w  . j a va 2 s.  co m*/
    try {
        uri = new URI(monitorUrl);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    ResponseEntity<AsyncOperationStatus> response = getOneDrive().getRestTemplate().exchange(uri,
            HttpMethod.GET, null, AsyncOperationStatus.class);
    AsyncOperationStatus monitor = response.getBody();
    if (monitor == null) {
        monitor = new AsyncOperationStatus(getOneDrive());
    }
    monitor.setMonitorUrl(monitorUrl);
    return monitor;
}

From source file:edu.wisc.cypress.dao.advrpt.RestAdvisorReportDao.java

@Override
public void getAdvisorReport(String pvi, String docId, ProxyResponse proxyResponse) {
    final HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.set("PVI", pvi);

    this.restOperations.proxyRequest(proxyResponse, this.statementUrl, HttpMethod.GET, httpHeaders, docId);
}

From source file:edu.wisc.cypress.dao.ernstmt.RestEarningStatementDao.java

@Override
public void getEarningStatement(String emplid, String docId, ProxyResponse proxyResponse) {
    final HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.set("HRID", emplid);
    this.restOperations.proxyRequest(proxyResponse, this.statementUrl, HttpMethod.GET, httpHeaders, docId);
}

From source file:org.energyos.espi.thirdparty.repository.impl.ResourceRESTRepositoryImplTests.java

@SuppressWarnings("unchecked")
@Test/*  ww w  .j  a v a2s. c om*/
public void get_usesAccessToken() throws JAXBException {
    repository.get(authorization, uri);

    @SuppressWarnings("rawtypes")
    ArgumentCaptor<HttpEntity> argumentCaptor = ArgumentCaptor.forClass(HttpEntity.class);
    verify(template).exchange(anyString(), eq(HttpMethod.GET), argumentCaptor.capture(), any(Class.class));
    assertEquals("Bearer token", argumentCaptor.getValue().getHeaders().get("Authorization").get(0));
}

From source file:com.wavemaker.commons.web.filter.EtagFilter.java

@Override
protected boolean isEligibleForEtag(HttpServletRequest request, HttpServletResponse response,
        int responseStatusCode, InputStream inputStream) {
    return (responseStatusCode >= 200 && responseStatusCode < 300)
            && HttpMethod.GET.name().equals(request.getMethod());
}

From source file:NNIOEngine.java

@Override
public ResponseEntity<String> submit(JCurlRequestOptions requestOptions) throws Exception {
    int ioWorkerCount = Runtime.getRuntime().availableProcessors() * 2;
    NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup(ioWorkerCount);

    try {/*w w  w  .j a v  a 2s  . c om*/
        final Netty4ClientHttpRequestFactory netty4ClientHttpRequestFactory = new Netty4ClientHttpRequestFactory(
                eventLoopGroup);
        netty4ClientHttpRequestFactory.setConnectTimeout(2000);
        netty4ClientHttpRequestFactory.setReadTimeout(2000);
        /*
                    SslContext sslContext = SslContextBuilder
        .forClient()
        .sslProvider(SslProvider.JDK)
        .build()
                    ;
        */
        if (requestOptions.getUrl().toLowerCase().startsWith("https://")) {
            SslContext sslContext = new DefaultClientSslContext();
            netty4ClientHttpRequestFactory.setSslContext(sslContext);
        }
        netty4ClientHttpRequestFactory.afterPropertiesSet();

        ResponseEntity<String> stringResponseEntity = null;
        for (int i = 0; i < requestOptions.getCount(); i++) {
            final HttpHeaders headers = new HttpHeaders();
            for (Map.Entry<String, String> e : requestOptions.getHeaderMap().entrySet()) {
                headers.put(e.getKey(), Collections.singletonList(e.getValue()));
            }

            final HttpEntity<Void> requestEntity = new HttpEntity<>(headers);

            AsyncRestTemplate template = new AsyncRestTemplate(netty4ClientHttpRequestFactory);
            final ListenableFuture<ResponseEntity<String>> exchange = template.exchange(requestOptions.getUrl(),
                    HttpMethod.GET, requestEntity, String.class);
            stringResponseEntity = exchange.get();
            System.out.println(stringResponseEntity.getBody());
        }
        return stringResponseEntity;
    } finally {
        eventLoopGroup.shutdownGracefully(100, 500, TimeUnit.MILLISECONDS);
    }
}

From source file:edu.wisc.cypress.dao.sabstmt.RestSabbaticalStatementDao.java

@Override
public void getSabbaticalReport(String emplid, String docId, ProxyResponse proxyResponse) {
    final HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.set("HRID", emplid);
    this.restOperations.proxyRequest(proxyResponse, this.statementUrl, HttpMethod.GET, httpHeaders, docId);
}