assertEquals("Incorrect name for /a/d", JANE, cache1.get("/a/d", "name"));
}
public void testPartialStateTferWithLoader() throws Exception
{
TreeCacheMBean cache1 = createCache("cache1", false, true, true);
cache1.activateRegion("/a");
cache1.put("/a/b", "name", JOE);
cache1.put("/a/b", "age", TWENTY);
cache1.put("/a/c", "name", BOB);
cache1.put("/a/c", "age", FORTY);
TreeCacheMBean cache2 = createCache("cache2", false, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
CacheLoader loader = cache2.getCacheLoader();
assertNull("/a/b transferred to loader against policy", loader.get(A_B));
assertNull("/a/b name transferred against policy", cache2.get("/a/b", "name"));
assertNull("/a/b age transferred against policy", cache2.get("/a/b", "age"));
assertNull("/a/c name transferred against policy", cache2.get("/a/c", "name"));
assertNull("/a/c age transferred against policy", cache2.get("/a/c", "age"));
cache2.activateRegion("/a/b");
Map ab = loader.get(A_B);
assertNotNull("Loader transferred /a/b", ab);
assertEquals("Incorrect name from loader for /a/b", JOE, ab.get("name"));
assertEquals("Incorrect age from loader for /a/b", TWENTY, ab.get("age"));
assertNull("/a/c transferred to loader against policy", loader.get(A_C));
assertEquals("Incorrect name for /a/b", JOE, cache2.get("/a/b", "name"));
assertEquals("Incorrect age for /a/b", TWENTY, cache2.get("/a/b", "age"));
assertNull("/a/c name transferred against policy", cache2.get("/a/c", "name"));
assertNull("/a/c age transferred against policy", cache2.get("/a/c", "age"));
cache1.put("/a/d", "name", JANE);
assertNull("/a/d name transferred against policy", cache2.get("/a/d", "name"));
cache2.activateRegion("/a/c");
ab = loader.get(A_B);
assertNotNull("Loader still has /a/b", ab);
assertEquals("Incorrect name from loader for /a/b", JOE, ab.get("name"));
assertEquals("Incorrect age from loader for /a/b", TWENTY, ab.get("age"));
Map ac = loader.get(A_C);
assertNotNull("Loader transferred /a/c", ac);
assertEquals("Incorrect name from loader for /a/c", BOB, ac.get("name"));
assertEquals("Incorrect age from loader for /a/c", FORTY, ac.get("age"));
assertEquals("Incorrect name for /a/b", JOE, cache2.get("/a/b", "name"));
assertEquals("Incorrect age for /a/b", TWENTY, cache2.get("/a/b", "age"));
assertEquals("Incorrect name for /a/c", BOB, cache2.get("/a/c", "name"));
assertEquals("Incorrect age for /a/c", FORTY, cache2.get("/a/c", "age"));
assertNull("/a/d name transferred against policy", cache2.get("/a/d", "name"));
cache2.activateRegion("/a/d");
ab = loader.get(A_B);
assertNotNull("Loader still has /a/b", ab);
assertEquals("Incorrect name from loader for /a/b", JOE, ab.get("name"));
assertEquals("Incorrect age from loader for /a/b", TWENTY, ab.get("age"));
ac = loader.get(A_C);
assertNotNull("Loader transferred /a/c", ac);
assertEquals("Incorrect name from loader for /a/c", BOB, ac.get("name"));
assertEquals("Incorrect age from loader for /a/c", FORTY, ac.get("age"));
Map ad = loader.get(A_D);
assertNotNull("Loader transferred /a/d", ad);
assertEquals("Incorrect name from loader for /a/d", JANE, ad.get("name"));
assertEquals("Incorrect name for /a/b", JOE, cache2.get("/a/b", "name"));
assertEquals("Incorrect age for /a/b", TWENTY, cache2.get("/a/b", "age"));
assertEquals("Incorrect name for /a/c", BOB, cache2.get("/a/c", "name"));
assertEquals("Incorrect age for /a/c", FORTY, cache2.get("/a/c", "age"));
assertEquals("Incorrect name for /a/d", JANE, cache2.get("/a/d", "name"));
cache1.inactivateRegion("/a");
cache1.activateRegion("/a/b");
cache1.activateRegion("/a/c");