Search in sources :

Example 11 with LockInfo

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);
}
Also used : ActiveLock(org.apache.jackrabbit.webdav.lock.ActiveLock) LockInfo(org.apache.jackrabbit.webdav.lock.LockInfo) Test(org.junit.Test)

Example 12 with LockInfo

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);
}
Also used : DavException(org.apache.jackrabbit.webdav.DavException) LockInfo(org.apache.jackrabbit.webdav.lock.LockInfo) Test(org.junit.Test)

Example 13 with LockInfo

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);
}
Also used : HttpUnlock(org.apache.jackrabbit.webdav.client.methods.HttpUnlock) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) LockInfo(org.apache.jackrabbit.webdav.lock.LockInfo) HttpLock(org.apache.jackrabbit.webdav.client.methods.HttpLock)

Aggregations

LockInfo (org.apache.jackrabbit.webdav.lock.LockInfo)13 Test (org.junit.Test)9 DavException (org.apache.jackrabbit.webdav.DavException)4 HttpLock (org.apache.jackrabbit.webdav.client.methods.HttpLock)3 ActiveLock (org.apache.jackrabbit.webdav.lock.ActiveLock)3 URI (java.net.URI)2 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)2 LockDiscovery (org.apache.jackrabbit.webdav.lock.LockDiscovery)2 Element (org.w3c.dom.Element)2 ArrayList (java.util.ArrayList)1 PutMethod (org.apache.commons.httpclient.methods.PutMethod)1 HttpResponse (org.apache.http.HttpResponse)1 HttpDelete (org.apache.http.client.methods.HttpDelete)1 HttpPut (org.apache.http.client.methods.HttpPut)1 HttpRequestBase (org.apache.http.client.methods.HttpRequestBase)1 StringEntity (org.apache.http.entity.StringEntity)1 MultiStatus (org.apache.jackrabbit.webdav.MultiStatus)1 MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)1 DeleteMethod (org.apache.jackrabbit.webdav.client.methods.DeleteMethod)1 HttpPropfind (org.apache.jackrabbit.webdav.client.methods.HttpPropfind)1