1 package org.jboss.cache.optimistic; 2 3 import org.jboss.cache.CacheImpl; 4 import org.jboss.cache.Fqn; 5 import org.jboss.cache.NodeSPI; 6 import org.jboss.cache.config.Configuration; 7 import org.jboss.cache.misc.TestingUtil; 8 9 import javax.transaction.TransactionManager ; 10 11 14 public class RemoveBeforeCreateTest extends AbstractOptimisticTestCase 15 { 16 CacheImpl[] c = null; 17 TransactionManager t; 18 19 protected void setUp() throws Exception 20 { 21 c = new CacheImpl[2]; 22 c[0] = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC); 23 c[1] = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC); 24 25 TestingUtil.blockUntilViewsReceived(c, 20000); 26 27 t = c[0].getTransactionManager(); 28 } 29 30 protected void tearDown() 31 { 32 if (c != null) 33 { 34 destroyCache(c[0]); 35 destroyCache(c[1]); 36 c = null; 37 } 38 } 39 40 public RemoveBeforeCreateTest(String name) 41 { 42 super(name); 43 } 44 45 public void testControl() throws Exception 46 { 47 t.begin(); 48 c[0].put("/control", "key", "value"); 49 t.commit(); 50 TestingUtil.sleepThread(200); 51 52 assertEquals("value", c[0].get("/control", "key")); 53 assertEquals("value", c[1].get("/control", "key")); 54 55 DefaultDataVersion v1 = (DefaultDataVersion) ((NodeSPI) c[0].get("/control")).getVersion(); 56 assertEquals(1, v1.getRawVersion()); 57 58 DefaultDataVersion v2 = (DefaultDataVersion) ((NodeSPI) c[1].get("/control")).getVersion(); 59 assertEquals(1, v2.getRawVersion()); 60 61 62 } 63 64 public void testRemoveBeforePut() throws Exception 65 { 66 Fqn f = Fqn.fromString("/test"); 67 assertNull(c[0].get(f)); 68 assertNull(c[1].get(f)); 69 70 t.begin(); 71 c[0].remove(f); 72 73 t.commit(); 75 TestingUtil.sleepThread(200); 76 77 assertNull(c[0].get(f)); 78 assertNull(c[1].get(f)); 79 } 80 81 } 82 | Popular Tags |