List of usage examples for org.apache.commons.httpclient.methods DeleteMethod DeleteMethod
public DeleteMethod(String paramString)
From source file:org.wso2.scim.sample.user.DeleteUser.java
public static void main(String[] args) { try {/*from w w w. j a va 2 s. c om*/ //load sample configuration SCIMSamplesUtils.loadConfiguration(); //set the keystore SCIMSamplesUtils.setKeyStore(); String userId = getSCIMIdOfUser(SCIMSamplesUtils.userNameToDeleteUser); String url = SCIMSamplesUtils.userEndpointURL + "/" + userId; //now send the delete request. DeleteMethod deleteMethod = new DeleteMethod(url); //add authorization header String authHeader = SCIMSamplesUtils.getAuthorizationHeader(); deleteMethod.addRequestHeader(SCIMConstants.AUTHORIZATION_HEADER, authHeader); HttpClient httpDeleteClient = new HttpClient(); int deleteResponseStatus = httpDeleteClient.executeMethod(deleteMethod); String deleteResponse = deleteMethod.getResponseBodyAsString(); System.out.println(""); System.out.println(""); System.out.println("/******SCIM user delete response status: " + deleteResponseStatus); System.out.println("SCIM user delete response data: " + deleteResponse + "******/"); System.out.println(""); } catch (CharonException e) { e.printStackTrace(); } catch (HttpException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.xwiki.test.rest.framework.AbstractHttpTest.java
protected DeleteMethod executeDelete(String uri) throws Exception { HttpClient httpClient = new HttpClient(); DeleteMethod deleteMethod = new DeleteMethod(uri); httpClient.executeMethod(deleteMethod); return deleteMethod; }
From source file:org.xwiki.test.rest.framework.AbstractHttpTest.java
protected DeleteMethod executeDelete(String uri, String userName, String password) throws Exception { HttpClient httpClient = new HttpClient(); httpClient.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password)); httpClient.getParams().setAuthenticationPreemptive(true); DeleteMethod deleteMethod = new DeleteMethod(uri); httpClient.executeMethod(deleteMethod); return deleteMethod; }
From source file:slash.navigation.rest.Delete.java
public Delete(String url) { super(new DeleteMethod(url)); }
From source file:terrastore.integration.IntegrationTest.java
private DeleteMethod makeDeleteMethod(int nodePort, String path) { DeleteMethod method = new DeleteMethod("http://" + HOST + ":" + nodePort + "/" + path); method.setRequestHeader("Content-Type", "application/json"); return method; }
From source file:terrastore.server.impl.JsonHttpServerTest.java
@Test public void testRemoveBucket() throws Exception { UpdateService updateService = createMock(UpdateService.class); QueryService queryService = createMock(QueryService.class); BackupService backupService = createMock(BackupService.class); StatsService statsService = createMock(StatsService.class); updateService.removeBucket("bucket"); expectLastCall().once();//from w w w.j a v a2 s . c o m replay(updateService, queryService, backupService, statsService); JsonHttpServer server = startServerWith(updateService, queryService, backupService, statsService); HttpClient client = new HttpClient(); DeleteMethod method = new DeleteMethod("http://localhost:8080/bucket"); client.executeMethod(method); assertEquals(HttpStatus.SC_NO_CONTENT, method.getStatusCode()); method.releaseConnection(); stopServer(server); verify(updateService, queryService, backupService, statsService); }
From source file:terrastore.server.impl.JsonHttpServerTest.java
@Test public void testRemoveValue() throws Exception { UpdateService updateService = createMock(UpdateService.class); QueryService queryService = createMock(QueryService.class); BackupService backupService = createMock(BackupService.class); StatsService statsService = createMock(StatsService.class); updateService.removeValue("bucket", new Key("test1")); expectLastCall().once();// w w w . ja va 2 s . c om replay(updateService, queryService, backupService, statsService); JsonHttpServer server = startServerWith(updateService, queryService, backupService, statsService); HttpClient client = new HttpClient(); DeleteMethod method = new DeleteMethod("http://localhost:8080/bucket/test1"); client.executeMethod(method); assertEquals(HttpStatus.SC_NO_CONTENT, method.getStatusCode()); method.releaseConnection(); stopServer(server); verify(updateService, queryService, backupService, statsService); }
From source file:terrastore.server.impl.JsonHttpServerTest.java
@Test public void testRemoveByRangeWithNoComparator() throws Exception { UpdateService updateService = createMock(UpdateService.class); QueryService queryService = createMock(QueryService.class); BackupService backupService = createMock(BackupService.class); StatsService statsService = createMock(StatsService.class); Range range = new Range(new Key("aaaa"), new Key("ffff"), 0, "", 0); updateService.removeByRange("bucket", range, new Predicate(null)); expectLastCall().andReturn(new Keys(Collections.EMPTY_SET)).once(); replay(updateService, queryService, backupService, statsService); JsonHttpServer server = startServerWith(updateService, queryService, backupService, statsService); HttpClient client = new HttpClient(); DeleteMethod method = new DeleteMethod("http://localhost:8080/bucket/range?startKey=aaaa&endKey=ffff"); client.executeMethod(method);//w ww .j a va 2 s.c o m assertEquals(HttpStatus.SC_OK, method.getStatusCode()); method.releaseConnection(); stopServer(server); verify(updateService, queryService, backupService, statsService); }
From source file:terrastore.server.impl.JsonHttpServerTest.java
@Test public void testRemoveByRangeWithComparator() throws Exception { UpdateService updateService = createMock(UpdateService.class); QueryService queryService = createMock(QueryService.class); BackupService backupService = createMock(BackupService.class); StatsService statsService = createMock(StatsService.class); Range range = new Range(new Key("aaaa"), new Key("ffff"), 0, "lexical-asc", 0); updateService.removeByRange("bucket", range, new Predicate(null)); expectLastCall().andReturn(new Keys(Collections.EMPTY_SET)).once(); replay(updateService, queryService, backupService, statsService); JsonHttpServer server = startServerWith(updateService, queryService, backupService, statsService); HttpClient client = new HttpClient(); DeleteMethod method = new DeleteMethod( "http://localhost:8080/bucket/range?startKey=aaaa&endKey=ffff&comparator=lexical-asc"); client.executeMethod(method);/*from w w w. j av a2s. c o m*/ assertEquals(HttpStatus.SC_OK, method.getStatusCode()); method.releaseConnection(); stopServer(server); verify(updateService, queryService, backupService, statsService); }
From source file:terrastore.server.impl.JsonHttpServerTest.java
@Test public void testRemoveByRangeWithLimit() throws Exception { UpdateService updateService = createMock(UpdateService.class); QueryService queryService = createMock(QueryService.class); BackupService backupService = createMock(BackupService.class); StatsService statsService = createMock(StatsService.class); Range range = new Range(new Key("aaaa"), new Key("ffff"), 100, "", 0); updateService.removeByRange("bucket", range, new Predicate(null)); expectLastCall().andReturn(new Keys(Collections.EMPTY_SET)).once(); replay(updateService, queryService, backupService, statsService); JsonHttpServer server = startServerWith(updateService, queryService, backupService, statsService); HttpClient client = new HttpClient(); DeleteMethod method = new DeleteMethod( "http://localhost:8080/bucket/range?startKey=aaaa&endKey=ffff&limit=100"); client.executeMethod(method);/* w ww.j ava 2 s. c o m*/ assertEquals(HttpStatus.SC_OK, method.getStatusCode()); method.releaseConnection(); stopServer(server); verify(updateService, queryService, backupService, statsService); }