List of usage examples for org.springframework.http HttpMethod DELETE
HttpMethod DELETE
To view the source code for org.springframework.http HttpMethod DELETE.
Click Source Link
From source file:com.appglu.impl.ApiHeadersTest.java
@Test public void defaultAndAuthHeadersArePresent() { mockServer.expect(requestTo("http://localhost/appglu/v1/tables/user/2")) .andExpect(header("ApiVersion", "2.0")).andExpect(header("AppgluVersion", "1.0")) .andExpect(header("Authorization", "Basic YXBwbGljYXRpb25LZXk6YXBwbGljYXRpb25TZWNyZXQ=")) .andExpect(method(HttpMethod.DELETE)).andRespond(withSuccess().headers(responseHeaders)); crudOperations.delete("user", 2); mockServer.verify();/* ww w. j av a 2 s.c o m*/ }
From source file:com.salatigacode.dao.ProductControllerTests.java
@Test public void testDelete() { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<Object> entity = new HttpEntity<>(headers); ResponseEntity<String> responseEntity = restTemplate.exchange(BASE_URL + "abc123", HttpMethod.DELETE, entity, String.class); Assert.assertEquals(HttpStatus.OK, responseEntity.getStatusCode().OK); }
From source file:cz.muni.fi.mushroomhunter.restclient.MushroomDeleteSwingWorker.java
@Override protected Integer doInBackground() throws Exception { 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.add("Authorization", "Basic " + base64Creds); HttpEntity<String> request = new HttpEntity<>(headers); restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory() { @Override//from www. j a va 2s .com protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) { if (HttpMethod.DELETE == httpMethod) { return new HttpEntityEnclosingDeleteRequest(uri); } return super.createHttpUriRequest(httpMethod, uri); } }); restTemplate.exchange( RestClient.SERVER_URL + "pa165/rest/mushroom/" + RestClient.getMushroomIDs().get(selectedRow), HttpMethod.DELETE, request, MushroomDto.class); RestClient.getMushroomIDs().remove(selectedRow); return selectedRow; }
From source file:cz.muni.fi.mushroomhunter.restclient.LocationDeleteSwingWorker.java
@Override protected Integer doInBackground() throws Exception { int selectedRow = restClient.getTblLocation().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.add("Authorization", "Basic " + base64Creds); HttpEntity<String> request = new HttpEntity<>(headers); restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory() { @Override// w ww.j av a 2 s . c o m protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) { if (HttpMethod.DELETE == httpMethod) { return new HttpEntityEnclosingDeleteRequest(uri); } return super.createHttpUriRequest(httpMethod, uri); } }); restTemplate.exchange( RestClient.SERVER_URL + "pa165/rest/location/" + RestClient.getLocationIDs().get(selectedRow), HttpMethod.DELETE, request, LocationDto.class); RestClient.getLocationIDs().remove(selectedRow); return selectedRow; }
From source file:com.appglu.impl.ApiExceptionsTest.java
@Test public void incompatibleClientVersion() { mockServer.expect(requestTo("http://localhost/appglu/v1/tables/user/2")) .andExpect(method(HttpMethod.DELETE)).andRespond(withBadRequest() .body(compactedJson("data/error_incompatible_client_version")).headers(responseHeaders)); try {// www. j ava2s . c o m crudOperations.delete("user", 2); Assert.fail("Should had caused a exception"); } catch (AppGluHttpIncompatibleClientVersionException e) { Error error = e.getError(); Assert.assertEquals(ErrorCode.INCOMPATIBLE_CLIENT_VERSION, error.getCode()); Assert.assertEquals( "Your client version is incompatible with the actual version. Please update it before making any new API call.", error.getMessage()); Assert.assertEquals("http://www.updateyourversion.com", error.getDetail()); } mockServer.verify(); }
From source file:org.openbaton.nfvo.vnfm_reg.impl.sender.RestVnfmSender.java
private void delete(String path, String url) { HttpEntity<String> requestEntity = new HttpEntity<>("", headers); ResponseEntity<String> responseEntity = rest.exchange(url + path, HttpMethod.DELETE, requestEntity, String.class); this.setStatus(responseEntity.getStatusCode()); }
From source file:org.zalando.github.spring.UsersTemplate.java
@Override public void deleteEmails(List<String> emails) { RequestEntity<List<String>> reqEntity = RequestEntity.method(HttpMethod.DELETE, buildUri(USER_EMAILS_PATH)) .contentType(MediaType.APPLICATION_JSON).body(emails); getRestOperations().exchange(reqEntity, Void.class); }
From source file:com.walmart.gatling.AbstractRestIntTest.java
protected void delete(String url, HttpStatus status) { ResponseEntity<Void> response = template.exchange(url, HttpMethod.DELETE, null, Void.class); HttpStatus code = response.getStatusCode(); assertEquals(status, code);//from w ww.ja va 2s.co m }
From source file:org.zalando.github.spring.UsersTemplateTest.java
@Test public void deleteEmails() throws Exception { mockServer.expect(requestTo("https://api.github.com/user/emails")).andExpect(method(HttpMethod.DELETE)) // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN")) .andRespond(MockRestResponseCreators.withNoContent()); usersTemplate.deleteEmails("octocat@github.com", "support@github.com"); mockServer.verify();//from ww w . ja v a 2 s. c o m }
From source file:com.logaritex.hadoop.configuration.manager.SimpleHttpService.java
@Override public <R> R delete(String url, Object request, Class<R> responseType, Object... uriVariables) { R response = restTemplate.exchange(baseUrl + url, HttpMethod.DELETE, new HttpEntity<Object>(request, httpHeaders), responseType, uriVariables).getBody(); return response; }