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