From c77089f48cfb1b5c470892a3f72b13f1789bc7a5 Mon Sep 17 00:00:00 2001 From: John Blum Date: Thu, 17 Nov 2016 13:43:11 -0800 Subject: [PATCH] SGF-567 - Remove old GemFire GatewayHub functionality. Remove other deprecated and no longer existing GemFire classes in GemFire 9. --- build.gradle | 2 + pom.xml | 12 + .../data/gemfire/CacheFactoryBean.java | 20 +- .../data/gemfire/GemfireCacheUtils.java | 5 - .../data/gemfire/RegionFactoryBean.java | 159 ++++----- .../data/gemfire/RegionLookupFactoryBean.java | 9 +- .../client/ClientCacheFactoryBean.java | 32 +- .../annotation/CacheServerApplication.java | 8 +- .../annotation/ClientCacheApplication.java | 8 +- .../annotation/PeerCacheApplication.java | 8 +- .../CustomEditorBeanFactoryPostProcessor.java | 3 - .../gemfire/config/xml/GatewayHubParser.java | 156 --------- .../config/xml/GemfireNamespaceHandler.java | 1 - .../wan/AsyncEventQueueFactoryBean.java | 4 +- .../gemfire/wan/GatewayHubFactoryBean.java | 221 ------------ .../data/gemfire/wan/GatewayProxy.java | 215 ------------ .../gemfire/wan/GatewaySenderFactoryBean.java | 4 +- .../gemfire/wan/GatewaySenderWrapper.java | 4 +- .../gemfire/wan/StartupPolicyConverter.java | 48 --- .../data/gemfire/wan/StartupPolicyType.java | 78 ----- ...ledClientCacheRegionsIntegrationTests.java | 2 + .../data/gemfire/GemfireUtilsTest.java | 38 --- ...itorBeanFactoryPostProcessorUnitTests.java | 4 - .../config/xml/GatewayHubNamespaceTest.java | 221 ------------ .../xml/GemfireV6GatewayNamespaceTest.java | 105 ------ .../xml/GemfireV7GatewayNamespaceTest.java | 2 +- .../TemplateClientRegionNamespaceTest.java | 2 - .../xml/TemplateRegionsNamespaceTests.java | 3 - .../adapter/QueryListenerAdapterTest.java | 124 +++---- .../data/gemfire/test/MockGatewayFactory.java | 266 --------------- .../gemfire/test/MockGatewayHubFactory.java | 179 ---------- .../data/gemfire/test/MockRegionFactory.java | 17 - .../test/StubAsyncEventQueueFactory.java | 13 +- .../data/gemfire/test/StubCache.java | 81 +---- .../test/StubCacheTransactionMananger.java | 199 ++++++----- .../test/StubGatewaySenderFactory.java | 8 +- .../gemfire/test/StubResourceManager.java | 21 ++ .../gemfire/test/support/FileSystemUtils.java | 2 +- .../wan/AsyncEventQueueFactoryBeanTest.java | 5 +- .../wan/GatewayHubFactoryBeanTest.java | 323 ------------------ .../wan/GatewaySenderFactoryBeanTest.java | 4 +- .../wan/StartupPolicyConverterUnitTests.java | 82 ----- .../gemfire/wan/StartupPolicyTypeTest.java | 62 ---- .../xml/GatewayHubNamespaceTest-context.xml | 50 --- .../data/gemfire/config/xml/gateway-v6-ns.xml | 40 --- template.mf | 4 +- 46 files changed, 339 insertions(+), 2515 deletions(-) delete mode 100644 src/main/java/org/springframework/data/gemfire/config/xml/GatewayHubParser.java delete mode 100644 src/main/java/org/springframework/data/gemfire/wan/GatewayHubFactoryBean.java delete mode 100644 src/main/java/org/springframework/data/gemfire/wan/GatewayProxy.java delete mode 100644 src/main/java/org/springframework/data/gemfire/wan/StartupPolicyConverter.java delete mode 100644 src/main/java/org/springframework/data/gemfire/wan/StartupPolicyType.java delete mode 100644 src/test/java/org/springframework/data/gemfire/config/xml/GatewayHubNamespaceTest.java delete mode 100644 src/test/java/org/springframework/data/gemfire/config/xml/GemfireV6GatewayNamespaceTest.java delete mode 100644 src/test/java/org/springframework/data/gemfire/test/MockGatewayFactory.java delete mode 100644 src/test/java/org/springframework/data/gemfire/test/MockGatewayHubFactory.java delete mode 100644 src/test/java/org/springframework/data/gemfire/wan/GatewayHubFactoryBeanTest.java delete mode 100644 src/test/java/org/springframework/data/gemfire/wan/StartupPolicyConverterUnitTests.java delete mode 100644 src/test/java/org/springframework/data/gemfire/wan/StartupPolicyTypeTest.java delete mode 100644 src/test/resources/org/springframework/data/gemfire/config/xml/GatewayHubNamespaceTest-context.xml delete mode 100644 src/test/resources/org/springframework/data/gemfire/config/xml/gateway-v6-ns.xml diff --git a/build.gradle b/build.gradle index 22ff96cd..5b3524df 100644 --- a/build.gradle +++ b/build.gradle @@ -98,6 +98,8 @@ dependencies { // GemFire compile("io.pivotal.gemfire:geode-core:$gemfireVersion") + compile("io.pivotal.gemfire:geode-cq:$gemfireVersion") + compile("io.pivotal.gemfire:geode-wan:$gemfireVersion") optional("com.google.code.findbugs:annotations:$googleCodeFindbugsVersion") runtime("antlr:antlr:$antlrVersion") diff --git a/pom.xml b/pom.xml index d3da75ba..0fe05b93 100644 --- a/pom.xml +++ b/pom.xml @@ -71,6 +71,18 @@ ${gemfire.version} + + io.pivotal.gemfire + geode-cq + ${gemfire.version} + + + + io.pivotal.gemfire + geode-wan + ${gemfire.version} + + antlr antlr diff --git a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java index 4f6733f9..44b04c88 100644 --- a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java @@ -52,20 +52,21 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.context.Phased; import org.springframework.core.io.Resource; import org.springframework.dao.DataAccessException; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.dao.support.PersistenceExceptionTranslator; import org.springframework.data.gemfire.util.CollectionUtils; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; /** - * FactoryBean used to configure a GemFire peer Cache node. Allows either retrieval of an existing, opened Cache - * or the creation of a new Cache instance. - *

- * This class implements the {@link org.springframework.dao.support.PersistenceExceptionTranslator} - * interface, as auto-detected by Spring's - * {@link org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor}, for AOP-based translation - * of native Exceptions to Spring DataAccessExceptions. Hence, the presence of this class automatically enables - * a PersistenceExceptionTranslationPostProcessor to translate GemFire Exceptions appropriately. + * Spring {@link FactoryBean} used to configure a GemFire peer Cache. This class either looks up an existing, open + * {@link Cache} instance already or creates a new {@link Cache} instance. + * + * This class implements the {@link org.springframework.dao.support.PersistenceExceptionTranslator} interface, + * as auto-detected by Spring's {@link PersistenceExceptionTranslationPostProcessor}, for AOP-based translation + * of native GemFire Exceptions to Spring {@link DataAccessException}. Hence, the presence of this class + * automatically enables a {@link PersistenceExceptionTranslationPostProcessor} to translate GemFire Exceptions + * appropriately. * * @author Costin Leau * @author David Turanski @@ -86,7 +87,7 @@ import org.springframework.util.ObjectUtils; */ @SuppressWarnings("unused") public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, FactoryBean, - Phased, InitializingBean, DisposableBean, PersistenceExceptionTranslator { + InitializingBean, DisposableBean, PersistenceExceptionTranslator, Phased { private boolean close = true; private boolean useBeanFactoryLocator = false; @@ -1090,5 +1091,4 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, this.props = props; } } - } diff --git a/src/main/java/org/springframework/data/gemfire/GemfireCacheUtils.java b/src/main/java/org/springframework/data/gemfire/GemfireCacheUtils.java index e3aa8b2f..93aab126 100644 --- a/src/main/java/org/springframework/data/gemfire/GemfireCacheUtils.java +++ b/src/main/java/org/springframework/data/gemfire/GemfireCacheUtils.java @@ -293,10 +293,6 @@ public abstract class GemfireCacheUtils { if (ex instanceof VersionException) { return new DataAccessResourceFailureException(ex.getMessage(), ex); } - // util.version exception (seems quite similar to the exception above) - if (ex instanceof org.apache.geode.cache.util.VersionException) { - return new DataAccessResourceFailureException(ex.getMessage(), ex); - } // admin exception if (ex instanceof org.apache.geode.admin.AdminException) { return new GemfireSystemException(ex); @@ -347,5 +343,4 @@ public abstract class GemfireCacheUtils { static DataAccessException convertCqInvalidException(RuntimeException ex) { return new GemfireQueryException(ex); } - } diff --git a/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java b/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java index 4dc58f81..dad5b456 100644 --- a/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java @@ -39,29 +39,27 @@ import org.apache.geode.cache.asyncqueue.AsyncEventQueue; import org.apache.geode.cache.wan.GatewaySender; import org.apache.geode.internal.cache.UserSpecifiedRegionAttributes; import org.springframework.beans.factory.DisposableBean; +import org.springframework.beans.factory.FactoryBean; import org.springframework.context.SmartLifecycle; import org.springframework.core.io.Resource; -import org.springframework.data.gemfire.client.ClientRegionFactoryBean; +import org.springframework.data.gemfire.util.ArrayUtils; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; /** - * Base class for FactoryBeans used to create GemFire {@link Region}s. Will try - * to first locate the region (by name) and, in case none if found, proceed to - * creating one using the given settings. - * - * Note that this factory bean allows for very flexible creation of GemFire - * {@link Region}. For "client" regions however, see - * {@link ClientRegionFactoryBean} which offers easier configuration and - * defaults. + * Abstract base class and Spring {@link FactoryBean} for constructing and initializing a GemFire {@link Region}. * * @author Costin Leau * @author David Turanski * @author John Blum + * @see org.springframework.beans.factory.DisposableBean + * @see org.springframework.context.SmartLifecycle + * @see org.springframework.data.gemfire.RegionLookupFactoryBean */ @SuppressWarnings("unused") -public abstract class RegionFactoryBean extends RegionLookupFactoryBean implements DisposableBean, SmartLifecycle { +public abstract class RegionFactoryBean extends RegionLookupFactoryBean + implements DisposableBean, SmartLifecycle { protected final Log log = LogFactory.getLog(getClass()); @@ -69,9 +67,10 @@ public abstract class RegionFactoryBean extends RegionLookupFactoryBean[] cacheListeners; private CacheLoader cacheLoader; @@ -80,8 +79,7 @@ public abstract class RegionFactoryBean extends RegionLookupFactoryBean attributes; @@ -92,7 +90,6 @@ public abstract class RegionFactoryBean extends RegionLookupFactoryBean extends RegionLookupFactoryBean lookupFallback(GemFireCache gemfireCache, String regionName) throws Exception { Assert.isTrue(gemfireCache instanceof Cache, String.format("Unable to create Regions from '%1$s'.", gemfireCache)); @@ -110,38 +107,12 @@ public abstract class RegionFactoryBean extends RegionLookupFactoryBean regionFactory = createRegionFactory(cache); - if (hubId != null) { - enableGateway = (enableGateway == null || enableGateway); - Assert.isTrue(enableGateway, "The 'hubId' requires the 'enableGateway' property to be true."); - regionFactory.setGatewayHubId(hubId); + for (AsyncEventQueue asyncEventQueue : ArrayUtils.nullSafeArray(asyncEventQueues, AsyncEventQueue.class)) { + regionFactory.addAsyncEventQueueId(asyncEventQueue.getId()); } - if (enableGateway != null) { - if (enableGateway) { - Assert.notNull(hubId, "The 'enableGateway' property requires the 'hubId' property to be set."); - } - regionFactory.setEnableGateway(enableGateway); - } - - if (!ObjectUtils.isEmpty(gatewaySenders)) { - Assert.isTrue(hubId == null, "It is invalid to configure a region with both a hubId and gatewaySenders." - + " Note that the enableGateway and hubId properties are deprecated since Gemfire 7.0"); - - for (Object gatewaySender : gatewaySenders) { - regionFactory.addGatewaySenderId(((GatewaySender) gatewaySender).getId()); - } - } - - if (!ObjectUtils.isEmpty(asyncEventQueues)) { - for (Object asyncEventQueue : asyncEventQueues) { - regionFactory.addAsyncEventQueueId(((AsyncEventQueue) asyncEventQueue).getId()); - } - } - - if (!ObjectUtils.isEmpty(cacheListeners)) { - for (CacheListener listener : cacheListeners) { - regionFactory.addCacheListener(listener); - } + for (CacheListener listener : ArrayUtils.nullSafeArray(cacheListeners, CacheListener.class)) { + regionFactory.addCacheListener(listener); } if (cacheLoader != null) { @@ -152,6 +123,10 @@ public abstract class RegionFactoryBean extends RegionLookupFactoryBean extends RegionLookupFactoryBean createRegionFactory(final Cache cache) { if (shortcut != null) { - RegionFactory regionFactory = mergeRegionAttributes( - cache.createRegionFactory(shortcut), attributes); + RegionFactory regionFactory = mergeRegionAttributes(cache.createRegionFactory(shortcut), attributes); setDataPolicy(getDataPolicy(regionFactory)); return regionFactory; } @@ -266,7 +240,7 @@ public abstract class RegionFactoryBean extends RegionLookupFactoryBean RegionFactory mergeRegionAttributes(final RegionFactory regionFactory, final RegionAttributes regionAttributes) { @@ -313,7 +287,7 @@ public abstract class RegionFactoryBean extends RegionLookupFactoryBean void mergePartitionAttributes(final RegionFactory regionFactory, - final RegionAttributes regionAttributes) { + RegionAttributes regionAttributes) { // NOTE PartitionAttributes are created by certain RegionShortcuts; need the null check since RegionAttributes // can technically return null! @@ -545,7 +519,7 @@ public abstract class RegionFactoryBean extends RegionLookupFactoryBean extends RegionLookupFactoryBean extends RegionLookupFactoryBean extends RegionLookupFactoryBean extends RegionLookupFactoryBean implements FactoryBean>, InitializingBean, BeanNameAware { +public abstract class RegionLookupFactoryBean + implements FactoryBean>, InitializingBean, BeanNameAware { protected final Log log = LogFactory.getLog(getClass()); @@ -54,6 +55,7 @@ public abstract class RegionLookupFactoryBean implements FactoryBean implements FactoryBean getObjectType() { ClientCache cache = getCache(); @@ -430,13 +432,17 @@ public class ClientCacheFactoryBean extends CacheFactoryBean implements Applicat return durableClientTimeout; } - /* (non-Javadoc) */ + /** + * @inheritDoc + */ @Override public final void setEnableAutoReconnect(final Boolean enableAutoReconnect) { throw new UnsupportedOperationException("Auto-reconnect does not apply to clients."); } - /* (non-Javadoc) */ + /** + * @inheritDoc + */ @Override public final Boolean getEnableAutoReconnect() { return Boolean.FALSE; @@ -769,13 +775,17 @@ public class ClientCacheFactoryBean extends CacheFactoryBean implements Applicat return threadLocalConnections; } - /* (non-Javadoc) */ + /** + * @inheritDoc + */ @Override public final void setUseClusterConfiguration(Boolean useClusterConfiguration) { throw new UnsupportedOperationException("Shared, cluster-based configuration is not applicable for clients."); } - /* (non-Javadoc) */ + /** + * @inheritDoc + */ @Override public final Boolean getUseClusterConfiguration() { return Boolean.FALSE; diff --git a/src/main/java/org/springframework/data/gemfire/config/annotation/CacheServerApplication.java b/src/main/java/org/springframework/data/gemfire/config/annotation/CacheServerApplication.java index c5ca2f78..a1ac04ff 100644 --- a/src/main/java/org/springframework/data/gemfire/config/annotation/CacheServerApplication.java +++ b/src/main/java/org/springframework/data/gemfire/config/annotation/CacheServerApplication.java @@ -82,9 +82,9 @@ public @interface CacheServerApplication { /** * Configures the percentage of heap at or above which the cache is considered in danger of becoming inoperable. * - * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_CRITICAL_HEAP_PERCENTAGE + * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_CRITICAL_PERCENTAGE */ - float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_HEAP_PERCENTAGE; + float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_PERCENTAGE; /** * By default, a GemFire member (both locators and servers) will attempt to reconnect and reinitialize the cache @@ -99,9 +99,9 @@ public @interface CacheServerApplication { * Configures the percentage of heap at or above which the eviction should begin on Regions configured * for HeapLRU eviction. * - * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_EVICTION_HEAP_PERCENTAGE + * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_EVICTION_PERCENTAGE */ - float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_HEAP_PERCENTAGE; + float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_PERCENTAGE; /** * Configures the ip address or host name that server locators will tell clients that this cache server diff --git a/src/main/java/org/springframework/data/gemfire/config/annotation/ClientCacheApplication.java b/src/main/java/org/springframework/data/gemfire/config/annotation/ClientCacheApplication.java index 4abcf527..2c3981fd 100644 --- a/src/main/java/org/springframework/data/gemfire/config/annotation/ClientCacheApplication.java +++ b/src/main/java/org/springframework/data/gemfire/config/annotation/ClientCacheApplication.java @@ -63,9 +63,9 @@ public @interface ClientCacheApplication { /** * Configures the percentage of heap at or above which the cache is considered in danger of becoming inoperable. * - * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_CRITICAL_HEAP_PERCENTAGE + * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_CRITICAL_PERCENTAGE */ - float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_HEAP_PERCENTAGE; + float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_PERCENTAGE; /** * Used only for clients in a client/server installation. If set, this indicates that the client is durable @@ -84,9 +84,9 @@ public @interface ClientCacheApplication { * Configures the percentage of heap at or above which the eviction should begin on Regions configured * for HeapLRU eviction. * - * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_EVICTION_HEAP_PERCENTAGE + * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_EVICTION_PERCENTAGE */ - float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_HEAP_PERCENTAGE; + float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_PERCENTAGE; /** * Configures the free connection timeout for this pool. diff --git a/src/main/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplication.java b/src/main/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplication.java index baf874af..e107391d 100644 --- a/src/main/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplication.java +++ b/src/main/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplication.java @@ -60,9 +60,9 @@ public @interface PeerCacheApplication { /** * Configures the percentage of heap at or above which the cache is considered in danger of becoming inoperable. * - * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_CRITICAL_HEAP_PERCENTAGE + * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_CRITICAL_PERCENTAGE */ - float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_HEAP_PERCENTAGE; + float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_PERCENTAGE; /** * By default, a GemFire member (both locators and servers) will attempt to reconnect and reinitialize the cache @@ -77,9 +77,9 @@ public @interface PeerCacheApplication { * Configures the percentage of heap at or above which the eviction should begin on Regions configured * for HeapLRU eviction. * - * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_EVICTION_HEAP_PERCENTAGE + * @see org.apache.geode.cache.control.ResourceManager#DEFAULT_EVICTION_PERCENTAGE */ - float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_HEAP_PERCENTAGE; + float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_PERCENTAGE; /** * Configures the list of GemFire Locators defining the cluster to which this GemFire cache data node diff --git a/src/main/java/org/springframework/data/gemfire/config/support/CustomEditorBeanFactoryPostProcessor.java b/src/main/java/org/springframework/data/gemfire/config/support/CustomEditorBeanFactoryPostProcessor.java index 8fa65cc0..1e97adff 100644 --- a/src/main/java/org/springframework/data/gemfire/config/support/CustomEditorBeanFactoryPostProcessor.java +++ b/src/main/java/org/springframework/data/gemfire/config/support/CustomEditorBeanFactoryPostProcessor.java @@ -45,8 +45,6 @@ import org.springframework.data.gemfire.support.AbstractPropertyEditorConverterS import org.springframework.data.gemfire.support.ConnectionEndpoint; import org.springframework.data.gemfire.support.ConnectionEndpointList; import org.springframework.data.gemfire.wan.OrderPolicyConverter; -import org.springframework.data.gemfire.wan.StartupPolicyConverter; -import org.springframework.data.gemfire.wan.StartupPolicyType; /** * {@link CustomEditorBeanFactoryPostProcessor} is a Spring {@link BeanFactoryPostProcessor} implementation @@ -78,7 +76,6 @@ public class CustomEditorBeanFactoryPostProcessor implements BeanFactoryPostProc beanFactory.registerCustomEditor(InterestResultPolicy.class, InterestResultPolicyConverter.class); beanFactory.registerCustomEditor(Gateway.OrderPolicy.class, OrderPolicyConverter.class); beanFactory.registerCustomEditor(Scope.class, ScopeConverter.class); - beanFactory.registerCustomEditor(StartupPolicyType.class, StartupPolicyConverter.class); beanFactory.registerCustomEditor(SubscriptionEvictionPolicy.class, SubscriptionEvictionPolicyConverter.class); } diff --git a/src/main/java/org/springframework/data/gemfire/config/xml/GatewayHubParser.java b/src/main/java/org/springframework/data/gemfire/config/xml/GatewayHubParser.java deleted file mode 100644 index d78da5e4..00000000 --- a/src/main/java/org/springframework/data/gemfire/config/xml/GatewayHubParser.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2010-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.data.gemfire.config.xml; - -import java.util.List; - -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.support.ManagedList; -import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser; -import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.data.gemfire.wan.GatewayHubFactoryBean; -import org.springframework.data.gemfire.wan.GatewayProxy; -import org.springframework.util.CollectionUtils; -import org.springframework.util.xml.DomUtils; -import org.w3c.dom.Element; - -/** - * Bean definition parser for the <gfe:gateway-hub> SDG XML namespace (XSD) element. - * - * @author David Turanski - * @author John Blum - * @see org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser - * @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean - * @see org.springframework.data.gemfire.wan.GatewayProxy - */ -class GatewayHubParser extends AbstractSimpleBeanDefinitionParser { - - /** - * {@inheritDoc} - */ - @Override - protected Class getBeanClass(Element element) { - return GatewayHubFactoryBean.class; - } - - /** - * {@inheritDoc} - */ - @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { - builder.addConstructorArgReference(ParsingUtils.resolveCacheReference(element.getAttribute("cache-ref"))); - builder.setLazyInit(false); - - ParsingUtils.setPropertyValue(element, builder, "bind-address"); - ParsingUtils.setPropertyValue(element, builder, "manual-start"); - ParsingUtils.setPropertyValue(element, builder, "max-connections"); - ParsingUtils.setPropertyValue(element, builder, "max-time-between-pings", "maximumTimeBetweenPings"); - ParsingUtils.setPropertyValue(element, builder, "port"); - ParsingUtils.setPropertyValue(element, builder, "socket-buffer-size"); - ParsingUtils.setPropertyValue(element, builder, "startup-policy"); - - parseGateways(element, parserContext, builder); - } - - /* (non-Javadoc) */ - private void parseGateways(Element element, ParserContext parserContext, BeanDefinitionBuilder gatewayHubBuilder) { - List gatewayElements = DomUtils.getChildElementsByTagName(element, "gateway"); - - if (!CollectionUtils.isEmpty(gatewayElements)) { - ManagedList gateways = new ManagedList(); - - for (Element gatewayElement : gatewayElements) { - BeanDefinitionBuilder gatewayBuilder = BeanDefinitionBuilder.genericBeanDefinition(GatewayProxy.class); - - ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "gateway-id", "id"); - ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "concurrency-level"); - ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "order-policy"); - ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "socket-buffer-size"); - ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "socket-read-timeout"); - - parseGatewayEndpoints(gatewayElement, gatewayBuilder); - parseGatewayListeners(gatewayElement, parserContext, gatewayBuilder); - parseGatewayQueue(gatewayElement, gatewayBuilder); - - gateways.add(gatewayBuilder.getBeanDefinition()); - } - - gatewayHubBuilder.addPropertyValue("gateways", gateways); - } - } - - /* (non-Javadoc) */ - private void parseGatewayEndpoints(Element gatewayElement, BeanDefinitionBuilder gatewayBuilder) { - List endpointElements = DomUtils.getChildElementsByTagName(gatewayElement, "gateway-endpoint"); - - if (!CollectionUtils.isEmpty(endpointElements)) { - ManagedList endpoints = new ManagedList(); - - for (Element endpointElement : endpointElements) { - BeanDefinitionBuilder endpointBuilder = BeanDefinitionBuilder.genericBeanDefinition( - GatewayProxy.GatewayEndpoint.class); - - ParsingUtils.setPropertyValue(endpointElement, endpointBuilder, "endpoint-id", "id"); - ParsingUtils.setPropertyValue(endpointElement, endpointBuilder, "host"); - ParsingUtils.setPropertyValue(endpointElement, endpointBuilder, "port"); - - endpoints.add(endpointBuilder.getBeanDefinition()); - } - - gatewayBuilder.addPropertyValue("endpoints", endpoints); - } - } - - /* (non-Javadoc) */ - private void parseGatewayListeners(Element gatewayElement, ParserContext parserContext, - BeanDefinitionBuilder gatewayBuilder) { - - Element gatewayListenerElement = DomUtils.getChildElementByTagName(gatewayElement, "gateway-listener"); - - if (gatewayListenerElement != null) { - gatewayBuilder.addPropertyValue("listeners", ParsingUtils.parseRefOrNestedBeanDeclaration( - parserContext, gatewayListenerElement, gatewayBuilder)); - } - } - - /* (non-Javadoc) */ - private void parseGatewayQueue(Element gatewayElement, BeanDefinitionBuilder gatewayBuilder) { - Element gatewayQueueElement = DomUtils.getChildElementByTagName(gatewayElement, "gateway-queue"); - - if (gatewayQueueElement != null) { - BeanDefinitionBuilder queueBuilder = BeanDefinitionBuilder.genericBeanDefinition( - GatewayProxy.GatewayQueue.class); - - ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "alert-threshold"); - ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "batch-size"); - ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "batch-time-interval"); - ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "disk-store-ref"); - ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "enable-batch-conflation"); - ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "maximum-queue-memory"); - ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "persistent"); - - /* Make sure any disk store is created first */ - if (gatewayQueueElement.hasAttribute("disk-store-ref")) { - gatewayBuilder.addDependsOn(gatewayQueueElement.getAttribute("disk-store-ref")); - } - - gatewayBuilder.addPropertyValue("queue", queueBuilder.getBeanDefinition()); - } - } -} diff --git a/src/main/java/org/springframework/data/gemfire/config/xml/GemfireNamespaceHandler.java b/src/main/java/org/springframework/data/gemfire/config/xml/GemfireNamespaceHandler.java index 4a1dd2e5..6038b781 100644 --- a/src/main/java/org/springframework/data/gemfire/config/xml/GemfireNamespaceHandler.java +++ b/src/main/java/org/springframework/data/gemfire/config/xml/GemfireNamespaceHandler.java @@ -43,7 +43,6 @@ class GemfireNamespaceHandler extends NamespaceHandlerSupport { registerBeanDefinitionParser("cq-listener-container", new GemfireListenerContainerParser()); registerBeanDefinitionParser("disk-store", new DiskStoreParser()); registerBeanDefinitionParser("function-service", new FunctionServiceParser()); - registerBeanDefinitionParser("gateway-hub", new GatewayHubParser()); registerBeanDefinitionParser("gateway-receiver", new GatewayReceiverParser()); registerBeanDefinitionParser("gateway-sender", new GatewaySenderParser()); registerBeanDefinitionParser("index", new IndexParser()); diff --git a/src/main/java/org/springframework/data/gemfire/wan/AsyncEventQueueFactoryBean.java b/src/main/java/org/springframework/data/gemfire/wan/AsyncEventQueueFactoryBean.java index e3dc62f3..fe0e4f7f 100644 --- a/src/main/java/org/springframework/data/gemfire/wan/AsyncEventQueueFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/wan/AsyncEventQueueFactoryBean.java @@ -20,7 +20,7 @@ import org.apache.geode.cache.CacheClosedException; import org.apache.geode.cache.asyncqueue.AsyncEventListener; import org.apache.geode.cache.asyncqueue.AsyncEventQueue; import org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory; -import org.apache.geode.cache.util.Gateway; +import org.apache.geode.cache.wan.GatewaySender; import org.springframework.util.Assert; /** @@ -123,7 +123,7 @@ public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean< Assert.isTrue(VALID_ORDER_POLICIES.contains(orderPolicy.toUpperCase()), String.format( "The value of Order Policy '$1%s' is invalid.", orderPolicy)); - asyncEventQueueFactory.setOrderPolicy(Gateway.OrderPolicy.valueOf(orderPolicy.toUpperCase())); + asyncEventQueueFactory.setOrderPolicy(GatewaySender.OrderPolicy.valueOf(orderPolicy.toUpperCase())); } if (persistent != null) { diff --git a/src/main/java/org/springframework/data/gemfire/wan/GatewayHubFactoryBean.java b/src/main/java/org/springframework/data/gemfire/wan/GatewayHubFactoryBean.java deleted file mode 100644 index 8fffd9ce..00000000 --- a/src/main/java/org/springframework/data/gemfire/wan/GatewayHubFactoryBean.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright 2010-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.gemfire.wan; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.util.Gateway; -import org.apache.geode.cache.util.GatewayEventListener; -import org.apache.geode.cache.util.GatewayHub; -import org.apache.geode.cache.util.GatewayQueueAttributes; -import org.springframework.data.gemfire.wan.GatewayProxy.GatewayQueue; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -/** - * FactoryBean for creating a GemFire {@link GatewayHub} (deprecated in Gemfire 7). - * - * @author David Turanski - * @author John Blum - * @see org.springframework.data.gemfire.wan.AbstractWANComponentFactoryBean - * @see org.apache.geode.cache.Cache - * @see org.apache.geode.cache.util.Gateway - * @see org.apache.geode.cache.util.GatewayHub - * @see org.apache.geode.cache.util.GatewayEventListener - * @see org.apache.geode.cache.util.GatewayQueueAttributes - */ -@SuppressWarnings({"deprecation", "unused" }) -public class GatewayHubFactoryBean extends AbstractWANComponentFactoryBean { - - private Boolean manualStart; - - private GatewayHub gatewayHub; - - private Integer maxConnections; - private Integer maximumTimeBetweenPings; - private Integer port; - private Integer socketBufferSize; - - private List gateways; - - private StartupPolicyType startupPolicy; - - private String bindAddress; - - /** - * Constructs an instance of the GatewayHubFactoryBean class used to create GemFire WAN GatewayHubs initialized - * with the specified GemFire Cache. - * - * @param cache a reference to the Gemfire Cache. - * @see org.apache.geode.cache.Cache - */ - public GatewayHubFactoryBean(final Cache cache) { - super(cache); - } - - @Override - public GatewayHub getObject() throws Exception { - return gatewayHub; - } - - @Override - public Class getObjectType() { - return (gatewayHub != null ? gatewayHub.getClass() : GatewayHub.class); - } - - @Override - protected void doInit() { - gatewayHub = cache.addGatewayHub(getName(), getPort()); - - if (log.isDebugEnabled()) { - log.debug(String.format("Adding GemFire GatewayHub (%1$s)", getName())); - } - - Assert.notNull(cache.getGatewayHub(getName())); - - gatewayHub.setBindAddress(getBindAddress()); - gatewayHub.setManualStart(isManualStart(GatewayHub.DEFAULT_MANUAL_START)); - gatewayHub.setMaxConnections(getMaxConnections()); - gatewayHub.setMaximumTimeBetweenPings(getMaximumTimeBetweenPings()); - gatewayHub.setSocketBufferSize(getSocketBufferSize()); - gatewayHub.setStartupPolicy(getStartupPolicy().getName()); - - configureGateways(); - autoStart(); - } - - private void configureGateways() { - for (GatewayProxy gatewayProxy : getGateways()) { - Gateway gateway = gatewayHub.addGateway(gatewayProxy.getId(), gatewayProxy.getConcurrencyLevel()); - - for (GatewayProxy.GatewayEndpoint endpoint : gatewayProxy.getEndpoints()) { - gateway.addEndpoint(endpoint.getId(), endpoint.getHost(), endpoint.getPort()); - } - - for (GatewayEventListener listener : gatewayProxy.getListeners()) { - gateway.addListener(listener); - } - - gateway.setOrderPolicy(gatewayProxy.getOrderPolicy()); - gateway.setSocketBufferSize(gatewayProxy.getSocketBufferSize()); - gateway.setSocketReadTimeout(gatewayProxy.getSocketReadTimeout()); - - if (gatewayProxy.getQueue() != null) { - GatewayQueue queue = gatewayProxy.getQueue(); - GatewayQueueAttributes queueAttributes = gateway.getQueueAttributes(); - - queueAttributes.setAlertThreshold(queue.getAlertThreshold()); - queueAttributes.setBatchConflation(queue.getEnableBatchConflation()); - queueAttributes.setBatchSize(queue.getBatchSize()); - queueAttributes.setBatchTimeInterval(queue.getBatchTimeInterval()); - queueAttributes.setMaximumQueueMemory(queue.getMaximumQueueMemory()); - queueAttributes.setEnablePersistence(queue.getPersistent()); - - if (queue.getDiskStoreRef() != null) { - queueAttributes.setDiskStoreName(queue.getDiskStoreRef()); - } - } - } - } - - private void autoStart() { - if (!gatewayHub.getManualStart()) { - try { - gatewayHub.start(); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - } - - public void setBindAddress(String bindAddress) { - this.bindAddress = bindAddress; - } - - /* (non-Javadoc) */ - String getBindAddress() { - return (StringUtils.hasText(bindAddress) ? bindAddress : GatewayHub.DEFAULT_BIND_ADDRESS); - } - - public void setGateways(List gateways) { - this.gateways = gateways; - } - - /* (non-Javadoc) */ - List getGateways() { - return (gateways != null ? gateways : Collections.emptyList()); - } - - public void setManualStart(Boolean manualStart) { - this.manualStart = manualStart; - } - - /* (non-Javadoc) */ - boolean isManualStart(final boolean defaultManualStart) { - return (manualStart != null ? manualStart : defaultManualStart); - } - - public void setMaxConnections(Integer maxConnections) { - this.maxConnections = maxConnections; - } - - // (non-Javadoc) - Integer getMaxConnections() { - return (maxConnections != null ? maxConnections : GatewayHub.DEFAULT_MAX_CONNECTIONS); - } - - public void setMaximumTimeBetweenPings(Integer maximumTimeBetweenPings) { - this.maximumTimeBetweenPings = maximumTimeBetweenPings; - } - - // (non-Javadoc) - Integer getMaximumTimeBetweenPings() { - return (maximumTimeBetweenPings != null ? maximumTimeBetweenPings - : GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS); - } - - public void setPort(Integer port) { - this.port = port; - } - - /* (non-Javadoc) */ - Integer getPort() { - return (port != null ? port : GatewayHub.DEFAULT_PORT); - } - - public void setSocketBufferSize(Integer socketBufferSize) { - this.socketBufferSize = socketBufferSize; - } - - /* (non-Javadoc) */ - Integer getSocketBufferSize() { - return (socketBufferSize != null ? socketBufferSize : GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE); - } - - public void setStartupPolicy(StartupPolicyType startupPolicy) { - this.startupPolicy = startupPolicy; - } - - /* (non-Javadoc) */ - StartupPolicyType getStartupPolicy() { - return (startupPolicy != null ? startupPolicy : StartupPolicyType.DEFAULT); - } - -} diff --git a/src/main/java/org/springframework/data/gemfire/wan/GatewayProxy.java b/src/main/java/org/springframework/data/gemfire/wan/GatewayProxy.java deleted file mode 100644 index 3570ab12..00000000 --- a/src/main/java/org/springframework/data/gemfire/wan/GatewayProxy.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright 2010-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.gemfire.wan; - -import java.util.Collections; -import java.util.List; - -import org.apache.geode.cache.util.Gateway; -import org.apache.geode.cache.util.GatewayEventListener; -import org.apache.geode.cache.util.GatewayQueueAttributes; - -/** - * The GatewayProxy class used to allow decoupling of 'gateway' parsing from 'gateway-hub' parsing. - * - * @author David Turanski - * @author John Blum - * @since org.apache.geode.cache.util.Gateway - */ -@SuppressWarnings({ "deprecation", "unused" }) -public class GatewayProxy { - - private Gateway.OrderPolicy orderPolicy; - - private GatewayQueue queue; - - private Integer concurrencyLevel = Gateway.DEFAULT_CONCURRENCY_LEVEL; - private Integer socketBufferSize = Gateway.DEFAULT_SOCKET_BUFFER_SIZE; - private Integer socketReadTimeout = Gateway.DEFAULT_SOCKET_READ_TIMEOUT; - - private List endpoints; - private List listeners; - - private String id; - - public void setConcurrencyLevel(Integer concurrencyLevel) { - this.concurrencyLevel = concurrencyLevel; - } - - public Integer getConcurrencyLevel() { - return (concurrencyLevel != null ? concurrencyLevel : Gateway.DEFAULT_CONCURRENCY_LEVEL); - } - - public void setEndpoints(List endpoints) { - this.endpoints = endpoints; - } - - public List getEndpoints() { - return (endpoints != null ? endpoints : Collections.emptyList()); - } - - public void setId(String id) { - this.id = id; - } - - public String getId() { - return this.id; - } - - public void setListeners(List listeners) { - this.listeners = listeners; - } - - public List getListeners() { - return (listeners != null ? listeners : Collections.emptyList()); - } - - public void setOrderPolicy(Gateway.OrderPolicy orderPolicy) { - this.orderPolicy = orderPolicy; - } - - public Gateway.OrderPolicy getOrderPolicy() { - return this.orderPolicy; - } - - public void setQueue(GatewayQueue queue) { - this.queue = queue; - } - - public GatewayQueue getQueue() { - return this.queue; - } - - public void setSocketBufferSize(int socketBufferSize) { - this.socketBufferSize = socketBufferSize; - } - - public Integer getSocketBufferSize() { - return (socketBufferSize != null ? socketBufferSize : Gateway.DEFAULT_SOCKET_BUFFER_SIZE); - } - - public void setSocketReadTimeout(final Integer socketReadTimeout) { - this.socketReadTimeout = socketReadTimeout; - } - - public Integer getSocketReadTimeout() { - return (socketReadTimeout != null ? socketReadTimeout : Gateway.DEFAULT_SOCKET_READ_TIMEOUT); - } - - public static class GatewayEndpoint { - - private int port; - - private String host; - private String id; - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - } - - public static class GatewayQueue { - - private Boolean enableBatchConflation; - private Boolean persistent; - - private Integer alertThreshold; - private Integer batchSize; - private Integer batchTimeInterval; - private Integer maximumQueueMemory; - - private String diskStoreRef; - - public void setAlertThreshold(Integer alertThreshold) { - this.alertThreshold = alertThreshold; - } - - public Integer getAlertThreshold() { - return (alertThreshold != null ? alertThreshold : GatewayQueueAttributes.DEFAULT_ALERT_THRESHOLD); - } - - public void setBatchSize(Integer batchSize) { - this.batchSize = batchSize; - } - - public Integer getBatchSize() { - return (batchSize != null ? batchSize : GatewayQueueAttributes.DEFAULT_BATCH_SIZE); - } - - public void setBatchTimeInterval(Integer batchTimeInterval) { - this.batchTimeInterval = batchTimeInterval; - } - - public Integer getBatchTimeInterval() { - return (batchTimeInterval != null ? batchTimeInterval : GatewayQueueAttributes.DEFAULT_BATCH_TIME_INTERVAL); - } - - public void setDiskStoreRef(String diskStoreRef) { - this.diskStoreRef = diskStoreRef; - } - - public String getDiskStoreRef() { - return diskStoreRef; - } - - public void setEnableBatchConflation(Boolean enableBatchConflation) { - this.enableBatchConflation = enableBatchConflation; - } - - public Boolean getEnableBatchConflation() { - return (enableBatchConflation != null ? enableBatchConflation - : GatewayQueueAttributes.DEFAULT_BATCH_CONFLATION); - } - - public void setMaximumQueueMemory(Integer maximumQueueMemory) { - this.maximumQueueMemory = maximumQueueMemory; - } - - public Integer getMaximumQueueMemory() { - return (maximumQueueMemory != null ? maximumQueueMemory - : GatewayQueueAttributes.DEFAULT_MAXIMUM_QUEUE_MEMORY); - } - - public void setPersistent(Boolean persistent) { - this.persistent = persistent; - } - - public Boolean getPersistent() { - return (persistent != null ? persistent : GatewayQueueAttributes.DEFAULT_ENABLE_PERSISTENCE); - } - } - -} diff --git a/src/main/java/org/springframework/data/gemfire/wan/GatewaySenderFactoryBean.java b/src/main/java/org/springframework/data/gemfire/wan/GatewaySenderFactoryBean.java index e58530ab..5192b1be 100644 --- a/src/main/java/org/springframework/data/gemfire/wan/GatewaySenderFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/wan/GatewaySenderFactoryBean.java @@ -18,7 +18,6 @@ package org.springframework.data.gemfire.wan; import java.util.List; import org.apache.geode.cache.Cache; -import org.apache.geode.cache.util.Gateway; import org.apache.geode.cache.wan.GatewayEventFilter; import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter; import org.apache.geode.cache.wan.GatewaySender; @@ -148,7 +147,7 @@ public class GatewaySenderFactoryBean extends AbstractWANComponentFactoryBean { - - /** - * Converts the given String value into an appropriate StartupPolicyType enumerated value. - * - * @param source the String to convert. - * @return a StartupPolicyType enumerated value for the given String. - * @throws java.lang.IllegalArgumentException if the String is not a valid GatewayHub Startup Policy. - * @see StartupPolicyType#valueOfIgnoreCase(String) - * @see #assertConverted(String, Object, Class) - */ - @Override - public StartupPolicyType convert(final String source) { - return assertConverted(source, StartupPolicyType.valueOfIgnoreCase(source), - StartupPolicyType.class); - } - -} diff --git a/src/main/java/org/springframework/data/gemfire/wan/StartupPolicyType.java b/src/main/java/org/springframework/data/gemfire/wan/StartupPolicyType.java deleted file mode 100644 index 02a486fb..00000000 --- a/src/main/java/org/springframework/data/gemfire/wan/StartupPolicyType.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2010-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.data.gemfire.wan; - -import org.apache.geode.cache.util.GatewayHub; - -/** - * The StartupPolicyType class is an enumeration of GemFire GatewayHub Startup Policies. - * - * @author John Blum - * @see org.apache.geode.cache.util.GatewayHub - * @since 1.7.0 - */ -@SuppressWarnings({"deprecation", "unused" }) -public enum StartupPolicyType { - NONE(GatewayHub.STARTUP_POLICY_NONE), - PRIMARY(GatewayHub.STARTUP_POLICY_PRIMARY), - SECONDARY(GatewayHub.STARTUP_POLICY_SECONDARY); - - public static final StartupPolicyType DEFAULT = StartupPolicyType.valueOfIgnoreCase( - GatewayHub.DEFAULT_STARTUP_POLICY); - - private final String name; - - /** - * Constructs an instance of the StartupPolicyType enum initialized with the given GemFire "named", - * GatewayHub Startup Policy. - * - * @param name a String specifying the name used by GemFire for the GatewayHub Startup Policy. - */ - StartupPolicyType(final String name) { - this.name = name; - } - - /** - * Returns a StartupPolicyType enumerated value matching the given official, case-insensitve "name" - * for the GatewayHub Startup Policy used by GemFire. - * - * @param name a String specifying the name used by GemFire for the GatewayHub Startup Policy. - * @return a StartupPolicyType enumerated value matching the given name used by GemFire to specify - * the GatewayHub Startup Policy. - * @see java.lang.String#equalsIgnoreCase(String) - * @see #getName() - */ - public static StartupPolicyType valueOfIgnoreCase(final String name) { - for (StartupPolicyType startupPolicyType : values()) { - if (startupPolicyType.getName().equalsIgnoreCase(name)) { - return startupPolicyType; - } - } - - return null; - } - - /** - * Gets the official name used by GemFire to specify the GatewayHub Startup Policy. - * - * @return the official GatewayHub Startup Policy name used by GemFire. - */ - public String getName() { - return name; - } - -} diff --git a/src/test/java/org/springframework/data/gemfire/GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationTests.java b/src/test/java/org/springframework/data/gemfire/GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationTests.java index 57143d5b..403b8f5e 100644 --- a/src/test/java/org/springframework/data/gemfire/GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationTests.java +++ b/src/test/java/org/springframework/data/gemfire/GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationTests.java @@ -255,8 +255,10 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT .setProperty("mcast-port", "0") .setProperty("log-level", logLevel()) .setProperty("locators", "localhost[11235]") + .setProperty("enable-cluster-configuration", "false") .setProperty("groups", groups()) .setProperty("start-locator", startLocator()) + .setProperty("use-cluster-configuration", "false") .build(); } diff --git a/src/test/java/org/springframework/data/gemfire/GemfireUtilsTest.java b/src/test/java/org/springframework/data/gemfire/GemfireUtilsTest.java index 1990ef2e..7622d0ee 100644 --- a/src/test/java/org/springframework/data/gemfire/GemfireUtilsTest.java +++ b/src/test/java/org/springframework/data/gemfire/GemfireUtilsTest.java @@ -17,9 +17,7 @@ package org.springframework.data.gemfire; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import static org.junit.Assume.assumeTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; @@ -32,7 +30,6 @@ import java.util.Properties; import org.apache.geode.cache.Cache; import org.apache.geode.cache.client.ClientCache; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.GemFireVersion; import org.junit.Test; /** @@ -136,39 +133,4 @@ public class GemfireUtilsTest { verifyZeroInteractions(mockClientCache); } - - // NOTE implementation is based on a GemFire internal class... org.apache.geode.internal.GemFireVersion. - protected int getGemFireVersion() { - try { - String gemfireVersion = GemFireVersion.getGemFireVersion(); - - return Integer.decode(String.valueOf(GemFireVersion.getMajorVersion(gemfireVersion)).concat( - String.valueOf(GemFireVersion.getMinorVersion(gemfireVersion)))); - } - catch (NumberFormatException ignore) { - return -1; - } - } - - @Test - public void gemfireVersionIs65OrAbove() { - int gemfireVersion = getGemFireVersion(); - assumeTrue(gemfireVersion > -1); - assertEquals(getGemFireVersion() >= 65, GemfireUtils.isGemfireVersion65OrAbove()); - } - - @Test - public void gemfireVersionIs7OrAbove() { - int gemfireVersion = getGemFireVersion(); - assumeTrue(gemfireVersion > -1); - assertEquals(getGemFireVersion() >= 70, GemfireUtils.isGemfireVersion7OrAbove()); - } - - @Test - public void gemfireVersionIs80rAbove() { - int gemfireVersion = getGemFireVersion(); - assumeTrue(gemfireVersion > -1); - assertEquals(getGemFireVersion() >= 80, GemfireUtils.isGemfireVersion8OrAbove()); - } - } diff --git a/src/test/java/org/springframework/data/gemfire/config/support/CustomEditorBeanFactoryPostProcessorUnitTests.java b/src/test/java/org/springframework/data/gemfire/config/support/CustomEditorBeanFactoryPostProcessorUnitTests.java index 9b970b92..b4132ac6 100644 --- a/src/test/java/org/springframework/data/gemfire/config/support/CustomEditorBeanFactoryPostProcessorUnitTests.java +++ b/src/test/java/org/springframework/data/gemfire/config/support/CustomEditorBeanFactoryPostProcessorUnitTests.java @@ -47,8 +47,6 @@ import org.springframework.data.gemfire.server.SubscriptionEvictionPolicyConvert import org.springframework.data.gemfire.support.ConnectionEndpoint; import org.springframework.data.gemfire.support.ConnectionEndpointList; import org.springframework.data.gemfire.wan.OrderPolicyConverter; -import org.springframework.data.gemfire.wan.StartupPolicyConverter; -import org.springframework.data.gemfire.wan.StartupPolicyType; import org.springframework.util.StringUtils; /** @@ -97,8 +95,6 @@ public class CustomEditorBeanFactoryPostProcessorUnitTests { eq(ScopeConverter.class)); verify(mockBeanFactory, times(1)).registerCustomEditor(eq(Gateway.OrderPolicy.class), eq(OrderPolicyConverter.class)); - verify(mockBeanFactory, times(1)).registerCustomEditor(eq(StartupPolicyType.class), - eq(StartupPolicyConverter.class)); verify(mockBeanFactory, times(1)).registerCustomEditor(eq(SubscriptionEvictionPolicy.class), eq(SubscriptionEvictionPolicyConverter.class)); verifyNoMoreInteractions(mockBeanFactory); diff --git a/src/test/java/org/springframework/data/gemfire/config/xml/GatewayHubNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/xml/GatewayHubNamespaceTest.java deleted file mode 100644 index 763b4861..00000000 --- a/src/test/java/org/springframework/data/gemfire/config/xml/GatewayHubNamespaceTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright 2010-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.data.gemfire.config.xml; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import javax.annotation.Resource; - -import org.apache.geode.cache.DataPolicy; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.util.Gateway; -import org.apache.geode.cache.util.GatewayEvent; -import org.apache.geode.cache.util.GatewayEventListener; -import org.apache.geode.cache.util.GatewayHub; -import org.apache.geode.cache.util.GatewayQueueAttributes; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * The GatewayHubNamespaceTest class is a test suite of test cases testing the contract and functionality - * of the GatewayHub SDG XML namespace (XSD) configuration meta-data. - * - * @author John Blum - * @see org.junit.Test - * @see org.junit.runner.RunWith - * @see org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer - * @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean - * @see org.springframework.data.gemfire.wan.GatewayProxy - * @see org.springframework.test.context.ContextConfiguration - * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner - * @see org.apache.geode.cache.util.Gateway - * @see org.apache.geode.cache.util.GatewayHub - * @since 1.5.3 - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(initializers = GemfireTestApplicationContextInitializer.class) -@SuppressWarnings({"deprecation", "unused" }) -public class GatewayHubNamespaceTest { - - @Resource(name = "Example") - private Region example; - - @Autowired - private GatewayHub gatewayHub; - - protected Gateway getGatewayById(final List gateways, final String id) { - for (Gateway gateway : gateways) { - if (gateway.getId().equals(id)) { - return gateway; - } - } - - return null; - } - - @Test - public void testRegionConfiguration() { - assertNotNull("The '/Example' Region was not properly initialized!", example); - assertEquals("Example", example.getName()); - assertEquals("/Example", example.getFullPath()); - assertNotNull(example.getAttributes()); - assertEquals(DataPolicy.REPLICATE, example.getAttributes().getDataPolicy()); - assertTrue(example.getAttributes().getEnableGateway()); - assertEquals("testGatewayHub", example.getAttributes().getGatewayHubId()); - } - - @Test - public void testGatewayConfiguration() { - assertNotNull("The 'TestGatewayHub' GatewayHub was not properly initialized!", gatewayHub); - assertEquals("localhost", gatewayHub.getBindAddress()); - assertEquals("TestGatewayHub", gatewayHub.getId()); - assertTrue(gatewayHub.getManualStart()); - assertEquals(125, gatewayHub.getMaxConnections()); - assertEquals(5000, gatewayHub.getMaximumTimeBetweenPings()); - assertEquals(45123, gatewayHub.getPort()); - assertEquals(16384, gatewayHub.getSocketBufferSize()); - assertEquals("primary", gatewayHub.getStartupPolicy()); - - List gateways = gatewayHub.getGateways(); - - assertNotNull(gateways); - assertFalse(gateways.isEmpty()); - assertEquals(3, gateways.size()); - - Gateway gatewayOne = getGatewayById(gateways, "gateway1"); - - assertNotNull(gatewayOne); - assertEquals("gateway1", gatewayOne.getId()); - assertEquals(8, gatewayOne.getConcurrencyLevel()); - assertEquals(Gateway.OrderPolicy.THREAD, gatewayOne.getOrderPolicy()); - assertEquals(65536, gatewayOne.getSocketBufferSize()); - assertEquals(75000, gatewayOne.getSocketReadTimeout()); - assertTrue(gatewayOne.getEndpoints() == null || gatewayOne.getEndpoints().isEmpty()); - - List gatewayEventListeners = gatewayOne.getListeners(); - - assertNotNull(gatewayEventListeners); - assertFalse(gatewayEventListeners.isEmpty()); - assertEquals(2, gatewayEventListeners.size()); - assertTrue(gatewayEventListeners.get(0) instanceof TestGatewayListener); - assertEquals("ListenerOne", gatewayEventListeners.get(0).toString()); - assertTrue(gatewayEventListeners.get(1) instanceof TestGatewayListener); - assertEquals("ListenerTwo", gatewayEventListeners.get(1).toString()); - - GatewayQueueAttributes gatewayQueueAttributes = gatewayOne.getQueueAttributes(); - - assertNotNull(gatewayQueueAttributes); - assertEquals(99, gatewayQueueAttributes.getAlertThreshold()); - assertTrue(gatewayQueueAttributes.getBatchConflation()); - assertEquals(3, gatewayQueueAttributes.getBatchSize()); - assertEquals(10, gatewayQueueAttributes.getBatchTimeInterval()); - assertEquals("TestGatewayQueueDiskStore", gatewayQueueAttributes.getDiskStoreName()); - assertFalse(gatewayQueueAttributes.getEnablePersistence()); - assertEquals(5, gatewayQueueAttributes.getMaximumQueueMemory()); - - Gateway gatewayTwo = getGatewayById(gateways, "gateway2"); - - assertNotNull(gatewayTwo); - assertEquals("gateway2", gatewayTwo.getId()); - assertEquals(Gateway.DEFAULT_CONCURRENCY_LEVEL, gatewayTwo.getConcurrencyLevel()); - assertNull(gatewayTwo.getOrderPolicy()); - assertEquals(Gateway.DEFAULT_SOCKET_BUFFER_SIZE, gatewayTwo.getSocketBufferSize()); - assertEquals(Gateway.DEFAULT_SOCKET_READ_TIMEOUT, gatewayTwo.getSocketReadTimeout()); - assertTrue(gatewayTwo.getListeners() == null || gatewayTwo.getListeners().isEmpty()); - - List gatewayEndpoints = gatewayTwo.getEndpoints(); - - assertNotNull(gatewayEndpoints); - assertFalse(gatewayEndpoints.isEmpty()); - assertEquals(2, gatewayEndpoints.size()); - - Gateway.Endpoint gatewayEndpointOne = (Gateway.Endpoint) gatewayEndpoints.get(0); - - assertEquals("endpoint1", gatewayEndpointOne.getId()); - assertEquals("localhost", gatewayEndpointOne.getHost()); - assertEquals(1234, gatewayEndpointOne.getPort()); - - Gateway.Endpoint gatewayEndpointTwo = (Gateway.Endpoint) gatewayEndpoints.get(1); - - assertEquals("endpoint2", gatewayEndpointTwo.getId()); - assertEquals("localhost", gatewayEndpointTwo.getHost()); - assertEquals(4321, gatewayEndpointTwo.getPort()); - - gatewayQueueAttributes = gatewayTwo.getQueueAttributes(); - - assertNotNull(gatewayQueueAttributes); - assertEquals(GatewayQueueAttributes.DEFAULT_ALERT_THRESHOLD, gatewayQueueAttributes.getAlertThreshold()); - assertFalse(gatewayQueueAttributes.getBatchConflation()); - assertEquals(6, gatewayQueueAttributes.getBatchSize()); - assertEquals(20, gatewayQueueAttributes.getBatchTimeInterval()); - assertNull(gatewayQueueAttributes.getDiskStoreName()); - assertTrue(gatewayQueueAttributes.getEnablePersistence()); - assertEquals(GatewayQueueAttributes.DEFAULT_MAXIMUM_QUEUE_MEMORY, gatewayQueueAttributes.getMaximumQueueMemory()); - - Gateway gatewayThree = getGatewayById(gateways, "gateway3"); - - assertNotNull(gatewayThree); - assertEquals("gateway3", gatewayThree.getId()); - assertEquals(Gateway.DEFAULT_CONCURRENCY_LEVEL, gatewayThree.getConcurrencyLevel()); - assertNull(gatewayThree.getOrderPolicy()); - assertEquals(Gateway.DEFAULT_SOCKET_BUFFER_SIZE, gatewayThree.getSocketBufferSize()); - assertEquals(Gateway.DEFAULT_SOCKET_READ_TIMEOUT, gatewayThree.getSocketReadTimeout()); - assertTrue(gatewayThree.getEndpoints() == null || gatewayThree.getEndpoints().isEmpty()); - - gatewayEventListeners = gatewayThree.getListeners(); - - assertNotNull(gatewayEventListeners); - assertFalse(gatewayEventListeners.isEmpty()); - assertEquals(1, gatewayEventListeners.size()); - assertTrue(gatewayEventListeners.get(0) instanceof TestGatewayListener); - assertEquals("ListenerTwo", gatewayEventListeners.get(0).toString()); - } - - public static final class TestGatewayListener implements GatewayEventListener { - - private String name; - - public void setName(final String name) { - this.name = name; - } - - @Override - public boolean processEvents(final List events) { - return false; - } - - @Override - public void close() { - } - - @Override - public String toString() { - return name; - } - } - -} diff --git a/src/test/java/org/springframework/data/gemfire/config/xml/GemfireV6GatewayNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/xml/GemfireV6GatewayNamespaceTest.java deleted file mode 100644 index 1d83d566..00000000 --- a/src/test/java/org/springframework/data/gemfire/config/xml/GemfireV6GatewayNamespaceTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2010-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.gemfire.config.xml; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.util.GatewayEvent; -import org.apache.geode.cache.util.GatewayEventListener; -import org.apache.geode.cache.util.GatewayHub; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.data.gemfire.TestUtils; -import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer; -import org.springframework.data.gemfire.wan.GatewayHubFactoryBean; -import org.springframework.data.gemfire.wan.GatewayProxy; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author David Turanski - * - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations= "/org/springframework/data/gemfire/config/xml/gateway-v6-ns.xml", - initializers=GemfireTestApplicationContextInitializer.class) -public class GemfireV6GatewayNamespaceTest { - - @Autowired ApplicationContext ctx; - - @Test - public void testGatewayHubFactoryBean() throws Exception { - GatewayHubFactoryBean gwhfb = ctx.getBean("&gateway-hub", GatewayHubFactoryBean.class); - List gateways = TestUtils.readField("gateways", gwhfb); - assertNotNull(gateways); - assertEquals(2, gateways.size()); - GatewayProxy gwp = gateways.get(0); - assertEquals("gateway", gwp.getId()); - assertTrue(gwp.getListeners().get(0) instanceof GatewayListener); - - gwp = gateways.get(1); - assertEquals("gateway2", gwp.getId()); - List endpoints = gwp.getEndpoints(); - assertEquals(2, endpoints.size()); - GatewayProxy.GatewayEndpoint endpoint; - - endpoint = endpoints.get(0); - assertEquals("endpoint1", endpoint.getId()); - assertEquals("host1", endpoint.getHost()); - assertEquals(1234, endpoint.getPort()); - - endpoint = endpoints.get(1); - assertEquals("endpoint2", endpoint.getId()); - assertEquals("host2", endpoint.getHost()); - assertEquals(2345, endpoint.getPort()); - } - - @SuppressWarnings("rawtypes") - @Test - public void testGatewaysInGemfire() { - Cache cache = ctx.getBean("gemfireCache", Cache.class); - GatewayHub gwh = cache.getGatewayHub("gateway-hub"); - assertNotNull(gwh); - - Region region = ctx.getBean("region-with-gateway", Region.class); - assertTrue(region.getAttributes().getEnableGateway()); - assertEquals("gateway-hub", region.getAttributes().getGatewayHubId()); - } - - public static class GatewayListener implements GatewayEventListener { - - @Override - public void close() { - // TODO Auto-generated method stub - - } - - @Override - public boolean processEvents(List event) { - // TODO Auto-generated method stub - return false; - } - - } -} diff --git a/src/test/java/org/springframework/data/gemfire/config/xml/GemfireV7GatewayNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/xml/GemfireV7GatewayNamespaceTest.java index b15d4a36..ecb21f4c 100644 --- a/src/test/java/org/springframework/data/gemfire/config/xml/GemfireV7GatewayNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/xml/GemfireV7GatewayNamespaceTest.java @@ -31,11 +31,11 @@ import org.apache.geode.cache.Region; import org.apache.geode.cache.asyncqueue.AsyncEvent; import org.apache.geode.cache.asyncqueue.AsyncEventListener; import org.apache.geode.cache.asyncqueue.AsyncEventQueue; -import org.apache.geode.cache.util.Gateway.OrderPolicy; import org.apache.geode.cache.wan.GatewayEventFilter; import org.apache.geode.cache.wan.GatewayQueueEvent; import org.apache.geode.cache.wan.GatewayReceiver; import org.apache.geode.cache.wan.GatewaySender; +import org.apache.geode.cache.wan.GatewaySender.OrderPolicy; import org.apache.geode.cache.wan.GatewayTransportFilter; import org.junit.AfterClass; import org.junit.Before; diff --git a/src/test/java/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceTest.java index f6bd5d4d..9585f4cb 100644 --- a/src/test/java/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceTest.java @@ -136,8 +136,6 @@ public class TemplateClientRegionNamespaceTest { assertNull(region.getAttributes().getCustomEntryIdleTimeout()); assertNull(region.getAttributes().getCustomEntryTimeToLive()); assertNull(region.getAttributes().getDiskStoreName()); - assertFalse(region.getAttributes().getEnableGateway()); - assertNullEmpty(region.getAttributes().getGatewayHubId()); assertFalse(region.getAttributes().getMulticastEnabled()); assertDefaultExpirationAttributes(region.getAttributes().getRegionTimeToLive()); assertDefaultExpirationAttributes(region.getAttributes().getRegionIdleTimeout()); diff --git a/src/test/java/org/springframework/data/gemfire/config/xml/TemplateRegionsNamespaceTests.java b/src/test/java/org/springframework/data/gemfire/config/xml/TemplateRegionsNamespaceTests.java index d0e720b6..3a615fe4 100644 --- a/src/test/java/org/springframework/data/gemfire/config/xml/TemplateRegionsNamespaceTests.java +++ b/src/test/java/org/springframework/data/gemfire/config/xml/TemplateRegionsNamespaceTests.java @@ -243,8 +243,6 @@ public class TemplateRegionsNamespaceTests { assertNull(region.getAttributes().getCustomEntryIdleTimeout()); assertNull(region.getAttributes().getCustomEntryTimeToLive()); assertNull(region.getAttributes().getDiskStoreName()); - assertFalse(region.getAttributes().getEnableGateway()); - assertNullEmpty(region.getAttributes().getGatewayHubId()); assertFalse(region.getAttributes().getMulticastEnabled()); assertNullEmpty(region.getAttributes().getPoolName()); assertDefaultExpirationAttributes(region.getAttributes().getRegionTimeToLive()); @@ -656,5 +654,4 @@ public class TemplateRegionsNamespaceTests { return name; } } - } diff --git a/src/test/java/org/springframework/data/gemfire/listener/adapter/QueryListenerAdapterTest.java b/src/test/java/org/springframework/data/gemfire/listener/adapter/QueryListenerAdapterTest.java index a6eb6694..795892d4 100644 --- a/src/test/java/org/springframework/data/gemfire/listener/adapter/QueryListenerAdapterTest.java +++ b/src/test/java/org/springframework/data/gemfire/listener/adapter/QueryListenerAdapterTest.java @@ -20,6 +20,8 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Matchers.same; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -27,7 +29,6 @@ import static org.mockito.Mockito.verify; import org.apache.geode.cache.Operation; import org.apache.geode.cache.query.CqEvent; import org.apache.geode.cache.query.CqQuery; -import org.apache.geode.cache.query.internal.CqQueryImpl; import org.junit.Before; import org.junit.Test; import org.springframework.data.gemfire.listener.ContinuousQueryListener; @@ -46,12 +47,12 @@ public class QueryListenerAdapterTest { } CqEvent event() { - CqEvent event = new CqEvent() { - final CqQuery cq = new CqQueryImpl(); - final byte[] ba = new byte[0]; + return new CqEvent() { + final CqQuery cq = mock(CqQuery.class); + final byte[] deltaValue = new byte[0]; final Object key = new Object(); final Object value = new Object(); - final Exception ex = new Exception(); + final Exception exception = new Exception(); public Operation getBaseOperation() { return Operation.CACHE_CLOSE; @@ -62,7 +63,7 @@ public class QueryListenerAdapterTest { } public byte[] getDeltaValue() { - return ba; + return deltaValue; } public Object getKey() { @@ -78,11 +79,9 @@ public class QueryListenerAdapterTest { } public Throwable getThrowable() { - return ex; + return exception; } }; - - return event; } interface Delegate { @@ -103,8 +102,7 @@ public class QueryListenerAdapterTest { void handleOps(Operation base, Operation query); - void handleAll(CqEvent event, CqQuery query, byte[] ba, Object key, Operation op, Throwable th, Operation qOp, - Object v); + void handleAll(CqEvent event, CqQuery query, byte[] ba, Object key, Operation op, Throwable th, Operation qOp, Object v); void handleInvalid(Object o1, Object o2, Object o3); } @@ -121,106 +119,116 @@ public class QueryListenerAdapterTest { @Test public void testAdapterWithListenerAndDefaultMessage() throws Exception { - ContinuousQueryListener mock = mock(ContinuousQueryListener.class); - - ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock); + ContinuousQueryListener mockCqListener = mock(ContinuousQueryListener.class); + ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockCqListener); CqEvent event = event(); - adapter.onEvent(event); - verify(mock).onEvent(event); + + cqListenerAdapter.onEvent(event); + + verify(mockCqListener).onEvent(same(event)); } @Test public void testHandleEvent() throws Exception { - Delegate mock = mock(Delegate.class); - ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock); + Delegate mockDelegate = mock(Delegate.class); + ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate); CqEvent event = event(); - adapter.onEvent(event); - verify(mock).handleEvent(event); + cqListenerAdapter.onEvent(event); + + verify(mockDelegate).handleEvent(same(event)); } @Test public void testHandleArray() throws Exception { - Delegate mock = mock(Delegate.class); - ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock); - adapter.setDefaultListenerMethod("handleArray"); + Delegate mockDelegate = mock(Delegate.class); + ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate); CqEvent event = event(); - adapter.onEvent(event); - verify(mock).handleArray(event.getDeltaValue()); + + cqListenerAdapter.setDefaultListenerMethod("handleArray"); + cqListenerAdapter.onEvent(event); + + verify(mockDelegate).handleArray(eq(event.getDeltaValue())); } @Test public void testHandleKey() throws Exception { - Delegate mock = mock(Delegate.class); - ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock); - adapter.setDefaultListenerMethod("handleKey"); + Delegate mockDelegate = mock(Delegate.class); + ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate); CqEvent event = event(); - adapter.onEvent(event); - verify(mock).handleKey(event.getKey()); + cqListenerAdapter.setDefaultListenerMethod("handleKey"); + cqListenerAdapter.onEvent(event); + + verify(mockDelegate).handleKey(eq(event.getKey())); } @Test public void testHandleKV() throws Exception { - Delegate mock = mock(Delegate.class); - ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock); - adapter.setDefaultListenerMethod("handleKV"); + Delegate mockDelegate = mock(Delegate.class); + ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate); CqEvent event = event(); - adapter.onEvent(event); - verify(mock).handleKV(event.getKey(), event.getNewValue()); + cqListenerAdapter.setDefaultListenerMethod("handleKV"); + cqListenerAdapter.onEvent(event); + + verify(mockDelegate).handleKV(eq(event.getKey()), eq(event.getNewValue())); } @Test public void testHandleEx() throws Exception { - Delegate mock = mock(Delegate.class); - ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock); - adapter.setDefaultListenerMethod("handleEx"); + Delegate mockDelegate = mock(Delegate.class); + ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate); CqEvent event = event(); - adapter.onEvent(event); - verify(mock).handleEx(event.getThrowable()); + cqListenerAdapter.setDefaultListenerMethod("handleEx"); + cqListenerAdapter.onEvent(event); + + verify(mockDelegate).handleEx(eq(event.getThrowable())); } @Test public void testHandleOps() throws Exception { - Delegate mock = mock(Delegate.class); - ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock); - adapter.setDefaultListenerMethod("handleOps"); + Delegate mockDelegate = mock(Delegate.class); + ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate); CqEvent event = event(); - adapter.onEvent(event); - verify(mock).handleOps(event.getBaseOperation(), event.getQueryOperation()); + cqListenerAdapter.setDefaultListenerMethod("handleOps"); + cqListenerAdapter.onEvent(event); + + verify(mockDelegate).handleOps(eq(event.getBaseOperation()), eq(event.getQueryOperation())); } @Test public void testHandleAll() throws Exception { - Delegate mock = mock(Delegate.class); - ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock); - adapter.setDefaultListenerMethod("handleAll"); + Delegate mockDelegate = mock(Delegate.class); + ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate); CqEvent event = event(); - adapter.onEvent(event); - verify(mock).handleAll(event, event.getCq(), event.getDeltaValue(), event.getKey(), event.getBaseOperation(), - event.getThrowable(), event.getQueryOperation(), event.getNewValue()); + cqListenerAdapter.setDefaultListenerMethod("handleAll"); + cqListenerAdapter.onEvent(event); + + verify(mockDelegate).handleAll(eq(event), eq(event.getCq()), eq(event.getDeltaValue()), eq(event.getKey()), + eq(event.getBaseOperation()), eq(event.getThrowable()), eq(event.getQueryOperation()), + eq(event.getNewValue())); } @Test public void testInvalid() throws Exception { - Delegate mock = mock(Delegate.class); - ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock); - adapter.setDefaultListenerMethod("handleInvalid"); + Delegate mockDelegate = mock(Delegate.class); + ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate); - adapter.onEvent(event()); - doThrow(new IllegalArgumentException()).when(mock); + cqListenerAdapter.setDefaultListenerMethod("handleInvalid"); + cqListenerAdapter.onEvent(event()); + + doThrow(new IllegalArgumentException()).when(mockDelegate); } /** - * @see SGF-89 + * @link https://jira.spring.io/browse/SGF-89 */ @Test public void triggersListenerImplementingInterfaceCorrectly() { - SampleListener listener = new SampleListener(); ContinuousQueryListener listenerAdapter = new ContinuousQueryListenerAdapter(listener) { diff --git a/src/test/java/org/springframework/data/gemfire/test/MockGatewayFactory.java b/src/test/java/org/springframework/data/gemfire/test/MockGatewayFactory.java deleted file mode 100644 index e9462110..00000000 --- a/src/test/java/org/springframework/data/gemfire/test/MockGatewayFactory.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright 2010-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.data.gemfire.test; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.geode.cache.util.Gateway; -import org.apache.geode.cache.util.GatewayEventListener; -import org.apache.geode.cache.util.GatewayQueueAttributes; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.springframework.data.gemfire.test.support.AbstractUnitAndIntegrationTestsWithMockSupport; - -/** - * The MockGatewayFactory class is a factory for creating mock GemFire Gateways, GatewayQueueAttributes - * and Gateway.Endpoints. - * - * @author John Blum - * @see org.mockito.Mockito - * @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean - * @see org.apache.geode.cache.util.Gateway - * @see org.apache.geode.cache.util.GatewayHub - * @since 1.5.3 - */ -@SuppressWarnings({ "deprecation", "unused" }) -public class MockGatewayFactory extends AbstractUnitAndIntegrationTestsWithMockSupport { - - private Boolean batchConflation = GatewayQueueAttributes.DEFAULT_BATCH_CONFLATION; - private Boolean persistence = GatewayQueueAttributes.DEFAULT_ENABLE_PERSISTENCE; - - private Gateway.OrderPolicy orderPolicy; - - private GatewayQueueAttributes queueAttributes; - - private Integer alertThreshold = GatewayQueueAttributes.DEFAULT_ALERT_THRESHOLD; - private Integer batchSize = GatewayQueueAttributes.DEFAULT_BATCH_SIZE; - private Integer batchTimeInterval = GatewayQueueAttributes.DEFAULT_BATCH_TIME_INTERVAL; - private Integer maxQueueMemory = GatewayQueueAttributes.DEFAULT_MAXIMUM_QUEUE_MEMORY; - private Integer socketBufferSize = Gateway.DEFAULT_SOCKET_BUFFER_SIZE; - private Integer socketReadTimeout = Gateway.DEFAULT_SOCKET_READ_TIMEOUT; - - private List endpoints; - private List listeners; - - private String diskStoreName; - - public MockGatewayFactory() { - endpoints = new ArrayList(); - listeners = new ArrayList(); - queueAttributes = mockGatewayQueueAttributes(); - } - - public Gateway mockGateway(final String id, final int concurrencyLevel) { - Gateway mockGateway = mock(Gateway.class, String.format("%1$s.MockGateway", getMockId())); - - when(mockGateway.getConcurrencyLevel()).thenReturn(concurrencyLevel); - when(mockGateway.getEndpoints()).thenReturn(endpoints); - when(mockGateway.getId()).thenReturn(id); - when(mockGateway.getListeners()).thenReturn(listeners); - when(mockGateway.getQueueSize()).thenThrow(new UnsupportedOperationException(NOT_IMPLEMENTED)); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - orderPolicy = invocation.getArgumentAt(0, Gateway.OrderPolicy.class); - return null; - } - }).when(mockGateway).setOrderPolicy(any(Gateway.OrderPolicy.class)); - - when(mockGateway.getOrderPolicy()).thenAnswer(new Answer() { - @Override public Gateway.OrderPolicy answer(final InvocationOnMock invocation) throws Throwable { - return orderPolicy; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - queueAttributes = invocation.getArgumentAt(0, GatewayQueueAttributes.class); - return null; - } - }).when(mockGateway).setQueueAttributes(any(GatewayQueueAttributes.class)); - - when(mockGateway.getQueueAttributes()).thenAnswer(new Answer() { - @Override public GatewayQueueAttributes answer(final InvocationOnMock invocation) throws Throwable { - return queueAttributes; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - socketBufferSize = invocation.getArgumentAt(0, Integer.class); - return null; - } - }).when(mockGateway).setSocketBufferSize(anyInt()); - - when(mockGateway.getSocketBufferSize()).thenAnswer(new Answer() { - @Override public Integer answer(final InvocationOnMock invocation) throws Throwable { - return socketBufferSize; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - socketReadTimeout = invocation.getArgumentAt(0, Integer.class); - return null; - } - }).when(mockGateway).setSocketReadTimeout(anyInt()); - - when(mockGateway.getSocketReadTimeout()).thenAnswer(new Answer() { - @Override public Integer answer(final InvocationOnMock invocation) throws Throwable { - return socketReadTimeout; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - String id = invocation.getArgumentAt(0, String.class); - String host = invocation.getArgumentAt(1, String.class); - int port = invocation.getArgumentAt(2, Integer.class); - endpoints.add(mockGatewayEndpoint(id, host, port)); - return null; - } - }).when(mockGateway).addEndpoint(anyString(), anyString(), anyInt()); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - listeners.add(invocation.getArgumentAt(0, GatewayEventListener.class)); - return null; - } - }).when(mockGateway).addListener(any(GatewayEventListener.class)); - - return mockGateway; - } - - public Gateway.Endpoint mockGatewayEndpoint(final String id, final String host, final int port) { - Gateway.Endpoint mockEndpoint = mock(Gateway.Endpoint.class, - String.format("%1$s.MockGatewayEndpoint", getMockId())); - - when(mockEndpoint.getId()).thenReturn(id); - when(mockEndpoint.getHost()).thenReturn(host); - when(mockEndpoint.getPort()).thenReturn(port); - - return mockEndpoint; - } - - public GatewayQueueAttributes mockGatewayQueueAttributes() { - GatewayQueueAttributes mockQueueAttributes = mock(GatewayQueueAttributes.class, - String.format("%1$s.MockGatewayQueueAttributes", getMockId())); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - alertThreshold = invocation.getArgumentAt(0, Integer.class); - return null; - } - }).when(mockQueueAttributes).setAlertThreshold(anyInt()); - - when(mockQueueAttributes.getAlertThreshold()).thenAnswer(new Answer() { - @Override public Integer answer(final InvocationOnMock invocation) throws Throwable { - return alertThreshold; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - batchConflation = invocation.getArgumentAt(0, Boolean.class); - return null; - } - }).when(mockQueueAttributes).setBatchConflation(anyBoolean()); - - when(mockQueueAttributes.getBatchConflation()).thenAnswer(new Answer() { - @Override public Boolean answer(final InvocationOnMock invocation) throws Throwable { - return batchConflation; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - batchSize = invocation.getArgumentAt(0, Integer.class); - return null; - } - }).when(mockQueueAttributes).setBatchSize(anyInt()); - - when(mockQueueAttributes.getBatchSize()).thenAnswer(new Answer() { - @Override public Integer answer(final InvocationOnMock invocation) throws Throwable { - return batchSize; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - batchTimeInterval = invocation.getArgumentAt(0, Integer.class); - return null; - } - }).when(mockQueueAttributes).setBatchTimeInterval(anyInt()); - - when(mockQueueAttributes.getBatchTimeInterval()).thenAnswer(new Answer() { - @Override public Integer answer(final InvocationOnMock invocation) throws Throwable { - return batchTimeInterval; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - diskStoreName = invocation.getArgumentAt(0, String.class); - return null; - } - }).when(mockQueueAttributes).setDiskStoreName(anyString()); - - when(mockQueueAttributes.getDiskStoreName()).thenAnswer(new Answer() { - @Override public String answer(final InvocationOnMock invocation) throws Throwable { - return diskStoreName; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - persistence = invocation.getArgumentAt(0, Boolean.class); - return null; - } - }).when(mockQueueAttributes).setEnablePersistence(anyBoolean()); - - when(mockQueueAttributes.getEnablePersistence()).thenAnswer(new Answer() { - @Override public Boolean answer(final InvocationOnMock invocation) throws Throwable { - return persistence; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - maxQueueMemory = invocation.getArgumentAt(0, Integer.class); - return null; - } - }).when(mockQueueAttributes).setMaximumQueueMemory(anyInt()); - - when(mockQueueAttributes.getMaximumQueueMemory()).thenAnswer(new Answer() { - @Override public Integer answer(final InvocationOnMock invocation) throws Throwable { - return maxQueueMemory; - } - }); - - return mockQueueAttributes; - } - -} diff --git a/src/test/java/org/springframework/data/gemfire/test/MockGatewayHubFactory.java b/src/test/java/org/springframework/data/gemfire/test/MockGatewayHubFactory.java deleted file mode 100644 index e7913061..00000000 --- a/src/test/java/org/springframework/data/gemfire/test/MockGatewayHubFactory.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2010-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.data.gemfire.test; - -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicLong; - -import org.apache.geode.cache.util.Gateway; -import org.apache.geode.cache.util.GatewayHub; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.springframework.data.gemfire.test.support.AbstractUnitAndIntegrationTestsWithMockSupport; - -/** - * The MockGatewayHubFactory class is a factory for creating mock GemFire GatewayHubs. - * - * @author John Blum - * @see org.mockito.Mockito - * @see AbstractUnitAndIntegrationTestsWithMockSupport - * @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean - * @see org.apache.geode.cache.util.Gateway - * @see org.apache.geode.cache.util.GatewayHub - * @since 1.5.3 - */ -@SuppressWarnings({ "deprecation", "unused" }) -public class MockGatewayHubFactory extends AbstractUnitAndIntegrationTestsWithMockSupport { - - private static final AtomicLong ID_SEQUENCE = new AtomicLong(System.currentTimeMillis()); - - private Boolean manualStart = GatewayHub.DEFAULT_MANUAL_START; - - private Integer maximumConnections = GatewayHub.DEFAULT_MAX_CONNECTIONS; - private Integer maximumTimeBetweenPings = GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS; - private Integer socketBufferSize = GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE; - - private List gateways = new ArrayList(); - - private String bindAddress = GatewayHub.DEFAULT_BIND_ADDRESS; - private String startupPolicy = GatewayHub.DEFAULT_STARTUP_POLICY; - - public GatewayHub mockGatewayHub(final String id, final int port) { - final GatewayHub mockGatewayHub = mock(GatewayHub.class, String.format("%1$s.MockGatewayHub", getMockId())); - - when(mockGatewayHub.getGateways()).thenReturn(gateways); - when(mockGatewayHub.getGatewayIds()).thenReturn(getGatewayIds(gateways)); - when(mockGatewayHub.getId()).thenReturn(id); - when(mockGatewayHub.getPort()).thenReturn(port); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - bindAddress = invocation.getArgumentAt(0, String.class); - return null; - } - }).when(mockGatewayHub).setBindAddress(anyString()); - - when(mockGatewayHub.getBindAddress()).thenAnswer(new Answer() { - @Override public String answer(final InvocationOnMock invocation) throws Throwable { - return bindAddress; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - manualStart = invocation.getArgumentAt(0, Boolean.class); - return null; - } - }).when(mockGatewayHub).setManualStart(anyBoolean()); - - when(mockGatewayHub.getManualStart()).thenAnswer(new Answer() { - @Override public Boolean answer(final InvocationOnMock invocation) throws Throwable { - return manualStart; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - maximumConnections = invocation.getArgumentAt(0, Integer.class); - return null; - } - }).when(mockGatewayHub).setMaxConnections(anyInt()); - - when(mockGatewayHub.getMaxConnections()).thenAnswer(new Answer() { - @Override public Integer answer(final InvocationOnMock invocation) throws Throwable { - return maximumConnections; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - maximumTimeBetweenPings = invocation.getArgumentAt(0, Integer.class); - return null; - } - }).when(mockGatewayHub).setMaximumTimeBetweenPings(anyInt()); - - when(mockGatewayHub.getMaximumTimeBetweenPings()).thenAnswer(new Answer() { - @Override public Integer answer(final InvocationOnMock invocation) throws Throwable { - return maximumTimeBetweenPings; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - socketBufferSize = invocation.getArgumentAt(0, Integer.class); - return null; - } - }).when(mockGatewayHub).setSocketBufferSize(anyInt()); - - when(mockGatewayHub.getSocketBufferSize()).thenAnswer(new Answer() { - @Override public Integer answer(final InvocationOnMock invocation) throws Throwable { - return socketBufferSize; - } - }); - - doAnswer(new Answer() { - @Override public Void answer(final InvocationOnMock invocation) throws Throwable { - startupPolicy = invocation.getArgumentAt(0, String.class); - return null; - } - }).when(mockGatewayHub).setStartupPolicy(anyString()); - - when(mockGatewayHub.getStartupPolicy()).thenAnswer(new Answer() { - @Override public String answer(final InvocationOnMock invocation) throws Throwable { - return startupPolicy; - } - }); - - when(mockGatewayHub.addGateway(anyString())).thenAnswer(new Answer() { - @Override public Gateway answer(final InvocationOnMock invocation) throws Throwable { - String id = invocation.getArgumentAt(0, String.class); - return mockGatewayHub.addGateway(id, Gateway.DEFAULT_CONCURRENCY_LEVEL); - } - }); - - when(mockGatewayHub.addGateway(anyString(), anyInt())).thenAnswer(new Answer() { - @Override public Gateway answer(final InvocationOnMock invocation) throws Throwable { - String id = invocation.getArgumentAt(0, String.class); - Integer concurrencyLevel = invocation.getArgumentAt(1, Integer.class); - Gateway mockGateway = new MockGatewayFactory().mockGateway(id, concurrencyLevel); - when(mockGateway.getGatewayHubId()).thenReturn(id); - gateways.add(mockGateway); - return mockGateway; - } - }); - - return mockGatewayHub; - } - - private List getGatewayIds(final List gateways) { - List gatewayIds = new ArrayList(gateways.size()); - - for (Gateway gateway : gateways) { - gatewayIds.add(gateway.getId()); - } - - return gatewayIds; - } - -} diff --git a/src/test/java/org/springframework/data/gemfire/test/MockRegionFactory.java b/src/test/java/org/springframework/data/gemfire/test/MockRegionFactory.java index 18d7084f..4ae95214 100644 --- a/src/test/java/org/springframework/data/gemfire/test/MockRegionFactory.java +++ b/src/test/java/org/springframework/data/gemfire/test/MockRegionFactory.java @@ -220,14 +220,6 @@ public class MockRegionFactory { } }); - when(regionFactory.setEnableGateway(anyBoolean())).thenAnswer(new Answer(){ - @Override public RegionFactory answer(InvocationOnMock invocation) throws Throwable { - boolean enableGateway = (Boolean) invocation.getArguments()[0]; - attributesFactory.setEnableGateway(enableGateway); - return regionFactory; - } - }); - when(regionFactory.setEnableSubscriptionConflation(anyBoolean())).thenAnswer(new Answer(){ @Override public RegionFactory answer(InvocationOnMock invocation) throws Throwable { boolean enableSubscriptionConflation = (Boolean) invocation.getArguments()[0]; @@ -276,14 +268,6 @@ public class MockRegionFactory { } }); - when(regionFactory.setGatewayHubId(anyString())).thenAnswer(new Answer(){ - @Override public RegionFactory answer(InvocationOnMock invocation) throws Throwable { - String gatewayHubId = (String) invocation.getArguments()[0]; - attributesFactory.setGatewayHubId(gatewayHubId); - return regionFactory; - } - }); - when(regionFactory.setIgnoreJTA(anyBoolean())).thenAnswer(new Answer(){ @Override public RegionFactory answer(InvocationOnMock invocation) throws Throwable { boolean ignoreJta = (Boolean) invocation.getArguments()[0]; @@ -500,5 +484,4 @@ public class MockRegionFactory { public static QueryService mockQueryService() { return mockQueryService; } - } diff --git a/src/test/java/org/springframework/data/gemfire/test/StubAsyncEventQueueFactory.java b/src/test/java/org/springframework/data/gemfire/test/StubAsyncEventQueueFactory.java index b9c1dc83..d3af1a21 100644 --- a/src/test/java/org/springframework/data/gemfire/test/StubAsyncEventQueueFactory.java +++ b/src/test/java/org/springframework/data/gemfire/test/StubAsyncEventQueueFactory.java @@ -22,10 +22,10 @@ import java.util.List; import org.apache.geode.cache.asyncqueue.AsyncEventListener; import org.apache.geode.cache.asyncqueue.AsyncEventQueue; import org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory; -import org.apache.geode.cache.util.Gateway.OrderPolicy; import org.apache.geode.cache.wan.GatewayEventFilter; import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter; import org.apache.geode.cache.wan.GatewaySender; +import org.apache.geode.cache.wan.GatewaySender.OrderPolicy; /** * @author David Turanski @@ -38,6 +38,7 @@ public class StubAsyncEventQueueFactory implements AsyncEventQueueFactory { private boolean batchConflationEnabled; private boolean diskSynchronous; + private boolean forwardExpirationDestroy; private boolean parallel; private boolean persistent; @@ -50,7 +51,7 @@ public class StubAsyncEventQueueFactory implements AsyncEventQueueFactory { private OrderPolicy orderPolicy; - private List gatewayEventFilters = new ArrayList(); + private List gatewayEventFilters = new ArrayList<>(); private String diskStoreName; @@ -70,6 +71,7 @@ public class StubAsyncEventQueueFactory implements AsyncEventQueueFactory { when(asyncEventQueue.getDispatcherThreads()).thenReturn(this.dispatcherThreads); when(asyncEventQueue.getGatewayEventSubstitutionFilter()).thenReturn(this.gatewayEventSubstitutionFilter); when(asyncEventQueue.getGatewayEventFilters()).thenReturn(Collections.unmodifiableList(gatewayEventFilters)); + when(asyncEventQueue.isForwardExpirationDestroy()).thenReturn(this.forwardExpirationDestroy); return this.asyncEventQueue; } @@ -145,7 +147,12 @@ public class StubAsyncEventQueueFactory implements AsyncEventQueueFactory { @Override public AsyncEventQueueFactory setGatewayEventSubstitutionListener(final GatewayEventSubstitutionFilter gatewayEventSubstitutionFilter) { this.gatewayEventSubstitutionFilter = gatewayEventSubstitutionFilter; - return null; + return this; } + @Override + public AsyncEventQueueFactory setForwardExpirationDestroy(boolean forward) { + this.forwardExpirationDestroy = forward; + return this; + } } diff --git a/src/test/java/org/springframework/data/gemfire/test/StubCache.java b/src/test/java/org/springframework/data/gemfire/test/StubCache.java index 6a5e8eb6..6c08bfaf 100644 --- a/src/test/java/org/springframework/data/gemfire/test/StubCache.java +++ b/src/test/java/org/springframework/data/gemfire/test/StubCache.java @@ -52,7 +52,6 @@ import org.apache.geode.cache.query.RegionNotFoundException; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache.snapshot.CacheSnapshotService; import org.apache.geode.cache.util.GatewayConflictResolver; -import org.apache.geode.cache.util.GatewayHub; import org.apache.geode.cache.wan.GatewayReceiver; import org.apache.geode.cache.wan.GatewayReceiverFactory; import org.apache.geode.cache.wan.GatewaySender; @@ -97,8 +96,6 @@ public class StubCache implements Cache, ClientCache { private HashMap allRegions; - private List gatewayHubs; - private LogWriter logWriter; private LogWriter securityLogWriter; @@ -115,8 +112,7 @@ public class StubCache implements Cache, ClientCache { private String name; public StubCache(){ - allRegions = new HashMap(); - gatewayHubs = new ArrayList(); + allRegions = new HashMap<>(); resourceManager = new StubResourceManager(); } @@ -280,7 +276,7 @@ public class StubCache implements Cache, ClientCache { @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Map> listRegionAttributes() { - Map> attributes = new HashMap>(); + Map> attributes = new HashMap<>(); for (Entry entry: allRegions().entrySet()) { attributes.put(entry.getKey(), entry.getValue().getAttributes()); } @@ -380,7 +376,7 @@ public class StubCache implements Cache, ClientCache { */ @Override public Set> rootRegions() { - Set> rootRegions = new HashSet>(); + Set> rootRegions = new HashSet<>(); for (String key: allRegions().keySet()) { if (!key.contains("/")) { rootRegions.add(allRegions().get(key)); @@ -389,15 +385,6 @@ public class StubCache implements Cache, ClientCache { return rootRegions; } - /* (non-Javadoc) - * @see org.apache.geode.cache.Cache#addBridgeServer() - */ - @Override - @Deprecated - public org.apache.geode.cache.util.BridgeServer addBridgeServer() { - throw new UnsupportedOperationException(NOT_IMPLEMENTED); - } - /* (non-Javadoc) * @see org.apache.geode.cache.Cache#addCacheServer() */ @@ -406,18 +393,6 @@ public class StubCache implements Cache, ClientCache { return mockCacheServer(); } - - /* (non-Javadoc) - * @see org.apache.geode.cache.Cache#addGatewayHub(java.lang.String, int) - */ - @Override - public GatewayHub addGatewayHub(final String id, final int port) { - GatewayHub gatewayHub = getGatewayHub(id); - gatewayHub = (gatewayHub != null ? gatewayHub : new MockGatewayHubFactory().mockGatewayHub(id, port)); - gatewayHubs.add(gatewayHub); - return gatewayHub; - } - /* (non-Javadoc) * @see org.apache.geode.cache.Cache#close(boolean) */ @@ -529,15 +504,6 @@ public class StubCache implements Cache, ClientCache { throw new UnsupportedOperationException(NOT_IMPLEMENTED); } - /* (non-Javadoc) - * @see org.apache.geode.cache.Cache#getBridgeServers() - */ - @Override - @Deprecated - public List getBridgeServers() { - throw new UnsupportedOperationException(NOT_IMPLEMENTED); - } - /* (non-Javadoc) * @see org.apache.geode.cache.Cache#getCacheServers() */ @@ -554,37 +520,6 @@ public class StubCache implements Cache, ClientCache { return this.gatewayConflictResolver; } - /* (non-Javadoc) - * @see org.apache.geode.cache.Cache#getGatewayHub() - */ - @Override - @Deprecated - public GatewayHub getGatewayHub() { - return (gatewayHubs.isEmpty() ? null : gatewayHubs.get(0)); - } - - /* (non-Javadoc) - * @see org.apache.geode.cache.Cache#getGatewayHub(java.lang.String) - */ - @Override - public GatewayHub getGatewayHub(final String id) { - for (GatewayHub gatewayHub : gatewayHubs) { - if (gatewayHub.getId().equals(id)) { - return gatewayHub; - } - } - - return null; - } - - /* (non-Javadoc) - * @see org.apache.geode.cache.Cache#getGatewayHubs() - */ - @Override - public List getGatewayHubs() { - return this.gatewayHubs; - } - /* (non-Javadoc) * @see org.apache.geode.cache.Cache#getGatewayReceivers() */ @@ -708,15 +643,6 @@ public class StubCache implements Cache, ClientCache { this.gatewayConflictResolver = arg0; } - /* (non-Javadoc) - * @see org.apache.geode.cache.Cache#setGatewayHub(java.lang.String, int) - */ - @Override - @Deprecated - public GatewayHub setGatewayHub(String arg0, int arg1) { - throw new UnsupportedOperationException(NOT_IMPLEMENTED); - } - /* (non-Javadoc) * @see org.apache.geode.cache.Cache#setIsServer(boolean) */ @@ -942,5 +868,4 @@ public class StubCache implements Cache, ClientCache { public QueryService getQueryService(final String poolName) { return getQueryService(); } - } diff --git a/src/test/java/org/springframework/data/gemfire/test/StubCacheTransactionMananger.java b/src/test/java/org/springframework/data/gemfire/test/StubCacheTransactionMananger.java index d41cc6f7..b5fdebf2 100644 --- a/src/test/java/org/springframework/data/gemfire/test/StubCacheTransactionMananger.java +++ b/src/test/java/org/springframework/data/gemfire/test/StubCacheTransactionMananger.java @@ -23,143 +23,127 @@ import org.apache.geode.cache.TransactionId; import org.apache.geode.cache.TransactionListener; import org.apache.geode.cache.TransactionWriter; - -/** - * @author David Turanski - * - */ public class StubCacheTransactionMananger implements CacheTransactionManager { - private List listeners = new ArrayList(); + private boolean distributed = false; + + private List listeners = new ArrayList<>(); + private TransactionWriter writer; - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#begin() + /** + * @inheritDoc + */ + @Override + public boolean isSuspended(TransactionId transactionId) { + return false; + } + + /** + * @inheritDoc */ @Override public void begin() { - // TODO Auto-generated method stub - } - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#commit() + /** + * @inheritDoc */ @Override public void commit() throws CommitConflictException { } - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#rollback() - */ - @Override - public void rollback() { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#suspend() - */ - @Override - public TransactionId suspend() { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#resume(org.apache.geode.cache.TransactionId) - */ - @Override - public void resume(TransactionId transactionId) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#isSuspended(org.apache.geode.cache.TransactionId) - */ - @Override - public boolean isSuspended(TransactionId transactionId) { - // TODO Auto-generated method stub - return false; - } - - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#tryResume(org.apache.geode.cache.TransactionId) - */ - @Override - public boolean tryResume(TransactionId transactionId) { - // TODO Auto-generated method stub - return false; - } - - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#tryResume(org.apache.geode.cache.TransactionId, long, java.util.concurrent.TimeUnit) - */ - @Override - public boolean tryResume(TransactionId transactionId, long time, TimeUnit unit) { - // TODO Auto-generated method stub - return false; - } - - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#exists(org.apache.geode.cache.TransactionId) - */ - @Override - public boolean exists(TransactionId transactionId) { - // TODO Auto-generated method stub - return false; - } - - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#exists() + /** + * @inheritDoc */ @Override public boolean exists() { - // TODO Auto-generated method stub return false; } - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#getTransactionId() + /** + * @inheritDoc */ @Override - public TransactionId getTransactionId() { - // TODO Auto-generated method stub + public boolean exists(TransactionId transactionId) { + return false; + } + + /** + * @inheritDoc + */ + @Override + public void resume(TransactionId transactionId) { + } + + /** + * @inheritDoc + */ + @Override + public void rollback() { + } + + /** + * @inheritDoc + */ + @Override + public TransactionId suspend() { return null; } - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#getListener() + /** + * @inheritDoc + */ + @Override + public boolean tryResume(TransactionId transactionId) { + return false; + } + + /** + * @inheritDoc + */ + @Override + public boolean tryResume(TransactionId transactionId, long time, TimeUnit unit) { + return false; + } + + /** + * @inheritDoc + */ + @Override + public TransactionId getTransactionId() { + return null; + } + + /** + * @inheritDoc */ @Override @Deprecated public TransactionListener getListener() { - // TODO Auto-generated method stub return null; } - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#getListeners() + /** + * @inheritDoc */ @Override public TransactionListener[] getListeners() { return listeners.toArray(new TransactionListener[listeners.size()]); } - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#setListener(org.apache.geode.cache.TransactionListener) + + /** + * @inheritDoc */ @Override @Deprecated public TransactionListener setListener(TransactionListener newListener) { - // TODO Auto-generated method stub return null; } - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#addListener(org.apache.geode.cache.TransactionListener) + /** + * @inheritDoc */ @Override public void addListener(TransactionListener aListener) { @@ -167,16 +151,16 @@ public class StubCacheTransactionMananger implements CacheTransactionManager { } - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#removeListener(org.apache.geode.cache.TransactionListener) + /** + * @inheritDoc */ @Override public void removeListener(TransactionListener aListener) { this.listeners.remove(aListener); } - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#initListeners(org.apache.geode.cache.TransactionListener[]) + /** + * @inheritDoc */ @Override public void initListeners(TransactionListener[] newListeners) { @@ -184,20 +168,35 @@ public class StubCacheTransactionMananger implements CacheTransactionManager { } - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#setWriter(org.apache.geode.cache.TransactionWriter) + /** + * @inheritDoc */ @Override public void setWriter(TransactionWriter writer) { this.writer = writer; } - /* (non-Javadoc) - * @see org.apache.geode.cache.CacheTransactionManager#getWriter() + /** + * @inheritDoc */ @Override public TransactionWriter getWriter() { return this.writer; } + /** + * @inheritDoc + */ + @Override + public void setDistributed(boolean distributed) { + this.distributed = distributed; + } + + /** + * @inheritDoc + */ + @Override + public boolean isDistributed() { + return this.distributed; + } } diff --git a/src/test/java/org/springframework/data/gemfire/test/StubGatewaySenderFactory.java b/src/test/java/org/springframework/data/gemfire/test/StubGatewaySenderFactory.java index 08aa296e..8a0b0bbe 100644 --- a/src/test/java/org/springframework/data/gemfire/test/StubGatewaySenderFactory.java +++ b/src/test/java/org/springframework/data/gemfire/test/StubGatewaySenderFactory.java @@ -10,6 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ + package org.springframework.data.gemfire.test; import static org.mockito.Mockito.doAnswer; @@ -19,10 +20,10 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.List; -import org.apache.geode.cache.util.Gateway.OrderPolicy; import org.apache.geode.cache.wan.GatewayEventFilter; import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter; import org.apache.geode.cache.wan.GatewaySender; +import org.apache.geode.cache.wan.GatewaySender.OrderPolicy; import org.apache.geode.cache.wan.GatewaySenderFactory; import org.apache.geode.cache.wan.GatewayTransportFilter; import org.mockito.invocation.InvocationOnMock; @@ -64,8 +65,8 @@ public class StubGatewaySenderFactory implements GatewaySenderFactory { private String diskStoreName; public StubGatewaySenderFactory() { - this.eventFilters = new ArrayList(); - this.transportFilters = new ArrayList(); + this.eventFilters = new ArrayList<>(); + this.transportFilters = new ArrayList<>(); } @Override @@ -225,5 +226,4 @@ public class StubGatewaySenderFactory implements GatewaySenderFactory { this.gatewayEventSubstitutionFilter = gatewayEventSubstitutionFilter; return this; } - } diff --git a/src/test/java/org/springframework/data/gemfire/test/StubResourceManager.java b/src/test/java/org/springframework/data/gemfire/test/StubResourceManager.java index 8db6681e..d1d6834b 100644 --- a/src/test/java/org/springframework/data/gemfire/test/StubResourceManager.java +++ b/src/test/java/org/springframework/data/gemfire/test/StubResourceManager.java @@ -33,7 +33,9 @@ import org.apache.geode.cache.control.ResourceManager; public class StubResourceManager implements ResourceManager { private float criticalHeapPercentage; + private float criticalOffHeapPercentage; private float evictionHeapPercentage; + private float evictionOffHeapPercentage; @Override public void setCriticalHeapPercentage(final float heapPercentage) { @@ -65,4 +67,23 @@ public class StubResourceManager implements ResourceManager { return Collections.emptySet(); } + @Override + public void setCriticalOffHeapPercentage(float offHeapPercentage) { + this.criticalOffHeapPercentage = offHeapPercentage; + } + + @Override + public float getCriticalOffHeapPercentage() { + return this.criticalOffHeapPercentage; + } + + @Override + public void setEvictionOffHeapPercentage(float offHeapPercentage) { + this.evictionOffHeapPercentage = offHeapPercentage; + } + + @Override + public float getEvictionOffHeapPercentage() { + return this.evictionOffHeapPercentage; + } } diff --git a/src/test/java/org/springframework/data/gemfire/test/support/FileSystemUtils.java b/src/test/java/org/springframework/data/gemfire/test/support/FileSystemUtils.java index dac19a74..a5bd8cfd 100644 --- a/src/test/java/org/springframework/data/gemfire/test/support/FileSystemUtils.java +++ b/src/test/java/org/springframework/data/gemfire/test/support/FileSystemUtils.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.apache.geode.management.internal.cli.util.spring.Assert; +import org.springframework.util.Assert; /** * The FileSystemUtils class is a utility class encapsulating functionality to process file system directories diff --git a/src/test/java/org/springframework/data/gemfire/wan/AsyncEventQueueFactoryBeanTest.java b/src/test/java/org/springframework/data/gemfire/wan/AsyncEventQueueFactoryBeanTest.java index dc21a82d..c12c417d 100644 --- a/src/test/java/org/springframework/data/gemfire/wan/AsyncEventQueueFactoryBeanTest.java +++ b/src/test/java/org/springframework/data/gemfire/wan/AsyncEventQueueFactoryBeanTest.java @@ -31,7 +31,7 @@ import org.apache.geode.cache.Cache; import org.apache.geode.cache.asyncqueue.AsyncEventListener; import org.apache.geode.cache.asyncqueue.AsyncEventQueue; import org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory; -import org.apache.geode.cache.util.Gateway; +import org.apache.geode.cache.wan.GatewaySender; import org.junit.Test; import org.springframework.data.gemfire.TestUtils; @@ -83,7 +83,8 @@ public class AsyncEventQueueFactoryBeanTest { String orderPolicy = TestUtils.readField("orderPolicy", factoryBean); if (orderPolicy != null) { - verify(mockAsyncEventQueueFactory).setOrderPolicy(eq(Gateway.OrderPolicy.valueOf(orderPolicy.toUpperCase()))); + verify(mockAsyncEventQueueFactory).setOrderPolicy( + eq(GatewaySender.OrderPolicy.valueOf(orderPolicy.toUpperCase()))); } Integer dispatcherThreads = TestUtils.readField("dispatcherThreads", factoryBean); diff --git a/src/test/java/org/springframework/data/gemfire/wan/GatewayHubFactoryBeanTest.java b/src/test/java/org/springframework/data/gemfire/wan/GatewayHubFactoryBeanTest.java deleted file mode 100644 index 9e0d6ee3..00000000 --- a/src/test/java/org/springframework/data/gemfire/wan/GatewayHubFactoryBeanTest.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright 2010-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.data.gemfire.wan; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.same; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Arrays; -import java.util.List; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.util.Gateway; -import org.apache.geode.cache.util.GatewayEventListener; -import org.apache.geode.cache.util.GatewayHub; -import org.apache.geode.cache.util.GatewayQueueAttributes; -import org.junit.Before; -import org.junit.Test; - -/** - * The GatewayHubFactoryBeanTest class is a test suite of test cases testing the contract and functionality - * of the GatewayHubFactoryBean. - * - * @author John Blum - * @see org.junit.Test - * @see org.mockito.Mockito - * @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean - * @since 1.7.0 - */ -@SuppressWarnings("deprecation") -public class GatewayHubFactoryBeanTest { - - private Cache mockCache; - - private GatewayHubFactoryBean factoryBean; - - @Before - public void setup() { - mockCache = mock(Cache.class, "GemFire Cache"); - factoryBean = new GatewayHubFactoryBean(mockCache); - } - - @Test - public void testGetObjectAndObjectType() throws Exception { - assertNull(factoryBean.getObject()); - assertEquals(GatewayHub.class, factoryBean.getObjectType()); - } - - @Test - public void testSetAndGetBindAddress() { - assertEquals(GatewayHub.DEFAULT_BIND_ADDRESS, factoryBean.getBindAddress()); - factoryBean.setBindAddress("10.127.255.1"); - assertEquals("10.127.255.1", factoryBean.getBindAddress()); - factoryBean.setBindAddress(null); - assertEquals(GatewayHub.DEFAULT_BIND_ADDRESS, factoryBean.getBindAddress()); - } - - @Test - public void testGetGateways() { - List gateways = factoryBean.getGateways(); - - assertNotNull(gateways); - assertTrue(gateways.isEmpty()); - } - - @Test - public void testSetAndIsManualStart() { - assertEquals(GatewayHub.DEFAULT_MANUAL_START, factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START)); - factoryBean.setManualStart(true); - assertTrue(factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START)); - factoryBean.setManualStart(false); - assertFalse(factoryBean.isManualStart(true)); - factoryBean.setManualStart(null); - assertEquals(GatewayHub.DEFAULT_MANUAL_START, factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START)); - } - - @Test - public void testSetAndGetMaxConnections() { - assertEquals(GatewayHub.DEFAULT_MAX_CONNECTIONS, factoryBean.getMaxConnections().intValue()); - factoryBean.setMaxConnections(8192); - assertEquals(8192, factoryBean.getMaxConnections().intValue()); - factoryBean.setMaxConnections(null); - assertEquals(GatewayHub.DEFAULT_MAX_CONNECTIONS, factoryBean.getMaxConnections().intValue()); - } - - @Test - public void testSetAndGetMaximumTimeBetweenPings() { - assertEquals(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS, factoryBean.getMaximumTimeBetweenPings().intValue()); - factoryBean.setMaximumTimeBetweenPings(15000); - assertEquals(15000, factoryBean.getMaximumTimeBetweenPings().intValue()); - factoryBean.setMaximumTimeBetweenPings(null); - assertEquals(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS, factoryBean.getMaximumTimeBetweenPings().intValue()); - } - - @Test - public void testSetAndGetPort() { - assertEquals(GatewayHub.DEFAULT_PORT, factoryBean.getPort().intValue()); - factoryBean.setPort(15221); - assertEquals(15221, factoryBean.getPort().intValue()); - factoryBean.setPort(null); - assertEquals(GatewayHub.DEFAULT_PORT, factoryBean.getPort().intValue()); - } - - @Test - public void testSetAndGetSocketBufferSize() { - assertEquals(GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE, factoryBean.getSocketBufferSize().intValue()); - factoryBean.setSocketBufferSize(16384); - assertEquals(16384, factoryBean.getSocketBufferSize().intValue()); - factoryBean.setSocketBufferSize(null); - assertEquals(GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE, factoryBean.getSocketBufferSize().intValue()); - } - - @Test - public void testSetAndGetStartUpPolicy() { - assertEquals(StartupPolicyType.DEFAULT, factoryBean.getStartupPolicy()); - factoryBean.setStartupPolicy(StartupPolicyType.PRIMARY); - assertEquals(StartupPolicyType.PRIMARY, factoryBean.getStartupPolicy()); - factoryBean.setStartupPolicy(null); - assertEquals(StartupPolicyType.DEFAULT, factoryBean.getStartupPolicy()); - factoryBean.setStartupPolicy(StartupPolicyType.SECONDARY); - assertEquals(StartupPolicyType.SECONDARY, factoryBean.getStartupPolicy()); - } - - @Test(expected = IllegalArgumentException.class) - public void testAfterPropertiesSetWitNullCache() throws Exception { - try { - new GatewayHubFactoryBean(null).afterPropertiesSet(); - } - catch (IllegalArgumentException expected) { - assertEquals("Cache must not be null.", expected.getMessage()); - throw expected; - } - } - - @Test(expected = IllegalArgumentException.class) - public void testAfterPropertiesSetWithNullName() throws Exception { - try { - factoryBean.afterPropertiesSet(); - } - catch (IllegalArgumentException expected) { - assertEquals("Name must not be null.", expected.getMessage()); - throw expected; - } - } - - @Test - public void testDoInit() throws Exception { - String gatewayHubName = "testDoInit"; - - GatewayProxy.GatewayEndpoint gatewayEndpointOne = new GatewayProxy.GatewayEndpoint(); - - gatewayEndpointOne.setHost("localhost"); - gatewayEndpointOne.setId("123"); - gatewayEndpointOne.setPort(2121); - - GatewayProxy.GatewayEndpoint gatewayEndpointTwo = new GatewayProxy.GatewayEndpoint(); - - gatewayEndpointOne.setHost("localhost"); - gatewayEndpointOne.setId("456"); - gatewayEndpointOne.setPort(4242); - - GatewayEventListener mockGatewayListener = mock(GatewayEventListener.class, - "testDoInit.MockGatewayEventListener"); - - GatewayProxy.GatewayQueue gatewayQueue = new GatewayProxy.GatewayQueue(); - - gatewayQueue.setAlertThreshold(20); - gatewayQueue.setBatchSize(100); - gatewayQueue.setBatchTimeInterval(60000); - gatewayQueue.setDiskStoreRef("diskX"); - gatewayQueue.setEnableBatchConflation(true); - gatewayQueue.setMaximumQueueMemory(1024); - gatewayQueue.setPersistent(true); - - GatewayProxy gatewayProxy = new GatewayProxy(); - - gatewayProxy.setId("gatewayProxyId"); - gatewayProxy.setConcurrencyLevel(4); - gatewayProxy.setEndpoints(Arrays.asList(gatewayEndpointOne, gatewayEndpointTwo)); - gatewayProxy.setListeners(Arrays.asList(mockGatewayListener)); - gatewayProxy.setOrderPolicy(Gateway.OrderPolicy.THREAD); - gatewayProxy.setQueue(gatewayQueue); - gatewayProxy.setSocketBufferSize(16384); - gatewayProxy.setSocketReadTimeout(300); - - GatewayHub mockGatewayHub = mock(GatewayHub.class, "testDoInit.MockGatewayHub"); - - Gateway mockGateway = mock(Gateway.class, "testDoInit.MockGateway"); - - GatewayQueueAttributes mockGatewayQueueAttributes = mock(GatewayQueueAttributes.class, - "testDoInit.MockGatewayQueueAttributes"); - - when(mockCache.addGatewayHub(eq(gatewayHubName), eq(8484))).thenReturn(mockGatewayHub); - when(mockCache.getGatewayHub(eq(gatewayHubName))).thenReturn(mockGatewayHub); - when(mockGatewayHub.addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel().intValue()))) - .thenReturn(mockGateway); - when(mockGatewayHub.getManualStart()).thenReturn(false); - when(mockGateway.getQueueAttributes()).thenReturn(mockGatewayQueueAttributes); - - factoryBean.setBindAddress("10.124.210.42"); - factoryBean.setGateways(Arrays.asList(gatewayProxy)); - factoryBean.setManualStart(false); - factoryBean.setMaxConnections(50); - factoryBean.setMaximumTimeBetweenPings(20480); - factoryBean.setName(gatewayHubName); - factoryBean.setPort(8484); - factoryBean.setSocketBufferSize(4096); - factoryBean.setStartupPolicy(StartupPolicyType.PRIMARY); - factoryBean.afterPropertiesSet(); - - verify(mockGatewayHub, times(1)).setBindAddress(eq("10.124.210.42")); - verify(mockGatewayHub, times(1)).setManualStart(eq(false)); - verify(mockGatewayHub, times(1)).setMaxConnections(eq(50)); - verify(mockGatewayHub, times(1)).setMaximumTimeBetweenPings(eq(20480)); - verify(mockGatewayHub, times(1)).setSocketBufferSize(eq(4096)); - verify(mockGatewayHub, times(1)).setStartupPolicy(eq(StartupPolicyType.PRIMARY.getName())); - verify(mockGatewayHub, times(1)).addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel())); - verify(mockGatewayHub, times(1)).start(); - verify(mockGateway, times(1)).addEndpoint(eq(gatewayEndpointOne.getId()), eq(gatewayEndpointOne.getHost()), - eq(gatewayEndpointOne.getPort())); - verify(mockGateway, times(1)).addEndpoint(eq(gatewayEndpointTwo.getId()), eq(gatewayEndpointTwo.getHost()), - eq(gatewayEndpointTwo.getPort())); - verify(mockGateway, times(1)).addListener(same(mockGatewayListener)); - verify(mockGateway, times(1)).setOrderPolicy(eq(gatewayProxy.getOrderPolicy())); - verify(mockGateway, times(1)).setSocketBufferSize(eq(gatewayProxy.getSocketBufferSize())); - verify(mockGateway, times(1)).setSocketReadTimeout(eq(gatewayProxy.getSocketReadTimeout())); - verify(mockGateway, times(1)).getQueueAttributes(); - verify(mockGatewayQueueAttributes, times(1)).setAlertThreshold(eq(gatewayQueue.getAlertThreshold())); - verify(mockGatewayQueueAttributes, times(1)).setBatchConflation(eq(gatewayQueue.getEnableBatchConflation())); - verify(mockGatewayQueueAttributes, times(1)).setBatchSize(eq(gatewayQueue.getBatchSize())); - verify(mockGatewayQueueAttributes, times(1)).setBatchTimeInterval(eq(gatewayQueue.getBatchTimeInterval())); - verify(mockGatewayQueueAttributes, times(1)).setDiskStoreName(eq(gatewayQueue.getDiskStoreRef())); - verify(mockGatewayQueueAttributes, times(1)).setMaximumQueueMemory(eq(gatewayQueue.getMaximumQueueMemory())); - verify(mockGatewayQueueAttributes, times(1)).setEnablePersistence(eq(gatewayQueue.getPersistent())); - } - - @Test - public void testGatewayQueueWithOverflowNoPersistence() throws Exception { - String gatewayHubName = "testGatewayQueueWithOverflowNoPersistence"; - - GatewayProxy.GatewayQueue gatewayQueue = new GatewayProxy.GatewayQueue(); - - gatewayQueue.setAlertThreshold(100); - gatewayQueue.setBatchSize(250); - gatewayQueue.setBatchTimeInterval(120000); - gatewayQueue.setDiskStoreRef("diskZ"); - gatewayQueue.setEnableBatchConflation(true); - gatewayQueue.setMaximumQueueMemory(2048); - gatewayQueue.setPersistent(false); - - GatewayProxy gatewayProxy = new GatewayProxy(); - - gatewayProxy.setId("gatewayProxyId"); - gatewayProxy.setConcurrencyLevel(2); - gatewayProxy.setEndpoints(null); - gatewayProxy.setListeners(null); - gatewayProxy.setOrderPolicy(Gateway.OrderPolicy.THREAD); - gatewayProxy.setQueue(gatewayQueue); - gatewayProxy.setSocketBufferSize(4096); - gatewayProxy.setSocketReadTimeout(60); - - GatewayHub mockGatewayHub = mock(GatewayHub.class, "testGatewayQueueWithOverflowNoPersistence.MockGatewayHub"); - - Gateway mockGateway = mock(Gateway.class, "testGatewayQueueWithOverflowNoPersistence.MockGateway"); - - GatewayQueueAttributes mockGatewayQueueAttributes = mock(GatewayQueueAttributes.class, - "testGatewayQueueWithOverflowNoPersistence.MockGatewayQueueAttributes"); - - when(mockCache.addGatewayHub(eq(gatewayHubName), eq(10224))).thenReturn(mockGatewayHub); - when(mockCache.getGatewayHub(eq(gatewayHubName))).thenReturn(mockGatewayHub); - when(mockGatewayHub.addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel()))) - .thenReturn(mockGateway); - when(mockGatewayHub.getManualStart()).thenReturn(GatewayHub.DEFAULT_MANUAL_START); - when(mockGateway.getQueueAttributes()).thenReturn(mockGatewayQueueAttributes); - - factoryBean.setGateways(Arrays.asList(gatewayProxy)); - factoryBean.setName(gatewayHubName); - factoryBean.setPort(10224); - factoryBean.afterPropertiesSet(); - - verify(mockGatewayHub, times(1)).setBindAddress(eq(GatewayHub.DEFAULT_BIND_ADDRESS)); - verify(mockGatewayHub, times(1)).setManualStart(eq(GatewayHub.DEFAULT_MANUAL_START)); - verify(mockGatewayHub, times(1)).setMaxConnections(GatewayHub.DEFAULT_MAX_CONNECTIONS); - verify(mockGatewayHub, times(1)).setMaximumTimeBetweenPings(eq(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS)); - verify(mockGatewayHub, times(1)).setSocketBufferSize(eq(GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE)); - verify(mockGatewayHub, times(1)).setStartupPolicy(eq(GatewayHub.DEFAULT_STARTUP_POLICY)); - verify(mockGatewayHub, times(1)).start(); - verify(mockGatewayHub, times(1)).addGateway(eq(gatewayProxy.getId()), eq(gatewayProxy.getConcurrencyLevel())); - verify(mockGateway, times(1)).setOrderPolicy(eq(gatewayProxy.getOrderPolicy())); - verify(mockGateway, times(1)).setSocketBufferSize(eq(gatewayProxy.getSocketBufferSize())); - verify(mockGateway, times(1)).setSocketReadTimeout(eq(gatewayProxy.getSocketReadTimeout())); - verify(mockGatewayQueueAttributes, times(1)).setAlertThreshold(gatewayQueue.getAlertThreshold()); - verify(mockGatewayQueueAttributes, times(1)).setBatchConflation(gatewayQueue.getEnableBatchConflation()); - verify(mockGatewayQueueAttributes, times(1)).setBatchSize(gatewayQueue.getBatchSize()); - verify(mockGatewayQueueAttributes, times(1)).setBatchTimeInterval(gatewayQueue.getBatchTimeInterval()); - verify(mockGatewayQueueAttributes, times(1)).setDiskStoreName(gatewayQueue.getDiskStoreRef()); - verify(mockGatewayQueueAttributes, times(1)).setMaximumQueueMemory(gatewayQueue.getMaximumQueueMemory()); - verify(mockGatewayQueueAttributes, times(1)).setEnablePersistence(gatewayQueue.getPersistent()); - } - -} diff --git a/src/test/java/org/springframework/data/gemfire/wan/GatewaySenderFactoryBeanTest.java b/src/test/java/org/springframework/data/gemfire/wan/GatewaySenderFactoryBeanTest.java index 0fb990e9..f46e1326 100644 --- a/src/test/java/org/springframework/data/gemfire/wan/GatewaySenderFactoryBeanTest.java +++ b/src/test/java/org/springframework/data/gemfire/wan/GatewaySenderFactoryBeanTest.java @@ -25,7 +25,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.apache.geode.cache.Cache; -import org.apache.geode.cache.util.Gateway; import org.apache.geode.cache.wan.GatewaySender; import org.apache.geode.cache.wan.GatewaySenderFactory; import org.junit.Test; @@ -75,7 +74,8 @@ public class GatewaySenderFactoryBeanTest { String orderPolicy = TestUtils.readField("orderPolicy", factoryBean); if (orderPolicy != null) { - verify(mockGatewaySenderFactory).setOrderPolicy(eq(Gateway.OrderPolicy.valueOf(orderPolicy.toUpperCase()))); + verify(mockGatewaySenderFactory).setOrderPolicy( + eq(GatewaySender.OrderPolicy.valueOf(orderPolicy.toUpperCase()))); } Integer dispatcherThreads = TestUtils.readField("dispatcherThreads", factoryBean); diff --git a/src/test/java/org/springframework/data/gemfire/wan/StartupPolicyConverterUnitTests.java b/src/test/java/org/springframework/data/gemfire/wan/StartupPolicyConverterUnitTests.java deleted file mode 100644 index 0528e63b..00000000 --- a/src/test/java/org/springframework/data/gemfire/wan/StartupPolicyConverterUnitTests.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2010-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.data.gemfire.wan; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; - -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -/** - * Unit tests for {@link StartupPolicyConverter}. - * - * @author John Blum - * @see org.junit.Test - * @see org.springframework.data.gemfire.wan.StartupPolicyType - * @see org.springframework.data.gemfire.wan.StartupPolicyConverter - * @since 1.6.0 - */ -public class StartupPolicyConverterUnitTests { - - @Rule - public ExpectedException exception = ExpectedException.none(); - - private StartupPolicyConverter converter = new StartupPolicyConverter(); - - @After - public void tearDown() { - converter.setValue(null); - } - - @Test - public void convert() { - assertThat(converter.convert("none")).isEqualTo(StartupPolicyType.NONE); - assertThat(converter.convert("Primary")).isEqualTo(StartupPolicyType.PRIMARY); - assertThat(converter.convert("SecONdARY")).isEqualTo(StartupPolicyType.SECONDARY); - } - - @Test - public void convertIllegalValue() { - exception.expect(IllegalArgumentException.class); - exception.expectCause(is(nullValue(Throwable.class))); - exception.expectMessage("[tertiary] is not a valid StartupPolicyType"); - - converter.convert("tertiary"); - } - - @Test - public void setAsText() { - assertThat(converter.getValue()).isNull(); - converter.setAsText("priMARY"); - assertThat(converter.getValue()).isEqualTo(StartupPolicyType.PRIMARY); - converter.setAsText("SecondAry"); - assertThat(converter.getValue()).isEqualTo(StartupPolicyType.SECONDARY); - } - - @Test - public void setAsTextWithIllegalValue() { - exception.expect(IllegalArgumentException.class); - exception.expectCause(is(nullValue(Throwable.class))); - exception.expectMessage("[invalid] is not a valid StartupPolicyType"); - - converter.setAsText("invalid"); - } -} diff --git a/src/test/java/org/springframework/data/gemfire/wan/StartupPolicyTypeTest.java b/src/test/java/org/springframework/data/gemfire/wan/StartupPolicyTypeTest.java deleted file mode 100644 index 396969c4..00000000 --- a/src/test/java/org/springframework/data/gemfire/wan/StartupPolicyTypeTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2010-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.data.gemfire.wan; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; - -import org.apache.geode.cache.util.GatewayHub; -import org.junit.Test; - -/** - * The StartupPolicyTypeTest class is a test suite of test cases testing the contract and functionality - * of the StartupPolicyType enum. - * - * @author John Blum - * @see org.junit.Test - * @see StartupPolicyType - * @since 1.6.0 - */ -@SuppressWarnings("deprecation") -public class StartupPolicyTypeTest { - - @Test - public void testDefault() { - assertEquals(GatewayHub.DEFAULT_STARTUP_POLICY, StartupPolicyType.DEFAULT.getName()); - assertSame(StartupPolicyType.NONE, StartupPolicyType.DEFAULT); - } - - @Test - public void testValueOfIgnoreCase() { - assertEquals(StartupPolicyType.NONE, StartupPolicyType.valueOfIgnoreCase("NONE")); - assertEquals(StartupPolicyType.PRIMARY, StartupPolicyType.valueOfIgnoreCase("Primary")); - assertEquals(StartupPolicyType.SECONDARY, StartupPolicyType.valueOfIgnoreCase("secondary")); - assertEquals(StartupPolicyType.SECONDARY, StartupPolicyType.valueOfIgnoreCase("SECONDary")); - assertEquals(StartupPolicyType.PRIMARY, StartupPolicyType.valueOfIgnoreCase("PriMarY")); - } - - @Test - public void testValueOfIgnoreCaseWithInvalidValues() { - assertNull(StartupPolicyType.valueOfIgnoreCase("NO")); - assertNull(StartupPolicyType.valueOfIgnoreCase("Prime")); - assertNull(StartupPolicyType.valueOfIgnoreCase("second")); - assertNull(StartupPolicyType.valueOfIgnoreCase("all")); - assertNull(StartupPolicyType.valueOfIgnoreCase("N0N3")); - } - -} diff --git a/src/test/resources/org/springframework/data/gemfire/config/xml/GatewayHubNamespaceTest-context.xml b/src/test/resources/org/springframework/data/gemfire/config/xml/GatewayHubNamespaceTest-context.xml deleted file mode 100644 index 13d448ee..00000000 --- a/src/test/resources/org/springframework/data/gemfire/config/xml/GatewayHubNamespaceTest-context.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - GatewayHubNamespaceTest - 0 - warning - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/resources/org/springframework/data/gemfire/config/xml/gateway-v6-ns.xml b/src/test/resources/org/springframework/data/gemfire/config/xml/gateway-v6-ns.xml deleted file mode 100644 index 5b109e45..00000000 --- a/src/test/resources/org/springframework/data/gemfire/config/xml/gateway-v6-ns.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - GatewayV6NamespaceConfig - 0 - warning - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/template.mf b/template.mf index 5e79fb86..cc3dfcbc 100644 --- a/template.mf +++ b/template.mf @@ -4,11 +4,11 @@ Bundle-SymbolicName: org.springframework.data.gemfire Bundle-Vendor: Pivotal Software, Inc. Import-Package: sun.reflect;version="0";resolution:=optional Import-Template: javax.enterprise.*;version="[1.0,2.0)";resolution:=optional, - org.apache.commons.logging.*;version="[1.1.1, 2.0.0)", org.aopalliance.*;version="[1.0.0, 2.0.0)";resolution:=optional, + org.apache.commons.logging.*;version="[1.1.1, 2.0.0)", + org.apache.geode.*;version="[8.0.0,9.0.0)", org.aspectj.*;version="[1.8.2, 2.0.0)";resolution:=optional, com.fasterxml.jackson.*;version="[2.4.1,3.0.0)";resolution:=optional, - com.gemstone.*;version="[8.0.0,9.0.0)", org.slf4j.*;version="[1.7.0,2.0)", org.springframework.*;version="[4.0.6, 5.0.0)", org.springframework.data.*;version="[1.9.0,2.0.0)",