Methods Summary |
---|
protected void | setUp()
this.lock = (SingleHostConcurrentStorageLock)SingleHostConcurrentStorageLock.getConcurrentStorageLock();
super.setUp();
|
protected void | tearDown()
super.tearDown();
threadResult = false;
this.lock.close();
|
public void | testClose()
|
public void | testGetConcurrentStorageLock()
ConcurrentStorageLock lock = SingleHostConcurrentStorageLock.getConcurrentStorageLock();
assertEquals(lock,SingleHostConcurrentStorageLock.getConcurrentStorageLock() );
|
public void | testIsKeyLocked()
|
public void | testReleaseLock()
final String key = "someKey";
final String nextKey = "fooKey";
assertTrue(lock.setLock(key));
assertTrue(lock.isKeyLocked(key));
assertTrue(lock.releaseLock(key));
assertTrue(this.lock.setLock(key));
try{
assertTrue(lock.setLock(nextKey));
fail("thread has already locked the key");
}catch (Exception e) {
// TODO: handle exception
}
Thread t = new Thread(new Runnable(){
public void run(){
threadResult = lock.setLock(nextKey);
}
});
t.start();
t.join(300);
assertTrue(threadResult);
try{
this.lock.releaseLock(nextKey);
fail("current thread is not owner");
}catch (ConcurrencyException e) {
// TODO: handle exception
}
|
public void | testReleaseThreadLocks()
|
public void | testSetLock()
final String key = "someKey";
final String nextKey = "fooKey";
assertTrue(lock.setLock(key));
assertTrue(lock.isKeyLocked(key));
try{
this.lock.setLock(key);
fail("thread has already locked the key");
}catch (Exception e) {
// TODO: handle exception
}
try{
assertTrue(lock.setLock(nextKey));
fail("thread has already locked the key");
}catch (Exception e) {
// TODO: handle exception
}
Thread t = new Thread(new Runnable(){
public void run(){
threadResult = lock.setLock(key);
}
});
t.start();
t.join(300);
assertFalse(threadResult);
t = new Thread(new Runnable(){
public void run(){
threadResult = lock.setLock(nextKey);
}
});
t.start();
t.join(300);
assertTrue(threadResult);
|