Java Code Examples for org.apache.jackrabbit.webdav.lock.Type#WRITE

The following examples show how to use org.apache.jackrabbit.webdav.lock.Type#WRITE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DavResourceTest.java    From archiva with Apache License 2.0 6 votes vote down vote up
@Test
public void testLockIfResourceUnlockable()
    throws Exception
{
    assertEquals( 0, resource.getLocks().length );

    LockInfo info = new LockInfo( Scope.SHARED, Type.WRITE, "/", 0, false );
    try
    {
        lockManager.createLock( info, resource );
        fail( "Did not throw dav exception" );
    }
    catch ( Exception e )
    {
        // Simple lock manager will die
    }
    assertEquals( 0, resource.getLocks().length );
}
 
Example 2
Source File: DavResourceTest.java    From archiva with Apache License 2.0 6 votes vote down vote up
@Test
public void testRefreshLockThrowsExceptionIfNoLockIsPresent()
    throws Exception
{
    LockInfo info = new LockInfo( Scope.EXCLUSIVE, Type.WRITE, "/", 0, false );

    assertEquals( 0, resource.getLocks().length );

    try
    {
        lockManager.refreshLock( info, "notoken", resource );
        fail( "Did not throw dav exception" );
    }
    catch ( DavException e )
    {
        assertEquals( DavServletResponse.SC_PRECONDITION_FAILED, e.getErrorCode() );
    }

    assertEquals( 0, resource.getLocks().length );
}
 
Example 3
Source File: DavResourceTest.java    From archiva with Apache License 2.0 6 votes vote down vote up
@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 );
}
 
Example 4
Source File: DavResourceTest.java    From archiva with Apache License 2.0 5 votes vote down vote up
@Test
public void testLock()
    throws Exception
{
    assertEquals( 0, resource.getLocks().length );

    LockInfo info = new LockInfo( Scope.EXCLUSIVE, Type.WRITE, "/", 0, false );
    lockManager.createLock( info, resource );

    assertEquals( 1, resource.getLocks().length );
}
 
Example 5
Source File: DavResourceTest.java    From archiva with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetLock()
    throws Exception
{
    LockInfo info = new LockInfo( Scope.EXCLUSIVE, Type.WRITE, "/", 0, false );
    lockManager.createLock( info, resource );

    assertEquals( 1, resource.getLocks().length );

    // Lock should exist
    assertNotNull( resource.getLock( Type.WRITE, Scope.EXCLUSIVE ) );

    // Lock should not exist
    assertNull( resource.getLock( Type.WRITE, Scope.SHARED ) );
}
 
Example 6
Source File: DavResourceTest.java    From archiva with Apache License 2.0 4 votes vote down vote up
@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 );
}
 
Example 7
Source File: DavResourceTest.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Test
public void testUnlock()
    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.releaseLock( lock.getToken(), resource );

    assertEquals( 0, resource.getLocks().length );
}