Skip to content

Commit

Permalink
Updating assertDeleted to check both HEAD and GET, and only accept 41…
Browse files Browse the repository at this point in the history
…0 Gone (not 404 Not Found)
  • Loading branch information
escowles committed Oct 31, 2014
1 parent c7df2f3 commit 188f953
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -22,7 +22,6 @@
import static javax.ws.rs.core.Response.Status.NO_CONTENT;
import static javax.ws.rs.core.Response.Status.OK;
import static org.fcrepo.http.commons.test.util.TestHelpers.parseTriples;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
Expand All @@ -44,6 +43,7 @@
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpPatch;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
Expand Down Expand Up @@ -179,7 +179,9 @@ protected static int getStatus(final HttpUriRequest method)
final int result = response.getStatusLine().getStatusCode();
if (!(result > 199) || !(result < 400)) {
logger.warn("Got status {}", result);
logger.warn(EntityUtils.toString(response.getEntity()));
if (response.getEntity() != null) {
logger.warn(EntityUtils.toString(response.getEntity()));
}
}
return result;
}
Expand Down Expand Up @@ -317,6 +319,7 @@ protected static String getRandomPropertyValue() {
}

protected static void assertDeleted(final String location) throws IOException {
assertThat("Expected object to be deleted", getStatus(new HttpGet(location)), anyOf(is(404), is(410)));
assertThat("Expected object to be deleted", getStatus(new HttpHead(location)), is(410));
assertThat("Expected object to be deleted", getStatus(new HttpGet(location)), is(410));
}
}

0 comments on commit 188f953

Please sign in to comment.