List of usage examples for org.apache.commons.httpclient.methods DeleteMethod getResponseHeader
@Override
public Header getResponseHeader(String headerName)
From source file:org.apache.wink.itest.InheritanceTest.java
public void testSubResourceLocaterInheritance() throws Exception { DeleteMethod deleteMethod = new DeleteMethod(PARKING_LOT_URI + "/cars/remove/ParkingLot"); GetMethod getMethod = new GetMethod(FRUIT_URI + "/fruit%20suffix"); PostMethod postMethod = new PostMethod(FRUIT_URI + "/orange%20suffix"); try {/*from w w w . j ava2s . c o m*/ // ParkingLot classes. Sub resource classes are potential root // resources httpClient.executeMethod(deleteMethod); Header header = deleteMethod.getResponseHeader("Invoked"); assertNotNull(header); assertEquals("ParkingLot.removeCar", header.getValue()); deleteMethod.releaseConnection(); deleteMethod = new DeleteMethod(PARKING_LOT_URI + "/cars/remove/ParkingGarage"); httpClient.executeMethod(deleteMethod); header = deleteMethod.getResponseHeader("Invoked"); assertNotNull(header); assertEquals("ParkingGarage.removeCar", header.getValue()); deleteMethod.releaseConnection(); deleteMethod = new DeleteMethod(PARKING_LOT_URI + "/cars/remove/CarFerry"); httpClient.executeMethod(deleteMethod); assertEquals(405, deleteMethod.getStatusCode()); // Fruit classes. Sub resource classes are not potential root // resources httpClient.executeMethod(getMethod); String response = getMethod.getResponseBodyAsString(); assertEquals("org.apache.wink.itest.fruits.Fruit;fruit%20suffix", response); getMethod.releaseConnection(); getMethod = new GetMethod(FRUIT_URI + "/apple%20suffix"); httpClient.executeMethod(getMethod); response = getMethod.getResponseBodyAsString(); assertEquals("org.apache.wink.itest.fruits.Apple;apple suffix", // parameters // on // class // are // not // inherited response); getMethod.releaseConnection(); getMethod = new GetMethod(FRUIT_URI + "/orange%20suffix"); httpClient.executeMethod(getMethod); assertEquals(405, getMethod.getStatusCode()); httpClient.executeMethod(postMethod); response = postMethod.getResponseBodyAsString(); assertEquals("org.apache.wink.itest.fruits.Orange;orange suffix", response); assertEquals(200, postMethod.getStatusCode()); } catch (Exception e) { e.printStackTrace(); fail(e.toString()); } finally { deleteMethod.releaseConnection(); getMethod.releaseConnection(); } }
From source file:org.soa4all.dashboard.gwt.module.wsmolite.server.WsmoLiteDataServiceImpl.java
@Override public boolean deleteRepositoryFile(String fullRequestUrl) throws Exception { DeleteMethod deleteMtd = new DeleteMethod(fullRequestUrl); HttpClient httpclient = new HttpClient(); try {//from w w w.j a v a2 s . c o m int result = httpclient.executeMethod(deleteMtd); if (result != 200) { deleteMtd.releaseConnection(); throw new Exception("Error " + result + ": " + deleteMtd.getResponseHeader("Error")); } } finally { deleteMtd.releaseConnection(); } return true; }