1 7 package org.jboss.cache.options; 8 9 import junit.framework.TestCase; 10 import org.jboss.cache.CacheImpl; 11 import org.jboss.cache.Fqn; 12 import org.jboss.cache.config.Configuration; 13 import org.jboss.cache.config.Option; 14 15 import javax.transaction.TransactionManager ; 16 17 20 public class CacheModeLocalSimpleTest extends TestCase 21 { 22 private CacheImpl cache1, cache2; 23 private Option cacheModeLocal; 24 25 public void setUp() throws Exception 26 { 27 cache1 = new CacheImpl(); 28 Configuration c = new Configuration(); 29 cache1.setConfiguration(c); 30 c.setCacheMode("REPL_SYNC"); 31 c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup"); 32 33 cache2 = new CacheImpl(); 34 c = new Configuration(); 35 cache2.setConfiguration(c); 36 c.setCacheMode("REPL_SYNC"); 37 c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup"); 38 39 cache1.start(); 40 cache2.start(); 41 42 cacheModeLocal = new Option(); 43 cacheModeLocal.setCacheModeLocal(true); 44 } 45 46 public void tearDown() 47 { 48 if (cache1 != null) 49 { 50 cache1.stop(); 51 cache1 = null; 52 } 53 54 if (cache2 != null) 55 { 56 cache2.stop(); 57 cache2 = null; 58 } 59 } 60 61 public void testCacheModeLocalWithTx() throws Exception 62 { 63 TransactionManager mgr = cache1.getTransactionManager(); 64 mgr.begin(); 65 66 cache1.put(Fqn.fromString("/replicate"), "k", "v"); 67 cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true); 68 cache1.put(Fqn.fromString("/not-replicate"), "k", "v"); 69 70 mgr.commit(); 71 72 assertEquals("v", cache1.get("/replicate", "k")); 73 assertEquals("v", cache1.get("/not-replicate", "k")); 74 75 assertEquals("v", cache2.get("/replicate", "k")); 76 assertNull(cache2.get("/not-replicate", "k")); 77 } 78 } 79 | Popular Tags |