1 7 package org.jboss.cache.lock; 8 9 import junit.framework.TestCase; 10 11 14 public class LockMapTest extends TestCase 15 { 16 private LockMap map_; 17 18 23 public LockMapTest(String arg0) 24 { 25 super(arg0); 26 } 27 28 public static void main(String [] args) 29 { 30 junit.textui.TestRunner.run(LockMapTest.class); 31 } 32 33 36 protected void setUp() throws Exception 37 { 38 super.setUp(); 39 map_ = new LockMap(); 40 } 41 42 45 protected void tearDown() throws Exception 46 { 47 super.tearDown(); 48 map_.removeAll(); 49 } 50 51 final public void testIsOwner() 52 { 53 map_.addReader(this); 54 assertTrue(map_.isOwner(this, LockMap.OWNER_READ)); 55 map_.setWriterIfNotNull(this); 56 assertTrue(map_.isOwner(this, LockMap.OWNER_WRITE)); 57 assertTrue(map_.isOwner(this, LockMap.OWNER_ANY)); 58 map_.removeAll(); 59 } 60 61 final public void testAddReader() 62 { 63 map_.addReader(this); 64 assertTrue(map_.isOwner(this, LockMap.OWNER_READ)); 65 map_.removeReader(this); 66 } 67 68 final public void testAddWriter() 69 { 70 map_.setWriterIfNotNull(this); 71 assertTrue(map_.writerOwner().equals(this)); 72 map_.removeWriter(); 73 } 74 75 } 76 | Popular Tags |