01: package org.compass.needle.coherence;
02:
03: import org.apache.lucene.store.Lock;
04: import org.apache.lucene.store.LockObtainFailedException;
05:
06: /**
07: * @author kimchy
08: */
09: public class InvocableCoherenceDirectoryTests extends
10: AbstractCoherenceDirectoryTests {
11:
12: protected CoherenceDirectory doCreateDirectory(String name,
13: int bucketSize) {
14: return new InvocableCoherenceDirectory(getCache(), name,
15: bucketSize);
16: }
17:
18: public void testSimpeLocking() throws Exception {
19: CoherenceDirectory dir = doCreateDirectory("test", 40);
20: Lock lock = dir.makeLock("testlock");
21: assertFalse(lock.isLocked());
22: assertTrue(lock.obtain(2000));
23: assertTrue(lock.isLocked());
24: try {
25: assertFalse(lock.obtain(2000));
26: fail();
27: } catch (LockObtainFailedException e) {
28: // all is well
29: }
30: lock.release();
31: assertFalse(lock.isLocked());
32: }
33:
34: }
|