status = client.executeMethod(get);
Assert.assertEquals(HttpServletResponse.SC_OK, status);
Assert.assertEquals(get.getResponseBodyAsString(), "content");
// delete and test delete
DeleteMethod delete = new DeleteMethod(jobUrl);
status = client.executeMethod(delete);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, status);
status = client.executeMethod(get);
Assert.assertEquals(HttpServletResponse.SC_GONE, status);
method.releaseConnection();
}
{
dispatcher.setMaxCacheSize(1);
latch = new CountDownLatch(1);
PostMethod method = createPostMethod("?asynch=true");
method.setRequestEntity(new StringRequestEntity("content", "text/plain", null));
int status = client.executeMethod(method);
Assert.assertEquals(HttpServletResponse.SC_ACCEPTED, status);
String jobUrl1 = method.getResponseHeader(HttpHeaders.LOCATION).getValue();
Assert.assertTrue(latch.await(3, TimeUnit.SECONDS));
latch = new CountDownLatch(1);
method.setRequestEntity(new StringRequestEntity("content", "text/plain", null));
status = client.executeMethod(method);
Assert.assertEquals(HttpServletResponse.SC_ACCEPTED, status);
String jobUrl2 = method.getResponseHeader(HttpHeaders.LOCATION).getValue();
Assert.assertTrue(latch.await(3, TimeUnit.SECONDS));
Assert.assertTrue(!jobUrl1.equals(jobUrl2));
GetMethod get = new GetMethod(jobUrl1);
status = client.executeMethod(get);
Assert.assertEquals(HttpServletResponse.SC_GONE, status);
// test its still there
get = new GetMethod(jobUrl2);
status = client.executeMethod(get);
Assert.assertEquals(HttpServletResponse.SC_OK, status);
Assert.assertEquals(get.getResponseBodyAsString(), "content");
// delete and test delete
DeleteMethod delete = new DeleteMethod(jobUrl2);
status = client.executeMethod(delete);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, status);
status = client.executeMethod(get);
Assert.assertEquals(HttpServletResponse.SC_GONE, status);