List of usage examples for org.springframework.http HttpMethod GET
HttpMethod GET
To view the source code for org.springframework.http HttpMethod GET.
Click Source Link
From source file:top.zhacker.ms.reactor.spring.function.Server.java
public RouterFunction<ServerResponse> routingFunction() { PersonRepository repository = new DummyPersonRepository(); PersonHandler handler = new PersonHandler(repository); return nest(path("/person"), nest(accept(APPLICATION_JSON), route(GET("/{id}"), handler::getPerson).andRoute(method(HttpMethod.GET), handler::listPeople)).andRoute(POST("/").and(contentType(APPLICATION_JSON)), handler::createPerson)); }
From source file:io.pivotal.dockerhub.client.DockerHubTemplate.java
@Override public List<Tag> getTags(String repositoryName) { return restTemplate.exchange("{baseUrl}/repositories/{name}/tags", HttpMethod.GET, null, TAGS_LIST_TYPE, baseUrl, repositoryName).getBody(); }
From source file:com.interop.webapp.WebAppTests.java
@Test public void testHome() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port, HttpMethod.GET, new HttpEntity<Void>(headers), String.class); assertEquals(HttpStatus.FOUND, entity.getStatusCode()); assertTrue("Wrong location:\n" + entity.getHeaders(), entity.getHeaders().getLocation().toString().endsWith(port + "/login")); }
From source file:HCNIOEngine.java
@Override public ResponseEntity<String> submit(JCurlRequestOptions requestOptions) throws Exception { ResponseEntity<String> stringResponseEntity = null; try (CloseableHttpAsyncClient hc = createCloseableHttpAsyncClient()) { 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())); }/* w w w.ja v a 2s . c o m*/ final HttpEntity<Void> requestEntity = new HttpEntity<>(headers); AsyncRestTemplate template = new AsyncRestTemplate( new HttpComponentsAsyncClientHttpRequestFactory(hc)); final ListenableFuture<ResponseEntity<String>> exchange = template.exchange(requestOptions.getUrl(), HttpMethod.GET, requestEntity, String.class); stringResponseEntity = exchange.get(); System.out.println(stringResponseEntity.getBody()); } return stringResponseEntity; } }
From source file:cz.muni.fi.mushroomhunter.restclient.MushroomUpdateSwingWorker.java
@Override protected Integer doInBackground() throws Exception { DefaultTableModel model = (DefaultTableModel) restClient.getTblMushroom().getModel(); int selectedRow = restClient.getTblMushroom().getSelectedRow(); RestTemplate restTemplate = new RestTemplate(); String plainCreds = RestClient.USER_NAME + ":" + RestClient.PASSWORD; byte[] plainCredsBytes = plainCreds.getBytes(); byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes); String base64Creds = new String(base64CredsBytes); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); List<MediaType> mediaTypeList = new ArrayList<>(); mediaTypeList.add(MediaType.ALL);// ww w. j a v a 2s.c o m headers.setAccept(mediaTypeList); headers.add("Authorization", "Basic " + base64Creds); HttpEntity request = new HttpEntity<>(headers); ResponseEntity<MushroomDto> responseEntity = restTemplate.exchange( RestClient.SERVER_URL + "pa165/rest/mushroom/" + RestClient.getMushroomIDs().get(selectedRow), HttpMethod.GET, request, MushroomDto.class); MushroomDto mushroomDto = responseEntity.getBody(); mushroomDto.setName(restClient.getTfMushroomName().getText()); SimpleDateFormat formatter = new SimpleDateFormat("dd-MMMM-yyyy", new Locale("en_US")); //to create date object only month is used, day and year are fixed values String dateInString = "01-" + restClient.getComboBoxMushroomStartOfOccurence().getSelectedItem().toString() + "-2000"; mushroomDto.setStartOfOccurence(formatter.parse(dateInString)); //to create date object only month is used, day and year are fixed values dateInString = "01-" + restClient.getComboBoxMushroomEndOfOccurence().getSelectedItem().toString() + "-2000"; mushroomDto.setEndOfOccurence(formatter.parse(dateInString)); ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); String json = ow.writeValueAsString(mushroomDto); request = new HttpEntity(json, headers); restTemplate.exchange(RestClient.SERVER_URL + "pa165/rest/mushroom", HttpMethod.PUT, request, MushroomDto.class); return selectedRow; }
From source file:com.pepaproch.gtswsdlclient.AddresCheckImplTest.java
/** * Test of checkAddres method, of class AddresCheckImpl. *//*from ww w. j av a 2 s .c o m*/ @Test public void testCheckAddres() { AddressQuery addrQuery = new AddressQuery(); RestTemplate restTemplate = getRestTemplate(); RestContext restContext = Mockito.mock(RestContext.class); when(restContext.getRestTemplate()).thenReturn(restTemplate); when(restContext.getBASE_URL()).thenReturn(BASE_URL); AddressResponse expResult = null; mockServer = MockRestServiceServer.createServer(restTemplate); this.mockServer.expect(requestTo(BASE_URL + AddresCheckImpl.ADDR_CHECK_PATH)) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(CHECK_ADDR_RESPONSE_BODY, MediaType.APPLICATION_JSON)); AddresCheckImpl instance = new AddresCheckImpl(restContext); AddressResponse result = instance.checkAddres(addrQuery); Integer expectedTotal = new Integer(3); assertEquals(result.getTotal(), expectedTotal); }
From source file:library.SecurityConfiguration.java
@Override protected void configure(HttpSecurity http) throws Exception { http.httpBasic().and().authorizeRequests().antMatchers(HttpMethod.DELETE, "/user/delete").hasRole("ADMIN") .antMatchers(HttpMethod.DELETE, "/user/passBook").hasRole("ADMIN") .antMatchers(HttpMethod.DELETE, "/books/delete").hasRole("ADMIN") .antMatchers(HttpMethod.GET, "/users/all").hasRole("ADMIN") .antMatchers(HttpMethod.GET, "/users/user/**").hasAnyRole("USER", "ADMIN") .antMatchers(HttpMethod.GET, "/books/user/**").hasAnyRole("USER", "ADMIN") .antMatchers(HttpMethod.GET, "/books/book/**").hasAnyRole("USER", "ADMIN") .antMatchers(HttpMethod.POST, "/books/book/search").hasAnyRole("USER", "ADMIN") .antMatchers(HttpMethod.GET, "/book/status/*").hasAnyRole("USER", "ADMIN") .antMatchers(HttpMethod.GET, "/books/all").hasAnyRole("USER", "ADMIN") .antMatchers(HttpMethod.POST, "/users/user/search").hasRole("ADMIN") .antMatchers(HttpMethod.POST, "/user/takeBook").hasAnyRole("USER", "ADMIN") .antMatchers(HttpMethod.POST, "/books/add").hasRole("ADMIN") .antMatchers(HttpMethod.POST, "/books/update").hasRole("ADMIN").and().csrf().disable(); }
From source file:fi.helsinki.opintoni.server.CoursePageServer.java
public void expectCourseImplementationRequest(String courseImplementationId, String responseFile) { server.expect(requestTo(courseImplementationUrl(courseImplementationId))).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(SampleDataFiles.toText("coursepage/" + responseFile), MediaType.APPLICATION_JSON)); }
From source file:com.acc.test.UserWebServiceTest.java
@Test() public void testGetUserReviews_Success_XML() { final HttpEntity<String> requestEntity = new HttpEntity<String>(getXMLHeaders()); final ResponseEntity<String> response = template.exchange( "http://localhost:9001/rest/v1/users/{userid}/reviews", HttpMethod.GET, requestEntity, String.class, TestConstants.USERNAME);/* www. j a v a 2 s . co m*/ assertEquals("application/xml;charset=UTF-8", response.getHeaders().getContentType().toString()); }
From source file:sample.jetty.SampleJettyApplicationTests.java
@Test public void testCompression() throws Exception { HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("Accept-Encoding", "gzip"); HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders); ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET, requestEntity, byte[].class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody())); try {/*w w w . ja v a2 s . co m*/ // assertThat(StreamUtils.copyToString(inflater, Charset.forName("UTF-8"))).isEqualTo("Hello World"); } finally { inflater.close(); } }