1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.cache.ehcache; |
35 |
|
|
36 |
|
import static org.mockito.Mockito.mock; |
37 |
|
import static org.mockito.Mockito.when; |
38 |
|
|
39 |
|
import info.magnolia.init.DefaultMagnoliaInitPaths; |
40 |
|
import info.magnolia.init.MagnoliaConfigurationProperties; |
41 |
|
import info.magnolia.module.ModuleLifecycleContext; |
42 |
|
import info.magnolia.module.ModuleLifecycleContextImpl; |
43 |
|
import info.magnolia.module.cache.AbstractCacheTest; |
44 |
|
import info.magnolia.module.cache.CacheModule; |
45 |
|
import info.magnolia.test.ComponentsTestUtil; |
46 |
|
|
47 |
|
import org.junit.After; |
48 |
|
import org.junit.Before; |
49 |
|
|
50 |
|
import net.sf.ehcache.config.PersistenceConfiguration; |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 5 |
Complexity Density: 0.26 |
|
52 |
|
public class AbstractEhCacheTest extends AbstractCacheTest { |
53 |
|
|
54 |
|
protected EhCacheFactory factory; |
55 |
|
protected ModuleLifecycleContextImpl moduleLifecycleContext = new ModuleLifecycleContextImpl(); |
56 |
|
protected MagnoliaConfigurationProperties magnoliaConfigurationProperties = mock(MagnoliaConfigurationProperties.class); |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
58 |
26 |
@Before... |
59 |
|
public void setUp() throws Exception { |
60 |
26 |
super.setUp(); |
61 |
26 |
DefaultMagnoliaInitPaths magnoliaInitPaths = mock(DefaultMagnoliaInitPaths.class); |
62 |
26 |
when(magnoliaInitPaths.getRootPath()).thenReturn("/rootPath"); |
63 |
26 |
factory = new EhCacheFactory(null, cacheModule, magnoliaInitPaths, magnoliaConfigurationProperties); |
64 |
26 |
moduleLifecycleContext.setPhase(ModuleLifecycleContext.PHASE_SYSTEM_STARTUP); |
65 |
26 |
ComponentsTestUtil.setInstance(CacheModule.class, cacheModule); |
66 |
|
} |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
68 |
26 |
@After... |
69 |
|
public void tearDown() throws Exception { |
70 |
26 |
super.tearDown(); |
71 |
26 |
ComponentsTestUtil.clear(); |
72 |
26 |
if (factory != null && factory.getWrappedCacheManager() != null) { |
73 |
21 |
moduleLifecycleContext.setPhase(ModuleLifecycleContext.PHASE_SYSTEM_SHUTDOWN); |
74 |
21 |
factory.stop(false); |
75 |
|
} |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
78 |
11 |
protected EhCacheConfiguration newCacheConfigForTest() {... |
79 |
11 |
EhCacheConfiguration config = new EhCacheConfiguration(); |
80 |
11 |
EhCachePersistenceConfiguration persistenceConfiguration = new EhCachePersistenceConfiguration(); |
81 |
11 |
persistenceConfiguration.setStrategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP); |
82 |
11 |
persistenceConfiguration.setSynchronousWrites(false); |
83 |
|
|
84 |
11 |
config.setTimeToIdleSeconds(0); |
85 |
11 |
config.setTimeToLiveSeconds(0); |
86 |
11 |
config.setMaxEntriesLocalHeap(1); |
87 |
11 |
return config; |
88 |
|
} |
89 |
|
} |