1 package org.jboss.cache.marshall; 2 3 import junit.framework.TestCase; 4 import org.jboss.cache.CacheImpl; 5 import org.jboss.cache.Fqn; 6 import org.jboss.cache.misc.TestingUtil; 7 8 public class ReplicateToInactiveRegionTest extends TestCase 9 { 10 CacheImpl[] caches; 11 12 protected void setUp() throws Exception 13 { 14 super.setUp(); 15 caches = new CacheImpl[]{createCache(), createCache()}; 16 TestingUtil.blockUntilViewsReceived(caches, 10000); 17 } 18 19 protected void tearDown() throws Exception 20 { 21 super.tearDown(); 22 destroyCache(caches[0]); 23 destroyCache(caches[1]); 24 caches = null; 25 } 26 27 private void destroyCache(CacheImpl c) 28 { 29 c.stop(); 30 } 31 32 private CacheImpl createCache() throws Exception 33 { 34 CacheImpl c = new CacheImpl(); 35 c.getConfiguration().setCacheMode("REPL_SYNC"); 36 c.getConfiguration().setUseRegionBasedMarshalling(true); 37 c.start(); 38 return c; 39 } 40 41 public void testTransferToInactiveRegion() 42 { 43 Fqn f = Fqn.fromString("/a/b"); 44 45 caches[0].put(f, "k", "v"); 46 47 assertEquals("v", caches[0].peek(f, "k")); 48 assertEquals("v", caches[1].peek(f, "k")); 49 50 caches[1].getRegionManager().getRegion(f, true).deactivate(); 52 53 caches[0].put(f, "k", "v2"); 54 assertEquals("v2", caches[0].peek(f, "k")); 55 assertNull(caches[1].peek(f, "k")); 56 57 } 58 } 59 60 | Popular Tags |