Search in sources :

Example 1 with FsFileResource

use of io.milton.http.fs.FsFileResource in project lobcder by skoulouzis.

the class MemoryLockManagerTest method testLockUnLock.

public void testLockUnLock() throws NotAuthorizedException {
    LockTimeout timeout = new LockTimeout(100l);
    LockInfo lockInfo = new LockInfo(LockInfo.LockScope.NONE, LockInfo.LockType.READ, "me", LockInfo.LockDepth.ZERO);
    SimpleFileContentService contentService = new SimpleFileContentService();
    FsResource resource = new FsFileResource(null, null, new File(File.pathSeparator), contentService);
    // lock it
    LockResult res = lockManager.lock(timeout, lockInfo, resource);
    assertNotNull(res);
    assertTrue(res.isSuccessful());
    // check is locked
    LockToken token = lockManager.getCurrentToken(resource);
    assertNotNull(token);
    assertEquals(token.tokenId, res.getLockToken().tokenId);
    // unlock
    lockManager.unlock(token.tokenId, resource);
    // check removed
    token = lockManager.getCurrentToken(resource);
    assertNull(token);
}
Also used : FsResource(io.milton.http.fs.FsResource) LockResult(io.milton.http.LockResult) FsFileResource(io.milton.http.fs.FsFileResource) LockToken(io.milton.http.LockToken) LockInfo(io.milton.http.LockInfo) SimpleFileContentService(io.milton.http.fs.SimpleFileContentService) File(java.io.File) LockTimeout(io.milton.http.LockTimeout)

Aggregations

LockInfo (io.milton.http.LockInfo)1 LockResult (io.milton.http.LockResult)1 LockTimeout (io.milton.http.LockTimeout)1 LockToken (io.milton.http.LockToken)1 FsFileResource (io.milton.http.fs.FsFileResource)1 FsResource (io.milton.http.fs.FsResource)1 SimpleFileContentService (io.milton.http.fs.SimpleFileContentService)1 File (java.io.File)1