1 package org.apache.commons.jcs3.auxiliary.remote.http.client;
2
3 import org.apache.commons.jcs3.engine.control.MockCompositeCacheManager;
4 import org.apache.commons.jcs3.auxiliary.AuxiliaryCache;
5 import org.apache.commons.jcs3.auxiliary.remote.http.client.behavior.IRemoteHttpCacheClient;
6 import org.apache.commons.jcs3.engine.behavior.ICompositeCacheManager;
7 import org.apache.commons.jcs3.engine.behavior.IElementSerializer;
8 import org.apache.commons.jcs3.engine.logging.behavior.ICacheEventLogger;
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 import junit.framework.TestCase;
30
31
32 public class RemoteHttpCacheFactoryUnitTest
33 extends TestCase
34 {
35
36 public void testCreateRemoteHttpCacheClient_Bad()
37 {
38
39 final String remoteHttpClientClassName = "junk";
40 final RemoteHttpCacheAttributes cattr = new RemoteHttpCacheAttributes();
41 cattr.setRemoteHttpClientClassName( remoteHttpClientClassName );
42
43 final RemoteHttpCacheFactory factory = new RemoteHttpCacheFactory();
44
45
46 final IRemoteHttpCacheClient<String, String> result = factory.createRemoteHttpCacheClientForAttributes( cattr );
47
48
49 assertNotNull( "Should have a cache.", result );
50 assertTrue( "Wrong default.", result instanceof RemoteHttpCacheClient );
51 assertTrue( "Should be initialized", ((RemoteHttpCacheClient<String, String>)result).isInitialized() );
52 }
53
54
55 public void testCreateRemoteHttpCacheClient_default()
56 {
57
58 final RemoteHttpCacheAttributes cattr = new RemoteHttpCacheAttributes();
59 final RemoteHttpCacheFactory factory = new RemoteHttpCacheFactory();
60
61
62 final IRemoteHttpCacheClient<String, String> result = factory.createRemoteHttpCacheClientForAttributes( cattr );
63
64
65 assertNotNull( "Should have a cache.", result );
66 assertTrue( "Wrong default.", result instanceof RemoteHttpCacheClient );
67 }
68
69
70 public void testGetCache_normal()
71 {
72
73 final ICompositeCacheManager cacheMgr = new MockCompositeCacheManager();
74 assertNotNull( "Should have a manager.", cacheMgr );
75 final ICacheEventLogger cacheEventLogger = null;
76 final IElementSerializer elementSerializer = null;
77
78 final RemoteHttpCacheAttributes cattr = new RemoteHttpCacheAttributes();
79 assertNotNull( "Should have attributes.", cattr );
80 final RemoteHttpCacheFactory factory = new RemoteHttpCacheFactory();
81 assertNotNull( "Should have a factory.", factory );
82
83
84
85 final AuxiliaryCache<String, String> result = factory.createCache(cattr, cacheMgr, cacheEventLogger, elementSerializer);
86
87
88 assertNotNull( "Should have a cache.", result );
89 }
90 }