[jboss-cvs] JBossAS SVN: r107965 - projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 2 17:44:51 EDT 2010
Author: pferraro
Date: 2010-09-02 17:44:50 -0400 (Thu, 02 Sep 2010)
New Revision: 107965
Modified:
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/CoarseSessionAttributeStorageTest.java
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DefaultCacheSourceTest.java
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DistributedCacheManagerFactoryTest.java
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DistributedCacheManagerTest.java
projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/FineSessionAttributeStorageTest.java
Log:
Add test for locate(...).
Use mock control.
Modified: projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/CoarseSessionAttributeStorageTest.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/CoarseSessionAttributeStorageTest.java 2010-09-02 20:04:01 UTC (rev 107964)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/CoarseSessionAttributeStorageTest.java 2010-09-02 21:44:50 UTC (rev 107965)
@@ -25,6 +25,7 @@
import java.util.Map;
import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
import org.infinispan.atomic.AtomicMap;
import org.jboss.web.tomcat.service.session.distributedcache.ispn.AtomicMapEntry;
import org.jboss.web.tomcat.service.session.distributedcache.ispn.CoarseSessionAttributeStorage;
@@ -32,6 +33,7 @@
import org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingSessionGranularitySessionData;
import org.jboss.web.tomcat.service.session.distributedcache.spi.SessionAttributeMarshaller;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -40,15 +42,24 @@
*/
public class CoarseSessionAttributeStorageTest
{
- private SessionAttributeMarshaller marshaller = EasyMock.createStrictMock(SessionAttributeMarshaller.class);
- private SessionAttributeStorage<OutgoingSessionGranularitySessionData> storage = new CoarseSessionAttributeStorage(this.marshaller);
+ private IMocksControl control;
+ private SessionAttributeMarshaller marshaller;
+ private SessionAttributeStorage<OutgoingSessionGranularitySessionData> storage;
+ @Before
+ public void before()
+ {
+ this.control = EasyMock.createStrictControl();
+ this.marshaller = this.control.createMock(SessionAttributeMarshaller.class);
+ this.storage = new CoarseSessionAttributeStorage(this.marshaller);
+ }
+
@Test
public void store()
{
@SuppressWarnings("unchecked")
- AtomicMap<Object, Object> map = EasyMock.createStrictMock(AtomicMap.class);
- OutgoingSessionGranularitySessionData data = EasyMock.createStrictMock(OutgoingSessionGranularitySessionData.class);
+ AtomicMap<Object, Object> map = this.control.createMock(AtomicMap.class);
+ OutgoingSessionGranularitySessionData data = this.control.createMock(OutgoingSessionGranularitySessionData.class);
Map<String, Object> attributes = Collections.emptyMap();
Object marshalledAttributes = new Object();
@@ -56,50 +67,46 @@
EasyMock.expect(this.marshaller.marshal(attributes)).andReturn(marshalledAttributes);
EasyMock.expect(map.put(EasyMock.eq((byte) AtomicMapEntry.ATTRIBUTES.ordinal()), EasyMock.same(marshalledAttributes))).andReturn(null);
- EasyMock.replay(this.marshaller, map, data);
+ this.control.replay();
this.storage.store(map, data);
-
- EasyMock.verify(this.marshaller, map, data);
- EasyMock.reset(this.marshaller, map, data);
+
+ this.control.verify();
}
@Test
public void storeNull()
{
@SuppressWarnings("unchecked")
- AtomicMap<Object, Object> map = EasyMock.createStrictMock(AtomicMap.class);
- OutgoingSessionGranularitySessionData data = EasyMock.createStrictMock(OutgoingSessionGranularitySessionData.class);
+ AtomicMap<Object, Object> map = this.control.createMock(AtomicMap.class);
+ OutgoingSessionGranularitySessionData data = this.control.createMock(OutgoingSessionGranularitySessionData.class);
EasyMock.expect(data.getSessionAttributes()).andReturn(null);
- EasyMock.replay(this.marshaller, map, data);
+ this.control.replay();
this.storage.store(map, data);
- EasyMock.verify(this.marshaller, map, data);
- EasyMock.reset(this.marshaller, map, data);
+ this.control.verify();
}
@Test
public void load() throws Exception
{
@SuppressWarnings("unchecked")
- AtomicMap<Object, Object> map = EasyMock.createStrictMock(AtomicMap.class);
+ AtomicMap<Object, Object> map = this.control.createMock(AtomicMap.class);
Object marshalledAttributes = new Object();
Map<String, Object> attributes = Collections.emptyMap();
EasyMock.expect(map.get(Byte.valueOf((byte) AtomicMapEntry.ATTRIBUTES.ordinal()))).andReturn(marshalledAttributes);
EasyMock.expect(this.marshaller.unmarshal(EasyMock.same(marshalledAttributes))).andReturn(attributes);
- EasyMock.replay(this.marshaller, map);
+ this.control.replay();
Map<String, Object> result = this.storage.load(map);
- EasyMock.verify(this.marshaller, map);
+ this.control.verify();
Assert.assertSame(attributes, result);
-
- EasyMock.reset(this.marshaller, map);
}
}
Modified: projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DefaultCacheSourceTest.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DefaultCacheSourceTest.java 2010-09-02 20:04:01 UTC (rev 107964)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DefaultCacheSourceTest.java 2010-09-02 21:44:50 UTC (rev 107965)
@@ -22,6 +22,7 @@
package org.jboss.web.tomcat.service.session.distributedcache.ispn;
import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
import org.infinispan.Cache;
import org.infinispan.config.Configuration;
import org.infinispan.config.Configuration.CacheMode;
@@ -31,6 +32,7 @@
import org.jboss.metadata.web.jboss.ReplicationMode;
import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -39,6 +41,19 @@
*/
public class DefaultCacheSourceTest
{
+ private IMocksControl control;
+ private CacheContainerRegistry registry;
+ private DefaultCacheSource source;
+
+ @Before
+ public void before()
+ {
+ this.control = EasyMock.createControl();
+ this.registry = this.control.createMock(CacheContainerRegistry.class);
+
+ this.source = new DefaultCacheSource(this.registry);
+ }
+
@Test
public void getCache()
{
@@ -106,15 +121,12 @@
private void getCache(String containerName, String templateCacheName, String hostName, String contextName, String cacheName, ReplicationConfig config, Configuration configuration, CacheMode mode)
{
- CacheContainerRegistry registry = EasyMock.createStrictMock(CacheContainerRegistry.class);
@SuppressWarnings("unchecked")
- Cache<Object, Object> cache = EasyMock.createStrictMock(Cache.class);
- EmbeddedCacheManager container = EasyMock.createStrictMock(EmbeddedCacheManager.class);
- LocalDistributableSessionManager manager = EasyMock.createStrictMock(LocalDistributableSessionManager.class);
+ Cache<Object, Object> cache = this.control.createMock(Cache.class);
+ EmbeddedCacheManager container = this.control.createMock(EmbeddedCacheManager.class);
+ LocalDistributableSessionManager manager = this.control.createMock(LocalDistributableSessionManager.class);
Configuration cacheConfiguration = configuration.clone();
- DefaultCacheSource source = new DefaultCacheSource(registry);
-
EasyMock.expect(manager.getReplicationConfig()).andReturn(config);
EasyMock.expect(registry.getCacheContainer(containerName)).andReturn(container);
@@ -123,15 +135,17 @@
EasyMock.expect(container.defineConfiguration(cacheName, templateCacheName, new Configuration())).andReturn(cacheConfiguration);
EasyMock.expect(container.getCache(cacheName)).andReturn(cache);
- EasyMock.replay(registry, manager, container, cache);
+ this.control.replay();
Cache<Object, Object> result = source.getCache(manager);
- EasyMock.verify(registry, manager, container, cache);
+ this.control.verify();
Assert.assertSame(cache, result);
Assert.assertSame(mode, cacheConfiguration.getCacheMode());
Assert.assertEquals((config.getBackups() != null) ? config.getBackups().intValue() : 2, cacheConfiguration.getNumOwners());
+
+ this.control.reset();
}
}
Modified: projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DistributedCacheManagerFactoryTest.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DistributedCacheManagerFactoryTest.java 2010-09-02 20:04:01 UTC (rev 107964)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DistributedCacheManagerFactoryTest.java 2010-09-02 21:44:50 UTC (rev 107965)
@@ -25,23 +25,20 @@
import java.util.ServiceLoader;
import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
import org.infinispan.AdvancedCache;
-import org.infinispan.atomic.AtomicMap;
import org.infinispan.config.Configuration;
import org.infinispan.transaction.tm.BatchModeTransactionManager;
import org.jboss.ha.ispn.atomic.AtomicMapFactory;
import org.jboss.ha.ispn.invoker.CacheInvoker;
import org.jboss.metadata.web.jboss.ReplicationConfig;
import org.jboss.metadata.web.jboss.ReplicationGranularity;
-import org.jboss.web.tomcat.service.session.distributedcache.ispn.DistributedCacheManager;
-import org.jboss.web.tomcat.service.session.distributedcache.ispn.DistributedCacheManagerFactory;
-import org.jboss.web.tomcat.service.session.distributedcache.ispn.SessionAttributeStorage;
-import org.jboss.web.tomcat.service.session.distributedcache.ispn.SessionAttributeStorageFactory;
import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
import org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingDistributableSessionData;
import org.jboss.web.tomcat.service.session.distributedcache.spi.SessionAttributeMarshaller;
import org.jboss.web.tomcat.service.session.distributedcache.spi.SessionAttributeMarshallerFactory;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -50,38 +47,54 @@
*/
public class DistributedCacheManagerFactoryTest
{
- private final CacheSource cacheSource = EasyMock.createStrictMock(CacheSource.class);
- private final LockManagerSource lockManagerSource = EasyMock.createStrictMock(LockManagerSource.class);
- private final SessionAttributeStorageFactory storageFactory = EasyMock.createStrictMock(SessionAttributeStorageFactory.class);
- private final SessionAttributeMarshallerFactory marshallerFactory = EasyMock.createStrictMock(SessionAttributeMarshallerFactory.class);
- private final CacheInvoker invoker = EasyMock.createStrictMock(CacheInvoker.class);
- private final LocalDistributableSessionManager manager = EasyMock.createStrictMock(LocalDistributableSessionManager.class);
+ private IMocksControl control;
+ private CacheSource cacheSource;
+ private LockManagerSource lockManagerSource;
+ private SessionAttributeStorageFactory storageFactory;
+ private SessionAttributeMarshallerFactory marshallerFactory;
+ private CacheInvoker invoker;
+ private LocalDistributableSessionManager manager;
+ private SessionAttributeStorage<OutgoingDistributableSessionData> storage;
+ private SessionAttributeMarshaller marshaller;
+ private AtomicMapFactory atomicMapFactory;
+ private AdvancedCache<Object, Object> cache;
+ private DistributedCacheManagerFactory factory;
+
@SuppressWarnings("unchecked")
- private final SessionAttributeStorage<OutgoingDistributableSessionData> storage = EasyMock.createStrictMock(SessionAttributeStorage.class);
- private final SessionAttributeMarshaller marshaller = EasyMock.createStrictMock(SessionAttributeMarshaller.class);
- private final AtomicMapFactory atomicMapFactory = EasyMock.createStrictMock(AtomicMapFactory.class);
- @SuppressWarnings("unchecked")
- private final AdvancedCache<String, AtomicMap<Object, Object>> cache = EasyMock.createStrictMock(AdvancedCache.class);
+ @Before
+ public void before()
+ {
+ this.control = EasyMock.createControl();
+ this.cacheSource = this.control.createMock(CacheSource.class);
+ this.lockManagerSource = this.control.createMock(LockManagerSource.class);
+ this.storageFactory = this.control.createMock(SessionAttributeStorageFactory.class);
+ this.marshallerFactory = this.control.createMock(SessionAttributeMarshallerFactory.class);
+ this.invoker = this.control.createMock(CacheInvoker.class);
+ this.manager = this.control.createMock(LocalDistributableSessionManager.class);
+ this.storage = this.control.createMock(SessionAttributeStorage.class);
+ this.marshaller = this.control.createMock(SessionAttributeMarshaller.class);
+ this.atomicMapFactory = this.control.createMock(AtomicMapFactory.class);
+ this.cache = this.control.createMock(AdvancedCache.class);
+
+ this.factory = new DistributedCacheManagerFactory();
+ this.factory.setAtomicMapFactory(this.atomicMapFactory);
+ this.factory.setSessionAttributeStorageFactory(this.storageFactory);
+ this.factory.setSessionAttributeMarshallerFactory(this.marshallerFactory);
+ this.factory.setCacheInvoker(this.invoker);
+ this.factory.setAtomicMapFactory(this.atomicMapFactory);
+ this.factory.setCacheSource(this.cacheSource);
+ this.factory.setLockManagerSource(this.lockManagerSource);
+ }
@Test
public void getDistributedCacheManager() throws Exception
{
- DistributedCacheManagerFactory factory = new DistributedCacheManagerFactory();
-
- factory.setAtomicMapFactory(this.atomicMapFactory);
- factory.setSessionAttributeStorageFactory(this.storageFactory);
- factory.setSessionAttributeMarshallerFactory(this.marshallerFactory);
- factory.setCacheInvoker(this.invoker);
- factory.setAtomicMapFactory(this.atomicMapFactory);
- factory.setCacheSource(this.cacheSource);
- factory.setLockManagerSource(this.lockManagerSource);
-
ReplicationConfig config = new ReplicationConfig();
ReplicationGranularity granularity = ReplicationGranularity.SESSION;
config.setReplicationGranularity(granularity);
- EasyMock.expect(this.cacheSource.<String, AtomicMap<Object, Object>>getCache(this.manager)).andReturn(this.cache);
- EasyMock.expect(this.lockManagerSource.getLockManager(EasyMock.same(cache))).andReturn(null);
+ EasyMock.expect(this.cacheSource.getCache(this.manager)).andReturn(this.cache);
+ EasyMock.expect(this.lockManagerSource.getLockManager(EasyMock.same(this.cache))).andReturn(null);
EasyMock.expect(this.cache.getAdvancedCache()).andReturn(this.cache);
EasyMock.expect(this.cache.getTransactionManager()).andReturn(new BatchModeTransactionManager());
EasyMock.expect(this.cache.getConfiguration()).andReturn(new Configuration());
@@ -90,16 +103,14 @@
EasyMock.expect(this.manager.getReplicationConfig()).andReturn(config);
EasyMock.expect(this.storageFactory.createStorage(granularity, this.marshaller)).andReturn(this.storage);
- EasyMock.replay(this.storageFactory, this.marshallerFactory, this.invoker, this.manager, this.storage, this.marshaller, this.atomicMapFactory, this.cacheSource, this.cache, this.lockManagerSource);
+ this.control.replay();
- org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager<?> result = factory.getDistributedCacheManager(this.manager);
+ org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager<?> result = this.factory.getDistributedCacheManager(this.manager);
- EasyMock.verify(this.storageFactory, this.marshallerFactory, this.invoker, this.manager, this.storage, this.marshaller, this.atomicMapFactory, this.cacheSource, this.cache, this.lockManagerSource);
+ this.control.verify();
Assert.assertNotNull(result);
Assert.assertTrue(result instanceof DistributedCacheManager);
-
- EasyMock.reset(this.storageFactory, this.marshallerFactory, this.invoker, this.manager, this.storage, this.marshaller, this.atomicMapFactory, this.cacheSource, this.cache, this.lockManagerSource);
}
@Test
Modified: projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DistributedCacheManagerTest.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DistributedCacheManagerTest.java 2010-09-02 20:04:01 UTC (rev 107964)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/DistributedCacheManagerTest.java 2010-09-02 21:44:50 UTC (rev 107965)
@@ -27,6 +27,7 @@
import org.easymock.Capture;
import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
import org.infinispan.AdvancedCache;
import org.infinispan.atomic.AtomicMap;
import org.infinispan.config.Configuration;
@@ -49,7 +50,6 @@
import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
import org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingDistributableSessionData;
import org.jboss.web.tomcat.service.session.distributedcache.spi.SessionOwnershipSupport;
-import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -60,41 +60,45 @@
*/
public class DistributedCacheManagerTest
{
- private final LocalDistributableSessionManager sessionManager = EasyMock.createStrictMock(LocalDistributableSessionManager.class);
- @SuppressWarnings("unchecked")
- private final SessionAttributeStorage<OutgoingDistributableSessionData> storage = EasyMock.createStrictMock(SessionAttributeStorage.class);
- private final AdvancedCache<?, ?> cache = EasyMock.createStrictMock(AdvancedCache.class);
- @SuppressWarnings("unchecked")
- private final AdvancedCache<String, AtomicMap<Object, Object>> sessionCache = (AdvancedCache<String, AtomicMap<Object, Object>>) this.cache;
- @SuppressWarnings("unchecked")
- private final AdvancedCache<Address, String> jvmRouteCache = (AdvancedCache<Address, String>) this.cache;
- private final SharedLocalYieldingClusterLockManager lockManager = EasyMock.createStrictMock(SharedLocalYieldingClusterLockManager.class);
- private final BatchingManager batchingManager = EasyMock.createStrictMock(BatchingManager.class);
- private final CacheInvoker invoker = EasyMock.createStrictMock(CacheInvoker.class);
- private final AtomicMapFactory atomicMapFactory = EasyMock.createStrictMock(AtomicMapFactory.class);
+ private IMocksControl control;
+ private LocalDistributableSessionManager sessionManager;
+ private SessionAttributeStorage<OutgoingDistributableSessionData> storage;
+ private AdvancedCache<?, ?> cache;
+ private AdvancedCache<String, AtomicMap<Object, Object>> sessionCache;
+ private AdvancedCache<Address, String> jvmRouteCache;
+ private SharedLocalYieldingClusterLockManager lockManager;
+ private BatchingManager batchingManager;
+ private CacheInvoker invoker;
+ private AtomicMapFactory atomicMapFactory;
private DistributedCacheManager<OutgoingDistributableSessionData> manager;
+ @SuppressWarnings("unchecked")
@Before
public void before()
{
+ this.control = EasyMock.createControl();
+ this.sessionManager = this.control.createMock(LocalDistributableSessionManager.class);
+ this.storage = this.control.createMock(SessionAttributeStorage.class);
+ this.cache = this.control.createMock(AdvancedCache.class);
+ this.sessionCache = (AdvancedCache<String, AtomicMap<Object, Object>>) this.cache;
+ this.jvmRouteCache = (AdvancedCache<Address, String>) this.cache;
+ this.lockManager = this.control.createMock(SharedLocalYieldingClusterLockManager.class);
+ this.batchingManager = this.control.createMock(BatchingManager.class);
+ this.invoker = this.control.createMock(CacheInvoker.class);
+ this.atomicMapFactory = this.control.createMock(AtomicMapFactory.class);
+
Configuration configuration = new Configuration();
EasyMock.expect(this.cache.getConfiguration()).andReturn(configuration);
- EasyMock.replay(this.sessionManager, this.storage, this.cache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
this.manager = new DistributedCacheManager<OutgoingDistributableSessionData>(this.sessionManager, this.cache, this.lockManager, this.storage, this.batchingManager, this.invoker, this.atomicMapFactory);
- EasyMock.verify(this.sessionManager, this.storage, this.cache, this.batchingManager, this.invoker, this.atomicMapFactory);
- this.reset();
+ this.control.verify();
+ this.control.reset();
}
- @After
- public void reset()
- {
- EasyMock.reset(this.sessionManager, this.storage, this.cache, this.batchingManager, this.invoker, this.atomicMapFactory);
- }
-
@Test
public void start()
{
@@ -115,8 +119,8 @@
private void start(ComponentStatus status, boolean startCache, CacheMode mode, boolean distributed)
{
- EmbeddedCacheManager container = EasyMock.createStrictMock(EmbeddedCacheManager.class);
- Address address = EasyMock.createMock(Address.class);
+ EmbeddedCacheManager container = this.control.createMock(EmbeddedCacheManager.class);
+ Address address = this.control.createMock(Address.class);
String jvmRoute = "node0";
Configuration configuration = new Configuration();
@@ -139,17 +143,17 @@
container.addListener(EasyMock.same(this.manager));
+ EasyMock.expect(container.getAddress()).andReturn(address);
EasyMock.expect(this.sessionManager.getJvmRoute()).andReturn(jvmRoute);
- EasyMock.expect(container.getAddress()).andReturn(address);
EasyMock.expect(this.jvmRouteCache.putIfAbsent(EasyMock.same(address), EasyMock.same(jvmRoute))).andReturn(null);
}
- EasyMock.replay(this.sessionManager, this.storage, this.cache, this.batchingManager, this.invoker, this.atomicMapFactory, container);
+ this.control.replay();
this.manager.start();
-
- EasyMock.verify(this.sessionManager, this.storage, this.cache, this.batchingManager, this.invoker, this.atomicMapFactory, container);
- this.reset();
+
+ this.control.verify();
+ this.control.reset();
}
@Test
@@ -166,7 +170,7 @@
private void stop(CacheMode mode, boolean distributed)
{
- EmbeddedCacheManager container = EasyMock.createStrictMock(EmbeddedCacheManager.class);
+ EmbeddedCacheManager container = this.control.createMock(EmbeddedCacheManager.class);
Address address = EasyMock.createMock(Address.class);
Configuration configuration = new Configuration();
@@ -186,30 +190,30 @@
this.cache.removeListener(EasyMock.same(this.manager));
this.cache.stop();
- EasyMock.replay(this.sessionManager, this.storage, this.cache, this.batchingManager, this.invoker, this.atomicMapFactory, container);
+ this.control.replay();
this.manager.stop();
-
- EasyMock.verify(this.sessionManager, this.storage, this.cache, this.batchingManager, this.invoker, this.atomicMapFactory, container);
- this.reset();
+
+ this.control.verify();
+ this.control.reset();
}
@Test
public void sessionCreated()
{
- EasyMock.replay(this.sessionManager, this.storage, this.cache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
this.manager.sessionCreated("abc");
-
- EasyMock.verify(this.sessionManager, this.storage, this.cache, this.batchingManager, this.invoker, this.atomicMapFactory);
+
+ this.control.verify();
}
@Test
public void storeSessionData()
{
- OutgoingDistributableSessionData data = EasyMock.createNiceMock(OutgoingDistributableSessionData.class);
+ OutgoingDistributableSessionData data = this.control.createMock(OutgoingDistributableSessionData.class);
@SuppressWarnings("unchecked")
- AtomicMap<Object, Object> map = EasyMock.createNiceMock(AtomicMap.class);
+ AtomicMap<Object, Object> map = this.control.createMock(AtomicMap.class);
Capture<DistributedCacheManager.Operation<AtomicMap<Object, Object>>> capturedOperation = new Capture<DistributedCacheManager.Operation<AtomicMap<Object, Object>>>();
String sessionId = "abc";
@@ -218,7 +222,7 @@
DistributableSessionMetadata metadata = new DistributableSessionMetadata();
EasyMock.expect(this.invoker.invoke(EasyMock.same(this.sessionCache), EasyMock.capture(capturedOperation))).andReturn(map);
-
+
EasyMock.expect(data.getRealId()).andReturn(sessionId);
EasyMock.expect(data.getVersion()).andReturn(version);
EasyMock.expect(map.put(Byte.valueOf((byte) AtomicMapEntry.VERSION.ordinal()), version)).andReturn(null);
@@ -229,23 +233,22 @@
this.storage.store(EasyMock.same(map), EasyMock.same(data));
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, data, map);
+ this.control.replay();
this.manager.storeSessionData(data);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, data, map);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, data, map);
+ this.control.verify();
+ this.control.reset();
-
DistributedCacheManager.Operation<AtomicMap<Object, Object>> operation = capturedOperation.getValue();
EasyMock.expect(this.atomicMapFactory.getAtomicMap(EasyMock.same(this.sessionCache), EasyMock.same(sessionId), EasyMock.eq(true))).andReturn(map);
-
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, data, map);
+ this.control.replay();
+
AtomicMap<Object, Object> result = operation.invoke(this.sessionCache);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, data, map);
+ this.control.verify();
Assert.assertSame(map, result);
}
@@ -262,7 +265,7 @@
{
String sessionId = "abc";
@SuppressWarnings("unchecked")
- AtomicMap<Object, Object> map = EasyMock.createNiceMock(AtomicMap.class);
+ AtomicMap<Object, Object> map = this.control.createMock(AtomicMap.class);
Map<String, Object> attributes = Collections.emptyMap();
Capture<DistributedCacheManager.Operation<AtomicMap<Object, Object>>> capturedOperation = new Capture<DistributedCacheManager.Operation<AtomicMap<Object, Object>>>();
@@ -282,11 +285,11 @@
EasyMock.expect(this.storage.load(map)).andReturn(attributes);
}
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, map);
+ this.control.replay();
IncomingDistributableSessionData result = this.manager.getSessionData(sessionId, null, includeAttributes);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, map);
+ this.control.verify();
Assert.assertNotNull(result);
Assert.assertEquals(version.intValue(), result.getVersion());
@@ -315,7 +318,7 @@
Assert.assertNotNull(exception);
}
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, map);
+ this.control.reset();
DistributedCacheManager.Operation<AtomicMap<Object, Object>> operation = capturedOperation.getValue();
@@ -324,15 +327,15 @@
EasyMock.expect(this.atomicMapFactory.getAtomicMap(EasyMock.same(this.sessionCache), EasyMock.same(sessionId), EasyMock.eq(false))).andReturn(expectedMap);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, map);
+ this.control.replay();
AtomicMap<Object, Object> resultMap = operation.invoke(this.sessionCache);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, map);
+ this.control.verify();
Assert.assertSame(expectedMap, resultMap);
- this.reset();
+ this.control.reset();
}
@Test
@@ -349,15 +352,15 @@
EasyMock.expect(this.invoker.invoke(EasyMock.same(this.sessionCache), EasyMock.capture(capturedOperation))).andReturn(null);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
IncomingDistributableSessionData result = this.manager.getSessionData("abc", null, includeAttributes);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
Assert.assertNull(result);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.reset();
DistributedCacheManager.Operation<AtomicMap<Object, Object>> operation = capturedOperation.getValue();
@@ -366,15 +369,15 @@
EasyMock.expect(this.atomicMapFactory.getAtomicMap(this.sessionCache, "abc", false)).andReturn(expectedMap);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
AtomicMap<Object, Object> resultMap = operation.invoke(this.sessionCache);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
Assert.assertSame(expectedMap, resultMap);
- this.reset();
+ this.control.reset();
}
@Test
@@ -387,15 +390,15 @@
private void getSessionDataWithOwner(boolean includeAttributes)
{
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
IncomingDistributableSessionData result = this.manager.getSessionData("abc", "owner1", includeAttributes);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
Assert.assertNull(result);
- this.reset();
+ this.control.reset();
}
@Test
@@ -407,12 +410,12 @@
EasyMock.expect(this.invoker.invoke(EasyMock.same(this.sessionCache), EasyMock.capture(capturedOperation))).andReturn(null);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
this.manager.removeSession(sessionId);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
+ this.control.reset();
DistributedCacheManager.Operation<AtomicMap<Object, Object>> operation = capturedOperation.getValue();
@@ -421,11 +424,11 @@
EasyMock.expect(this.sessionCache.remove(sessionId)).andReturn(expectedMap);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
AtomicMap<Object, Object> resultMap = operation.invoke(this.sessionCache);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
Assert.assertSame(expectedMap, resultMap);
}
@@ -439,12 +442,12 @@
EasyMock.expect(this.invoker.invoke(EasyMock.same(this.sessionCache), EasyMock.capture(capturedOperation))).andReturn(null);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
this.manager.removeSessionLocal(sessionId);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
+ this.control.reset();
DistributedCacheManager.Operation<AtomicMap<Object, Object>> operation = capturedOperation.getValue();
@@ -455,11 +458,11 @@
EasyMock.expect(this.sessionCache.withFlags(Flag.CACHE_MODE_LOCAL)).andReturn(this.sessionCache);
EasyMock.expect(this.sessionCache.remove(sessionId)).andReturn(expectedMap);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
AtomicMap<Object, Object> resultMap = operation.invoke(this.sessionCache);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
Assert.assertSame(expectedMap, resultMap);
}
@@ -473,12 +476,12 @@
EasyMock.expect(this.invoker.invoke(EasyMock.same(this.sessionCache), EasyMock.capture(capturedOperation))).andReturn(null);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
this.manager.removeSessionLocal(sessionId, null);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
+ this.control.reset();
DistributedCacheManager.Operation<AtomicMap<Object, Object>> operation = capturedOperation.getValue();
@@ -489,11 +492,11 @@
EasyMock.expect(this.sessionCache.withFlags(Flag.CACHE_MODE_LOCAL)).andReturn(this.sessionCache);
EasyMock.expect(this.sessionCache.remove(sessionId)).andReturn(expectedMap);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
AtomicMap<Object, Object> resultMap = operation.invoke(this.sessionCache);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
Assert.assertSame(expectedMap, resultMap);
}
@@ -501,11 +504,11 @@
@Test
public void removeSessionLocalWithOwner()
{
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
this.manager.removeSessionLocal("abc", "owner1");
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
}
@Test
@@ -517,23 +520,23 @@
EasyMock.expect(this.invoker.invoke(EasyMock.same(this.sessionCache), EasyMock.capture(capturedOperation))).andReturn(null);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
this.manager.evictSession(sessionId);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
+ this.control.reset();
DistributedCacheManager.Operation<Void> operation = capturedOperation.getValue();
this.sessionCache.evict(sessionId);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
Void result = operation.invoke(this.sessionCache);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
Assert.assertNull(result);
}
@@ -547,23 +550,23 @@
EasyMock.expect(this.invoker.invoke(EasyMock.same(this.sessionCache), EasyMock.capture(capturedOperation))).andReturn(null);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
this.manager.evictSession(sessionId, null);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
+ this.control.reset();
DistributedCacheManager.Operation<Void> operation = capturedOperation.getValue();
this.sessionCache.evict(sessionId);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
Void result = operation.invoke(this.sessionCache);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
Assert.assertNull(result);
}
@@ -571,11 +574,11 @@
@Test
public void evictSessionLocalWithOwner()
{
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
this.manager.evictSession("abc", "owner1");
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
}
@Test
@@ -583,11 +586,11 @@
{
EasyMock.expect(this.sessionCache.keySet()).andReturn(Collections.singleton("abc"));
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
Map<String, String> result = this.manager.getSessionIds();
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
Assert.assertNotNull(result);
Assert.assertEquals(1, result.size());
@@ -606,22 +609,22 @@
{
this.invoker.setForceSynchronous(forceSynchronous);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
this.manager.setForceSynchronous(forceSynchronous);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
+ this.control.reset();
}
@Test
public void getSessionOwnershipSupport()
{
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
SessionOwnershipSupport support = manager.getSessionOwnershipSupport();
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
Assert.assertSame(manager, support);
}
@@ -629,27 +632,27 @@
@Test
public void removed()
{
- CacheEntryRemovedEvent event = EasyMock.createNiceMock(CacheEntryRemovedEvent.class);
+ CacheEntryRemovedEvent event = this.control.createMock(CacheEntryRemovedEvent.class);
EasyMock.expect(event.isPre()).andReturn(true);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.replay();
this.manager.removed(event);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.verify();
+ this.control.reset();
EasyMock.expect(event.isPre()).andReturn(false);
EasyMock.expect(event.isOriginLocal()).andReturn(true);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.replay();
this.manager.removed(event);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.verify();
+ this.control.reset();
EasyMock.expect(event.isPre()).andReturn(false);
@@ -658,53 +661,53 @@
this.sessionManager.notifyRemoteInvalidation("abc");
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.replay();
this.manager.removed(event);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.verify();
}
@Test
public void modified()
{
- CacheEntryModifiedEvent event = EasyMock.createNiceMock(CacheEntryModifiedEvent.class);
+ CacheEntryModifiedEvent event = this.control.createMock(CacheEntryModifiedEvent.class);
EasyMock.expect(event.isPre()).andReturn(true);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.replay();
this.manager.modified(event);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.verify();
+ this.control.reset();
EasyMock.expect(event.isPre()).andReturn(false);
EasyMock.expect(event.isOriginLocal()).andReturn(true);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.replay();
this.manager.modified(event);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.verify();
+ this.control.reset();
EasyMock.expect(event.isPre()).andReturn(false);
EasyMock.expect(event.isOriginLocal()).andReturn(false);
EasyMock.expect(event.getKey()).andReturn(EasyMock.createMock(Address.class));
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.replay();
this.manager.modified(event);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.verify();
+ this.control.reset();
@SuppressWarnings("unchecked")
- AtomicMap<Object, Object> map = EasyMock.createNiceMock(AtomicMap.class);
+ AtomicMap<Object, Object> map = this.control.createMock(AtomicMap.class);
Integer version = Integer.valueOf(10);
Long timestamp = Long.valueOf(System.currentTimeMillis());
@@ -721,49 +724,49 @@
EasyMock.expect(this.sessionManager.sessionChangedInDistributedCache("abc", null, version.intValue(), timestamp.longValue(), metadata)).andReturn(false);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event, map);
+ this.control.replay();
this.manager.modified(event);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event, map);
+ this.control.verify();
}
@Test
public void activated()
{
- CacheEntryActivatedEvent event = EasyMock.createNiceMock(CacheEntryActivatedEvent.class);
+ CacheEntryActivatedEvent event = this.control.createMock(CacheEntryActivatedEvent.class);
EasyMock.expect(event.isPre()).andReturn(true);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.replay();
this.manager.activated(event);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.verify();
+ this.control.reset();
EasyMock.expect(event.isPre()).andReturn(false);
EasyMock.expect(event.getKey()).andReturn(EasyMock.createMock(Address.class));
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.replay();
this.manager.activated(event);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.verify();
+ this.control.reset();
EasyMock.expect(event.isPre()).andReturn(false);
EasyMock.expect(event.getKey()).andReturn("string");
EasyMock.expect(this.sessionManager.isPassivationEnabled()).andReturn(false);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.replay();
this.manager.activated(event);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
- EasyMock.reset(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.verify();
+ this.control.reset();
EasyMock.expect(event.isPre()).andReturn(false);
@@ -771,17 +774,17 @@
EasyMock.expect(this.sessionManager.isPassivationEnabled()).andReturn(true);
this.sessionManager.sessionActivated();
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.replay();
this.manager.activated(event);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.verify();
}
@Test
public void viewChanged()
{
- ViewChangedEvent event = EasyMock.createNiceMock(ViewChangedEvent.class);
+ ViewChangedEvent event = this.control.createMock(ViewChangedEvent.class);
Address newMember = EasyMock.createMock(Address.class);
Address member = EasyMock.createMock(Address.class);
Address oldMember = EasyMock.createMock(Address.class);
@@ -795,55 +798,85 @@
EasyMock.expect(this.sessionManager.getJvmRoute()).andReturn(jvmRoute);
EasyMock.expect(this.jvmRouteCache.put(EasyMock.same(newMember), EasyMock.same(jvmRoute))).andReturn(null);
- EasyMock.replay(this.sessionManager, this.storage, this.jvmRouteCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.replay();
this.manager.viewChanged(event);
- EasyMock.verify(this.sessionManager, this.storage, this.jvmRouteCache, this.batchingManager, this.invoker, this.atomicMapFactory, event);
+ this.control.verify();
}
@Test
- public void isLocalReplicationMode()
+ public void isLocal()
{
+ this.isLocal(null, true);
+
+ DistributionManager distManager = this.control.createMock(DistributionManager.class);
+
+ this.isLocal(distManager, true);
+ this.isLocal(distManager, false);
+ }
+
+ private void isLocal(DistributionManager distManager, boolean local)
+ {
String sessionId = "ABC123";
- EasyMock.expect(this.sessionCache.getAdvancedCache()).andReturn(this.sessionCache);
- EasyMock.expect(this.sessionCache.getDistributionManager()).andReturn(null);
+ EasyMock.expect(this.jvmRouteCache.getAdvancedCache()).andReturn(this.jvmRouteCache);
+ EasyMock.expect(this.jvmRouteCache.getDistributionManager()).andReturn(distManager);
+ if (distManager != null)
+ {
+ EasyMock.expect(distManager.isLocal(sessionId)).andReturn(local);
+ }
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.replay();
- boolean result = manager.isLocal(sessionId);
+ boolean result = this.manager.isLocal(sessionId);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory);
+ this.control.verify();
- Assert.assertTrue(result);
+ Assert.assertEquals(local, result);
+
+ this.control.reset();
}
@Test
- public void isLocalDistributionMode()
+ public void locate()
{
- this.isLocalDistributionMode(true);
- this.isLocalDistributionMode(false);
- }
-
- private void isLocalDistributionMode(boolean local)
- {
- DistributionManager distManager = EasyMock.createStrictMock(DistributionManager.class);
-
String sessionId = "ABC123";
+ String expected = "node1";
- EasyMock.expect(this.sessionCache.getAdvancedCache()).andReturn(this.sessionCache);
- EasyMock.expect(this.sessionCache.getDistributionManager()).andReturn(distManager);
- EasyMock.expect(distManager.isLocal(sessionId)).andReturn(local);
+ EasyMock.expect(this.jvmRouteCache.getAdvancedCache()).andReturn(this.jvmRouteCache);
+ EasyMock.expect(this.jvmRouteCache.getDistributionManager()).andReturn(null);
+ EasyMock.expect(this.sessionManager.getJvmRoute()).andReturn(expected);
- EasyMock.replay(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, distManager);
+ this.control.replay();
- boolean result = manager.isLocal(sessionId);
+ String result = this.manager.locate(sessionId);
- EasyMock.verify(this.sessionManager, this.storage, this.sessionCache, this.batchingManager, this.invoker, this.atomicMapFactory, distManager);
+ this.control.verify();
- Assert.assertEquals(local, result);
+ Assert.assertSame(expected, result);
- this.reset();
+ this.control.reset();
+
+
+ DistributionManager distManager = this.control.createMock(DistributionManager.class);
+ Address address1 = this.control.createMock(Address.class);
+ Address address2 = this.control.createMock(Address.class);
+ Address address3 = this.control.createMock(Address.class);
+
+ EasyMock.expect(this.jvmRouteCache.getAdvancedCache()).andReturn(this.jvmRouteCache);
+ EasyMock.expect(this.jvmRouteCache.getDistributionManager()).andReturn(distManager);
+ EasyMock.expect(distManager.locate(EasyMock.same(sessionId))).andReturn(Arrays.asList(address1, address2, address3));
+ EasyMock.expect(this.jvmRouteCache.get(EasyMock.same(address1))).andReturn(null);
+ EasyMock.expect(this.jvmRouteCache.get(EasyMock.same(address2))).andReturn(expected);
+ EasyMock.expect(this.jvmRouteCache.withFlags(Flag.FORCE_SYNCHRONOUS)).andReturn(this.jvmRouteCache);
+
+ this.control.replay();
+
+ result = this.manager.locate(sessionId);
+
+ this.control.verify();
+
+ Assert.assertSame(expected, result);
}
}
Modified: projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/FineSessionAttributeStorageTest.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/FineSessionAttributeStorageTest.java 2010-09-02 20:04:01 UTC (rev 107964)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/ispn/FineSessionAttributeStorageTest.java 2010-09-02 21:44:50 UTC (rev 107965)
@@ -30,12 +30,14 @@
import java.util.Set;
import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
import org.infinispan.atomic.AtomicMap;
import org.jboss.web.tomcat.service.session.distributedcache.ispn.FineSessionAttributeStorage;
import org.jboss.web.tomcat.service.session.distributedcache.ispn.SessionAttributeStorage;
import org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingAttributeGranularitySessionData;
import org.jboss.web.tomcat.service.session.distributedcache.spi.SessionAttributeMarshaller;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -44,15 +46,24 @@
*/
public class FineSessionAttributeStorageTest
{
- private SessionAttributeMarshaller marshaller = EasyMock.createStrictMock(SessionAttributeMarshaller.class);
- private SessionAttributeStorage<OutgoingAttributeGranularitySessionData> storage = new FineSessionAttributeStorage(this.marshaller);
+ private IMocksControl control;
+ private SessionAttributeMarshaller marshaller;
+ private SessionAttributeStorage<OutgoingAttributeGranularitySessionData> storage;
+ @Before
+ public void before()
+ {
+ this.control = EasyMock.createStrictControl();
+ this.marshaller = this.control.createMock(SessionAttributeMarshaller.class);
+ this.storage = new FineSessionAttributeStorage(this.marshaller);
+ }
+
@Test
public void store()
{
@SuppressWarnings("unchecked")
- AtomicMap<Object, Object> map = EasyMock.createStrictMock(AtomicMap.class);
- OutgoingAttributeGranularitySessionData data = EasyMock.createStrictMock(OutgoingAttributeGranularitySessionData.class);
+ AtomicMap<Object, Object> map = this.control.createMock(AtomicMap.class);
+ OutgoingAttributeGranularitySessionData data = this.control.createMock(OutgoingAttributeGranularitySessionData.class);
Map<String, Object> modifiedAttributes = Collections.singletonMap("key", (Object) "value");
Set<String> removedAttributes = Collections.singleton("removed");
Object marshalledAttribute = new Object();
@@ -63,37 +74,35 @@
EasyMock.expect(data.getRemovedSessionAttributes()).andReturn(removedAttributes);
EasyMock.expect(map.remove("removed")).andReturn(null);
- EasyMock.replay(this.marshaller, map, data);
+ this.control.replay();
this.storage.store(map, data);
- EasyMock.verify(this.marshaller, map, data);
- EasyMock.reset(this.marshaller, map, data);
+ this.control.verify();
}
@Test
public void storeNull()
{
@SuppressWarnings("unchecked")
- AtomicMap<Object, Object> map = EasyMock.createStrictMock(AtomicMap.class);
- OutgoingAttributeGranularitySessionData data = EasyMock.createStrictMock(OutgoingAttributeGranularitySessionData.class);
+ AtomicMap<Object, Object> map = this.control.createMock(AtomicMap.class);
+ OutgoingAttributeGranularitySessionData data = this.control.createMock(OutgoingAttributeGranularitySessionData.class);
EasyMock.expect(data.getModifiedSessionAttributes()).andReturn(null);
EasyMock.expect(data.getRemovedSessionAttributes()).andReturn(null);
- EasyMock.replay(this.marshaller, map, data);
+ this.control.replay();
this.storage.store(map, data);
- EasyMock.verify(this.marshaller, map, data);
- EasyMock.reset(this.marshaller, map, data);
+ this.control.verify();
}
@Test
public void load() throws Exception
{
@SuppressWarnings("unchecked")
- AtomicMap<Object, Object> map = EasyMock.createStrictMock(AtomicMap.class);
+ AtomicMap<Object, Object> map = this.control.createMock(AtomicMap.class);
Object marshalledAttribute = new Object();
Map.Entry<Object, Object> nonAttributeEntry = new AbstractMap.SimpleImmutableEntry<Object, Object>(new Object(), new Object());
@@ -104,18 +113,16 @@
EasyMock.expect(map.entrySet()).andReturn(new HashSet<Map.Entry<Object, Object>>(entries));
EasyMock.expect(this.marshaller.unmarshal(EasyMock.same(marshalledAttribute))).andReturn("value");
- EasyMock.replay(this.marshaller, map);
+ this.control.replay();
Map<String, Object> result = this.storage.load(map);
- EasyMock.verify(this.marshaller, map);
+ this.control.verify();
Assert.assertNotNull(result);
Assert.assertEquals(1, result.size());
Assert.assertTrue(result.toString(), result.containsKey("key"));
Assert.assertEquals("value", result.get("key"));
-
- EasyMock.reset(this.marshaller, map);
}
}
More information about the jboss-cvs-commits
mailing list