use of org.apache.jackrabbit.webdav.lock.LockInfo in project archiva by apache.
the class DavResourceTest method testRefreshLock.
@Test
public void testRefreshLock() throws Exception {
LockInfo info = new LockInfo(Scope.EXCLUSIVE, Type.WRITE, "/", 0, false);
assertEquals(0, resource.getLocks().length);
lockManager.createLock(info, resource);
assertEquals(1, resource.getLocks().length);
ActiveLock lock = resource.getLocks()[0];
lockManager.refreshLock(info, lock.getToken(), resource);
assertEquals(1, resource.getLocks().length);
}
use of org.apache.jackrabbit.webdav.lock.LockInfo in project archiva by apache.
the class DavResourceTest method testUnlockThrowsDavExceptionIfNotLocked.
@Test
public void testUnlockThrowsDavExceptionIfNotLocked() throws Exception {
LockInfo info = new LockInfo(Scope.EXCLUSIVE, Type.WRITE, "/", 0, false);
assertEquals(0, resource.getLocks().length);
lockManager.createLock(info, resource);
assertEquals(1, resource.getLocks().length);
try {
lockManager.releaseLock("BLAH", resource);
fail("Did not throw DavException");
} catch (DavException e) {
assertEquals(DavServletResponse.SC_LOCKED, e.getErrorCode());
}
assertEquals(1, resource.getLocks().length);
}
use of org.apache.jackrabbit.webdav.lock.LockInfo in project nuxeo-filesystem-connectors by nuxeo.
the class WebDavClientTest method testLockUnlock.
protected void testLockUnlock(String accept) throws Exception {
String fileUri = ROOT_URI + "quality.jpg";
HttpLock request = new HttpLock(fileUri, new LockInfo(Scope.EXCLUSIVE, Type.WRITE, USERNAME, 10000L, false));
if (accept != null) {
request.setHeader("Accept", accept);
}
int status;
String token;
try (CloseableHttpResponse response = client.execute(request, context)) {
request.checkSuccess(response);
status = response.getStatusLine().getStatusCode();
token = request.getLockToken(response);
}
assertEquals(HttpStatus.SC_OK, status);
assertEquals("urn:uuid:Administrator", token);
HttpUnlock request2 = new HttpUnlock(fileUri, token);
if (accept != null) {
request2.setHeader("Accept", accept);
}
try (CloseableHttpResponse response = client.execute(request2, context)) {
status = response.getStatusLine().getStatusCode();
}
assertEquals(HttpStatus.SC_NO_CONTENT, status);
}
Aggregations