use of org.apache.jackrabbit.webdav.client.methods.HttpUnbind in project jackrabbit by apache.
the class BindTest method testUnbind.
//will fail until <https://issues.apache.org/jira/browse/JCR-1773> is fixed
public void testUnbind() throws Exception {
String testcol = this.root + "testUnbind/";
String subcol1 = testcol + "bindtest1/";
String testres1 = subcol1 + "res1";
String subcol2 = testcol + "bindtest2/";
String testres2 = subcol2 + "res2";
int status;
try {
HttpMkcol mkcol = new HttpMkcol(testcol);
status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
assertEquals(201, status);
mkcol = new HttpMkcol(subcol1);
status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
assertEquals(201, status);
mkcol = new HttpMkcol(subcol2);
status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
assertEquals(201, status);
//create new resource R with path testSimpleBind/bindtest1/res1
HttpPut put = new HttpPut(testres1);
put.setEntity(new StringEntity("foo", ContentType.create("text/plain", "UTF-8")));
status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
assertEquals(201, status);
//create new binding of R with path testSimpleBind/bindtest2/res2
HttpBind bind = new HttpBind(subcol2, new BindInfo(testres1, "res2"));
status = this.client.execute(bind, this.context).getStatusLine().getStatusCode();
assertEquals(201, status);
//check if both bindings report the same DAV:resource-id
assertEquals(this.getResourceId(testres1), this.getResourceId(testres2));
//remove new path
HttpUnbind unbind = new HttpUnbind(subcol2, new UnbindInfo("res2"));
status = this.client.execute(unbind, this.context).getStatusLine().getStatusCode();
assertTrue("status: " + status, status == 200 || status == 204);
//verify that the new binding is gone
HttpHead head = new HttpHead(testres2);
status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
assertEquals(404, status);
//verify that the initial binding is still there
head = new HttpHead(testres1);
status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
assertEquals(200, status);
} finally {
delete(testcol);
}
}
Aggregations