Refactored and cleaned up deprecated and unchecked/unsafe Java and GemFire API usage.
This commit is contained in:
@@ -43,9 +43,6 @@ import com.gemstone.gemfire.NoSystemException;
|
||||
import com.gemstone.gemfire.SystemConnectException;
|
||||
import com.gemstone.gemfire.SystemIsRunningException;
|
||||
import com.gemstone.gemfire.UnmodifiableException;
|
||||
import com.gemstone.gemfire.admin.AdminException;
|
||||
import com.gemstone.gemfire.admin.RegionNotFoundException;
|
||||
import com.gemstone.gemfire.admin.RuntimeAdminException;
|
||||
import com.gemstone.gemfire.cache.CacheException;
|
||||
import com.gemstone.gemfire.cache.CacheExistsException;
|
||||
import com.gemstone.gemfire.cache.CacheLoaderException;
|
||||
@@ -58,7 +55,6 @@ import com.gemstone.gemfire.cache.DiskAccessException;
|
||||
import com.gemstone.gemfire.cache.EntryDestroyedException;
|
||||
import com.gemstone.gemfire.cache.EntryExistsException;
|
||||
import com.gemstone.gemfire.cache.EntryNotFoundException;
|
||||
import com.gemstone.gemfire.cache.EntryNotFoundInRegion;
|
||||
import com.gemstone.gemfire.cache.FailedSynchronizationException;
|
||||
import com.gemstone.gemfire.cache.OperationAbortedException;
|
||||
import com.gemstone.gemfire.cache.PartitionedRegionDistributionException;
|
||||
@@ -90,18 +86,18 @@ public abstract class GemfireCacheUtils {
|
||||
|
||||
private static Class<?> CQ_EXCEPTION_CLASS;
|
||||
|
||||
{
|
||||
Class<?> clz = null;
|
||||
static {
|
||||
Class<?> type = null;
|
||||
|
||||
try {
|
||||
type = ClassUtils.resolveClassName("com.gemstone.gemfire.cache.query.CqInvalidException",
|
||||
GemfireCacheUtils.class.getClassLoader());
|
||||
|
||||
clz = ClassUtils.resolveClassName("com.gemstone.gemfire.cache.query.CqInvalidException",
|
||||
GemfireCacheUtils.class.getClassLoader());
|
||||
|
||||
} catch (IllegalArgumentException iae) {
|
||||
}
|
||||
catch (IllegalArgumentException ignore) {
|
||||
}
|
||||
|
||||
CQ_EXCEPTION_CLASS = clz;
|
||||
CQ_EXCEPTION_CLASS = type;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +108,7 @@ public abstract class GemfireCacheUtils {
|
||||
* @param ex Gemfire unchecked exception
|
||||
* @return new the corresponding DataAccessException instance
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static DataAccessException convertGemfireAccessException(GemFireException ex) {
|
||||
if (ex instanceof CacheException) {
|
||||
if (ex instanceof CacheExistsException) {
|
||||
@@ -179,7 +176,7 @@ public abstract class GemfireCacheUtils {
|
||||
if (ex instanceof RegionDestroyedException) {
|
||||
return new InvalidDataAccessResourceUsageException(ex.getMessage(), ex);
|
||||
}
|
||||
if (ex instanceof RegionNotFoundException) {
|
||||
if (ex instanceof com.gemstone.gemfire.admin.RegionNotFoundException) {
|
||||
return new InvalidDataAccessResourceUsageException(ex.getMessage(), ex);
|
||||
}
|
||||
if (ex instanceof ResourceException) {
|
||||
@@ -198,7 +195,7 @@ public abstract class GemfireCacheUtils {
|
||||
if (ex instanceof CopyException) {
|
||||
return new GemfireSystemException(ex);
|
||||
}
|
||||
if (ex instanceof EntryNotFoundInRegion) {
|
||||
if (ex instanceof com.gemstone.gemfire.cache.EntryNotFoundInRegion) {
|
||||
return new DataRetrievalFailureException(ex.getMessage(), ex);
|
||||
}
|
||||
if (ex instanceof FunctionException) {
|
||||
@@ -234,7 +231,7 @@ public abstract class GemfireCacheUtils {
|
||||
if (ex instanceof NoSystemException) {
|
||||
return new GemfireSystemException(ex);
|
||||
}
|
||||
if (ex instanceof RuntimeAdminException) {
|
||||
if (ex instanceof com.gemstone.gemfire.admin.RuntimeAdminException) {
|
||||
return new GemfireSystemException(ex);
|
||||
}
|
||||
if (ex instanceof ServerConnectivityException) {
|
||||
@@ -263,9 +260,6 @@ public abstract class GemfireCacheUtils {
|
||||
* Dedicated method for converting exceptions changed in 6.5 that had their
|
||||
* parent changed. This method exists to 'fool' the compiler type checks
|
||||
* by loosening the type so the code compiles on both 6.5 (pre and current) branches.
|
||||
*
|
||||
* @param ex
|
||||
* @return
|
||||
*/
|
||||
static DataAccessException convertQueryExceptions(RuntimeException ex) {
|
||||
if (ex instanceof IndexInvalidException) {
|
||||
@@ -290,6 +284,7 @@ public abstract class GemfireCacheUtils {
|
||||
* @param ex Gemfire unchecked exception
|
||||
* @return new the corresponding DataAccessException instance
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static DataAccessException convertGemfireAccessException(GemFireCheckedException ex) {
|
||||
// query exceptions
|
||||
if (ex instanceof QueryException) {
|
||||
@@ -304,7 +299,7 @@ public abstract class GemfireCacheUtils {
|
||||
return new DataAccessResourceFailureException(ex.getMessage(), ex);
|
||||
}
|
||||
// admin exception
|
||||
if (ex instanceof AdminException) {
|
||||
if (ex instanceof com.gemstone.gemfire.admin.AdminException) {
|
||||
return new GemfireSystemException(ex);
|
||||
}
|
||||
// fall back
|
||||
@@ -337,9 +332,6 @@ public abstract class GemfireCacheUtils {
|
||||
|
||||
/**
|
||||
* Package protected method for detecting CqInvalidException which has been removed in GemFire 6.5 GA.
|
||||
*
|
||||
* @param ex
|
||||
* @return
|
||||
*/
|
||||
static boolean isCqInvalidException(RuntimeException ex) {
|
||||
return (CQ_EXCEPTION_CLASS != null && CQ_EXCEPTION_CLASS.isAssignableFrom(ex.getClass()));
|
||||
@@ -356,4 +348,5 @@ public abstract class GemfireCacheUtils {
|
||||
static DataAccessException convertCqInvalidException(RuntimeException ex) {
|
||||
return new GemfireQueryException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.data.gemfire;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import com.gemstone.gemfire.cache.AttributesFactory;
|
||||
import com.gemstone.gemfire.cache.RegionAttributes;
|
||||
|
||||
/**
|
||||
@@ -27,9 +26,15 @@ import com.gemstone.gemfire.cache.RegionAttributes;
|
||||
* a XML 'factory-method' tag.
|
||||
* <p/>
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.FactoryBean
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
* @see com.gemstone.gemfire.cache.AttributesFactory
|
||||
* @see com.gemstone.gemfire.cache.RegionAttributes
|
||||
*/
|
||||
public class RegionAttributesFactoryBean extends AttributesFactory implements FactoryBean<RegionAttributes>,
|
||||
InitializingBean {
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RegionAttributesFactoryBean extends com.gemstone.gemfire.cache.AttributesFactory
|
||||
implements FactoryBean<RegionAttributes>, InitializingBean {
|
||||
|
||||
private RegionAttributes attributes;
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.AttributesFactory;
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.CacheListener;
|
||||
import com.gemstone.gemfire.cache.CacheLoader;
|
||||
@@ -66,7 +65,6 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
private boolean autoStartup = true;
|
||||
private boolean close = true;
|
||||
private boolean destroy = false;
|
||||
private boolean running;
|
||||
@@ -288,13 +286,13 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
* @see com.gemstone.gemfire.cache.RegionAttributes#getDataPolicy
|
||||
* @see com.gemstone.gemfire.cache.DataPolicy
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "unchecked"})
|
||||
@SuppressWarnings({ "deprecation", "unchecked" })
|
||||
DataPolicy getDataPolicy(final RegionFactory regionFactory) {
|
||||
// NOTE cannot pass RegionAttributes.class as the "targetType" on the second invocation of getFieldValue(..)
|
||||
// since the "regionAttributes" field is naively of the implementation class type rather than the interface
|
||||
// type... so much for programming to interfaces.
|
||||
return ((RegionAttributes) getFieldValue(getFieldValue(regionFactory, "attrsFactory", AttributesFactory.class),
|
||||
"regionAttributes", null)).getDataPolicy();
|
||||
return ((RegionAttributes) getFieldValue(getFieldValue(regionFactory, "attrsFactory",
|
||||
com.gemstone.gemfire.cache.AttributesFactory.class), "regionAttributes", null)).getDataPolicy();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -415,7 +413,7 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
void validateRegionAttributes(final RegionAttributes regionAttributes) {
|
||||
AttributesFactory.validateAttributes(regionAttributes);
|
||||
com.gemstone.gemfire.cache.AttributesFactory.validateAttributes(regionAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -725,7 +723,7 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
*/
|
||||
@Override
|
||||
public boolean isAutoStartup() {
|
||||
return this.autoStartup;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.AttributesFactory;
|
||||
import com.gemstone.gemfire.cache.CacheListener;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
|
||||
@@ -40,9 +39,9 @@ import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
* (e.g. ReplicatedRegionFactoryBean) instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class SubRegionFactoryBean<K, V> extends AttributesFactory<K, V> implements FactoryBean<Region<K, V>>,
|
||||
InitializingBean {
|
||||
@SuppressWarnings({"deprecation", "unused"})
|
||||
public class SubRegionFactoryBean<K, V> extends com.gemstone.gemfire.cache.AttributesFactory<K, V>
|
||||
implements FactoryBean<Region<K, V>>, InitializingBean {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -56,7 +55,6 @@ public class SubRegionFactoryBean<K, V> extends AttributesFactory<K, V> implemen
|
||||
private Region<?, ?> parentRegion;
|
||||
private Region<K, V> subRegion;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String name;
|
||||
private String regionName;
|
||||
|
||||
@@ -125,8 +123,8 @@ public class SubRegionFactoryBean<K, V> extends AttributesFactory<K, V> implemen
|
||||
|
||||
/**
|
||||
* Sets the cache listeners used for the region used by this factory. Used
|
||||
* only when a new region is created.Overrides the settings specified
|
||||
* through {@link #setAttributes(com.gemstone.gemfire.cache.RegionAttributes)}.
|
||||
* only when a new region is created. Overrides the settings specified
|
||||
* through {@link setAttributes(com.gemstone.gemfire.cache.RegionAttributes)}.
|
||||
*
|
||||
* @param cacheListeners the cacheListeners to set on a newly created region
|
||||
*/
|
||||
@@ -134,10 +132,6 @@ public class SubRegionFactoryBean<K, V> extends AttributesFactory<K, V> implemen
|
||||
this.cacheListeners = cacheListeners;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param gatewaySenders
|
||||
*/
|
||||
public void setGatewaySenders(Object[] gatewaySenders) {
|
||||
this.gatewaySenders = gatewaySenders;
|
||||
}
|
||||
@@ -145,7 +139,6 @@ public class SubRegionFactoryBean<K, V> extends AttributesFactory<K, V> implemen
|
||||
/**
|
||||
* Set to true if the subregion should already exist, e.g., specified by
|
||||
* <lookup-region>
|
||||
* @param lookupOnly
|
||||
*/
|
||||
public void setLookupOnly(boolean lookupOnly) {
|
||||
this.lookupOnly = lookupOnly;
|
||||
@@ -153,7 +146,6 @@ public class SubRegionFactoryBean<K, V> extends AttributesFactory<K, V> implemen
|
||||
|
||||
/**
|
||||
* Set the bean name - the same as the subregion full path
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
@@ -161,7 +153,6 @@ public class SubRegionFactoryBean<K, V> extends AttributesFactory<K, V> implemen
|
||||
|
||||
/**
|
||||
* Set the simple name of the region
|
||||
* @param regionName
|
||||
*/
|
||||
public void setRegionName(String regionName) {
|
||||
this.regionName = regionName;
|
||||
@@ -169,7 +160,6 @@ public class SubRegionFactoryBean<K, V> extends AttributesFactory<K, V> implemen
|
||||
|
||||
/**
|
||||
* Set the parent Region
|
||||
* @param parent
|
||||
*/
|
||||
public void setParent(Region<?, ?> parent) {
|
||||
this.parentRegion = parent;
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class PoolFactoryBean implements FactoryBean<Pool>, InitializingBean,
|
||||
DisposableBean, BeanNameAware, BeanFactoryAware {
|
||||
|
||||
@@ -115,9 +116,10 @@ public class PoolFactoryBean implements FactoryBean<Pool>, InitializingBean,
|
||||
try {
|
||||
ClientCacheFactoryBean clientCacheFactoryBean = beanFactory.getBean(ClientCacheFactoryBean.class);
|
||||
properties = clientCacheFactoryBean.getProperties();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
}
|
||||
|
||||
connectToTemporaryDs(properties);
|
||||
|
||||
}
|
||||
@@ -393,10 +395,12 @@ public class PoolFactoryBean implements FactoryBean<Pool>, InitializingBean,
|
||||
* initialize a client-like Distributed System before initializing
|
||||
* the pool
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
static void connectToTemporaryDs(Properties properties) {
|
||||
Properties props = properties != null? (Properties) properties.clone() : new Properties();
|
||||
props.setProperty("mcast-port", "0");
|
||||
props.setProperty("locators", "");
|
||||
DistributedSystem.connect(props);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,9 +19,6 @@ package org.springframework.data.gemfire.config;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import com.gemstone.gemfire.cache.DiskWriteAttributes;
|
||||
import com.gemstone.gemfire.cache.DiskWriteAttributesFactory;
|
||||
|
||||
/**
|
||||
* Simple utility class used for defining nested factory-method like definitions
|
||||
* w/o polluting the container with useless beans.
|
||||
@@ -30,11 +27,12 @@ import com.gemstone.gemfire.cache.DiskWriteAttributesFactory;
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
class DiskWriteAttributesFactoryBean implements FactoryBean<DiskWriteAttributes>, InitializingBean {
|
||||
@SuppressWarnings({ "deprecation", "unused" })
|
||||
class DiskWriteAttributesFactoryBean implements FactoryBean<com.gemstone.gemfire.cache.DiskWriteAttributes>, InitializingBean {
|
||||
|
||||
private DiskWriteAttributes attributes;
|
||||
private com.gemstone.gemfire.cache.DiskWriteAttributes attributes;
|
||||
|
||||
private DiskWriteAttributesFactory attrFactory;
|
||||
private com.gemstone.gemfire.cache.DiskWriteAttributesFactory attrFactory;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
@@ -42,13 +40,13 @@ class DiskWriteAttributesFactoryBean implements FactoryBean<DiskWriteAttributes>
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiskWriteAttributes getObject() throws Exception {
|
||||
public com.gemstone.gemfire.cache.DiskWriteAttributes getObject() throws Exception {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return (attributes != null ? attributes.getClass() : DiskWriteAttributes.class);
|
||||
return (attributes != null ? attributes.getClass() : com.gemstone.gemfire.cache.DiskWriteAttributes.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,7 +54,8 @@ class DiskWriteAttributesFactoryBean implements FactoryBean<DiskWriteAttributes>
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setDiskAttributesFactory(DiskWriteAttributesFactory dwaf) {
|
||||
public void setDiskAttributesFactory(com.gemstone.gemfire.cache.DiskWriteAttributesFactory dwaf) {
|
||||
this.attrFactory = dwaf;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,8 +39,9 @@ import com.gemstone.gemfire.cache.server.ServerLoadProbe;
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class CacheServerFactoryBean implements FactoryBean<CacheServer>, InitializingBean, DisposableBean,
|
||||
SmartLifecycle {
|
||||
SmartLifecycle {
|
||||
|
||||
private boolean autoStartup = true;
|
||||
private boolean notifyBySubscription = CacheServer.DEFAULT_NOTIFY_BY_SUBSCRIPTION;
|
||||
@@ -68,7 +69,7 @@ public class CacheServerFactoryBean implements FactoryBean<CacheServer>, Initial
|
||||
private String hostNameForClients = CacheServer.DEFAULT_HOSTNAME_FOR_CLIENTS;
|
||||
private String subscriptionDiskStore;
|
||||
|
||||
private String[] serverGroups = CacheServer.DEFAULT_GROUPS;
|
||||
private String[] serverGroups = {};
|
||||
|
||||
private SubscriptionEvictionPolicy subscriptionEvictionPolicy = SubscriptionEvictionPolicy.valueOf(
|
||||
ClientSubscriptionConfig.DEFAULT_EVICTION_POLICY.toUpperCase());
|
||||
@@ -85,6 +86,7 @@ public class CacheServerFactoryBean implements FactoryBean<CacheServer>, Initial
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void afterPropertiesSet() throws IOException {
|
||||
Assert.notNull(cache, "A GemFire Cache is required.");
|
||||
|
||||
|
||||
@@ -23,10 +23,13 @@ import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
|
||||
/**
|
||||
* Spring Framework {@link Cache} implementation using a GemFire {@link Region} underneath.
|
||||
* Supports Gemfire 6.5 or higher.
|
||||
*
|
||||
* Spring Framework {@link Cache} implementation backed by a GemFire {@link Region}.
|
||||
* <p/>
|
||||
* Supports GemFire 6.5 or higher.
|
||||
* <p/>
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
*
|
||||
*/
|
||||
public class GemfireCache implements Cache {
|
||||
|
||||
@@ -64,7 +67,9 @@ public class GemfireCache implements Cache {
|
||||
return (value == null ? null : new SimpleValueWrapper(value));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void put(Object key, Object value) {
|
||||
region.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ public class CacheServerIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testCacheServerRunningWithSubscription() {
|
||||
assertNotNull(cacheServer);
|
||||
assertTrue(cacheServer.isRunning());
|
||||
|
||||
@@ -17,14 +17,13 @@
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import com.gemstone.gemfire.cache.util.ObjectSizer;
|
||||
import com.gemstone.gemfire.cache.util.ObjectSizerImpl;
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class SimpleObjectSizer implements ObjectSizer {
|
||||
|
||||
private static final ObjectSizer sizer = new ObjectSizerImpl();
|
||||
private static final ObjectSizer sizer = ObjectSizer.DEFAULT;
|
||||
|
||||
@Override
|
||||
public int sizeof(Object o) {
|
||||
|
||||
@@ -55,6 +55,7 @@ public class CacheServerNamespaceTest {
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testBasicCacheServer() throws Exception {
|
||||
CacheServer cacheServer = context.getBean("advanced-config", CacheServer.class);
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ public class ClientRegionNamespaceTest {
|
||||
assertEquals(5, attrs.getEvictionAttributes().getMaximum());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "rawtypes" })
|
||||
public void testPersistent() throws Exception {
|
||||
assertTrue(context.containsBean("persistent"));
|
||||
Region region = context.getBean("persistent", Region.class);
|
||||
|
||||
@@ -29,16 +29,14 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.query.Index;
|
||||
import com.gemstone.gemfire.cache.query.IndexType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
*/
|
||||
@ContextConfiguration(locations="index-ns.xml", initializers=GemfireTestApplicationContextInitializer.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations="index-ns.xml",
|
||||
initializers=GemfireTestApplicationContextInitializer.class)
|
||||
@SuppressWarnings("deprecation")
|
||||
public class IndexNamespaceTest {
|
||||
|
||||
private final String name = "test-index";
|
||||
@@ -49,6 +47,7 @@ public class IndexNamespaceTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
Cache cache = (Cache) context.getBean("gemfireCache");
|
||||
|
||||
if (cache.getRegion(name) == null) {
|
||||
cache.createRegionFactory().create("test-index");
|
||||
}
|
||||
@@ -62,7 +61,7 @@ public class IndexNamespaceTest {
|
||||
assertEquals("status", idx.getIndexedExpression());
|
||||
assertEquals("simple", idx.getName());
|
||||
assertEquals(name, idx.getRegion().getName());
|
||||
assertEquals(IndexType.FUNCTIONAL, idx.getType());
|
||||
assertEquals(com.gemstone.gemfire.cache.query.IndexType.FUNCTIONAL, idx.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,6 +72,7 @@ public class IndexNamespaceTest {
|
||||
assertEquals("tsi.name", idx.getIndexedExpression());
|
||||
assertEquals("complex-index", idx.getName());
|
||||
assertEquals(name, idx.getRegion().getName());
|
||||
assertEquals(IndexType.HASH, idx.getType());
|
||||
assertEquals(com.gemstone.gemfire.cache.query.IndexType.HASH, idx.getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ public class LocalRegionNamespaceTest {
|
||||
assertTrue(context.containsBean("simple"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "rawtypes" })
|
||||
public void testPublishingLocal() throws Exception {
|
||||
assertTrue(context.containsBean("pub"));
|
||||
RegionFactoryBean fb = context.getBean("&pub", RegionFactoryBean.class);
|
||||
@@ -117,4 +117,4 @@ public class LocalRegionNamespaceTest {
|
||||
RegionAttributes attrs = region.getAttributes();
|
||||
assertTrue(attrs.getDataPolicy().withPersistence());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PdxDiskStoreAwareBeanFactoryPostProcessorTest {
|
||||
return (array == null || array.length == 0);
|
||||
}
|
||||
|
||||
protected static boolean isBeanType(final BeanDefinition beanDefinition, final Class beanType) {
|
||||
protected static boolean isBeanType(final BeanDefinition beanDefinition, final Class<?> beanType) {
|
||||
return (beanDefinition instanceof AbstractBeanDefinition
|
||||
&& ((AbstractBeanDefinition) beanDefinition).hasBeanClass()
|
||||
&& beanType.isAssignableFrom(((AbstractBeanDefinition) beanDefinition).getBeanClass()));
|
||||
|
||||
@@ -56,13 +56,13 @@ public class ReplicatedRegionNamespaceTest {
|
||||
public void testBasicReplica() throws Exception {
|
||||
assertTrue(context.containsBean("simple"));
|
||||
RegionFactoryBean fb = context.getBean("&simple", RegionFactoryBean.class);
|
||||
assertEquals(false ,(Boolean)TestUtils.readField("close", fb));
|
||||
assertEquals(false, TestUtils.readField("close", fb));
|
||||
RegionAttributes attrs = TestUtils.readField("attributes", fb);
|
||||
assertFalse(attrs.getConcurrencyChecksEnabled());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "rawtypes" })
|
||||
public void testPublishingReplica() throws Exception {
|
||||
assertTrue(context.containsBean("pub"));
|
||||
RegionFactoryBean fb = context.getBean("&pub", RegionFactoryBean.class);
|
||||
@@ -122,4 +122,4 @@ public class ReplicatedRegionNamespaceTest {
|
||||
assertEquals(existing, context.getBean("lookup"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,8 @@ import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
import org.springframework.data.gemfire.ForkUtil;
|
||||
|
||||
import com.gemstone.gemfire.cache.AttributesFactory;
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.CacheFactory;
|
||||
import com.gemstone.gemfire.cache.DataPolicy;
|
||||
@@ -31,11 +29,11 @@ import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.RegionFactory;
|
||||
import com.gemstone.gemfire.cache.Scope;
|
||||
import com.gemstone.gemfire.cache.server.CacheServer;
|
||||
import com.gemstone.gemfire.distributed.DistributedSystem;
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class CacheServerProcess {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
@@ -75,4 +73,5 @@ public class CacheServerProcess {
|
||||
System.out.println("Waiting for shutdown");
|
||||
bufferedReader.readLine();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -262,6 +262,7 @@ public class FunctionArgumentResolverTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testMethodWithFunctionContextAndResultSender() throws NoSuchMethodException {
|
||||
FunctionContext functionContext = mock(FunctionContext.class);
|
||||
ResultSender resultSender = mock(ResultSender.class);
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.gemstone.gemfire.cache.Region;
|
||||
* @see org.springframework.data.gemfire.mapping.Regions
|
||||
* @since 1.3.4
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class RegionsTest {
|
||||
|
||||
private MappingContext mockMappingContext;
|
||||
@@ -74,7 +75,6 @@ public class RegionsTest {
|
||||
}
|
||||
|
||||
@Before
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setup() {
|
||||
mockMappingContext = mock(GemfireMappingContext.class, "GemfireMappingContext");
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.Properties;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
|
||||
import com.gemstone.gemfire.cache.AttributesFactory;
|
||||
import com.gemstone.gemfire.cache.CacheFactory;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.distributed.DistributedSystem;
|
||||
@@ -36,6 +35,7 @@ public class GemfireCacheTest extends AbstractNativeCacheTest<Region<Object, Obj
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"deprecation", "unchecked" })
|
||||
protected Region<Object, Object> createNativeCache() throws Exception {
|
||||
com.gemstone.gemfire.cache.Cache instance = null;
|
||||
try {
|
||||
@@ -49,9 +49,10 @@ public class GemfireCacheTest extends AbstractNativeCacheTest<Region<Object, Obj
|
||||
}
|
||||
Region reg = instance.getRegion(CACHE_NAME);
|
||||
if (reg == null) {
|
||||
reg = instance.createRegion(CACHE_NAME, new AttributesFactory().create());
|
||||
reg = instance.createRegion(CACHE_NAME, new com.gemstone.gemfire.cache.AttributesFactory().create());
|
||||
}
|
||||
|
||||
return reg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,11 +19,8 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codehaus.jackson.JsonGenerationException;
|
||||
import org.codehaus.jackson.map.JsonMappingException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -38,11 +35,12 @@ import com.gemstone.gemfire.cache.query.SelectResults;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SuppressWarnings("unchecked")
|
||||
public class JSONRegionAdviceTest {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Resource(name="someRegion")
|
||||
private Region region;
|
||||
@@ -75,14 +73,14 @@ public class JSONRegionAdviceTest {
|
||||
map.put("key1", "{\"hello1\":\"world1\"}");
|
||||
map.put("key2", "{\"hello2\":\"world2\"}");
|
||||
region.putAll(map);
|
||||
List<String> keys = Arrays.asList(new String[]{"key1","key2"});
|
||||
List<String> keys = Arrays.asList("key1", "key2");
|
||||
Map<String,String> results = region.getAll(keys);
|
||||
assertEquals("{\"hello1\":\"world1\"}",results.get("key1"));
|
||||
assertEquals("{\"hello2\":\"world2\"}",results.get("key2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testObjectToJSon() throws JsonGenerationException, JsonMappingException, IOException {
|
||||
public void testObjectToJSon() throws IOException {
|
||||
Person dave = new Person(1L,"Dave","Turanski");
|
||||
region.put("dave",dave);
|
||||
String json = (String)region.get("dave");
|
||||
|
||||
@@ -24,13 +24,11 @@ import java.io.File;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import com.gemstone.gemfire.cache.AttributesFactory;
|
||||
import com.gemstone.gemfire.cache.CacheListener;
|
||||
import com.gemstone.gemfire.cache.CacheLoader;
|
||||
import com.gemstone.gemfire.cache.CacheWriter;
|
||||
import com.gemstone.gemfire.cache.CustomExpiry;
|
||||
import com.gemstone.gemfire.cache.DataPolicy;
|
||||
import com.gemstone.gemfire.cache.DiskWriteAttributes;
|
||||
import com.gemstone.gemfire.cache.EvictionAttributes;
|
||||
import com.gemstone.gemfire.cache.ExpirationAttributes;
|
||||
import com.gemstone.gemfire.cache.MembershipAttributes;
|
||||
@@ -53,7 +51,7 @@ public class MockRegionFactory<K,V> {
|
||||
private static QueryService queryService = mock(QueryService.class);
|
||||
private static RegionService regionService = mock(RegionService.class);
|
||||
|
||||
private AttributesFactory<K,V> attributesFactory;
|
||||
private com.gemstone.gemfire.cache.AttributesFactory<K,V> attributesFactory;
|
||||
|
||||
private final StubCache cache;
|
||||
|
||||
@@ -65,10 +63,10 @@ public class MockRegionFactory<K,V> {
|
||||
return createMockRegionFactory(null);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({ "deprecation", "rawtypes", "unchecked" })
|
||||
public RegionFactory<K, V> createMockRegionFactory(RegionAttributes<K,V> attributes) {
|
||||
attributesFactory = (attributes != null ? new AttributesFactory<K,V>(attributes)
|
||||
: new AttributesFactory<K,V>());
|
||||
attributesFactory = (attributes != null ? new com.gemstone.gemfire.cache.AttributesFactory<K,V>(attributes)
|
||||
: new com.gemstone.gemfire.cache.AttributesFactory<K,V>());
|
||||
|
||||
//Workaround for GemFire bug
|
||||
if (attributes !=null) {
|
||||
@@ -340,10 +338,12 @@ public class MockRegionFactory<K,V> {
|
||||
}
|
||||
});
|
||||
|
||||
when(regionFactory.setDiskWriteAttributes(any(DiskWriteAttributes.class))).thenAnswer(new Answer<RegionFactory>(){
|
||||
when(regionFactory.setDiskWriteAttributes(any(com.gemstone.gemfire.cache.DiskWriteAttributes.class)))
|
||||
.thenAnswer(new Answer<RegionFactory>(){
|
||||
@Override
|
||||
public RegionFactory answer(InvocationOnMock invocation) throws Throwable {
|
||||
DiskWriteAttributes val = (DiskWriteAttributes)invocation.getArguments()[0];
|
||||
com.gemstone.gemfire.cache.DiskWriteAttributes val =
|
||||
(com.gemstone.gemfire.cache.DiskWriteAttributes) invocation.getArguments()[0];
|
||||
attributesFactory.setDiskWriteAttributes(val);
|
||||
return regionFactory;
|
||||
}
|
||||
@@ -505,8 +505,7 @@ public class MockRegionFactory<K,V> {
|
||||
when(region.getAttributes()).thenAnswer(new Answer<RegionAttributes>() {
|
||||
@Override
|
||||
public RegionAttributes answer(InvocationOnMock invocation) throws Throwable {
|
||||
RegionAttributes attributes = attributesFactory.create();
|
||||
return attributes;
|
||||
return attributesFactory.create();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -523,9 +522,7 @@ public class MockRegionFactory<K,V> {
|
||||
String subRegionPath = (parentRegionName.startsWith("/") ? parentRegionName+"/"+subRegionName
|
||||
: "/"+parentRegionName+"/"+subRegionName);
|
||||
|
||||
Region region = cache.getRegion(subRegionPath);
|
||||
|
||||
return region;
|
||||
return cache.getRegion(subRegionPath);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package org.springframework.data.gemfire.test;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -10,7 +14,6 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.naming.Context;
|
||||
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
@@ -38,12 +41,10 @@ import com.gemstone.gemfire.cache.query.Index;
|
||||
import com.gemstone.gemfire.cache.query.IndexExistsException;
|
||||
import com.gemstone.gemfire.cache.query.IndexInvalidException;
|
||||
import com.gemstone.gemfire.cache.query.IndexNameConflictException;
|
||||
import com.gemstone.gemfire.cache.query.IndexType;
|
||||
import com.gemstone.gemfire.cache.query.QueryService;
|
||||
import com.gemstone.gemfire.cache.query.RegionNotFoundException;
|
||||
import com.gemstone.gemfire.cache.server.CacheServer;
|
||||
import com.gemstone.gemfire.cache.snapshot.CacheSnapshotService;
|
||||
import com.gemstone.gemfire.cache.util.BridgeServer;
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.util.GatewayConflictResolver;
|
||||
import com.gemstone.gemfire.cache.util.GatewayHub;
|
||||
@@ -58,6 +59,8 @@ import com.gemstone.gemfire.i18n.LogWriterI18n;
|
||||
import com.gemstone.gemfire.pdx.PdxInstance;
|
||||
import com.gemstone.gemfire.pdx.PdxInstanceFactory;
|
||||
import com.gemstone.gemfire.pdx.PdxSerializer;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class StubCache implements Cache {
|
||||
|
||||
private Properties properties;
|
||||
@@ -390,7 +393,7 @@ public class StubCache implements Cache {
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public BridgeServer addBridgeServer() {
|
||||
public com.gemstone.gemfire.cache.util.BridgeServer addBridgeServer() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -462,8 +465,7 @@ public class StubCache implements Cache {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <K, V> RegionFactory<K, V> createRegionFactory() {
|
||||
RegionFactory<K, V> regionFactory = new MockRegionFactory<K,V>(this).createRegionFactory();
|
||||
return regionFactory;
|
||||
return new MockRegionFactory<K,V>(this).createRegionFactory();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -472,8 +474,7 @@ public class StubCache implements Cache {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <K, V> RegionFactory<K, V> createRegionFactory(RegionShortcut shortCut) {
|
||||
RegionFactory<K, V> regionFactory = new MockRegionFactory<K,V>(this).createRegionFactory();
|
||||
return regionFactory;
|
||||
return new MockRegionFactory<K,V>(this).createRegionFactory();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -482,8 +483,7 @@ public class StubCache implements Cache {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <K, V> RegionFactory<K, V> createRegionFactory(String arg0) {
|
||||
RegionFactory<K, V> regionFactory = new MockRegionFactory<K,V>(this).createRegionFactory();
|
||||
return regionFactory;
|
||||
return new MockRegionFactory<K,V>(this).createRegionFactory();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -491,8 +491,7 @@ public class StubCache implements Cache {
|
||||
*/
|
||||
@Override
|
||||
public <K, V> RegionFactory<K, V> createRegionFactory(RegionAttributes<K, V> regionAttributes) {
|
||||
RegionFactory<K, V> regionFactory = new MockRegionFactory<K,V>(this).createMockRegionFactory(regionAttributes);
|
||||
return regionFactory;
|
||||
return new MockRegionFactory<K,V>(this).createMockRegionFactory(regionAttributes);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -754,9 +753,6 @@ public class StubCache implements Cache {
|
||||
this.searchTimeout = arg0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
DistributedSystem mockDistributedSystem() {
|
||||
DistributedSystem ds = mock(DistributedSystem.class);
|
||||
DistributedMember dm = mockDistributedMember();
|
||||
@@ -777,10 +773,7 @@ public class StubCache implements Cache {
|
||||
return dm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
CacheServer mockCacheServer() {
|
||||
CacheServer mockCacheServer() {
|
||||
return new StubCacheServer();
|
||||
}
|
||||
|
||||
@@ -814,7 +807,7 @@ public class StubCache implements Cache {
|
||||
String indexName = (String)invocation.getArguments()[0];
|
||||
String indexedExpression = (String)invocation.getArguments()[1];
|
||||
String fromClause = (String)invocation.getArguments()[2];
|
||||
return mockIndex(indexName, IndexType.FUNCTIONAL, indexedExpression, fromClause, null);
|
||||
return mockIndex(indexName, com.gemstone.gemfire.cache.query.IndexType.FUNCTIONAL, indexedExpression, fromClause, null);
|
||||
}
|
||||
});
|
||||
when(qs.createIndex(anyString(), anyString(),anyString(),anyString())).thenAnswer(new Answer<Index>(){
|
||||
@@ -824,7 +817,7 @@ public class StubCache implements Cache {
|
||||
String indexedExpression = (String)invocation.getArguments()[1];
|
||||
String fromClause = (String)invocation.getArguments()[2];
|
||||
String imports = (String)invocation.getArguments()[3];
|
||||
return mockIndex(indexName, IndexType.FUNCTIONAL, indexedExpression, fromClause, imports);
|
||||
return mockIndex(indexName, com.gemstone.gemfire.cache.query.IndexType.FUNCTIONAL, indexedExpression, fromClause, imports);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -835,7 +828,7 @@ public class StubCache implements Cache {
|
||||
String indexedExpression = (String)invocation.getArguments()[1];
|
||||
String fromClause = (String)invocation.getArguments()[2];
|
||||
|
||||
return mockIndex(indexName, IndexType.PRIMARY_KEY, indexedExpression, fromClause, null);
|
||||
return mockIndex(indexName, com.gemstone.gemfire.cache.query.IndexType.PRIMARY_KEY, indexedExpression, fromClause, null);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -846,7 +839,7 @@ public class StubCache implements Cache {
|
||||
String indexedExpression = (String)invocation.getArguments()[1];
|
||||
String fromClause = (String)invocation.getArguments()[2];
|
||||
|
||||
return mockIndex(indexName, IndexType.HASH, indexedExpression, fromClause, null);
|
||||
return mockIndex(indexName, com.gemstone.gemfire.cache.query.IndexType.HASH, indexedExpression, fromClause, null);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -858,15 +851,16 @@ public class StubCache implements Cache {
|
||||
String fromClause = (String)invocation.getArguments()[2];
|
||||
String imports = (String)invocation.getArguments()[3];
|
||||
|
||||
return mockIndex(indexName, IndexType.HASH, indexedExpression, fromClause, imports);
|
||||
return mockIndex(indexName, com.gemstone.gemfire.cache.query.IndexType.HASH, indexedExpression, fromClause, imports);
|
||||
}
|
||||
});
|
||||
|
||||
return qs;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
Index mockIndex(String indexName, IndexType indexType,String indexedExpression, String fromClause, String imports){
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
Index mockIndex(String indexName, com.gemstone.gemfire.cache.query.IndexType indexType, String indexedExpression,
|
||||
String fromClause, String imports){
|
||||
Index idx = mock(Index.class);
|
||||
when(idx.getFromClause()).thenReturn(fromClause);
|
||||
when(idx.getIndexedExpression()).thenReturn(indexedExpression);
|
||||
@@ -888,18 +882,8 @@ public class StubCache implements Cache {
|
||||
return this.allRegions;
|
||||
}
|
||||
|
||||
GatewaySender mockGatewaySender(String id, int remoteId) {
|
||||
GatewaySender gwSender = mock(GatewaySender.class);
|
||||
when(gwSender.getId()).thenReturn(id);
|
||||
when(gwSender.getRemoteDSId()).thenReturn(remoteId);
|
||||
return gwSender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param props
|
||||
*/
|
||||
public void setProperties(Properties props) {
|
||||
this.properties = props;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.gemstone.gemfire.distributed.DistributedMember;
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class StubCacheServer implements CacheServer {
|
||||
|
||||
private boolean isRunning;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.test;
|
||||
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -20,19 +19,20 @@ import static org.mockito.Mockito.when;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import com.gemstone.gemfire.cache.util.Gateway.OrderPolicy;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayEventFilter;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySenderFactory;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
/**
|
||||
* The StubGatewaySenderFactory class for testing purposes.
|
||||
* <p/>
|
||||
* @author David Turanski
|
||||
*
|
||||
* @see com.gemstone.gemfire.cache.wan.GatewaySenderFactory
|
||||
*/
|
||||
public class StubGatewaySenderFactory implements GatewaySenderFactory {
|
||||
|
||||
@@ -210,4 +210,5 @@ public class StubGatewaySenderFactory implements GatewaySenderFactory {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user