1 package org.apache.ojb.otm; 2 3 6 import org.apache.ojb.otm.lock.isolation.TransactionIsolation; 7 import org.apache.ojb.otm.lock.isolation.SerializableIsolation; 8 9 public class LockTestSerializable extends LockTestBase 10 { 11 private static Class CLASS = LockTestSerializable.class; 12 13 public LockTestSerializable(String name) 14 { 15 super(name); 16 } 17 18 protected TransactionIsolation newIsolation() 19 { 20 return new SerializableIsolation(); 21 } 22 23 26 public void testSingleReadLock() 27 { 28 assertTrue(readLock(_tx1)); 29 } 30 31 34 public void testReadThenWrite() 35 { 36 assertTrue(readLock(_tx1)); 37 assertTrue(writeLock(_tx1)); 38 } 39 40 43 public void testSingleWriteLock() 44 { 45 assertTrue(writeLock(_tx1)); 46 } 47 48 51 public void testWriteThenRead() 52 { 53 assertTrue(writeLock(_tx1)); 54 assertTrue(readLock(_tx1)); 55 } 56 57 60 public void testMultipleReadLock() 61 { 62 assertTrue(readLock(_tx1)); 63 assertTrue(!readLock(_tx2)); 64 } 65 66 69 public void testWriteWithExistingReader() 70 { 71 assertTrue(readLock(_tx1)); 72 assertTrue(!writeLock(_tx2)); 73 } 74 75 78 public void testWriteWithMultipleReaders() 79 { 80 assertTrue(readLock(_tx1)); 81 assertTrue(!readLock(_tx2)); 82 assertTrue(!writeLock(_tx2)); 83 } 84 85 88 public void testWriteWithMultipleReadersOn1() 89 { 90 assertTrue(readLock(_tx1)); 91 assertTrue(!readLock(_tx2)); 92 assertTrue(writeLock(_tx1)); 93 } 94 95 98 public void testReadWithExistingWriter() 99 { 100 assertTrue(writeLock(_tx1)); 101 assertTrue(!readLock(_tx2)); 102 } 103 104 107 public void testMultipleWriteLock() 108 { 109 assertTrue(writeLock(_tx1)); 110 assertTrue(!writeLock(_tx2)); 111 } 112 113 116 public void testReleaseReadLock() 117 { 118 assertTrue(readLock(_tx1)); 119 assertTrue(releaseLock(_tx1)); 120 assertTrue(writeLock(_tx2)); 121 } 122 123 126 public void testReleaseWriteLock() 127 { 128 assertTrue(writeLock(_tx1)); 129 assertTrue(releaseLock(_tx1)); 130 assertTrue(writeLock(_tx2)); 131 } 132 133 136 public void testReadThenRead() 137 { 138 assertTrue(readLock(_tx1)); 139 assertTrue(readLock(_tx1)); 140 } 141 142 public static void main(String [] args) 143 { 144 String [] arr = {CLASS.getName()}; 145 junit.textui.TestRunner.main(arr); 146 } 147 148 } 149 | Popular Tags |