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:io.syndesis.runtime.BaseITCase.java
protected <T> ResponseEntity<T> delete(String url, Class<T> responseClass, String token, HttpStatus expectedStatus) { return http(HttpMethod.DELETE, url, null, responseClass, token, expectedStatus); }
From source file:org.openbaton.common.vnfm_sdk.rest.VnfmRestHelper.java
private void delete(String path) { 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.openbaton.nse.beans.connectivitymanageragent.ConnectivityManagerRequestor.java
public HttpStatus delQueue(String hypervisorName, String qosId, String queueId, String queueNumber) { String url = configuration.getBaseUrl() + "/queue/" + hypervisorName + "/" + queueId + "/" + queueNumber + "/" + qosId; HttpHeaders headers = new HttpHeaders(); HttpEntity<String> delQueueEntity = new HttpEntity<>(headers); ResponseEntity<String> delete = template.exchange(url, HttpMethod.DELETE, delQueueEntity, String.class); logger.debug(// w w w . j a v a 2 s .co m "deleting queue " + queueId + " with qosID " + qosId + " has returned " + delete.getStatusCode()); return delete.getStatusCode(); }
From source file:org.zalando.boot.etcd.EtcdClientTest.java
@Test public void delete() throws EtcdException { server.expect(MockRestRequestMatchers.requestTo("http://localhost:2379/v2/keys/sample")) .andExpect(MockRestRequestMatchers.method(HttpMethod.DELETE)).andRespond( MockRestResponseCreators.withSuccess(new ClassPathResource("EtcdClientTest_delete.json"), MediaType.APPLICATION_JSON)); EtcdResponse response = client.delete("sample"); Assert.assertNotNull("response", response); server.verify();/*w w w . ja va2 s . com*/ }
From source file:com.logsniffer.event.publisher.http.HttpPublisherTest.java
@Test public void testDelete() throws PublishException { stubFor(delete(urlEqualTo("/eventId/123456789")).willReturn(aResponse().withStatus(201))); publisher.setMethod(HttpMethod.DELETE); publisher.setUrl("http://localhost:" + port + "/eventId/123456789"); Event event = new Event(); event.setId("123"); publisher.publish(event);/*from w w w.j a va 2s.com*/ }
From source file:org.cloudfoundry.identity.uaa.integration.TokenAdminEndpointsIntegrationTests.java
@Test @OAuth2ContextConfiguration(resource = OAuth2ContextConfiguration.ClientCredentials.class) public void testRevokeTokenByClient() throws Exception { OAuth2AccessToken token = context.getAccessToken(); String hash = new StandardPasswordEncoder().encode(token.getValue()); HttpEntity<?> request = new HttpEntity<String>(token.getValue()); assertEquals(HttpStatus.OK,// w w w .j a va 2 s .co m serverRunning.getRestTemplate().exchange(serverRunning.getUrl("/oauth/clients/scim/tokens/" + hash), HttpMethod.DELETE, request, Void.class).getStatusCode()); // The token was revoked so if we trya nd use it again it should come back unauthorized ResponseEntity<String> result = serverRunning.getForString("/oauth/clients/scim/tokens/"); assertEquals(HttpStatus.UNAUTHORIZED, result.getStatusCode()); String body = result.getBody(); assertTrue("Wrong body: " + body, body.contains("invalid_token")); }
From source file:com.gooddata.gdc.DataStoreService.java
/** * Delete given path from datastore./* w ww. j ava2 s . c o m*/ * @param path path to delete * @throws com.gooddata.gdc.DataStoreException in case delete failed */ public void delete(String path) { notEmpty(path, "path"); final URI uri = getUri(path); try { final ResponseEntity result = restTemplate.exchange(uri, HttpMethod.DELETE, org.springframework.http.HttpEntity.EMPTY, Void.class); // in case we get redirect (i.e. when we want to delete collection) we will follow redirect to the new location if (HttpStatus.MOVED_PERMANENTLY.equals(result.getStatusCode())) { restTemplate.exchange(result.getHeaders().getLocation(), HttpMethod.DELETE, org.springframework.http.HttpEntity.EMPTY, Void.class); } } catch (RestClientException e) { throw new DataStoreException("Unable to delete " + uri, e); } }
From source file:com.orange.ngsi.client.NgsiRestClient.java
/** * Retrieve an attribute of a context element * @param url the URL of the broker//from www . j a va 2 s .c om * @param httpHeaders the HTTP header to use, or null for default * @param entityID the ID of the entity * @param attributeName the name of the attribute * @return a future for a StatusCode */ public ListenableFuture<StatusCode> deleteContextAttribute(String url, HttpHeaders httpHeaders, String entityID, String attributeName) { return request(HttpMethod.DELETE, url + entitiesPath + entityID + attributesPath + attributeName, httpHeaders, null, StatusCode.class); }
From source file:gateway.test.ServiceTests.java
/** * Test DELETE /service/{serviceId}//from w w w . ja v a 2 s . co m */ @Test public void testDelete() { // Mock when(restTemplate.exchange(anyString(), eq(HttpMethod.DELETE), eq(null), eq(SuccessResponse.class))) .thenReturn(new ResponseEntity<SuccessResponse>( new SuccessResponse("Deleted", "Service Controller"), HttpStatus.OK)); // Test ResponseEntity<PiazzaResponse> entity = serviceController.deleteService("123456", false, user); SuccessResponse response = (SuccessResponse) entity.getBody(); // Verify assertTrue(entity.getStatusCode().equals(HttpStatus.OK)); assertTrue(response.data.getMessage().contains("Deleted")); // Test Exception when(restTemplate.exchange(anyString(), eq(HttpMethod.DELETE), eq(null), eq(SuccessResponse.class))) .thenThrow(new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR)); entity = serviceController.deleteService("123456", false, user); assertTrue(entity.getStatusCode().equals(HttpStatus.INTERNAL_SERVER_ERROR)); assertTrue(entity.getBody() instanceof ErrorResponse); }
From source file:io.github.microcks.util.test.HttpTestRunner.java
/** * Build the HttpMethod corresponding to string. Default to POST * if unknown or unrecognized./*from w w w .j a v a 2s.c o m*/ */ @Override public HttpMethod buildMethod(String method) { if (method != null) { if ("GET".equals(method.toUpperCase().trim())) { return HttpMethod.GET; } else if ("PUT".equals(method.toUpperCase().trim())) { return HttpMethod.PUT; } else if ("DELETE".equals(method.toUpperCase().trim())) { return HttpMethod.DELETE; } } return HttpMethod.POST; }