From 8363d6f4630d3880a69f94c3ddbcc7ac4d63cc2c Mon Sep 17 00:00:00 2001 From: John Blum Date: Fri, 22 May 2015 18:22:50 -0700 Subject: [PATCH] SGF-398 - Provide early support of Apache Geode (Pivotal GemFire OSS). Fixed up and polished additional SDG test suite classes related to Pivotal GemFire functionality and features when ran with Apache Geode. Also introduced a GemfireFeature enumerated type to implement more fine-grained control of specific feature checking when attributes of XML namespace elements refer to Pivotal GemFire specific features. --- build.gradle | 4 +- gradle.properties | 4 +- .../data/gemfire/CacheFactoryBean.java | 10 ++-- .../data/gemfire/GemfireUtils.java | 14 ++++- .../gemfire/PartitionedRegionFactoryBean.java | 6 -- .../gemfire/config/AbstractRegionParser.java | 9 +-- .../data/gemfire/config/CacheParser.java | 4 +- .../data/gemfire/config/ParsingUtils.java | 29 ++++----- .../config/support/GemfireFeature.java | 59 +++++++++++++++++++ .../CacheAutoReconnectIntegrationTests.java | 2 + .../data/gemfire/CacheFactoryBeanTest.java | 6 -- .../data/gemfire/GemfireUtilsTest.java | 2 +- ...usQueryListenerContainerNamespaceTest.java | 8 ++- ...GatewayReceiverAutoStartNamespaceTest.java | 6 ++ ...ewayReceiverDefaultStartNamespaceTest.java | 6 ++ ...tewayReceiverManualStartNamespaceTest.java | 6 ++ .../config/GemfireV7GatewayNamespaceTest.java | 13 +--- .../listener/ListenerContainerTests.java | 3 +- .../adapter/ContainerXmlSetupTest.java | 3 +- .../test/GemfireProfileValueSource.java | 2 +- .../data/gemfire/test/StubCache.java | 11 +++- ...alGatewayReceiverStartIntegrationTest.java | 3 +- 22 files changed, 145 insertions(+), 65 deletions(-) create mode 100644 src/main/java/org/springframework/data/gemfire/config/support/GemfireFeature.java diff --git a/build.gradle b/build.gradle index 27bcfb25..ee28ab9b 100644 --- a/build.gradle +++ b/build.gradle @@ -52,6 +52,7 @@ if (project.hasProperty('platformVersion')) { tasks.withType(Test).all { forkEvery = 1 + systemProperties['product.name'] = 'Apache Geode' systemProperties['gemfire.disableShutdownHook'] = 'true' systemProperties['org.springframework.data.gemfire.test.GemfireTestRunner.nomock'] = System.getProperty('org.springframework.data.gemfire.test.GemfireTestRunner.nomock') } @@ -71,7 +72,7 @@ dependencies { exclude group: "commons-logging", module: "commons-logging" } - // GemFire + // Apache Geode (a.k.a. Pivotal GemFire) compile("com.gemstone.gemfire:gemfire-core:$gemfireVersion") compile("com.gemstone.gemfire:gemfire-jgroups:$gemfireVersion") compile("com.gemstone.gemfire:gemfire-joptsimple:$gemfireVersion") @@ -80,7 +81,6 @@ dependencies { runtime("antlr:antlr:$antlrVersion") compile "org.aspectj:aspectjweaver:$aspectjVersion" - compile "com.fasterxml.jackson.core:jackson-core:$jacksonVersion" compile "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion" compile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion" compile "org.slf4j:slf4j-api:$slf4jVersion" diff --git a/gradle.properties b/gradle.properties index 37ef5305..227ed336 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ antlrVersion=2.7.7 aspectjVersion=1.8.5 -gemfireVersion=1.0.0.0-SNAPSHOT +gemfireVersion=1.0.0-incubating-SNAPSHOT hamcrestVersion=1.3 jacksonVersion=2.5.1 junitVersion=4.12 @@ -11,4 +11,4 @@ spring.range="[4.0.0, 5.0.0)" springVersion=4.1.6.RELEASE springDataBuildVersion=1.7.0.BUILD-SNAPSHOT springDataCommonsVersion=1.11.0.BUILD-SNAPSHOT -version=1.7.0.BUILD-SNAPSHOT +version=1.7.0.APACHE-GEODE-BUILD-SNAPSHOT diff --git a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java index b45559c3..8a9ba326 100644 --- a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java @@ -252,12 +252,10 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, /* (non-Javadoc) */ protected void postProcessPropertiesBeforeInitialization(Properties gemfireProperties) { - if (GemfireUtils.isGemfireVersion8OrAbove()) { - gemfireProperties.setProperty("disable-auto-reconnect", String.valueOf( - !Boolean.TRUE.equals(getEnableAutoReconnect()))); - gemfireProperties.setProperty("use-cluster-configuration", String.valueOf( - Boolean.TRUE.equals(getUseClusterConfiguration()))); - } + gemfireProperties.setProperty("disable-auto-reconnect", String.valueOf( + !Boolean.TRUE.equals(getEnableAutoReconnect()))); + gemfireProperties.setProperty("use-cluster-configuration", String.valueOf( + Boolean.TRUE.equals(getUseClusterConfiguration()))); } /* (non-Javadoc) */ diff --git a/src/main/java/org/springframework/data/gemfire/GemfireUtils.java b/src/main/java/org/springframework/data/gemfire/GemfireUtils.java index 76bb9379..58236680 100644 --- a/src/main/java/org/springframework/data/gemfire/GemfireUtils.java +++ b/src/main/java/org/springframework/data/gemfire/GemfireUtils.java @@ -18,6 +18,7 @@ package org.springframework.data.gemfire; import java.util.concurrent.ConcurrentMap; +import org.springframework.data.gemfire.config.support.GemfireFeature; import org.springframework.util.ClassUtils; import org.w3c.dom.Element; @@ -38,7 +39,7 @@ public abstract class GemfireUtils { public final static String GEMFIRE_VERSION = CacheFactory.getVersion(); // TODO use a more reliable means of determining implementing class for GemFire features such as Java's SPI support - private static final String ASYNC_EVENT_QUEUE_TYPE_NAME = "com.gemstone.gemfire.cache.AsyncEventQueue"; + private static final String ASYNC_EVENT_QUEUE_TYPE_NAME = "com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue"; private static final String CQ_TYPE_NAME = "com.gemstone.gemfire.cache.query.internal.cq.CqServiceFactoryImpl"; private static final String GATEWAY_TYPE_NAME = "com.gemstone.gemfire.internal.cache.wan.GatewaySenderFactoryImpl"; @@ -46,6 +47,13 @@ public abstract class GemfireUtils { return ClassUtils.isPresent(fullyQualifiedClassName, GemfireUtils.class.getClassLoader()); } + public static boolean isGemfireFeatureAvailable(GemfireFeature feature) { + boolean featureAvailable = (!GemfireFeature.AEQ.equals(feature) || isAsyncEventQueueAvailable()); + featureAvailable &= (!GemfireFeature.CONTINUOUS_QUERY.equals(feature) || isContinuousQueryAvailable()); + featureAvailable &= (!GemfireFeature.WAN.equals(feature) || isGatewayAvailable()); + return featureAvailable; + } + public static boolean isGemfireFeatureAvailable(Element element) { boolean featureAvailable = (!isAsyncEventQueue(element) || isAsyncEventQueueAvailable()); featureAvailable &= (!isContinuousQuery(element) || isContinuousQueryAvailable()); @@ -53,6 +61,10 @@ public abstract class GemfireUtils { return featureAvailable; } + public static boolean isGemfireFeatureUnavailable(GemfireFeature feature) { + return !isGemfireFeatureAvailable(feature); + } + public static boolean isGemfireFeatureUnavailable(Element element) { return !isGemfireFeatureAvailable(element); } diff --git a/src/main/java/org/springframework/data/gemfire/PartitionedRegionFactoryBean.java b/src/main/java/org/springframework/data/gemfire/PartitionedRegionFactoryBean.java index 270287ed..c05da736 100644 --- a/src/main/java/org/springframework/data/gemfire/PartitionedRegionFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/PartitionedRegionFactoryBean.java @@ -17,7 +17,6 @@ package org.springframework.data.gemfire; import org.springframework.util.Assert; -import com.gemstone.gemfire.cache.CacheFactory; import com.gemstone.gemfire.cache.DataPolicy; import com.gemstone.gemfire.cache.RegionFactory; @@ -29,11 +28,6 @@ public class PartitionedRegionFactoryBean extends RegionFactoryBean @Override protected void resolveDataPolicy(RegionFactory regionFactory, Boolean persistent, DataPolicy dataPolicy) { - // First, verify the GemFire version is 6.5 or Higher when Persistence is specified... - Assert.isTrue(!DataPolicy.PERSISTENT_PARTITION.equals(dataPolicy) || GemfireUtils.isGemfireVersion65OrAbove(), - String.format("Persistent PARTITION Regions can only be used from GemFire 6.5 onwards; current version is [%1$s].", - CacheFactory.getVersion())); - if (dataPolicy == null) { dataPolicy = (isPersistent() ? DataPolicy.PERSISTENT_PARTITION : DataPolicy.PARTITION); } diff --git a/src/main/java/org/springframework/data/gemfire/config/AbstractRegionParser.java b/src/main/java/org/springframework/data/gemfire/config/AbstractRegionParser.java index ab343643..95f95629 100644 --- a/src/main/java/org/springframework/data/gemfire/config/AbstractRegionParser.java +++ b/src/main/java/org/springframework/data/gemfire/config/AbstractRegionParser.java @@ -119,17 +119,14 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser { // Factory will enable gateway if it is not set and hub-id is set. if (StringUtils.hasText(enableGateway)) { - if (GemfireUtils.isGemfireVersion7OrAbove()) { - log.warn("'enable-gateway' has been deprecated since Gemfire 7.0"); - } + log.warn("'enable-gateway' has been deprecated since Gemfire 7.0; use the new GatewaySender/Receiver WAN support instead"); } ParsingUtils.setPropertyValue(element, regionBuilder, "enable-gateway"); if (StringUtils.hasText(hubId)) { - if (GemfireUtils.isGemfireVersion7OrAbove()) { - log.warn("'hub-id' has been deprecated since Gemfire 7.0"); - } + log.warn("'hub-id' has been deprecated since Gemfire 7.0; use the new GatewaySender/Receiver WAN support instead"); + if (!CollectionUtils.isEmpty(DomUtils.getChildElementsByTagName(element, "gateway-sender"))) { parserContext.getReaderContext().error("specifying both 'hub-id' and 'gateway-sender' is invalid", element); diff --git a/src/main/java/org/springframework/data/gemfire/config/CacheParser.java b/src/main/java/org/springframework/data/gemfire/config/CacheParser.java index 5a364d61..86443eed 100644 --- a/src/main/java/org/springframework/data/gemfire/config/CacheParser.java +++ b/src/main/java/org/springframework/data/gemfire/config/CacheParser.java @@ -27,6 +27,7 @@ import org.springframework.beans.factory.support.ManagedMap; import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.data.gemfire.CacheFactoryBean; +import org.springframework.data.gemfire.config.support.GemfireFeature; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.util.xml.DomUtils; @@ -97,7 +98,8 @@ class CacheParser extends AbstractSimpleBeanDefinitionParser { Element gatewayConflictResolver = DomUtils.getChildElementByTagName(element, "gateway-conflict-resolver"); if (gatewayConflictResolver != null) { - ParsingUtils.throwExceptionIfNotGemfireV7(element.getLocalName(), "gateway-conflict-resolver", parserContext); + ParsingUtils.throwExceptionWhenGemFireFeatureUnavailable(GemfireFeature.WAN, element.getLocalName(), + "gateway-conflict-resolver", parserContext); builder.addPropertyValue("gatewayConflictResolver", ParsingUtils.parseRefOrSingleNestedBeanDeclaration( parserContext, gatewayConflictResolver, builder)); } diff --git a/src/main/java/org/springframework/data/gemfire/config/ParsingUtils.java b/src/main/java/org/springframework/data/gemfire/config/ParsingUtils.java index 989302fa..eb6ab025 100644 --- a/src/main/java/org/springframework/data/gemfire/config/ParsingUtils.java +++ b/src/main/java/org/springframework/data/gemfire/config/ParsingUtils.java @@ -18,8 +18,6 @@ package org.springframework.data.gemfire.config; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.springframework.beans.PropertyValue; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.RuntimeBeanReference; @@ -31,6 +29,7 @@ import org.springframework.data.gemfire.EvictionAttributesFactoryBean; import org.springframework.data.gemfire.ExpirationAttributesFactoryBean; import org.springframework.data.gemfire.GemfireUtils; import org.springframework.data.gemfire.SubscriptionAttributesFactoryBean; +import org.springframework.data.gemfire.config.support.GemfireFeature; import org.springframework.util.StringUtils; import org.springframework.util.xml.DomUtils; import org.w3c.dom.Element; @@ -49,8 +48,6 @@ import com.gemstone.gemfire.cache.ResumptionAction; */ abstract class ParsingUtils { - private static final Log log = LogFactory.getLog(ParsingUtils.class); - static void setPropertyReference(Element element, BeanDefinitionBuilder builder, String attributeName, String propertyName) { @@ -329,12 +326,7 @@ abstract class ParsingUtils { String concurrencyChecksEnabled = element.getAttribute("concurrency-checks-enabled"); if (StringUtils.hasText(concurrencyChecksEnabled)) { - if (GemfireUtils.isGemfireVersion7OrAbove()) { - ParsingUtils.setPropertyValue(element, regionAttributesBuilder, "concurrency-checks-enabled"); - } - else { - log.warn("Setting 'concurrency-checks-enabled' is only available in Gemfire 7.0 or above!"); - } + ParsingUtils.setPropertyValue(element, regionAttributesBuilder, "concurrency-checks-enabled"); } } @@ -397,7 +389,8 @@ abstract class ParsingUtils { Element expirationElement = DomUtils.getChildElementByTagName(rootElement, elementName); if (expirationElement != null) { - Object customExpiry = parseRefOrSingleNestedBeanDeclaration(parserContext, expirationElement, regionAttributesBuilder); + Object customExpiry = parseRefOrSingleNestedBeanDeclaration(parserContext, expirationElement, + regionAttributesBuilder); regionAttributesBuilder.addPropertyValue(propertyName, customExpiry); return true; } @@ -416,10 +409,6 @@ abstract class ParsingUtils { } } - static String resolveCacheReference(final String cacheRef) { - return (StringUtils.hasText(cacheRef) ? cacheRef : GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME); - } - static void assertGemFireFeatureAvailable(Element element, ParserContext parserContext) { if (GemfireUtils.isGemfireFeatureUnavailable(element)) { parserContext.getReaderContext().error(String.format("'%1$s' is not supported in %2$s v%3$s", @@ -427,8 +416,14 @@ abstract class ParsingUtils { } } - static void throwExceptionIfNotGemfireV7(String elementName, String attributeName, ParserContext parserContext) { - if (!GemfireUtils.isGemfireVersion7OrAbove()) { + static String resolveCacheReference(final String cacheRef) { + return (StringUtils.hasText(cacheRef) ? cacheRef : GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME); + } + + static void throwExceptionWhenGemFireFeatureUnavailable(GemfireFeature feature, + String elementName, String attributeName, ParserContext parserContext) { + + if (GemfireUtils.isGemfireFeatureUnavailable(feature)) { String messagePrefix = (attributeName != null) ? String.format("Attribute '%1$s' of element '%2$s'", attributeName, elementName) : String.format("Element '%1$s'", elementName); diff --git a/src/main/java/org/springframework/data/gemfire/config/support/GemfireFeature.java b/src/main/java/org/springframework/data/gemfire/config/support/GemfireFeature.java new file mode 100644 index 00000000..6e0dcd58 --- /dev/null +++ b/src/main/java/org/springframework/data/gemfire/config/support/GemfireFeature.java @@ -0,0 +1,59 @@ +/* + * 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.support; + +/** + * The GemfireFeature enum is an enumeration of features available in Apache Geode and Pivotal GemFire combined. + * + * @author John Blum + * @since 1.7.0 + */ +@SuppressWarnings("unused") +public enum GemfireFeature { + AEQ, + BACKUP, + CACHING, + CLIENT_SERVER, + COMPRESSION, + CONFIGURATION, + CONSISTENCY, + CONTINUOUS_QUERY, + DELTA_PROPAGATION, + EVENT_HANDLING, + FUNCTIONS, + HTTP_SESSION_MANAGEMENT, + INDEXING, + JSON, + LOGGING, + MANAGEMENT_MONITORING, + MEMCACHE_SUPPORT, + NETWORK_PARTITIONING, + OFF_HEAP, + PARTITIONING, + PEER_TO_PEER, + PERSISTENCE, + QUERY, + REGISTER_INTEREST, + REPLICATION, + SECURITY, + SERIALIZATION, + STATISTICS, + TRANSACTIONS, + TUNING, + WAN + +} diff --git a/src/test/java/org/springframework/data/gemfire/CacheAutoReconnectIntegrationTests.java b/src/test/java/org/springframework/data/gemfire/CacheAutoReconnectIntegrationTests.java index b2c3f7cf..fb2825d6 100644 --- a/src/test/java/org/springframework/data/gemfire/CacheAutoReconnectIntegrationTests.java +++ b/src/test/java/org/springframework/data/gemfire/CacheAutoReconnectIntegrationTests.java @@ -59,6 +59,7 @@ public class CacheAutoReconnectIntegrationTests { @Test public void testAutoReconnectDisabled() { Cache cache = getCache("cacheAutoReconnectDisabledIntegrationTests.xml"); + assertNotNull(cache); assertNotNull(cache.getDistributedSystem()); assertNotNull(cache.getDistributedSystem().getProperties()); assertTrue(Boolean.valueOf(cache.getDistributedSystem().getProperties().getProperty("disable-auto-reconnect"))); @@ -67,6 +68,7 @@ public class CacheAutoReconnectIntegrationTests { @Test public void testAutoReconnectEnabled() { Cache cache = getCache("cacheAutoReconnectEnabledIntegrationTests.xml"); + assertNotNull(cache); assertNotNull(cache.getDistributedSystem()); assertNotNull(cache.getDistributedSystem().getProperties()); assertFalse(Boolean.valueOf(cache.getDistributedSystem().getProperties().getProperty("disable-auto-reconnect"))); diff --git a/src/test/java/org/springframework/data/gemfire/CacheFactoryBeanTest.java b/src/test/java/org/springframework/data/gemfire/CacheFactoryBeanTest.java index de5e3a55..0fdfcee3 100644 --- a/src/test/java/org/springframework/data/gemfire/CacheFactoryBeanTest.java +++ b/src/test/java/org/springframework/data/gemfire/CacheFactoryBeanTest.java @@ -270,8 +270,6 @@ public class CacheFactoryBeanTest { @Test public void testPostProcessPropertiesBeforeInitializationDefaults() { - assumeTrue(GemfireUtils.isGemfireVersion8OrAbove()); - Properties gemfireProperties = new Properties(); assertTrue(gemfireProperties.isEmpty()); @@ -289,8 +287,6 @@ public class CacheFactoryBeanTest { @Test public void testPostProcessPropertiesBeforeInitializationDisabled() { - assumeTrue(GemfireUtils.isGemfireVersion8OrAbove()); - Properties gemfireProperties = new Properties(); assertTrue(gemfireProperties.isEmpty()); @@ -310,8 +306,6 @@ public class CacheFactoryBeanTest { @Test public void testPostProcessPropertiesBeforeInitializationEnabled() { - assumeTrue(GemfireUtils.isGemfireVersion8OrAbove()); - Properties gemfireProperties = new Properties(); assertTrue(gemfireProperties.isEmpty()); diff --git a/src/test/java/org/springframework/data/gemfire/GemfireUtilsTest.java b/src/test/java/org/springframework/data/gemfire/GemfireUtilsTest.java index 44682718..fb689fdd 100644 --- a/src/test/java/org/springframework/data/gemfire/GemfireUtilsTest.java +++ b/src/test/java/org/springframework/data/gemfire/GemfireUtilsTest.java @@ -64,7 +64,7 @@ public class GemfireUtilsTest { public void isGemfireVersion8OrAbove() { int gemfireVersion = getGemFireVersion(); assumeTrue(gemfireVersion > -1); - assertEquals(getGemFireVersion() >= 80, GemfireUtils.isGemfireVersion7OrAbove()); + assertEquals(getGemFireVersion() >= 80, GemfireUtils.isGemfireVersion8OrAbove()); } } diff --git a/src/test/java/org/springframework/data/gemfire/config/ContinuousQueryListenerContainerNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/ContinuousQueryListenerContainerNamespaceTest.java index c3cf6705..9b46942d 100644 --- a/src/test/java/org/springframework/data/gemfire/config/ContinuousQueryListenerContainerNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/ContinuousQueryListenerContainerNamespaceTest.java @@ -39,6 +39,9 @@ import org.springframework.data.gemfire.listener.ContinuousQueryListener; import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer; import org.springframework.data.gemfire.listener.GemfireMDP; import org.springframework.data.gemfire.listener.adapter.ContinuousQueryListenerAdapter; +import org.springframework.data.gemfire.test.GemfireProfileValueSource; +import org.springframework.test.annotation.IfProfileValue; +import org.springframework.test.annotation.ProfileValueSourceConfiguration; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.util.ErrorHandler; @@ -63,8 +66,11 @@ import com.gemstone.gemfire.cache.query.CqQuery; * @see com.gemstone.gemfire.cache.query.CqQuery * @since 1.4.0 */ -@ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration +@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, + value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) +@ProfileValueSourceConfiguration(GemfireProfileValueSource.class) @SuppressWarnings("unused") public class ContinuousQueryListenerContainerNamespaceTest { diff --git a/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverAutoStartNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverAutoStartNamespaceTest.java index 5b072576..4593af96 100644 --- a/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverAutoStartNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverAutoStartNamespaceTest.java @@ -24,8 +24,11 @@ import javax.annotation.Resource; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.data.gemfire.test.GemfireProfileValueSource; import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer; import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean; +import org.springframework.test.annotation.IfProfileValue; +import org.springframework.test.annotation.ProfileValueSourceConfiguration; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -52,6 +55,9 @@ import com.gemstone.gemfire.cache.wan.GatewayReceiver; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(value = "GatewayReceiverNamespaceTest-context.xml", initializers = GemfireTestApplicationContextInitializer.class) +@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, + value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) +@ProfileValueSourceConfiguration(GemfireProfileValueSource.class) @ActiveProfiles("autoStart") @SuppressWarnings("unused") public class GatewayReceiverAutoStartNamespaceTest { diff --git a/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverDefaultStartNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverDefaultStartNamespaceTest.java index 1be48e47..98da64ef 100644 --- a/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverDefaultStartNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverDefaultStartNamespaceTest.java @@ -24,8 +24,11 @@ import javax.annotation.Resource; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.data.gemfire.test.GemfireProfileValueSource; import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer; import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean; +import org.springframework.test.annotation.IfProfileValue; +import org.springframework.test.annotation.ProfileValueSourceConfiguration; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -52,6 +55,9 @@ import com.gemstone.gemfire.cache.wan.GatewayReceiver; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(value = "GatewayReceiverNamespaceTest-context.xml", initializers = GemfireTestApplicationContextInitializer.class) +@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, + value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) +@ProfileValueSourceConfiguration(GemfireProfileValueSource.class) @ActiveProfiles("defaultStart") @SuppressWarnings("unused") public class GatewayReceiverDefaultStartNamespaceTest { diff --git a/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverManualStartNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverManualStartNamespaceTest.java index 6c455f8f..a535a60e 100644 --- a/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverManualStartNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/GatewayReceiverManualStartNamespaceTest.java @@ -24,8 +24,11 @@ import javax.annotation.Resource; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.data.gemfire.test.GemfireProfileValueSource; import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer; import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean; +import org.springframework.test.annotation.IfProfileValue; +import org.springframework.test.annotation.ProfileValueSourceConfiguration; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -51,6 +54,9 @@ import com.gemstone.gemfire.cache.wan.GatewayReceiver; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(value = "GatewayReceiverNamespaceTest-context.xml", initializers = GemfireTestApplicationContextInitializer.class) +@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, + value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) +@ProfileValueSourceConfiguration(GemfireProfileValueSource.class) @ActiveProfiles("manualStart") @SuppressWarnings("unused") public class GatewayReceiverManualStartNamespaceTest { diff --git a/src/test/java/org/springframework/data/gemfire/config/GemfireV7GatewayNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/GemfireV7GatewayNamespaceTest.java index 96a5b308..ace3d5b6 100644 --- a/src/test/java/org/springframework/data/gemfire/config/GemfireV7GatewayNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/GemfireV7GatewayNamespaceTest.java @@ -28,10 +28,8 @@ import java.io.OutputStream; import java.util.List; import org.junit.AfterClass; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.data.gemfire.GemfireUtils; import org.springframework.data.gemfire.RecreatingContextTest; import org.springframework.data.gemfire.RegionFactoryBean; import org.springframework.data.gemfire.TestUtils; @@ -60,7 +58,8 @@ import com.gemstone.gemfire.cache.wan.GatewayTransportFilter; * @author John Blum */ @RunWith(SpringJUnit4ClassRunner.class) -@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) +@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, + value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) @ProfileValueSourceConfiguration(GemfireProfileValueSource.class) @SuppressWarnings("unused") public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest { @@ -79,14 +78,6 @@ public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest { ctx.getBeanFactory().addBeanPostProcessor(new GemfireTestBeanPostProcessor()); } - @Before - @Override - public void createCtx() { - if (GemfireUtils.isGemfireVersion7OrAbove()) { - super.createCtx(); - } - } - @AfterClass public static void tearDown() { for (String name : new File(".").list(new FilenameFilter() { diff --git a/src/test/java/org/springframework/data/gemfire/listener/ListenerContainerTests.java b/src/test/java/org/springframework/data/gemfire/listener/ListenerContainerTests.java index a4714e01..8455eab5 100644 --- a/src/test/java/org/springframework/data/gemfire/listener/ListenerContainerTests.java +++ b/src/test/java/org/springframework/data/gemfire/listener/ListenerContainerTests.java @@ -41,7 +41,8 @@ import com.gemstone.gemfire.cache.query.CqEvent; * @author Costin Leau */ @RunWith(SpringJUnit4ClassRunner.class) -@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) +@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, + value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) @ProfileValueSourceConfiguration(GemfireProfileValueSource.class) public class ListenerContainerTests { diff --git a/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlSetupTest.java b/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlSetupTest.java index 0b9a764c..54a69cfc 100644 --- a/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlSetupTest.java +++ b/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlSetupTest.java @@ -42,7 +42,8 @@ import com.gemstone.gemfire.cache.query.CqQuery; * @author John Blum */ @RunWith(SpringJUnit4ClassRunner.class) -@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) +@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, + value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) @ProfileValueSourceConfiguration(GemfireProfileValueSource.class) public class ContainerXmlSetupTest { diff --git a/src/test/java/org/springframework/data/gemfire/test/GemfireProfileValueSource.java b/src/test/java/org/springframework/data/gemfire/test/GemfireProfileValueSource.java index fefa8b8e..3be08236 100644 --- a/src/test/java/org/springframework/data/gemfire/test/GemfireProfileValueSource.java +++ b/src/test/java/org/springframework/data/gemfire/test/GemfireProfileValueSource.java @@ -40,7 +40,7 @@ public class GemfireProfileValueSource implements ProfileValueSource { private static final Map PROFILE_VALUES = new ConcurrentHashMap(); static { - PROFILE_VALUES.put(PRODUCT_NAME_KEY, GemfireUtils.GEMFIRE_NAME); + PROFILE_VALUES.put(PRODUCT_NAME_KEY, System.getProperty(PRODUCT_NAME_KEY, GemfireUtils.GEMFIRE_NAME)); } @Override 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 48bac9d3..72b84796 100644 --- a/src/test/java/org/springframework/data/gemfire/test/StubCache.java +++ b/src/test/java/org/springframework/data/gemfire/test/StubCache.java @@ -37,6 +37,7 @@ import com.gemstone.gemfire.cache.TimeoutException; import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue; import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueueFactory; import com.gemstone.gemfire.cache.control.ResourceManager; +import com.gemstone.gemfire.cache.lucene.LuceneService; import com.gemstone.gemfire.cache.query.Index; import com.gemstone.gemfire.cache.query.IndexExistsException; import com.gemstone.gemfire.cache.query.IndexInvalidException; @@ -578,9 +579,17 @@ public class StubCache implements Cache { } /* (non-Javadoc) - * @see com.gemstone.gemfire.cache.Cache#getMembers() + * @see com.gemstone.gemfire.cache.Cache#getLuceneService() */ @Override + public LuceneService getLuceneService() { + throw new UnsupportedOperationException(NOT_IMPLEMENTED); + } + + /* (non-Javadoc) + * @see com.gemstone.gemfire.cache.Cache#getMembers() + */ + @Override public Set getMembers() { throw new UnsupportedOperationException(NOT_IMPLEMENTED); } diff --git a/src/test/java/org/springframework/data/gemfire/wan/ManualGatewayReceiverStartIntegrationTest.java b/src/test/java/org/springframework/data/gemfire/wan/ManualGatewayReceiverStartIntegrationTest.java index fb5a5fc3..9f972490 100644 --- a/src/test/java/org/springframework/data/gemfire/wan/ManualGatewayReceiverStartIntegrationTest.java +++ b/src/test/java/org/springframework/data/gemfire/wan/ManualGatewayReceiverStartIntegrationTest.java @@ -49,7 +49,8 @@ import com.gemstone.gemfire.cache.wan.GatewayReceiver; */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(initializers = GemfireTestApplicationContextInitializer.class) -@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) +@IfProfileValue(name = GemfireProfileValueSource.PRODUCT_NAME_KEY, + value = GemfireProfileValueSource.PIVOTAL_GEMFIRE_PRODUCT_NAME) @ProfileValueSourceConfiguration(GemfireProfileValueSource.class) @SuppressWarnings("unused") public class ManualGatewayReceiverStartIntegrationTest {