01: package junit;
02:
03: import java.util.*;
04: import javax.cache.Cache;
05: import javax.cache.CacheException;
06:
07: import ri.cache.BasicCache;
08: import ri.cache.transport.*;
09: import org.junit.Before;
10: import org.junit.Test;
11: import org.junit.After;
12:
13: /**
14: * LocalPullTestCase -- test case for a parent-child cache, where one cache pulls from another, over the
15: * local (in-memory) transport
16: *
17: * @author Brian Goetz
18: */
19: public class LocalPullTestCase extends ParentChildCacheTestCase {
20:
21: protected TransportListenerAdapter parentTransportListener;
22:
23: protected TransportEndpointFactory getTransportFactory() {
24: return LocalTransportFactory.getFactory();
25: }
26:
27: protected Map getNameMap() {
28: Map nameMap = new HashMap();
29: nameMap.put(LocalTransportFactory.ENDPOINT_NAME, "a");
30: return nameMap;
31: }
32:
33: @After
34: public void tearDown() throws Exception {
35: getTransportFactory().unregisterListener(getNameMap(),
36: parentTransportListener);
37: super .tearDown();
38: }
39:
40: protected Cache createParentCache() throws TransportException {
41: Cache c = new BasicCache("TestCache", new IdentityLoader());
42: parentTransportListener = new ReadOnlyTransportListenerAdapter(
43: c);
44: getTransportFactory().registerListener(getNameMap(),
45: parentTransportListener);
46: return c;
47: }
48:
49: protected Cache createChildCache() throws TransportException {
50: return new BasicCache("TestCache", new RemoteCacheLoader(
51: getTransportFactory().getEndpoint(getNameMap())));
52: }
53:
54: @Test
55: public void localPullTest() throws CacheException {
56: doTest1();
57: }
58: }
|