Fix additional tests based on the STDG 0.0.26 upgrade.

Resolves gh-296.
This commit is contained in:
John Blum
2021-09-08 13:28:38 -07:00
parent 4024fc9d24
commit d9c8542454
106 changed files with 854 additions and 859 deletions

View File

@@ -16,14 +16,21 @@
package org.springframework.data.gemfire;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.data.gemfire.util.RegionUtils;
import org.springframework.util.Assert;
/**
* Spring {@link FactoryBean} used to create an Apache Geode {@literal PARTITION} {@link Region}.
*
* @author David Turanski
* @author John Blum
* @see org.apache.geode.cache.Region
* @see org.apache.geode.cache.RegionFactory
* @see org.springframework.beans.factory.BeanFactory
*/
public class PartitionedRegionFactoryBean<K, V> extends PeerRegionFactoryBean<K, V> {
@@ -36,8 +43,8 @@ public class PartitionedRegionFactoryBean<K, V> extends PeerRegionFactoryBean<K,
else {
// Validate that the user-defined Data Policy matches the appropriate Spring GemFire XML namespace
// configuration meta-data element for Region (i.e. <gfe:partitioned-region .../>)!
Assert.isTrue(dataPolicy.withPartitioning(), String.format(
"Data Policy [%s] is not supported in Partitioned Regions.", dataPolicy));
Assert.isTrue(dataPolicy.withPartitioning(),
String.format("Data Policy [%s] is not supported in Partitioned Regions.", dataPolicy));
}
// Validate the data-policy and persistent attributes are compatible when specified!

View File

@@ -232,12 +232,12 @@ public abstract class PeerRegionFactoryBean<K, V> extends ConfigurableRegionFact
}
/**
* Creates an instance of {@link RegionFactory} with the given {@link Cache} which is then used to construct,
* configure and initialize the {@link Region} specified by this {@link PeerRegionFactoryBean}.
* Create a new instance of {@link RegionFactory} initialized with the given {@link Cache} that is then used
* to construct, configure and initialize the {@link Region} specified by this {@link PeerRegionFactoryBean}.
*
* @param cache reference to the {@link Cache}.
* @return a {@link RegionFactory} used to construct, configure and initialized the {@link Region} specified by
* this {@link PeerRegionFactoryBean}.
* @return a {@link RegionFactory} used to construct, configure and initialize the {@link Region}
* specified by this {@link PeerRegionFactoryBean}.
* @see org.apache.geode.cache.Cache#createRegionFactory(org.apache.geode.cache.RegionShortcut)
* @see org.apache.geode.cache.Cache#createRegionFactory(org.apache.geode.cache.RegionAttributes)
* @see org.apache.geode.cache.Cache#createRegionFactory()

View File

@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire;
import org.apache.geode.cache.Scope;
@@ -29,6 +28,7 @@ import org.springframework.util.StringUtils;
*/
@SuppressWarnings("unused")
public enum ScopeType {
DISTRIBUTED_ACK(Scope.DISTRIBUTED_ACK),
DISTRIBUTED_NO_ACK(Scope.DISTRIBUTED_NO_ACK),
GLOBAL(Scope.GLOBAL),
@@ -42,7 +42,7 @@ public enum ScopeType {
* @param gemfireScope the GemFire Scope paired with this enumerated value.
* @see org.apache.geode.cache.Scope
*/
ScopeType(final Scope gemfireScope) {
ScopeType(Scope gemfireScope) {
this.gemfireScope = gemfireScope;
}
@@ -55,8 +55,8 @@ public enum ScopeType {
* @see org.apache.geode.cache.Scope
* @see #getScope()
*/
public static Scope getScope(final ScopeType scopeType) {
return (scopeType != null ? scopeType.getScope() : null);
public static Scope getScope(ScopeType scopeType) {
return scopeType != null ? scopeType.getScope() : null;
}
/**
@@ -69,6 +69,7 @@ public enum ScopeType {
* @see #values()
*/
public static ScopeType valueOf(final Scope scope) {
for (ScopeType scopeType : values()) {
if (scopeType.getScope().equals(scope)) {
return scopeType;
@@ -89,6 +90,7 @@ public enum ScopeType {
* @see #transform(String)
*/
public static ScopeType valueOfIgnoreCase(String name) {
name = transform(name);
for (ScopeType scopeType : values()) {
@@ -108,8 +110,8 @@ public enum ScopeType {
* @return a String value with underscores for hyphens and all leading/trailing whitespace trimmed, or null
* if the given String name is null.
*/
private static String transform(final String name) {
return (StringUtils.hasText(name) ? name.trim().replaceAll("-", "_") : name);
private static String transform(String name) {
return StringUtils.hasText(name) ? name.trim().replaceAll("-", "_") : name;
}
/**
@@ -119,7 +121,6 @@ public enum ScopeType {
* @see org.apache.geode.cache.Scope
*/
public Scope getScope() {
return gemfireScope;
return this.gemfireScope;
}
}

View File

@@ -148,12 +148,24 @@ public class ClientRegionFactoryBean<K, V> extends ConfigurableRegionFactoryBean
@Override
public void afterPropertiesSet() throws Exception {
initializePoolResolver();
super.afterPropertiesSet();
}
/**
* Initializes the {@literal default} {@link PoolResolver} and optionally sets the main {@link PoolResolver}
* used to resolve {@link Pool} objects from Apache Geode if not configured by the user.
*
* @see org.springframework.data.gemfire.client.PoolResolver
* @see org.springframework.data.gemfire.client.support.BeanFactoryPoolResolver
* @see org.springframework.data.gemfire.client.support.PoolManagerPoolResolver
*/
void initializePoolResolver() {
this.defaultPoolResolver =
ComposablePoolResolver.compose(new BeanFactoryPoolResolver(getBeanFactory()), new PoolManagerPoolResolver());
this.poolResolver = defaultPoolResolver;
super.afterPropertiesSet();
this.poolResolver = this.poolResolver != null ? this.poolResolver : this.defaultPoolResolver;
}
/**

View File

@@ -309,6 +309,7 @@ public class CachingDefinedRegionsConfiguration extends AbstractAnnotationConfig
GemFireCache gemfireCache = beanFactory.getBean(GemFireCache.class);
regionFactoryBean.setBeanFactory(beanFactory);
regionFactoryBean.setCache(gemfireCache);
regionFactoryBean.setClientRegionShortcut(resolveClientRegionShortcut());
regionFactoryBean.setRegionConfigurers(resolveRegionConfigurers());

View File

@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.config.annotation;
import static java.util.Arrays.stream;

View File

@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.config.annotation;
import static org.springframework.data.gemfire.config.annotation.CompressionConfiguration.SNAPPY_COMPRESSOR_BEAN_NAME;

View File

@@ -26,8 +26,11 @@ import org.apache.geode.cache.Scope;
import org.apache.geode.cache.wan.GatewaySender;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyEditorRegistrar;
import org.springframework.beans.PropertyEditorRegistry;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.Ordered;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.gemfire.IndexMaintenancePolicyConverter;
import org.springframework.data.gemfire.IndexMaintenancePolicyType;
@@ -56,10 +59,20 @@ import org.springframework.data.gemfire.wan.OrderPolicyConverter;
* @author John Blum
* @see java.beans.PropertyEditor
* @see java.beans.PropertyEditorSupport
* @see org.springframework.beans.PropertyEditorRegistrar
* @see org.springframework.beans.PropertyEditorRegistry
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor
* @since 1.6.0
*/
public class CustomEditorBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
public class CustomEditorBeanFactoryPostProcessor implements BeanFactoryPostProcessor, Ordered {
/**
* {@inheritDoc}
*/
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE;
}
/**
* {@inheritDoc}
@@ -67,21 +80,52 @@ public class CustomEditorBeanFactoryPostProcessor implements BeanFactoryPostProc
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
beanFactory.registerCustomEditor(ConnectionEndpoint.class, StringToConnectionEndpointConverter.class);
//beanFactory.registerCustomEditor(ConnectionEndpoint[].class, ConnectionEndpointArrayToIterableConverter.class);
beanFactory.registerCustomEditor(ConnectionEndpointList.class, StringToConnectionEndpointListConverter.class);
beanFactory.registerCustomEditor(EvictionAction.class, EvictionActionConverter.class);
beanFactory.registerCustomEditor(EvictionPolicyType.class, EvictionPolicyConverter.class);
beanFactory.registerCustomEditor(ExpirationAction.class, ExpirationActionConverter.class);
beanFactory.registerCustomEditor(IndexMaintenancePolicyType.class, IndexMaintenancePolicyConverter.class);
beanFactory.registerCustomEditor(IndexType.class, IndexTypeConverter.class);
beanFactory.registerCustomEditor(InterestPolicy.class, InterestPolicyConverter.class);
beanFactory.registerCustomEditor(InterestResultPolicy.class, InterestResultPolicyConverter.class);
beanFactory.registerCustomEditor(GatewaySender.OrderPolicy.class, OrderPolicyConverter.class);
beanFactory.registerCustomEditor(Scope.class, ScopeConverter.class);
beanFactory.registerCustomEditor(SubscriptionEvictionPolicy.class, SubscriptionEvictionPolicyConverter.class);
beanFactory.addPropertyEditorRegistrar(new CustomEditorPropertyEditorRegistrar());
//registerCustomEditors(beanFactory);
}
@SuppressWarnings("unused")
private void registerCustomEditors(ConfigurableListableBeanFactory beanFactory) {
if (beanFactory != null) {
beanFactory.registerCustomEditor(ConnectionEndpoint.class, StringToConnectionEndpointConverter.class);
//beanFactory.registerCustomEditor(ConnectionEndpoint[].class, ConnectionEndpointArrayToIterableConverter.class);
beanFactory.registerCustomEditor(ConnectionEndpointList.class, StringToConnectionEndpointListConverter.class);
beanFactory.registerCustomEditor(EvictionAction.class, EvictionActionConverter.class);
beanFactory.registerCustomEditor(EvictionPolicyType.class, EvictionPolicyConverter.class);
beanFactory.registerCustomEditor(ExpirationAction.class, ExpirationActionConverter.class);
beanFactory.registerCustomEditor(IndexMaintenancePolicyType.class, IndexMaintenancePolicyConverter.class);
beanFactory.registerCustomEditor(IndexType.class, IndexTypeConverter.class);
beanFactory.registerCustomEditor(InterestPolicy.class, InterestPolicyConverter.class);
beanFactory.registerCustomEditor(InterestResultPolicy.class, InterestResultPolicyConverter.class);
beanFactory.registerCustomEditor(GatewaySender.OrderPolicy.class, OrderPolicyConverter.class);
beanFactory.registerCustomEditor(Scope.class, ScopeConverter.class);
beanFactory.registerCustomEditor(SubscriptionEvictionPolicy.class, SubscriptionEvictionPolicyConverter.class);
}
}
public static class CustomEditorPropertyEditorRegistrar implements PropertyEditorRegistrar {
@Override
public void registerCustomEditors(PropertyEditorRegistry registry) {
if (registry != null) {
registry.registerCustomEditor(ConnectionEndpoint.class, new StringToConnectionEndpointConverter());
//registry.registerCustomEditor(ConnectionEndpoint[].class, new ConnectionEndpointArrayToIterableConverter()));
registry.registerCustomEditor(ConnectionEndpointList.class, new StringToConnectionEndpointListConverter());
registry.registerCustomEditor(EvictionAction.class, new EvictionActionConverter());
registry.registerCustomEditor(EvictionPolicyType.class, new EvictionPolicyConverter());
registry.registerCustomEditor(ExpirationAction.class, new ExpirationActionConverter());
registry.registerCustomEditor(IndexMaintenancePolicyType.class, new IndexMaintenancePolicyConverter());
registry.registerCustomEditor(IndexType.class, new IndexTypeConverter());
registry.registerCustomEditor(InterestPolicy.class, new InterestPolicyConverter());
registry.registerCustomEditor(InterestResultPolicy.class, new InterestResultPolicyConverter());
registry.registerCustomEditor(GatewaySender.OrderPolicy.class, new OrderPolicyConverter());
registry.registerCustomEditor(Scope.class, new ScopeConverter());
registry.registerCustomEditor(SubscriptionEvictionPolicy.class, new SubscriptionEvictionPolicyConverter());
}
}
}
public static class ConnectionEndpointArrayToIterableConverter extends PropertyEditorSupport
implements Converter<ConnectionEndpoint[], Iterable<?>> {

View File

@@ -19,13 +19,13 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
import org.apache.geode.cache.wan.GatewaySender;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
/**
* Abstract Spring XML Parser for peer {@link Region} bean definitions.
* Abstract Spring XML parser for peer {@link Region} bean definitions.
*
* @author John Blum
* @see org.apache.geode.cache.Region
@@ -33,11 +33,15 @@ import org.springframework.beans.factory.xml.ParserContext;
* @see org.apache.geode.cache.wan.GatewaySender
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
* @see org.springframework.beans.factory.xml.ParserContext
* @see org.springframework.data.gemfire.config.xml.AbstractRegionParser
* @see org.w3c.dom.Element
* @since 2.2.0
*/
public abstract class AbstractPeerRegionParser extends AbstractRegionParser {
/**
* @inheritDoc
*/
@Override
protected void doParseRegionConfiguration(Element element, ParserContext parserContext,
BeanDefinitionBuilder regionBuilder, BeanDefinitionBuilder regionAttributesBuilder, boolean subRegion) {

View File

@@ -22,12 +22,9 @@ import java.util.Optional;
import org.apache.geode.cache.Region;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -35,11 +32,16 @@ import org.springframework.beans.factory.support.ManagedArray;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.data.gemfire.PeerRegionFactoryBean;
import org.springframework.lang.NonNull;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
/**
* Abstract base class encapsulating functionality common to all Region parsers.
*
@@ -50,6 +52,10 @@ import org.springframework.util.xml.DomUtils;
*/
abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
protected static final String REGION_DEFINITION_SUFFIX = "region";
protected static final String REGION_TEMPLATE_SUFFIX = "-template";
protected static final String TEMPLATE_ATTRIBUTE = "template";
protected final Logger logger = LoggerFactory.getLogger(getClass());
/**
@@ -60,6 +66,13 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
return getRegionFactoryClass();
}
/**
* Return the {@link Class type} of the {@link Region} {@link FactoryBean}.
*
* @return the {@link Class type} of the {@link Region} {@link FactoryBean}.
* @see org.springframework.beans.factory.FactoryBean
* @see java.lang.Class
*/
protected abstract Class<?> getRegionFactoryClass();
/**
@@ -68,23 +81,41 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
@Override
protected String getParentName(Element element) {
String regionTemplate = element.getAttribute("template");
String regionTemplate = element.getAttribute(TEMPLATE_ATTRIBUTE);
return StringUtils.hasText(regionTemplate) ? regionTemplate : super.getParentName(element);
}
protected boolean isRegionTemplate(Element element) {
/**
* Determines whether the given SDG XML namespace configuration {@link Element} defines a {@link Region} template
* used as the base configuration for one or more {@link Region Regions}.
*
* @param element SDG XML namespace {@link Element}.
* @return a boolean value indicating whether the given SDG XML namespace configuration {@link Element}
* defines a {@link Region} template.
* @see org.w3c.dom.Element
*/
protected boolean isRegionTemplate(@NonNull Element element) {
String localName = element.getLocalName();
return localName != null && localName.endsWith("-template");
return localName != null && localName.endsWith(REGION_TEMPLATE_SUFFIX);
}
protected boolean isSubRegion(Element element) {
/**
* Determines whether the current SDG XML namespace {@link Region} {@link Element} is a {@link Region Sub-Region}
* definition.
*
* @param element SDG XML namespace {@link Region} {@link Element} to evaluate as a {@link Region Sub-Region}.
* @return a boolean value indicating whether the current SDG XML namespace {@link Region} {@link Element}
* is a {@link Region Sub-Region} definition.
* @see org.w3c.dom.Element
*/
protected boolean isSubRegion(@NonNull Element element) {
String localName = element.getParentNode().getLocalName();
return localName != null && localName.endsWith("region");
return localName != null && localName.endsWith(REGION_DEFINITION_SUFFIX);
}
/**
@@ -93,7 +124,7 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
super.doParse(element, builder);
super.doParse(element, parserContext, builder);
builder.setAbstract(isRegionTemplate(element));

View File

@@ -21,6 +21,8 @@ import java.util.Optional;
import org.apache.geode.internal.datasource.ConfigProperty;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
@@ -30,10 +32,14 @@ import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.gemfire.CacheFactoryBean;
import org.springframework.data.gemfire.config.support.CustomEditorBeanFactoryPostProcessor;
import org.springframework.data.gemfire.config.support.GemfireFeature;
import org.springframework.data.gemfire.config.support.PdxDiskStoreAwareBeanFactoryPostProcessor;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
@@ -43,18 +49,18 @@ import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
/**
* {@link BeanDefinitionParser} for the &lt;gfe:cache&gt; SDG XML Namespace (XSD) element.
* Spring {@link BeanDefinitionParser} for the &lt;gfe:cache&gt; SDG XML namespace element.
*
* @author Costin Leau
* @author Oliver Gierke
* @author David Turanski
* @author John Blum
* @author Patrick Johnson
* @see org.w3c.dom.Element
* @see org.springframework.beans.factory.support.AbstractBeanDefinition
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
* @see org.springframework.beans.factory.support.BeanDefinitionRegistry
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
* @see org.springframework.beans.factory.xml.BeanDefinitionParser
* @see org.springframework.beans.factory.xml.ParserContext
* @see org.springframework.data.gemfire.CacheFactoryBean
* @see org.w3c.dom.Element
@@ -77,7 +83,7 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
super.doParse(element, cacheBuilder);
registerGemFireBeanFactoryPostProcessors(getRegistry(parserContext));
registerGemFirePropertyEditorRegistrarWithBeanFactory(getRegistry(parserContext));
ParsingUtils.setPropertyValue(element, cacheBuilder, "cache-xml-location", "cacheXml");
ParsingUtils.setPropertyReference(element, cacheBuilder, "properties-ref", "properties");
@@ -92,7 +98,6 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
ParsingUtils.setPropertyValue(element, cacheBuilder, "lock-lease");
ParsingUtils.setPropertyValue(element, cacheBuilder, "lock-timeout");
ParsingUtils.setPropertyValue(element, cacheBuilder, "message-sync-interval");
parsePdxDiskStore(element, parserContext, cacheBuilder);
ParsingUtils.setPropertyValue(element, cacheBuilder, "pdx-ignore-unread-fields");
ParsingUtils.setPropertyValue(element, cacheBuilder, "pdx-read-serialized");
ParsingUtils.setPropertyValue(element, cacheBuilder, "pdx-persistent");
@@ -100,6 +105,21 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
ParsingUtils.setPropertyValue(element, cacheBuilder, "search-timeout");
ParsingUtils.setPropertyValue(element, cacheBuilder, "use-cluster-configuration");
parsePdxDiskStore(element, parserContext, cacheBuilder);
parseJndiBindings(element, parserContext, cacheBuilder);
Element gatewayConflictResolver =
DomUtils.getChildElementByTagName(element, "gateway-conflict-resolver");
if (gatewayConflictResolver != null) {
ParsingUtils.throwExceptionWhenGemFireFeatureUnavailable(GemfireFeature.WAN, element.getLocalName(),
"gateway-conflict-resolver", parserContext);
cacheBuilder.addPropertyValue("gatewayConflictResolver", ParsingUtils.parseRefOrSingleNestedBeanDeclaration(
gatewayConflictResolver, parserContext, cacheBuilder));
}
List<Element> transactionListeners =
DomUtils.getChildElementsByTagName(element, "transaction-listener");
@@ -121,32 +141,29 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
cacheBuilder.addPropertyValue("transactionWriter",
ParsingUtils.parseRefOrNestedBeanDeclaration(transactionWriter, parserContext, cacheBuilder));
}
Element gatewayConflictResolver =
DomUtils.getChildElementByTagName(element, "gateway-conflict-resolver");
if (gatewayConflictResolver != null) {
ParsingUtils.throwExceptionWhenGemFireFeatureUnavailable(GemfireFeature.WAN, element.getLocalName(),
"gateway-conflict-resolver", parserContext);
cacheBuilder.addPropertyValue("gatewayConflictResolver", ParsingUtils.parseRefOrSingleNestedBeanDeclaration(
gatewayConflictResolver, parserContext, cacheBuilder));
}
parseJndiBindings(element, cacheBuilder);
}
protected BeanDefinitionRegistry getRegistry(ParserContext parserContext) {
protected @NonNull BeanDefinitionRegistry getRegistry(@NonNull ParserContext parserContext) {
return parserContext.getRegistry();
}
private void registerGemFireBeanFactoryPostProcessors(BeanDefinitionRegistry registry) {
protected @Nullable BeanFactory resolveBeanFactory(@Nullable BeanDefinitionRegistry registry) {
AbstractBeanDefinition customEditorBeanFactoryPostProcessorDefinition =
BeanDefinitionBuilder.genericBeanDefinition(CustomEditorBeanFactoryPostProcessor.class).getBeanDefinition();
return registry instanceof ConfigurableApplicationContext ? ((ConfigurableApplicationContext) registry).getBeanFactory()
: registry instanceof ApplicationContext ? ((ApplicationContext) registry).getAutowireCapableBeanFactory()
: registry instanceof ConfigurableListableBeanFactory ? (ConfigurableListableBeanFactory) registry
: registry instanceof BeanFactory ? (BeanFactory) registry
: null;
}
BeanDefinitionReaderUtils.registerWithGeneratedName(customEditorBeanFactoryPostProcessorDefinition, registry);
private void registerGemFirePropertyEditorRegistrarWithBeanFactory(BeanDefinitionRegistry registry) {
Optional.ofNullable(registry)
.map(this::resolveBeanFactory)
.filter(ConfigurableListableBeanFactory.class::isInstance)
.map(ConfigurableListableBeanFactory.class::cast)
.ifPresent(beanFactory -> beanFactory.addPropertyEditorRegistrar(new CustomEditorBeanFactoryPostProcessor
.CustomEditorPropertyEditorRegistrar()));
}
private void parsePdxDiskStore(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
@@ -178,7 +195,8 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
return builder.getBeanDefinition();
}
private void parseJndiBindings(Element element, BeanDefinitionBuilder cacheBuilder) {
@SuppressWarnings("unused")
private void parseJndiBindings(Element element, ParserContext parserContext, BeanDefinitionBuilder cacheBuilder) {
List<Element> jndiBindings = DomUtils.getChildElementsByTagName(element, "jndi-binding");

View File

@@ -15,13 +15,13 @@
*/
package org.springframework.data.gemfire.config.xml;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
import org.w3c.dom.Element;
/**
* {@link BeanDefinitionParser} for the &lt;gfe:client-cache&gt; SDG XML Namespace (XSD) element.
*

View File

@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.config.xml;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
@@ -32,6 +31,7 @@ class GemfireNamespaceHandler extends NamespaceHandlerSupport {
@Override
public void init() {
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenParser());
registerBeanDefinitionParser("async-event-queue", new AsyncEventQueueParser());
registerBeanDefinitionParser("auto-region-lookup", new AutoRegionLookupParser());

View File

@@ -21,8 +21,6 @@ import org.apache.geode.cache.LossAction;
import org.apache.geode.cache.MembershipAttributes;
import org.apache.geode.cache.ResumptionAction;
import org.w3c.dom.Element;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
@@ -39,6 +37,8 @@ import org.springframework.data.gemfire.util.SpringUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
/**
* Utilities used by the Spring Data GemFire XML Namespace Parsers.
*
@@ -394,10 +394,13 @@ abstract class ParsingUtils {
setPropertyValue(element, regionAttributesBuilder, "publisher");
setPropertyValue(element, regionAttributesBuilder, "value-constraint");
String concurrencyChecksEnabled = element.getAttribute("concurrency-checks-enabled");
if (element.hasAttribute("concurrency-checks-enabled")) {
if (StringUtils.hasText(concurrencyChecksEnabled)) {
ParsingUtils.setPropertyValue(element, regionAttributesBuilder, "concurrency-checks-enabled");
String concurrencyChecksEnabled = element.getAttribute("concurrency-checks-enabled");
if (StringUtils.hasText(concurrencyChecksEnabled)) {
setPropertyValue(element, regionAttributesBuilder, "concurrency-checks-enabled");
}
}
}

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.xml;
import java.util.List;
import org.w3c.dom.Element;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -32,6 +30,8 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
/**
* Bean definition parser for the &lt;gfe:partitioned-region&gt; SDG XML namespace (XSD) element.
*
@@ -76,7 +76,7 @@ class PartitionedRegionParser extends AbstractPeerRegionParser {
BeanDefinitionBuilder partitionAttributesBuilder =
BeanDefinitionBuilder.genericBeanDefinition(PartitionAttributesFactoryBean.class);
mergeTemplateRegionPartitionAttributes(element, parserContext, regionBuilder, partitionAttributesBuilder);
mergeRegionTemplatePartitionAttributes(element, parserContext, regionBuilder, partitionAttributesBuilder);
parseCollocatedWith(element, regionBuilder, partitionAttributesBuilder, "colocated-with");
ParsingUtils.setPropertyValue(element, partitionAttributesBuilder, "copies", "redundantCopies");
@@ -86,21 +86,24 @@ class PartitionedRegionParser extends AbstractPeerRegionParser {
ParsingUtils.setPropertyValue(element, partitionAttributesBuilder, "total-buckets", "totalNumBuckets");
ParsingUtils.setPropertyValue(element, partitionAttributesBuilder, "total-max-memory");
Element partitionListenerSubElement = DomUtils.getChildElementByTagName(element, "partition-listener");
Element partitionListenerSubElement =
DomUtils.getChildElementByTagName(element, "partition-listener");
if (partitionListenerSubElement != null) {
partitionAttributesBuilder.addPropertyValue("partitionListeners",
parsePartitionListeners(partitionListenerSubElement, parserContext, regionBuilder));
}
Element partitionResolverSubElement = DomUtils.getChildElementByTagName(element, "partition-resolver");
Element partitionResolverSubElement =
DomUtils.getChildElementByTagName(element, "partition-resolver");
if (partitionResolverSubElement != null) {
partitionAttributesBuilder.addPropertyValue("partitionResolver",
parsePartitionResolver(partitionResolverSubElement, parserContext, regionBuilder));
}
List<Element> fixedPartitionSubElements = DomUtils.getChildElementsByTagName(element, "fixed-partition");
List<Element> fixedPartitionSubElements =
DomUtils.getChildElementsByTagName(element, "fixed-partition");
if (!CollectionUtils.isEmpty(fixedPartitionSubElements)){
@@ -122,10 +125,11 @@ class PartitionedRegionParser extends AbstractPeerRegionParser {
partitionAttributesBuilder.addPropertyValue("fixedPartitionAttributes", fixedPartitionAttributes);
}
regionAttributesBuilder.addPropertyValue("partitionAttributes", partitionAttributesBuilder.getBeanDefinition());
regionAttributesBuilder.addPropertyValue("partitionAttributes",
partitionAttributesBuilder.getBeanDefinition());
}
void mergeTemplateRegionPartitionAttributes(Element element, ParserContext parserContext,
void mergeRegionTemplatePartitionAttributes(Element element, ParserContext parserContext,
BeanDefinitionBuilder regionBuilder, BeanDefinitionBuilder partitionAttributesBuilder) {
String regionTemplateName = getParentName(element);
@@ -153,9 +157,12 @@ class PartitionedRegionParser extends AbstractPeerRegionParser {
}
}
else {
parserContext.getReaderContext().error(String.format(
"The Region template [%1$s] must be 'defined before' the Region [%2$s] referring to the template!",
regionTemplateName, resolveId(element, regionBuilder.getRawBeanDefinition(), parserContext)), element);
String message =
String.format("The Region template [%1$s] must be defined before the Region [%2$s] referring to the template!",
regionTemplateName, resolveId(element, regionBuilder.getRawBeanDefinition(), parserContext));
parserContext.getReaderContext().error(message, element);
}
}
}
@@ -164,8 +171,8 @@ class PartitionedRegionParser extends AbstractPeerRegionParser {
BeanDefinitionBuilder partitionAttributesBuilder, String attributeName) {
// NOTE rather than using a dependency (with depends-on) we could also set the colocatedWith property of the
// PartitionAttributesFactoryBean with a reference to the Region "this" Partitioned Region will be colocated
// with, where the colocated-with attribute refers to the the bean name/alias of the other, depended on Region
// PartitionAttributesFactoryBean with a reference to the Region "this" Partitioned Region will be collocated
// with, where the collocated-with attribute refers to the the bean name/alias of the other, depended on Region
// providing that the Region's name is also a bean alias of the bean definition.
//ParsingUtils.setPropertyReference(element, partitionAttributesBuilder, attributeName, "colocatedWith");

View File

@@ -81,10 +81,13 @@ public class GatewayReceiverFactoryBean extends AbstractWANComponentFactoryBean<
super(cache);
}
/**
* @inheritDoc
*/
@Override
protected void doInit() {
GatewayReceiverFactory gatewayReceiverFactory = this.cache.createGatewayReceiverFactory();
GatewayReceiverFactory gatewayReceiverFactory = getCache().createGatewayReceiverFactory();
StreamSupport.stream(CollectionUtils.nullSafeIterable(this.gatewayReceiverConfigurers).spliterator(), false)
.forEach(it -> it.configure(getName(), this));

View File

@@ -51,9 +51,8 @@ public abstract class RecreatingSpringApplicationContextTest extends Integration
}
@After
public void destroyContext() {
if (applicationContext != null) {
applicationContext.destroy();
}
public void closeContext() {
closeApplicationContext(this.applicationContext);
destroyAllGemFireMockObjects();
}
}

View File

@@ -30,6 +30,7 @@ import org.apache.geode.cache.RegionShortcut;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.data.gemfire.util.RegionUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -48,8 +49,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* @since 1.4.0
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "region-datapolicy-shortcuts.xml",
initializers = GemFireMockObjectsApplicationContextInitializer.class)
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings("unused")
public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsSupport {
@@ -78,7 +78,7 @@ public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsS
private Region<?, ?> shortcutOverrides;
@Test
public void testLocalRegionWithDataPolicy() {
public void localRegionWithDataPolicyIsCorrect() {
assertThat(localWithDataPolicy)
.describedAs("A reference to the 'LocalWithDataPolicy' Region was not property configured!")
@@ -91,7 +91,7 @@ public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsS
}
@Test
public void testLocalRegionWithShortcut() {
public void localRegionWithShortcutIsCorrect() {
assertThat(localWithShortcut)
.describedAs("A reference to the 'LocalWithShortcut' Region was not property configured!")
@@ -104,7 +104,7 @@ public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsS
}
@Test
public void testPartitionRegionWithDataPolicy() {
public void partitionRegionWithDataPolicyIsCorrect() {
assertThat(partitionWithDataPolicy)
.describedAs("A reference to the 'PartitionWithDataPolicy' Region was not property configured!")
@@ -117,7 +117,7 @@ public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsS
}
@Test
public void testPartitionRegionWithShortcut() {
public void partitionRegionWithShortcutIsCorrect() {
assertThat(partitionWithShortcut)
.describedAs("A reference to the 'PartitionWithShortcut' Region was not property configured!")
@@ -130,7 +130,7 @@ public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsS
}
@Test
public void testReplicateRegionWithDataPolicy() {
public void replicateRegionWithDataPolicyIsCorrect() {
assertThat(replicateWithDataPolicy)
.describedAs("A reference to the 'ReplicateWithDataPolicy' Region was not property configured!")
@@ -143,7 +143,7 @@ public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsS
}
@Test
public void testReplicateRegionWithShortcut() {
public void replicateRegionWithShortcutIsCorrect() {
assertThat(replicateWithShortcut)
.describedAs("A reference to the 'ReplicateWithShortcut' Region was not property configured!")
@@ -156,14 +156,14 @@ public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsS
}
@Test
public void testShortcutDefaultsRegion() {
public void shortcutDefaultsRegionIsCorrect() {
assertThat(shortcutDefaults)
.describedAs("A reference to the 'ShortcutDefaults' Region was not properly configured!")
.isNotNull();
assertThat(shortcutDefaults.getName()).isEqualTo("ShortcutDefaults");
assertThat(shortcutDefaults.getFullPath()).isEqualTo("/ShortcutDefaults");
assertThat(shortcutDefaults.getFullPath()).isEqualTo(RegionUtils.toRegionPath("ShortcutDefaults"));
assertThat(shortcutDefaults.getAttributes()).isNotNull();
assertThat(shortcutDefaults.getAttributes().getCloningEnabled()).isFalse();
assertThat(shortcutDefaults.getAttributes().getConcurrencyChecksEnabled()).isTrue();
@@ -173,6 +173,7 @@ public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsS
assertThat(shortcutDefaults.getAttributes().getInitialCapacity()).isEqualTo(101);
assertThat(new Float(shortcutDefaults.getAttributes().getLoadFactor())).isEqualTo(new Float(0.85f));
assertThat(shortcutDefaults.getAttributes().getKeyConstraint()).isEqualTo(Long.class);
assertThat(shortcutDefaults.getAttributes().getMulticastEnabled()).isFalse();
assertThat(shortcutDefaults.getAttributes().getValueConstraint()).isEqualTo(String.class);
assertThat(shortcutDefaults.getAttributes().getEvictionAttributes()).isNotNull();
assertThat(shortcutDefaults.getAttributes().getEvictionAttributes().getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
@@ -183,14 +184,14 @@ public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsS
}
@Test
public void testShortcutOverridesRegion() {
public void shortcutOverridesRegionIsCorrect() {
assertThat(shortcutOverrides)
.describedAs("A reference to the 'ShortcutOverrides' Region was not properly configured!")
.isNotNull();
assertThat(shortcutOverrides.getName()).isEqualTo("ShortcutOverrides");
assertThat(shortcutOverrides.getFullPath()).isEqualTo("/ShortcutOverrides");
assertThat(shortcutOverrides.getFullPath()).isEqualTo(RegionUtils.toRegionPath("ShortcutOverrides"));
assertThat(shortcutOverrides.getAttributes()).isNotNull();
assertThat(shortcutOverrides.getAttributes().getCloningEnabled()).isTrue();
assertThat(shortcutOverrides.getAttributes().getConcurrencyChecksEnabled()).isFalse();

View File

@@ -22,17 +22,21 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.withSettings;
import java.io.InputStream;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.EvictionAttributes;
@@ -57,7 +61,10 @@ import org.springframework.data.gemfire.util.ArrayUtils;
* @author David Turanski
* @author John Blum
* @see org.junit.Test
* @see org.mockito.Mock
* @see org.mockito.Mockito
* @see org.mockito.Spy
* @see org.mockito.junit.MockitoJUnitRunner
* @see org.apache.geode.cache.EvictionAttributes
* @see org.apache.geode.cache.ExpirationAttributes
* @see org.apache.geode.cache.Region
@@ -67,17 +74,25 @@ import org.springframework.data.gemfire.util.ArrayUtils;
* @see org.springframework.data.gemfire.client.ClientRegionFactoryBean
*/
@SuppressWarnings("rawtypes")
@RunWith(MockitoJUnitRunner.class)
public class ClientRegionFactoryBeanUnitTests {
@Mock
private BeanFactory mockBeanFactory;
@Spy
private ClientRegionFactoryBean<Object, Object> factoryBean;
@Before
public void setup() {
this.factoryBean = spy(new ClientRegionFactoryBean<>());
this.factoryBean.setBeanFactory(this.mockBeanFactory);
this.factoryBean.initializePoolResolver();
}
@After
public void tearDown() throws Exception {
this.factoryBean.destroy();
this.factoryBean = null;
}
@@ -86,8 +101,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings({ "deprecation", "unchecked" })
public void createRegionUsingDefaultShortcut() throws Exception {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientCache mockClientCache = mock(ClientCache.class);
ClientRegionFactory mockClientRegionFactory = mock(ClientRegionFactory.class);
@@ -102,7 +115,6 @@ public class ClientRegionFactoryBeanUnitTests {
when(mockClientCache.createClientRegionFactory(eq(ClientRegionShortcut.LOCAL)))
.thenReturn(mockClientRegionFactory);
when(mockClientRegionFactory.create(eq("TestRegion"))).thenReturn(mockRegion);
when(mockPool.getName()).thenReturn("TestPoolTwo");
when(mockRegionAttributes.getCloningEnabled()).thenReturn(false);
when(mockRegionAttributes.getCompressor()).thenReturn(mock(Compressor.class));
when(mockRegionAttributes.getConcurrencyChecksEnabled()).thenReturn(true);
@@ -167,8 +179,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings({ "deprecation", "unchecked" })
public void createRegionUsingDefaultPersistentShortcut() throws Exception {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientCache mockClientCache = mock(ClientCache.class);
ClientRegionFactory<Object, Object> mockClientRegionFactory = mock(ClientRegionFactory.class);
@@ -205,8 +215,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings("unchecked")
public void createRegionWithSpecifiedShortcut() {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientCache mockClientCache = mock(ClientCache.class);
ClientRegionFactory<Object, Object> mockClientRegionFactory = mock(ClientRegionFactory.class);
@@ -236,8 +244,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings("unchecked")
public void createRegionAsSubRegion() {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientCache mockClientCache = mock(ClientCache.class);
ClientRegionFactory<Object, Object> mockClientRegionFactory = mock(ClientRegionFactory.class);
@@ -288,8 +294,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings("unchecked")
public void configurePoolFromClientRegionFactoryBeanAndEagerlyInitializePool() {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientRegionFactory<Object, Object> mockClientRegionFactory = mock(ClientRegionFactory.class);
Pool mockPool = mock(Pool.class);
@@ -308,8 +312,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings("unchecked")
public void configurePoolFromClientRegionFactoryBeanEvenWhenRegionAttributesPoolNameIsSet() {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientRegionFactory<Object, Object> mockClientRegionFactory = mock(ClientRegionFactory.class);
Pool mockPool = mock(Pool.class);
@@ -334,8 +336,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings("unchecked")
public void configurePoolFromRegionAttributesAndEagerlyInitializePool() {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientRegionFactory<Object, Object> mockClientRegionFactory = mock(ClientRegionFactory.class);
Pool mockPool = mock(Pool.class);
@@ -358,8 +358,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings("unchecked")
public void configurePoolThrowsExceptionWhileEagerlyInitializingPool() {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientRegionFactory<Object, Object> mockClientRegionFactory = mock(ClientRegionFactory.class);
when(mockBeanFactory.getBean(anyString(), eq(Pool.class))).thenThrow(new BeanCreationException("test"));
@@ -387,8 +385,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings("unchecked")
public void doesNotConfigurePoolWhenClientRegionFactoryBeanPoolIsDefaultPool() {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientRegionFactory<Object, Object> mockClientRegionFactory = mock(ClientRegionFactory.class);
factoryBean.setBeanFactory(mockBeanFactory);
@@ -405,8 +401,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings("unchecked")
public void doesNotConfigurePoolWhenRegionAttributesPoolIsDefaultPool() {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientRegionFactory<Object, Object> mockClientRegionFactory = mock(ClientRegionFactory.class);
RegionAttributes<Object, Object> mockRegionAttributes = mock(RegionAttributes.class);
@@ -428,8 +422,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings("unchecked")
public void doesNotConfigurePoolWhenDeclaredPoolIsEmpty() {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientRegionFactory<Object, Object> mockClientRegionFactory = mock(ClientRegionFactory.class);
RegionAttributes<Object, Object> mockRegionAttributes = mock(RegionAttributes.class);
@@ -452,8 +444,6 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings("unchecked")
public void doesNotConfigurePoolWhenDeclaredPoolIsNull() {
BeanFactory mockBeanFactory = mock(BeanFactory.class);
ClientRegionFactory<Object, Object> mockClientRegionFactory = mock(ClientRegionFactory.class);
RegionAttributes<Object, Object> mockRegionAttributes = mock(RegionAttributes.class);
@@ -780,12 +770,11 @@ public class ClientRegionFactoryBeanUnitTests {
@SuppressWarnings("unchecked")
public void destroyCallsRegionDestroy() throws Exception {
Region mockRegion = mock(Region.class, "MockRegion");
Region mockRegion = mock(Region.class, withSettings().lenient());
RegionService mockRegionService = mock(RegionService.class, "MockRegionService");
RegionService mockRegionService = mock(RegionService.class);
when(mockRegion.getRegionService()).thenReturn(mockRegionService);
when(mockRegionService.isClosed()).thenReturn(false);
doReturn(mockRegion).when(factoryBean).getObject();

View File

@@ -139,7 +139,7 @@ public class ListRegionsOnServerFunctionUnitTests {
@Test
public void getIdIsFullyQualifiedClassName() {
assertThat(function.getId()).isEqualTo(ListRegionsOnServerFunction.class.getName());
assertThat(function.getId()).startsWith(ListRegionsOnServerFunction.class.getName());
}
@Test

View File

@@ -227,7 +227,7 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ForkingClien
public static class GeodeServerConfiguration {
public static void main(String[] args) {
runSpringApplication(GeodeServerConfiguration.class, args).refresh();
runSpringApplication(GeodeServerConfiguration.class, args);
}
@Autowired

View File

@@ -18,7 +18,6 @@ package org.springframework.data.gemfire.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -30,10 +29,8 @@ import org.apache.geode.cache.Region;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.integration.SpringApplicationContextIntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects;
import org.springframework.data.gemfire.util.CollectionUtils;
import org.springframework.stereotype.Service;
@@ -50,41 +47,26 @@ import org.springframework.stereotype.Service;
* @see org.springframework.cache.annotation.Cacheable
* @see org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions
* @see org.springframework.data.gemfire.config.annotation.CachingDefinedRegionsConfiguration
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.integration.SpringApplicationContextIntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.stereotype.Service
* @see <a href="https://jira.spring.io/browse/DATAGEODE-232">Add support for @CacheConfig in @EnableCachingDefinedRegions</a>
* @since 2.2.0
*/
@SuppressWarnings("unused")
public class CachingDefinedRegionsConsidersCacheConfigCacheNamesIntegrationTests extends IntegrationTestsSupport {
private ConfigurableApplicationContext applicationContext;
public class CachingDefinedRegionsConsidersCacheConfigCacheNamesIntegrationTests
extends SpringApplicationContextIntegrationTestsSupport {
@After
public void closeApplicationContext() {
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
}
private ConfigurableApplicationContext newApplicationContext(Class<?>... annotatedClasses) {
AnnotationConfigApplicationContext applicationContext =
new AnnotationConfigApplicationContext();
applicationContext.register(annotatedClasses);
applicationContext.registerShutdownHook();
applicationContext.refresh();
this.applicationContext = applicationContext;
return applicationContext;
public void tearDown() {
destroyAllGemFireMockObjects();
}
private Set<String> resolveCacheRegionNames(Class<?>... annotatedClasses) {
newApplicationContext(annotatedClasses);
GemFireCache cache = this.applicationContext.getBean(GemFireCache.class);
GemFireCache cache = getBean(GemFireCache.class);
assertThat(cache).isNotNull();

View File

@@ -38,6 +38,7 @@ import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects;
import org.springframework.data.gemfire.util.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.test.context.ContextConfiguration;
@@ -56,6 +57,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* @see org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions
* @see org.springframework.data.gemfire.config.annotation.CachingDefinedRegionsConfiguration
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @see <a href="https://jira.spring.io/browse/DATAGEODE-232">Add support for @CacheConfig in @EnableCachingDefinedRegions</a>
@@ -146,8 +148,9 @@ public class CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests exte
Arrays.asList(this.b, this.c).forEach(region -> assertThat(region).isEmpty());
}
@ClientCacheApplication
@ClientCacheApplication(name = "CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests")
@EnableCachingDefinedRegions(clientRegionShortcut = ClientRegionShortcut.LOCAL)
@EnableGemFireMockObjects
static class TestConfiguration {
@Bean

View File

@@ -112,7 +112,6 @@ public class ClientCacheConfigurationIntegrationTests extends IntegrationTestsSu
@EnableGemFireMockObjects
@ClientCacheApplication(
name = "ClientCacheDefaultPoolWithCustomSocketFactoryConfiguration",
logLevel = "error",
serverConnectionTimeout = 60000,
socketFactoryBeanName = "mockSocketFactory"
)
@@ -125,7 +124,7 @@ public class ClientCacheConfigurationIntegrationTests extends IntegrationTestsSu
}
@EnableGemFireMockObjects
@ClientCacheApplication(name = "ClientCacheDefaultPoolWithCustomSocketFactoryConfiguration", logLevel = "error")
@ClientCacheApplication(name = "ClientCacheDefaultPoolWithDefaultSocketFactoryConfiguration")
static class ClientCacheDefaultPoolWithDefaultSocketFactoryConfiguration {
@Bean

View File

@@ -20,7 +20,6 @@ import static org.mockito.Mockito.mock;
import static org.springframework.data.gemfire.config.annotation.CompressionConfiguration.SNAPPY_COMPRESSOR_BEAN_NAME;
import java.util.Arrays;
import java.util.Optional;
import org.junit.After;
import org.junit.Test;
@@ -62,8 +61,8 @@ public class EnableCompressionConfigurationUnitTests extends IntegrationTestsSup
@After
public void tearDown() {
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
//GemFireMockObjectsSupport.destroy();
closeApplicationContext(this.applicationContext);
destroyAllGemFireMockObjects();
}
private ConfigurableApplicationContext newApplicationContext(Class<?>... annotatedClasses) {
@@ -132,7 +131,6 @@ public class EnableCompressionConfigurationUnitTests extends IntegrationTestsSup
LocalRegionFactoryBean<Object, Object> localRegion = new LocalRegionFactoryBean<>();
localRegion.setCache(gemfireCache);
localRegion.setClose(false);
localRegion.setPersistent(false);
return localRegion;
@@ -144,7 +142,6 @@ public class EnableCompressionConfigurationUnitTests extends IntegrationTestsSup
PartitionedRegionFactoryBean<Object, Object> partitionRegion = new PartitionedRegionFactoryBean<>();
partitionRegion.setCache(gemfireCache);
partitionRegion.setClose(false);
partitionRegion.setPersistent(false);
return partitionRegion;
@@ -156,7 +153,6 @@ public class EnableCompressionConfigurationUnitTests extends IntegrationTestsSup
ReplicatedRegionFactoryBean<Object, Object> replicateRegion = new ReplicatedRegionFactoryBean<>();
replicateRegion.setCache(gemfireCache);
replicateRegion.setClose(false);
replicateRegion.setPersistent(false);
return replicateRegion;
@@ -176,7 +172,6 @@ public class EnableCompressionConfigurationUnitTests extends IntegrationTestsSup
ClientRegionFactoryBean<Object, Object> clientRegion = new ClientRegionFactoryBean<>();
clientRegion.setCache(gemfireCache);
clientRegion.setClose(false);
clientRegion.setShortcut(ClientRegionShortcut.LOCAL);
return clientRegion;

View File

@@ -89,6 +89,8 @@ import lombok.Data;
* @see org.springframework.data.gemfire.config.annotation.EnableContinuousQueries
* @see org.springframework.data.gemfire.listener.annotation.ContinuousQuery
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.GemFireMockObjectsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @since 2.0.1
*/
public class EnableContinuousQueriesConfigurationUnitTests extends IntegrationTestsSupport {
@@ -107,12 +109,12 @@ public class EnableContinuousQueriesConfigurationUnitTests extends IntegrationTe
ErrorHandler mockErrorHandler = applicationContext.getBean("mockErrorHandler", ErrorHandler.class);
Executor mockTaskExecutor = applicationContext.getBean("mockTaskExecutor", Executor.class);
Pool mockPool = applicationContext.getBean("mockPool", Pool.class);
QueryService mockQueryService = applicationContext.getBean("mockQueryService", QueryService.class);
Executor mockTaskExecutor = applicationContext.getBean("mockTaskExecutor", Executor.class);
assertThat(applicationContext.containsBean("continuousQueryListenerContainer")).isTrue();
ContinuousQueryListenerContainer container =
@@ -128,6 +130,7 @@ public class EnableContinuousQueriesConfigurationUnitTests extends IntegrationTe
}
finally {
IOUtils.close(applicationContext);
GemFireMockObjectsSupport.destroy();
}
}
@@ -162,6 +165,7 @@ public class EnableContinuousQueriesConfigurationUnitTests extends IntegrationTe
}
finally {
IOUtils.close(applicationContext);
GemFireMockObjectsSupport.destroy();
}
}
@@ -336,8 +340,8 @@ public class EnableContinuousQueriesConfigurationUnitTests extends IntegrationTe
static class TestContinuousQueryComponent {
@ContinuousQuery(name = "TestQuery", query = "SELECT * FROM /Example")
public void handle(CqEvent event) {
}
public void handle(CqEvent event) { }
}
@Data

View File

@@ -384,13 +384,13 @@ public class EnableEntityDefinedRegionsUnitTests extends IntegrationTestsSupport
Region<Object, Object> accounts = this.applicationContext.getBean("Sessions", Region.class);
assertRegionWithAttributes(accounts, "Sessions", DataPolicy.REPLICATE,
null, true, false, null, Scope.DISTRIBUTED_NO_ACK);
null, true, false, null, Scope.DISTRIBUTED_ACK);
Region<Object, Object> genericRegionEntity =
this.applicationContext.getBean("GenericRegionEntity", Region.class);
assertRegionWithAttributes(genericRegionEntity, "GenericRegionEntity", DataPolicy.REPLICATE,
null, true, false, null, Scope.DISTRIBUTED_NO_ACK);
null, true, false, null, Scope.DISTRIBUTED_ACK);
Region<Object, Object> localRegionEntity =
this.applicationContext.getBean("LocalRegionEntity", Region.class);

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Optional;
import org.junit.After;
import org.junit.Test;
@@ -29,12 +27,11 @@ import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.eviction.EvictionActionType;
import org.springframework.data.gemfire.eviction.EvictionPolicyType;
import org.springframework.data.gemfire.test.model.Person;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.integration.SpringApplicationContextIntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects;
import org.springframework.stereotype.Service;
@@ -45,25 +42,18 @@ import org.springframework.stereotype.Service;
* @see org.apache.geode.cache.Region
* @see org.springframework.data.gemfire.config.annotation.EnableEviction
* @see org.springframework.data.gemfire.config.annotation.EvictionConfiguration
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.integration.SpringApplicationContextIntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @since 1.9.0
*/
@SuppressWarnings("unused")
public class EnableEvictionConfigurationIntegrationTests extends IntegrationTestsSupport {
public class EnableEvictionConfigurationIntegrationTests extends SpringApplicationContextIntegrationTestsSupport {
private static final String GEMFIRE_LOG_LEVEL = "error";
private ConfigurableApplicationContext applicationContext;
@After
public void tearDown() {
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
}
private ConfigurableApplicationContext newApplicationContext(Class<?>... annotatedClasses) {
this.applicationContext = new AnnotationConfigApplicationContext(annotatedClasses);
return this.applicationContext;
destroyAllGemFireMockObjects();
}
@SuppressWarnings("unchecked")
@@ -115,7 +105,7 @@ public class EnableEvictionConfigurationIntegrationTests extends IntegrationTest
"People", EvictionActionType.OVERFLOW_TO_DISK, 10000);
}
@ClientCacheApplication(name = "EnableEvictionConfigurationIntegrationTests", logLevel = GEMFIRE_LOG_LEVEL)
@ClientCacheApplication(name = "EnableEvictionConfigurationIntegrationTests")
@EnableCachingDefinedRegions(clientRegionShortcut = ClientRegionShortcut.LOCAL)
@EnableEviction(policies = @EnableEviction.EvictionPolicy(maximum = 100))
@EnableGemFireMockObjects

View File

@@ -17,36 +17,27 @@
package org.springframework.data.gemfire.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.springframework.data.gemfire.config.annotation.EnableEviction.EvictionPolicy;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.After;
import org.junit.Test;
import org.mockito.stubbing.Answer;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.EvictionAttributes;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionAttributes;
import org.apache.geode.cache.RegionFactory;
import org.apache.geode.cache.util.ObjectSizer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.gemfire.PartitionedRegionFactoryBean;
import org.springframework.data.gemfire.ReplicatedRegionFactoryBean;
import org.springframework.data.gemfire.eviction.EvictionActionType;
import org.springframework.data.gemfire.eviction.EvictionAttributesFactoryBean;
import org.springframework.data.gemfire.eviction.EvictionPolicyType;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects;
import org.springframework.data.gemfire.util.ArrayUtils;
/**
@@ -61,6 +52,7 @@ import org.springframework.data.gemfire.util.ArrayUtils;
* @see org.springframework.data.gemfire.config.annotation.EvictionConfiguration
* @see org.springframework.data.gemfire.eviction.EvictionAttributesFactoryBean
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @since 1.9.0
*/
public class EnableEvictionConfigurationUnitTests extends IntegrationTestsSupport {
@@ -69,9 +61,8 @@ public class EnableEvictionConfigurationUnitTests extends IntegrationTestsSuppor
@After
public void tearDown() {
if (applicationContext != null) {
applicationContext.close();
}
closeApplicationContext(this.applicationContext);
destroyAllGemFireMockObjects();
}
private void assertEvictionAttributes(Region<?, ?> region, EvictionAttributes expectedEvictionAttributes) {
@@ -180,50 +171,11 @@ public class EnableEvictionConfigurationUnitTests extends IntegrationTestsSuppor
lastMatchingEvictionAttributes);
}
@Configuration
@PeerCacheApplication
@EnableGemFireMockObjects
@SuppressWarnings("unused")
static class CacheRegionConfiguration {
@Bean("mockCache")
@SuppressWarnings("unchecked")
Cache mockCache() {
Cache mockCache = mock(Cache.class);
RegionFactory<Object, Object> mockRegionFactory = mock(RegionFactory.class);
AtomicReference<EvictionAttributes> evictionAttributes = new AtomicReference<>(null);
when(mockCache.createRegionFactory()).thenReturn(mockRegionFactory);
when(mockRegionFactory.setEvictionAttributes(any(EvictionAttributes.class)))
.thenAnswer((Answer<RegionFactory<?, ?>>) invocation -> {
evictionAttributes.set(invocation.getArgument(0));
return (RegionFactory<?, ?>) invocation.getMock();
}
);
when(mockRegionFactory.create(anyString()))
.thenAnswer(invocation -> {
String regionName = invocation.getArgument(0);
Region<?, ?> mockRegion = mock(Region.class, regionName);
RegionAttributes<?, ?> mockRegionAttributes =
mock(RegionAttributes.class, regionName.concat("Attributes"));
doReturn(regionName).when(mockRegion).getName();
doReturn(String.format("%1$s%2$s", Region.SEPARATOR, regionName)).when(mockRegion).getFullPath();
doReturn(mockRegion).when(mockRegion).getAttributes();
doReturn(evictionAttributes.get()).when(mockRegionAttributes).getEvictionAttributes();
return mockRegion;
});
return mockCache;
}
@Bean("PartitionRegion")
PartitionedRegionFactoryBean<Object, Object> mockPartitionRegion(Cache gemfireCache) {

View File

@@ -132,7 +132,7 @@ public class PeerCacheApplicationWithAddedCacheServerIntegrationTests
}
@EnableCacheServer
@PeerCacheApplication
@PeerCacheApplication(name = "PeerCacheApplicationWithAddedCacheServerIntegrationTests")
static class TestPeerCacheConfiguration { }
}

View File

@@ -19,7 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import java.net.InetSocketAddress;
import java.util.Optional;
import org.junit.After;
import org.junit.Test;
@@ -62,7 +61,7 @@ public class PoolPropertiesIntegrationTests extends IntegrationTestsSupport {
@After
public void tearDown() {
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
closeApplicationContext(this.applicationContext);
}
private ConfigurableApplicationContext newApplicationContext(PropertySource<?> testPropertySource,

View File

@@ -66,10 +66,7 @@ public class RegionConfigurerIntegrationTests extends IntegrationTestsSupport {
@After
public void tearDown() {
Optional.ofNullable(this.applicationContext)
.ifPresent(ConfigurableApplicationContext::close);
closeApplicationContext(this.applicationContext);
destroyAllGemFireMockObjects();
}

View File

@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Resource;
import org.junit.After;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -76,6 +77,11 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp
Thread.currentThread().getContextClassLoader()));
}
@After
public void tearDown() {
TestAppender.getInstance().clear();
}
@Resource(name = "ClientRegion")
private Region<Object, Object> region;
@@ -172,6 +178,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp
@Test
public void logsRegionInvalidate() {
this.region.put("testKey", "testValue");
this.region.invalidate("testKey");
String logMessage = TestAppender.getInstance().lastLogMessage();
@@ -186,6 +193,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp
@Test
public void logsRegionInvalidateWithCallbackArgument() {
this.region.put("testKey", "testValue");
this.region.invalidate("testKey", regionCallbackArgument(new AtomicBoolean(false)));
String logMessage = TestAppender.getInstance().lastLogMessage();
@@ -270,6 +278,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp
@Test
public void logsRegionLocalInvalidate() {
this.region.put("testKey", "testValue");
this.region.localInvalidate("testKey");
String logMessage = TestAppender.getInstance().lastLogMessage();
@@ -284,6 +293,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp
@Test
public void logsRegionLocalInvalidateWithCallbackArgument() {
this.region.put("testKey", "testValue");
this.region.localInvalidate("testKey", regionCallbackArgument(new AtomicBoolean(false)));
String logMessage = TestAppender.getInstance().lastLogMessage();
@@ -529,7 +539,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp
}
@ClientCacheApplication
@EnableGemFireMockObjects
@EnableGemFireMockObjects()
@EnableRegionDataAccessTracing
static class TestConfiguration {

View File

@@ -103,7 +103,7 @@ public class AutoRegionLookupBeanPostProcessorUnitTests {
}
catch (IllegalArgumentException expected) {
assertThat(expected).hasMessage("BeanFactory [%1$s] must be an instance of %2$s",
assertThat(expected).hasMessageStartingWith("BeanFactory [%1$s] must be an instance of %2$s",
mockBeanFactory.getClass().getName(), ConfigurableListableBeanFactory.class.getSimpleName());
assertThat(expected).hasNoCause();
@@ -120,7 +120,7 @@ public class AutoRegionLookupBeanPostProcessorUnitTests {
}
catch (IllegalArgumentException expected) {
assertThat(expected).hasMessage("BeanFactory [null] must be an instance of %s",
assertThat(expected).hasMessageStartingWith("BeanFactory [null] must be an instance of %s",
ConfigurableListableBeanFactory.class.getSimpleName());
assertThat(expected).hasNoCause();

View File

@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.config.support;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -32,7 +32,7 @@ import org.apache.geode.cache.InterestResultPolicy;
import org.apache.geode.cache.Scope;
import org.apache.geode.cache.wan.GatewaySender;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.PropertyEditorRegistry;
import org.springframework.data.gemfire.IndexMaintenancePolicyConverter;
import org.springframework.data.gemfire.IndexMaintenancePolicyType;
import org.springframework.data.gemfire.IndexType;
@@ -52,59 +52,61 @@ import org.springframework.data.gemfire.wan.OrderPolicyConverter;
import org.springframework.util.StringUtils;
/**
* Unit tests for {@link CustomEditorBeanFactoryPostProcessor}.
* Unit Tests for {@link CustomEditorBeanFactoryPostProcessor}.
*
* @author John Blum
* @see org.junit.Test
* @see org.mockito.Mockito
* @see CustomEditorBeanFactoryPostProcessor
* @see org.springframework.data.gemfire.config.support.CustomEditorBeanFactoryPostProcessor
* @since 1.6.0
*/
@SuppressWarnings("deprecation")
public class CustomEditorBeanFactoryPostProcessorUnitTests {
protected ConnectionEndpoint newConnectionEndpoint(String host, int port) {
private ConnectionEndpoint newConnectionEndpoint(String host, int port) {
return new ConnectionEndpoint(host, port);
}
@Test
public void customEditorRegistrationIsSuccessful() {
ConfigurableListableBeanFactory mockBeanFactory = mock(ConfigurableListableBeanFactory.class);
new CustomEditorBeanFactoryPostProcessor().postProcessBeanFactory(mockBeanFactory);
PropertyEditorRegistry mockRegistry = mock(PropertyEditorRegistry.class);
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(ConnectionEndpoint.class),
eq(CustomEditorBeanFactoryPostProcessor.StringToConnectionEndpointConverter.class));
new CustomEditorBeanFactoryPostProcessor.CustomEditorPropertyEditorRegistrar().registerCustomEditors(mockRegistry);
verify(mockRegistry, times(1)).registerCustomEditor(eq(ConnectionEndpoint.class),
isA(CustomEditorBeanFactoryPostProcessor.StringToConnectionEndpointConverter.class));
//verify(mockBeanFactory, times(1)).registerCustomEditor(eq(ConnectionEndpoint[].class),
// eq(CustomEditorBeanFactoryPostProcessor.ConnectionEndpointArrayToIterableConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(ConnectionEndpointList.class),
eq(CustomEditorBeanFactoryPostProcessor.StringToConnectionEndpointListConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(EvictionAction.class),
eq(EvictionActionConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(EvictionPolicyType.class),
eq(EvictionPolicyConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(ExpirationAction.class),
eq(ExpirationActionConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(IndexMaintenancePolicyType.class),
eq(IndexMaintenancePolicyConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(IndexType.class),
eq(IndexTypeConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(InterestPolicy.class),
eq(InterestPolicyConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(InterestResultPolicy.class),
eq(InterestResultPolicyConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(Scope.class), eq(ScopeConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(GatewaySender.OrderPolicy.class),
eq(OrderPolicyConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(Scope.class), eq(ScopeConverter.class));
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(SubscriptionEvictionPolicy.class),
eq(SubscriptionEvictionPolicyConverter.class));
verifyNoMoreInteractions(mockBeanFactory);
verify(mockRegistry, times(1)).registerCustomEditor(eq(ConnectionEndpointList.class),
isA(CustomEditorBeanFactoryPostProcessor.StringToConnectionEndpointListConverter.class));
verify(mockRegistry, times(1)).registerCustomEditor(eq(EvictionAction.class),
isA(EvictionActionConverter.class));
verify(mockRegistry, times(1)).registerCustomEditor(eq(EvictionPolicyType.class),
isA(EvictionPolicyConverter.class));
verify(mockRegistry, times(1)).registerCustomEditor(eq(ExpirationAction.class),
isA(ExpirationActionConverter.class));
verify(mockRegistry, times(1)).registerCustomEditor(eq(IndexMaintenancePolicyType.class),
isA(IndexMaintenancePolicyConverter.class));
verify(mockRegistry, times(1)).registerCustomEditor(eq(IndexType.class),
isA(IndexTypeConverter.class));
verify(mockRegistry, times(1)).registerCustomEditor(eq(InterestPolicy.class),
isA(InterestPolicyConverter.class));
verify(mockRegistry, times(1)).registerCustomEditor(eq(InterestResultPolicy.class),
isA(InterestResultPolicyConverter.class));
verify(mockRegistry, times(1)).registerCustomEditor(eq(Scope.class), isA(ScopeConverter.class));
verify(mockRegistry, times(1)).registerCustomEditor(eq(GatewaySender.OrderPolicy.class),
isA(OrderPolicyConverter.class));
verify(mockRegistry, times(1)).registerCustomEditor(eq(Scope.class), isA(ScopeConverter.class));
verify(mockRegistry, times(1)).registerCustomEditor(eq(SubscriptionEvictionPolicy.class),
isA(SubscriptionEvictionPolicyConverter.class));
verifyNoMoreInteractions(mockRegistry);
}
@Test
@SuppressWarnings("unchecked")
public void connectionEndpointArrayToIterableConversionIsSuccessful() {
ConnectionEndpoint[] array = {
newConnectionEndpoint("localhost", 10334),
newConnectionEndpoint("localhost", 40404)
@@ -126,6 +128,7 @@ public class CustomEditorBeanFactoryPostProcessorUnitTests {
@Test
public void stringToConnectionEndpointConversionIsSuccessful() {
String hostPort = "skullbox[54321]";
ConnectionEndpoint connectionEndpoint = new CustomEditorBeanFactoryPostProcessor
@@ -138,6 +141,7 @@ public class CustomEditorBeanFactoryPostProcessorUnitTests {
@Test
public void stringToConnectionEndpointListConversionIsSuccessful() {
String[] hostsPorts = { "toolbox[10334]", "skullbox", "[40404]" };
String source = StringUtils.arrayToCommaDelimitedString(hostsPorts);

View File

@@ -36,6 +36,7 @@ import org.apache.geode.cache.wan.GatewayQueueEvent;
import org.apache.geode.cache.wan.GatewaySender;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -48,13 +49,14 @@ import org.springframework.test.context.junit4.SpringRunner;
* @see org.apache.geode.cache.asyncqueue.AsyncEventQueue
* @see org.springframework.data.gemfire.config.AsyncEventQueueParser
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
* @see org.springframework.data.gemfire.wan.AsyncEventQueueFactoryBean
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
* @since 1.0.0
*/
@RunWith(SpringRunner.class)
@ContextConfiguration
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings("all")
public class AsyncEventQueueNamespaceIntegrationTests extends IntegrationTestsSupport {

View File

@@ -21,6 +21,7 @@ import static org.springframework.data.gemfire.support.GemfireBeanFactoryLocator
import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,6 +36,7 @@ import org.springframework.core.io.Resource;
import org.springframework.data.gemfire.CacheFactoryBean;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -48,25 +50,33 @@ import org.springframework.test.context.junit4.SpringRunner;
* @see org.springframework.data.gemfire.CacheFactoryBean
* @see org.springframework.data.gemfire.config.xml.CacheParser
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
*/
@RunWith(SpringRunner.class)
@ContextConfiguration
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport {
@Autowired
@SuppressWarnings("unused")
private ApplicationContext applicationContext;
@Before
public void setup() {
assertThat(this.applicationContext.getBean("gemfireCache"))
.isNotEqualTo(this.applicationContext.getBean("cache-with-name"));
}
@Test
public void testNoNamedCache() {
public void noNamedCacheConfigurationIsCorrect() {
assertThat(applicationContext.containsBean("gemfireCache")).isTrue();
assertThat(applicationContext.containsBean("gemfire-cache")).isTrue();
CacheFactoryBean cacheFactoryBean = applicationContext.getBean("&gemfireCache", CacheFactoryBean.class);
assertThat(cacheFactoryBean.getBeanName()).isEqualTo("gemfireCache");
assertThat(cacheFactoryBean.getCacheXml()).isNull();
Properties gemfireProperties = cacheFactoryBean.getProperties();
@@ -84,19 +94,23 @@ public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport {
assertThat(gemfireCache).isNotNull();
assertThat(gemfireCache.getDistributedSystem()).isNotNull();
assertThat(gemfireCache.getDistributedSystem().getProperties()).isNotNull();
assertThat(gemfireCache.getDistributedSystem().getProperties().containsKey("disable-auto-reconnect")).isNotNull();
assertThat(gemfireCache.getDistributedSystem().getProperties().containsKey("disable-auto-reconnect")).isTrue();
assertThat(Boolean.parseBoolean(gemfireCache.getDistributedSystem().getProperties()
.getProperty("disable-auto-reconnect"))).isTrue();
assertThat(gemfireCache.getDistributedSystem().getProperties().containsKey("use-cluster-configuration")).isTrue();
assertThat(Boolean.parseBoolean(gemfireCache.getDistributedSystem().getProperties()
.getProperty("use-cluster-configuration"))).isFalse();
}
@Test
public void testNamedCache() {
public void namedCacheConfigurationIsCorrect() {
assertThat(applicationContext.containsBean("cache-with-name")).isTrue();
CacheFactoryBean cacheFactoryBean =
applicationContext.getBean("&cache-with-name", CacheFactoryBean.class);
assertThat(cacheFactoryBean.getBeanName()).isEqualTo("cache-with-name");
assertThat(cacheFactoryBean.getCacheXml()).isNull();
Properties gemfireProperties = cacheFactoryBean.getProperties();
@@ -109,17 +123,20 @@ public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport {
assertThat(gemfireProperties.containsKey("use-cluster-configuration")).isTrue();
assertThat(Boolean.parseBoolean(gemfireProperties.getProperty("use-cluster-configuration"))).isFalse();
Cache gemfireCache = applicationContext.getBean("gemfireCache", Cache.class);
Cache gemfireCache = applicationContext.getBean("cache-with-name", Cache.class);
assertThat(Boolean.parseBoolean(gemfireCache.getDistributedSystem().getProperties()
.getProperty("disable-auto-reconnect"))).isTrue();
assertThat(gemfireCache).isNotNull();
assertThat(gemfireCache.getDistributedSystem()).isNotNull();
assertThat(Boolean.parseBoolean(gemfireCache.getDistributedSystem().getProperties()
.getProperty("use-cluster-configuration"))).isFalse();
Properties distributedSystemProperties = gemfireCache.getDistributedSystem().getProperties();
assertThat(distributedSystemProperties).isNotNull();
assertThat(Boolean.parseBoolean(distributedSystemProperties.getProperty("disable-auto-reconnect"))).isTrue();
assertThat(Boolean.parseBoolean(distributedSystemProperties.getProperty("use-cluster-configuration"))).isFalse();
}
@Test
public void testCacheWithAutoReconnectDisabled() {
public void cacheWithAutoReconnectDisabledIsCorrect() {
assertThat(applicationContext.containsBean("cache-with-auto-reconnect-disabled")).isTrue();
@@ -135,7 +152,7 @@ public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport {
}
@Test
public void testCacheWithAutoReconnectEnabled() {
public void cacheWithAutoReconnectEnabledIsCorrect() {
assertThat(applicationContext.containsBean("cache-with-auto-reconnect-enabled")).isTrue();
@@ -151,7 +168,7 @@ public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport {
}
@Test
public void testCacheWithGatewayConflictResolver() {
public void cacheWithGatewayConflictResolverIsCorrect() {
Cache cache = applicationContext.getBean("cache-with-gateway-conflict-resolver", Cache.class);
@@ -159,7 +176,7 @@ public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport {
}
@Test(expected = IllegalStateException.class)
public void testCacheWithNoBeanFactoryLocator() {
public void cacheWithNoBeanFactoryLocatorIsCorrect() {
assertThat(applicationContext.containsBean("cache-with-no-bean-factory-locator")).isTrue();
@@ -172,7 +189,7 @@ public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport {
}
@Test
public void testCacheWithUseClusterConfigurationDisabled() {
public void cacheWithUseClusterConfigurationDisabledIsCorrect() {
assertThat(applicationContext.containsBean("cache-with-use-cluster-configuration-disabled")).isTrue();
@@ -189,7 +206,7 @@ public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport {
}
@Test
public void testCacheWithUseClusterConfigurationEnabled() {
public void cacheWithUseClusterConfigurationEnabledIsCorrect() {
assertThat(applicationContext.containsBean("cache-with-use-cluster-configuration-enabled")).isTrue();
@@ -206,7 +223,7 @@ public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport {
}
@Test
public void testCacheWithXmlAndProperties() throws Exception {
public void cacheWithXmlAndPropertiesConfigurationIsCorrect() throws Exception {
assertThat(applicationContext.containsBean("cache-with-xml-and-props")).isTrue();
@@ -225,7 +242,7 @@ public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport {
}
@Test
public void testHeapTunedCache() {
public void heapTunedCacheIsCorrect() {
assertThat(applicationContext.containsBean("heap-tuned-cache")).isTrue();
@@ -240,7 +257,7 @@ public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport {
}
@Test
public void testOffHeapTunedCache() {
public void offHeapTunedCacheIsCorrect() {
assertThat(applicationContext.containsBean("off-heap-tuned-cache")).isTrue();

View File

@@ -46,8 +46,7 @@ import org.springframework.util.StringUtils;
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "server-ns.xml",
initializers = GemFireMockObjectsApplicationContextInitializer.class)
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings("unused")
public class CacheServerNamespaceIntegrationTests extends IntegrationTestsSupport {
@@ -56,7 +55,7 @@ public class CacheServerNamespaceIntegrationTests extends IntegrationTestsSuppor
@Test
@SuppressWarnings("deprecation")
public void testBasicCacheServer() {
public void basicCacheServerConfigurationIsCorrect() {
CacheServer cacheServer = applicationContext.getBean("advanced-config", CacheServer.class);

View File

@@ -14,13 +14,14 @@
* limitations under the License.
*
*/
package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -34,22 +35,23 @@ import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
/**
* Unit tests for {@link ClientCacheParser}.
* Unit Tests for {@link ClientCacheParser}.
*
* @author John Blum
* @author Patrick Johnson
* @see org.junit.Test
* @see org.mockito.Mock
* @see org.mockito.Mockito
* @see org.mockito.Spy
* @see org.mockito.junit.MockitoJUnitRunner
* @see org.springframework.data.gemfire.config.xml.ClientCacheParser
* @see org.w3c.dom.Element
* @since 1.8.0
*/
@RunWith(MockitoJUnitRunner.class)
@@ -58,15 +60,15 @@ public class ClientCacheParserUnitTests {
@Mock
private Element mockElement;
protected void assertPropertyIsPresent(BeanDefinition beanDefinition, String propertyName) {
private void assertPropertyIsPresent(BeanDefinition beanDefinition, String propertyName) {
assertThat(beanDefinition.getPropertyValues().contains(propertyName)).isTrue();
}
protected void assertPropertyIsNotPresent(BeanDefinition beanDefinition, String propertyName) {
private void assertPropertyIsNotPresent(BeanDefinition beanDefinition, String propertyName) {
assertThat(beanDefinition.getPropertyValues().contains(propertyName)).isFalse();
}
protected void assertPropertyValueEquals(BeanDefinition beanDefinition, String propertyName,
private void assertPropertyValueEquals(BeanDefinition beanDefinition, String propertyName,
Object expectedPropertyValue) {
assertPropertyIsPresent(beanDefinition, propertyName);
@@ -82,6 +84,7 @@ public class ClientCacheParserUnitTests {
@Test
public void doParseSetsProperties() {
NodeList mockNodeList = mock(NodeList.class);
when(mockElement.getAttribute(eq("durable-client-id"))).thenReturn("123");
@@ -94,15 +97,11 @@ public class ClientCacheParserUnitTests {
BeanDefinitionBuilder clientCacheBuilder = BeanDefinitionBuilder.genericBeanDefinition();
final BeanDefinitionRegistry mockRegistry = mock(BeanDefinitionRegistry.class);
BeanDefinitionRegistry mockRegistry = mock(BeanDefinitionRegistry.class);
when(mockRegistry.containsBeanDefinition(anyString())).thenReturn(false);
ClientCacheParser clientCacheParser = spy(new ClientCacheParser());
ClientCacheParser clientCacheParser = new ClientCacheParser() {
@Override protected BeanDefinitionRegistry getRegistry(ParserContext parserContext) {
return mockRegistry;
}
};
doReturn(mockRegistry).when(clientCacheParser).getRegistry(any());
clientCacheParser.doParse(mockElement, null, clientCacheBuilder);

View File

@@ -34,7 +34,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "index-ns.xml", initializers = GemFireMockObjectsApplicationContextInitializer.class)
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings({ "deprecation", "unused" })
public class IndexNamespaceIntegrationTests extends IntegrationTestsSupport {
@@ -74,6 +74,7 @@ public class IndexNamespaceIntegrationTests extends IntegrationTestsSupport {
assertThat(complex.getName()).isEqualTo("complex-index");
assertThat(complex.getIndexedExpression()).isEqualTo("tsi.name");
assertThat(complex.getFromClause()).isEqualTo(Region.SEPARATOR + TEST_REGION_NAME + " tsi");
assertThat(complex.getRegion()).isNotNull();
assertThat(complex.getRegion().getName()).isEqualTo(TEST_REGION_NAME);
assertThat(complex.getType()).isEqualTo(org.apache.geode.cache.query.IndexType.HASH);
}

View File

@@ -30,7 +30,7 @@ import org.springframework.data.gemfire.tests.mock.beans.factory.config.GemFireM
import org.xml.sax.SAXParseException;
/**
* Unit Tests testing the proper syntax for declaring "custom" expiration attributes on a {@link Region}.
* Integration Tests testing the proper syntax for declaring "custom" expiration attributes on a {@link Region}.
*
* @author John Blum
* @see org.junit.Test

View File

@@ -22,6 +22,8 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheListener;
import org.apache.geode.cache.CacheLoader;
import org.apache.geode.cache.CacheWriter;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionAttributes;
@@ -41,7 +43,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ObjectUtils;
/**
* Integration Tests for the Local Region XML namespace configuration metadata.
* Integration Tests for the Local {@link Region} SDG XML namespace configuration metadata.
*
* @author Costin Leau
* @author David Turanski
@@ -56,7 +58,7 @@ import org.springframework.util.ObjectUtils;
* @see org.springframework.test.context.junit4.SpringRunner
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(locations="local-ns.xml", initializers = GemFireMockObjectsApplicationContextInitializer.class)
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings("unused")
public class LocalRegionNamespaceIntegrationTests extends IntegrationTestsSupport {
@@ -116,9 +118,9 @@ public class LocalRegionNamespaceIntegrationTests extends IntegrationTestsSuppor
assertThat(cacheListeners[0]).isSameAs(applicationContext.getBean("c-listener"));
assertThat(cacheListeners[1] instanceof SimpleCacheListener).isTrue();
assertThat(cacheListeners[1]).isNotSameAs(cacheListeners[0]);
assertThat(TestUtils.<String>readField("cacheLoader", complexRegionFactoryBean))
assertThat(TestUtils.<CacheLoader>readField("cacheLoader", complexRegionFactoryBean))
.isSameAs(applicationContext.getBean("c-loader"));
assertThat(TestUtils.<String>readField("cacheWriter", complexRegionFactoryBean))
assertThat(TestUtils.<CacheWriter>readField("cacheWriter", complexRegionFactoryBean))
.isSameAs(applicationContext.getBean("c-writer"));
}

View File

@@ -17,31 +17,22 @@
package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.stubbing.Answer;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.lucene.LuceneIndex;
import org.apache.geode.cache.lucene.LuceneIndexFactory;
import org.apache.geode.cache.lucene.LuceneSerializer;
import org.apache.geode.cache.lucene.LuceneService;
@@ -49,19 +40,21 @@ import org.apache.lucene.analysis.Analyzer;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.data.gemfire.search.lucene.LuceneServiceFactoryBean;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.GemFireMockObjectsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import lombok.SneakyThrows;
/**
* Unit tests for the {@link LuceneServiceParser} and {@link LuceneIndexParser}.
* Unit Tests for the {@link LuceneServiceParser} and {@link LuceneIndexParser}.
*
* @author John Blum
* @see org.junit.Test
@@ -189,104 +182,23 @@ public class LuceneNamespaceUnitTests extends IntegrationTestsSupport {
assertThat(this.luceneIndexFour.getLuceneSerializer()).isEqualTo(luceneSerializer);
}
public static class LuceneNamespaceUnitTestsBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
public static class LuceneNamespaceUnitTestsBeanPostProcessor implements BeanPostProcessor {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
beanFactory.getBeanDefinition("luceneService")
.setBeanClassName(MockLuceneServiceFactoryBean.class.getName());
}
}
@SneakyThrows @Nullable @Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
public static class MockLuceneServiceFactoryBean implements FactoryBean<LuceneService>, InitializingBean {
if (bean instanceof LuceneServiceFactoryBean) {
private GemFireCache gemfireCache;
LuceneServiceFactoryBean factoryBean = spy((LuceneServiceFactoryBean) bean);
private LuceneService luceneService;
doNothing().when(factoryBean).afterPropertiesSet();
doAnswer(invocation -> GemFireMockObjectsSupport.mockLuceneService(null))
.when(factoryBean).getObject();
@Override
public void afterPropertiesSet() throws Exception {
assertThat(this.gemfireCache).describedAs("GemFireCache must not be null").isNotNull();
}
bean = factoryBean;
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public LuceneService getObject() throws Exception {
return Optional.ofNullable(this.luceneService).orElseGet(() -> {
this.luceneService = mock(LuceneService.class);
when(this.luceneService.createIndexFactory()).thenAnswer(invocation -> {
LuceneIndexFactory mockLuceneIndexFactory = mock(LuceneIndexFactory.class);
List<String> fieldNames = new ArrayList<>();
when(mockLuceneIndexFactory.setFields((String[]) any())).thenAnswer(setFieldsInvocation -> {
Collections.addAll(fieldNames, toStringArray(setFieldsInvocation.getArguments()));
return mockLuceneIndexFactory;
});
Map<String, Analyzer> fieldAnalyzers = new HashMap<>();
when(mockLuceneIndexFactory.setFields(any(Map.class))).thenAnswer(setFieldsInvocation -> {
fieldAnalyzers.putAll(setFieldsInvocation.getArgument(0));
return mockLuceneIndexFactory;
});
AtomicReference<LuceneSerializer> luceneSerializer = new AtomicReference<>(null);
when(mockLuceneIndexFactory.setLuceneSerializer(any())).thenAnswer(setLuceneSerializerInvocation -> {
luceneSerializer.set(setLuceneSerializerInvocation.getArgument(0));
return mockLuceneIndexFactory;
});
Answer mockLuceneIndex =
mockLuceneIndex(this.luceneService, fieldAnalyzers, fieldNames, luceneSerializer);
doAnswer(mockLuceneIndex).when(mockLuceneIndexFactory).create(anyString(), anyString());
return mockLuceneIndexFactory;
});
return this.luceneService;
});
}
@SuppressWarnings("rawtypes")
private Answer<LuceneIndex> mockLuceneIndex(LuceneService mockLuceneService,
Map<String, Analyzer> fieldAnalyzers, List<String> fieldNames,
AtomicReference<LuceneSerializer> luceneSerializer) {
return invocation -> {
String indexName = invocation.getArgument(0);
String regionPath = invocation.getArgument(1);
LuceneIndex mockLuceneIndex = mock(LuceneIndex.class, indexName);
when(mockLuceneIndex.getFieldAnalyzers()).thenReturn(fieldAnalyzers);
when(mockLuceneIndex.getFieldNames()).thenReturn(asArray(fieldNames));
when(mockLuceneIndex.getLuceneSerializer()).thenAnswer(it -> luceneSerializer.get());
when(mockLuceneIndex.getName()).thenReturn(indexName);
when(mockLuceneIndex.getRegionPath()).thenReturn(regionPath);
when(mockLuceneService.getIndex(eq(indexName), eq(regionPath))).thenReturn(mockLuceneIndex);
return mockLuceneIndex;
};
}
@Override
public Class<?> getObjectType() {
return Optional.ofNullable(this.luceneService)
.<Class<?>>map(LuceneService::getClass)
.orElse(LuceneService.class);
}
public void setCache(GemFireCache gemfireCache) {
this.gemfireCache = gemfireCache;
return bean;
}
}

View File

@@ -17,6 +17,8 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -26,8 +28,6 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.ResumptionAction;
import org.apache.geode.distributed.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
@@ -47,33 +47,38 @@ import org.springframework.test.context.junit4.SpringRunner;
* @see org.springframework.test.context.junit4.SpringRunner
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "/org/springframework/data/gemfire/config/xml/membership-attributes-ns.xml",
initializers = GemFireMockObjectsApplicationContextInitializer.class)
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings({ "deprecation", "unused" })
public class MembershipAttributesIntegrationTests extends IntegrationTestsSupport {
@Autowired
private ApplicationContext applicationContext;
@Resource(name = "secure")
private Region<?, ?> secure;
@Resource(name = "simple")
private Region<?, ?> simple;
@Test
public void membershipAttributesConfigurationIsCorrect() {
public void secureRegionMembershipAttributesConfigurationIsCorrect() {
Region<?, ?> simple = applicationContext.getBean("simple", Region.class);
MembershipAttributes membershipAttributes = secure.getAttributes().getMembershipAttributes();
assertThat(membershipAttributes).isNotNull();
assertThat(membershipAttributes.getLossAction()).isEqualTo(LossAction.LIMITED_ACCESS);
assertThat(membershipAttributes.hasRequiredRoles()).isTrue();
assertThat(membershipAttributes.getRequiredRoles().stream().map(Role::getName))
.containsExactlyInAnyOrder("ROLE1", "ROLE2");
assertThat(membershipAttributes.getResumptionAction()).isEqualTo(ResumptionAction.REINITIALIZE);
}
@Test
public void simpleRegionMembershipAttributesConfigurationIsCorrect() {
MembershipAttributes membershipAttributes = simple.getAttributes().getMembershipAttributes();
assertThat(membershipAttributes).isNotNull();
assertThat(membershipAttributes.getLossAction()).isEqualTo(LossAction.FULL_ACCESS);
assertThat(membershipAttributes.hasRequiredRoles()).isFalse();
Region<?, ?> secure = applicationContext.getBean("secure", Region.class);
membershipAttributes = secure.getAttributes().getMembershipAttributes();
assertThat(membershipAttributes.hasRequiredRoles()).isTrue();
assertThat(membershipAttributes.getResumptionAction()).isEqualTo(ResumptionAction.REINITIALIZE);
assertThat(membershipAttributes.getLossAction()).isEqualTo(LossAction.LIMITED_ACCESS);
for (Role role : membershipAttributes.getRequiredRoles()) {
assertThat("ROLE1".equals(role.getName()) || "ROLE2".equals(role.getName())).isTrue();
}
assertThat(membershipAttributes.getRequiredRoles()).isEmpty();
assertThat(membershipAttributes.getResumptionAction()).isEqualTo(ResumptionAction.NONE);
}
}

View File

@@ -38,7 +38,7 @@ import org.springframework.test.context.junit4.SpringRunner;
/**
* Integration Tests testing the contract and functionality of the SDG {@link PeerRegionFactoryBean} class,
* and specifically the specification of the Apache Geode {@link Region} {@link DataPolicy}, when used as
* and specifically the specification of the Apache Geode {@link Region} {@link DataPolicy} when used as
* raw bean definition in Spring XML configuration metadata.
*
* @author John Blum

View File

@@ -34,7 +34,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Integration Tests for Apache Geode {@link Region} Eviction configuration settings ({@link EvictionAttributes})
* Integration Tests for {@link Region} Eviction configuration settings ({@link EvictionAttributes})
* using SDG XML namespace configuration metadata.
*
* @author John Blum

View File

@@ -36,8 +36,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.Assert;
/**
* Integration Tests with test cases testing the configuration of {@link ExpirationAttributes} settings
* on {@link Region} entries.
* Integration Tests testing the configuration of {@link ExpirationAttributes} settings on {@link Region} entries.
*
* @author John Blum
* @see org.junit.Test

View File

@@ -25,6 +25,7 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.InterestPolicy;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.SubscriptionAttributes;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
@@ -32,13 +33,14 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Integration Tests with test cases testing the contract and functionality of declaring and defining Subscription
* Attributes for a {@link Region} in the SDG XML namespace (XSD) configuration metadata.
* Integration Tests testing the contract and functionality of declaring and defining {@link SubscriptionAttributes}
* for a {@link Region} in the SDG XML namespace configuration metadata.
*
* @author John Blum
* @see org.junit.Test
* @see org.junit.runner.RunWith
* @see org.apache.geode.cache.Region
* @see org.apache.geode.cache.SubscriptionAttributes
* @see org.springframework.data.gemfire.SubscriptionAttributesFactoryBean
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer

View File

@@ -45,7 +45,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ObjectUtils;
/**
* Integration Tests for the Replicated Region XML namespace configuration metadata.
* Integration Tests for {@link DataPolicy#REPLICATE} {@link Region} XML namespace configuration metadata.
*
* @author Costin Leau
* @author David Turanski
@@ -60,16 +60,15 @@ import org.springframework.util.ObjectUtils;
* @see org.springframework.test.context.junit4.SpringRunner
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "replicated-ns.xml",
initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings("unused")
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings({ "rawtypes", "unused" })
public class ReplicatedRegionNamespaceIntegrationTests extends IntegrationTestsSupport {
@Autowired
private ApplicationContext applicationContext;
@Test
public void testSimpleReplicateRegion() throws Exception {
public void simpleReplicateRegionConfigurationIsCorrect() throws Exception {
assertThat(applicationContext.containsBean("simple")).isTrue();
@@ -80,7 +79,7 @@ public class ReplicatedRegionNamespaceIntegrationTests extends IntegrationTestsS
assertThat(TestUtils.<Boolean>readField("close", simpleRegionFactoryBean)).isEqualTo(false);
assertThat(TestUtils.<Scope>readField("scope", simpleRegionFactoryBean)).isNull();
RegionAttributes<?, ?> simpleRegionAttributes = TestUtils.readField("attributes", simpleRegionFactoryBean);
RegionAttributes<?, ?> simpleRegionAttributes = simpleRegionFactoryBean.getAttributes();
assertThat(simpleRegionAttributes).isNotNull();
assertThat(simpleRegionAttributes.getConcurrencyChecksEnabled()).isFalse();
@@ -89,8 +88,8 @@ public class ReplicatedRegionNamespaceIntegrationTests extends IntegrationTestsS
}
@Test
@SuppressWarnings({ "deprecation", "rawtypes" })
public void testPublishReplicateRegion() throws Exception {
@SuppressWarnings("deprecation")
public void publisherReplicateRegionConfigurationIsCorrect() throws Exception {
assertThat(applicationContext.containsBean("pub")).isTrue();
@@ -101,15 +100,14 @@ public class ReplicatedRegionNamespaceIntegrationTests extends IntegrationTestsS
assertThat(TestUtils.<String>readField("name", publisherRegionFactoryBean)).isEqualTo("publisher");
assertThat(TestUtils.<Scope>readField("scope", publisherRegionFactoryBean)).isEqualTo(Scope.DISTRIBUTED_ACK);
RegionAttributes publisherRegionAttributes = TestUtils.readField("attributes", publisherRegionFactoryBean);
RegionAttributes publisherRegionAttributes = publisherRegionFactoryBean.getAttributes();
assertThat(publisherRegionAttributes.getConcurrencyChecksEnabled()).isTrue();
assertThat(publisherRegionAttributes.getPublisher()).isFalse();
}
@Test
@SuppressWarnings("rawtypes")
public void testComplexReplicateRegion() throws Exception {
public void complexReplicateRegionConfigurationIsCorrect() throws Exception {
assertThat(applicationContext.containsBean("complex")).isTrue();
@@ -133,8 +131,7 @@ public class ReplicatedRegionNamespaceIntegrationTests extends IntegrationTestsS
}
@Test
@SuppressWarnings("rawtypes")
public void testReplicatedRegionWithAttributes() {
public void replicatedRegionWithAttributesConfigurationIsCorrect() {
assertThat(applicationContext.containsBean("replicated-with-attributes")).isTrue();
@@ -165,7 +162,7 @@ public class ReplicatedRegionNamespaceIntegrationTests extends IntegrationTestsS
}
@Test
public void testReplicatedWithSynchronousIndexUpdates() {
public void replicatedWithSynchronousIndexUpdatesConfigurationIsCorrect() {
assertThat(applicationContext.containsBean("replicated-with-synchronous-index-updates")).isTrue();
@@ -181,8 +178,7 @@ public class ReplicatedRegionNamespaceIntegrationTests extends IntegrationTestsS
}
@Test
@SuppressWarnings("rawtypes")
public void testRegionLookup() throws Exception {
public void regionLookupConfigurationIsCorrect() throws Exception {
Cache cache = applicationContext.getBean(Cache.class);
@@ -199,7 +195,7 @@ public class ReplicatedRegionNamespaceIntegrationTests extends IntegrationTestsS
}
@Test
public void testCompressedReplicateRegion() {
public void compressedReplicateRegionConfigurationIsCorrect() {
assertThat(applicationContext.containsBean("Compressed")).isTrue();

View File

@@ -41,11 +41,8 @@ import org.apache.geode.cache.ExpirationAction;
import org.apache.geode.cache.ExpirationAttributes;
import org.apache.geode.cache.InterestPolicy;
import org.apache.geode.cache.LoaderHelper;
import org.apache.geode.cache.LossAction;
import org.apache.geode.cache.MembershipAttributes;
import org.apache.geode.cache.PartitionResolver;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.ResumptionAction;
import org.apache.geode.cache.Scope;
import org.apache.geode.cache.SubscriptionAttributes;
import org.apache.geode.cache.asyncqueue.AsyncEvent;
@@ -55,7 +52,6 @@ import org.apache.geode.cache.partition.PartitionListenerAdapter;
import org.apache.geode.cache.util.CacheListenerAdapter;
import org.apache.geode.cache.util.CacheWriterAdapter;
import org.apache.geode.cache.util.ObjectSizer;
import org.apache.geode.distributed.Role;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanIsAbstractException;
@@ -65,7 +61,6 @@ import org.springframework.data.gemfire.tests.integration.IntegrationTestsSuppor
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
@@ -187,27 +182,6 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
assertThat(Arrays.asList(gatewaySenderIds).containsAll(region.getAttributes().getGatewaySenderIds())).isTrue();
}
private void assertDefaultMembershipAttributes(MembershipAttributes membershipAttributes) {
assumeNotNull(membershipAttributes);
assertMembershipAttributes(membershipAttributes, LossAction.FULL_ACCESS, ResumptionAction.NONE);
}
private void assertMembershipAttributes(MembershipAttributes membershipAttributes, LossAction expectedLossAction,
ResumptionAction expectedResumptionAction, String... expectedRequiredRoles) {
assertThat(membershipAttributes).as("The 'MembershipAttributes' must not be null!").isNotNull();
assertThat(membershipAttributes.getLossAction()).isEqualTo(expectedLossAction);
assertThat(membershipAttributes.getResumptionAction()).isEqualTo(expectedResumptionAction);
if (!ObjectUtils.isEmpty(expectedRequiredRoles)) {
for (Role membershipRole : membershipAttributes.getRequiredRoles()) {
assertThat(Arrays.asList(expectedRequiredRoles).contains(membershipRole.getName()))
.as(String.format("Role '%1$s' was not found!", membershipRole)).isTrue();
}
}
}
private void assertPartitionListener(Region<?, ?> region, String... expectedNames) {
assertThat(region).isNotNull();
@@ -235,6 +209,7 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
.isEqualTo(expectedName);
}
@SuppressWarnings("unchecked")
private void assertDefaultRegionAttributes(Region region) {
assertThat(region).describedAs("The Region must not be null!").isNotNull();
@@ -346,7 +321,6 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getKeyConstraint()).isNull();
assertThat(String.valueOf(nonTemplateBasedReplicateRegion.getAttributes().getLoadFactor())).isEqualTo("0.65");
assertThat(nonTemplateBasedReplicateRegion.getAttributes().isLockGrantor()).isFalse();
assertDefaultMembershipAttributes(nonTemplateBasedReplicateRegion.getAttributes().getMembershipAttributes());
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getPartitionAttributes()).isNull();
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getScope()).isEqualTo(Scope.DISTRIBUTED_NO_ACK);
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getStatisticsEnabled()).isFalse();
@@ -383,7 +357,6 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
assertThat(templateBasedReplicateRegion.getAttributes().getKeyConstraint()).isEqualTo(String.class);
assertThat(String.valueOf(templateBasedReplicateRegion.getAttributes().getLoadFactor())).isEqualTo("0.85");
assertThat(templateBasedReplicateRegion.getAttributes().isLockGrantor()).isTrue();
assertDefaultMembershipAttributes(templateBasedReplicateRegion.getAttributes().getMembershipAttributes());
assertThat(templateBasedReplicateRegion.getAttributes().getPartitionAttributes()).isNull();
assertThat(templateBasedReplicateRegion.getAttributes().getScope()).isEqualTo(Scope.GLOBAL);
assertThat(templateBasedReplicateRegion.getAttributes().getStatisticsEnabled()).isTrue();
@@ -421,8 +394,6 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
assertThat(templateBasedReplicateSubRegion.getAttributes().getKeyConstraint()).isEqualTo(Integer.class);
assertThat(String.valueOf(templateBasedReplicateSubRegion.getAttributes().getLoadFactor())).isEqualTo("0.95");
assertThat(templateBasedReplicateSubRegion.getAttributes().isLockGrantor()).isFalse();
assertMembershipAttributes(templateBasedReplicateSubRegion.getAttributes().getMembershipAttributes(),
LossAction.LIMITED_ACCESS, ResumptionAction.NONE, "readWriteNode");
assertThat(templateBasedReplicateSubRegion.getAttributes().getPartitionAttributes()).isNull();
assertThat(templateBasedReplicateSubRegion.getAttributes().getScope()).isEqualTo(Scope.DISTRIBUTED_NO_ACK);
assertThat(templateBasedReplicateSubRegion.getAttributes().getStatisticsEnabled()).isTrue();
@@ -461,8 +432,6 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getLoadFactor())
.isCloseTo(0.85f, offset(0.0f));
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().isLockGrantor()).isFalse();
assertDefaultMembershipAttributes(
templateBasedReplicateRegionNoOverrides.getAttributes().getMembershipAttributes());
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getPartitionAttributes()).isNull();
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getScope()).isEqualTo(Scope.DISTRIBUTED_ACK);
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getStatisticsEnabled()).isTrue();
@@ -502,8 +471,6 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
assertThat(templateBasedPartitionRegion.getAttributes().getKeyConstraint()).isEqualTo(Date.class);
assertThat(String.valueOf(templateBasedPartitionRegion.getAttributes().getLoadFactor())).isEqualTo("0.7");
assertThat(templateBasedPartitionRegion.getAttributes().isLockGrantor()).isFalse();
assertMembershipAttributes(templateBasedPartitionRegion.getAttributes().getMembershipAttributes(),
LossAction.NO_ACCESS, ResumptionAction.REINITIALIZE, "admin", "root", "supertool");
assertThat(templateBasedPartitionRegion.getAttributes().getPartitionAttributes()).isNotNull();
assertThat(templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getColocatedWith())
.isEqualTo("Neighbor");
@@ -557,7 +524,6 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
assertThat(templateBasedLocalRegion.getAttributes().getKeyConstraint()).isEqualTo(Long.class);
assertThat(String.valueOf(templateBasedLocalRegion.getAttributes().getLoadFactor())).isEqualTo("0.85");
assertThat(templateBasedLocalRegion.getAttributes().isLockGrantor()).isFalse();
assertDefaultMembershipAttributes(templateBasedLocalRegion.getAttributes().getMembershipAttributes());
assertThat(templateBasedLocalRegion.getAttributes().getPartitionAttributes()).isNull();
assertThat(templateBasedLocalRegion.getAttributes().getScope()).isEqualTo(Scope.LOCAL);
assertThat(templateBasedLocalRegion.getAttributes().getStatisticsEnabled()).isTrue();

View File

@@ -33,8 +33,8 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Integration Tests for Apache Geode cache transaction event handling configuration declared in
* SDG XML namespace configuration metadata.
* Integration Tests for Apache Geode cache transaction event handlers (listeners) declared in SDG XML namespace
* configuration metadata.
*
* @author David Turanski
* @author John Blum
@@ -49,12 +49,9 @@ import org.springframework.test.context.junit4.SpringRunner;
* @see org.springframework.test.context.junit4.SpringRunner
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(
locations = "tx-listeners-and-writers.xml",
initializers = GemFireMockObjectsApplicationContextInitializer.class
)
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings("unused")
public class TxEventHandlersIntegrationTests extends IntegrationTestsSupport {
public class TransactionEventHandlersIntegrationTests extends IntegrationTestsSupport {
@Autowired
TestTransactionListener txListener1;

View File

@@ -17,8 +17,8 @@
package org.springframework.data.gemfire.expiration;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import javax.annotation.Resource;
@@ -40,8 +40,8 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Integration Tests with test cases testing the configuration of Annotation-defined expiration policies
* on {@link Region} entry TTL and TTI custom expiration settings.
* Integration Tests testing the configuration of Annotation-defined expiration policies on {@link Region} entry
* TTL and TTI custom expiration settings.
*
* @author John Blum
* @see org.junit.Test
@@ -115,7 +115,7 @@ public class AnnotationBasedExpirationConfigurationIntegrationTest extends Integ
Region.Entry<Object, Object> mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
when(mockRegionEntry.getValue()).thenReturn(value);
doReturn(value).when(mockRegionEntry).getValue();
return mockRegionEntry;
}
@@ -169,7 +169,7 @@ public class AnnotationBasedExpirationConfigurationIntegrationTest extends Integ
assertExpiration(genericExpiration.getExpiry(mockRegionEntry(new RegionEntryGenericExpirationPolicy())), 60, ExpirationAction.DESTROY);
}
@Test(expected = IllegalArgumentException.class)
@Test(expected = EvaluationException.class)
public void invalidExpirationAction() {
try {

View File

@@ -13,31 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.fork;
import java.io.IOException;
import java.util.Scanner;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheClosedException;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionFactory;
import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.cache.Scope;
import org.apache.geode.cache.server.CacheServer;
import org.springframework.data.gemfire.ForkUtil;
import org.springframework.data.gemfire.util.SpringUtils;
/**
* @author Costin Leau
* @author John Blum
*/
@SuppressWarnings("unchecked")
public class CqCacheServerProcess {
private static final int DEFAULT_CACHE_SERVER_PORT = 40404;
private static final int DEFAULT_CACHE_SERVER_PORT = CacheServer.DEFAULT_PORT;
private static Region<String, Integer> testCqRegion;
@@ -45,7 +42,6 @@ public class CqCacheServerProcess {
private static final String GEMFIRE_LOG_LEVEL = "error";
private static final String GEMFIRE_NAME = "CqServer";
@SuppressWarnings("deprecation")
public static void main(final String[] args) throws Exception {
waitForShutdown(registerShutdownHook(startCacheServer(addRegion(
newGemFireCache(GEMFIRE_NAME, GEMFIRE_LOG_LEVEL), "test-cq"))));
@@ -60,9 +56,8 @@ public class CqCacheServerProcess {
}
private static Cache addRegion(Cache gemfireCache, String name) {
RegionFactory<String, Integer> regionFactory = gemfireCache.createRegionFactory(RegionShortcut.REPLICATE);
regionFactory.setScope(Scope.DISTRIBUTED_ACK);
RegionFactory<String, Integer> regionFactory = gemfireCache.createRegionFactory(RegionShortcut.REPLICATE);
testCqRegion = regionFactory.create(name);
@@ -70,9 +65,12 @@ public class CqCacheServerProcess {
}
private static Cache startCacheServer(Cache gemfireCache) throws IOException {
CacheServer cacheServer = gemfireCache.addCacheServer();
cacheServer.setPort(getCacheServerPort(DEFAULT_CACHE_SERVER_PORT));
cacheServer.start();
return gemfireCache;
}
@@ -81,21 +79,15 @@ public class CqCacheServerProcess {
}
private static Cache registerShutdownHook(Cache gemfireCache) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (gemfireCache != null) {
try {
gemfireCache.close();
}
catch (CacheClosedException ignore) {
}
}
}));
Runtime.getRuntime().addShutdownHook(new Thread(() -> SpringUtils.safeDoOperation(() -> gemfireCache.close())));
return gemfireCache;
}
@SuppressWarnings("deprecation")
@SuppressWarnings({ "deprecation", "unused" })
private static void waitForShutdown(Cache gemfireCache) throws IOException {
ForkUtil.createControlFile(CqCacheServerProcess.class.getName());
Scanner scanner = new Scanner(System.in);

View File

@@ -35,10 +35,17 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Integration Tests for SDG Annotation-driver Apache Geode {@link Function} configuration.
*
* @author David Turanski
* @author John Blum
* @see org.junit.Test
* @see org.apache.geode.cache.execute.Function
* @see org.apache.geode.cache.execute.FunctionService
* @see org.springframework.data.gemfire.function.annotation.GemfireFunction
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
*/
@RunWith(SpringRunner.class)
@ContextConfiguration

View File

@@ -18,6 +18,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.execute.Function;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@@ -33,11 +34,15 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Integration Tests for the execution of Apache Geode {@link Function Functions}
* using SDG's {@link Function} execution annotation support.
*
* @author David Turanski
* @author John Blum
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = TestConfig.class, initializers = GemFireMockObjectsApplicationContextInitializer.class)
@ContextConfiguration(classes = FunctionExecutionIntegrationTests.TestConfiguration.class,
initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings("unused")
public class FunctionExecutionIntegrationTests extends IntegrationTestsSupport {
@@ -60,9 +65,11 @@ public class FunctionExecutionIntegrationTests extends IntegrationTestsSupport {
assertThat(TestUtils.<Region<?, ?>>readField("region", template)).isSameAs(regionOne);
}
@Configuration
@EnableGemfireFunctionExecutions(basePackages = "org.springframework.data.gemfire.function.config.two")
@ImportResource("/org/springframework/data/gemfire/function/config/FunctionExecutionIntegrationTests-context.xml")
static class TestConfiguration { }
}
@Configuration
@EnableGemfireFunctionExecutions(basePackages = "org.springframework.data.gemfire.function.config.two")
@ImportResource("/org/springframework/data/gemfire/function/config/FunctionExecutionIntegrationTests-context.xml")
class TestConfig { }

View File

@@ -65,7 +65,7 @@ public class FunctionExecutionIntegrationTests extends ForkingClientServerIntegr
.set("name", FunctionExecutionIntegrationTests.class.getSimpleName())
.set("log-level", "error")
.setPoolSubscriptionEnabled(true)
.addPoolServer("localhost", Integer.getInteger(GEMFIRE_POOL_SERVERS_PROPERTY))
.addPoolServer("localhost", Integer.getInteger(GEMFIRE_CACHE_SERVER_PORT_PROPERTY))
.create();
assertThat(this.gemfireCache).isNotNull();

View File

@@ -64,7 +64,7 @@ public class GemfireFunctionTemplateIntegrationTests extends ForkingClientServer
.set("name", GemfireFunctionTemplateIntegrationTests.class.getSimpleName())
.set("log-level", "error")
.setPoolSubscriptionEnabled(true)
.addPoolServer("localhost", Integer.getInteger(GEMFIRE_POOL_SERVERS_PROPERTY))
.addPoolServer("localhost", Integer.getInteger(GEMFIRE_CACHE_SERVER_PORT_PROPERTY))
.create();
assertThat(this.gemfireCache).isNotNull();
@@ -88,7 +88,7 @@ public class GemfireFunctionTemplateIntegrationTests extends ForkingClientServer
}
@Test
public void testFunctionTemplates() {
public void functionTemplatesAreCorrect() {
verifyFunctionTemplateExecution(new GemfireOnRegionFunctionTemplate(gemfireRegion));
verifyFunctionTemplateExecution(new GemfireOnServerFunctionTemplate(gemfireCache));

View File

@@ -15,7 +15,6 @@ package org.springframework.data.gemfire.function.result;
import static org.assertj.core.api.Assertions.assertThat;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
@@ -27,9 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.ReplicatedRegionFactoryBean;
import org.springframework.data.gemfire.config.annotation.PeerCacheApplication;
import org.springframework.data.gemfire.function.annotation.FunctionId;
import org.springframework.data.gemfire.function.annotation.GemfireFunction;
import org.springframework.data.gemfire.function.annotation.OnRegion;
import org.springframework.data.gemfire.function.config.EnableGemfireFunctionExecutions;
import org.springframework.data.gemfire.function.config.EnableGemfireFunctions;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
@@ -53,12 +49,12 @@ import org.springframework.test.context.junit4.SpringRunner;
* @see org.springframework.test.context.junit4.SpringRunner
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = FunctionResultTypeIntegrationTests.TestGeodeConfiguration.class)
@ContextConfiguration(classes = FunctionResultTypeIntegrationTests.TestConfiguration.class)
@SuppressWarnings("unused")
public class FunctionResultTypeIntegrationTests extends IntegrationTestsSupport {
@Autowired
private FunctionExecutions functionExecutions;
private MixedResultTypeFunctionExecutions functionExecutions;
@Test
public void singleResultFunctionsExecuteCorrectly() {
@@ -79,12 +75,12 @@ public class FunctionResultTypeIntegrationTests extends IntegrationTestsSupport
}
@PeerCacheApplication(name = "FunctionResultTypeIntegrationTests")
@EnableGemfireFunctionExecutions(basePackageClasses = FunctionExecutions.class)
@EnableGemfireFunctionExecutions(basePackageClasses = MixedResultTypeFunctionExecutions.class)
@EnableGemfireFunctions
public static class TestGeodeConfiguration {
public static class TestConfiguration {
@Bean("Numbers")
protected ReplicatedRegionFactoryBean<Long, BigDecimal> numbersRegion(GemFireCache gemFireCache) {
ReplicatedRegionFactoryBean<Long, BigDecimal> numbersRegion(GemFireCache gemFireCache) {
ReplicatedRegionFactoryBean<Long, BigDecimal> numbersRegion = new ReplicatedRegionFactoryBean<>();
@@ -94,33 +90,9 @@ public class FunctionResultTypeIntegrationTests extends IntegrationTestsSupport
return numbersRegion;
}
@GemfireFunction(id = "returnSingleObject", hasResult = true)
public BigDecimal returnSingleObject() {
return new BigDecimal(5);
}
@GemfireFunction(id = "returnList", hasResult = true)
public List<BigDecimal> returnList() {
return Collections.singletonList(new BigDecimal(10));
}
@GemfireFunction(id = "returnPrimitive", hasResult = true)
public int returnPrimitive() {
return 7;
@Bean
MixedResultTypeFunctions functions() {
return new MixedResultTypeFunctions();
}
}
}
@OnRegion(region = "Numbers")
interface FunctionExecutions {
@FunctionId("returnSingleObject")
BigDecimal returnFive();
@FunctionId("returnList")
List<BigDecimal> returnList();
@FunctionId("returnPrimitive")
int returnPrimitive();
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright 2020 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
*
* https://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.function.result;
import java.math.BigDecimal;
import java.util.List;
import org.apache.geode.cache.execute.Function;
import org.springframework.data.gemfire.function.annotation.FunctionId;
import org.springframework.data.gemfire.function.annotation.OnRegion;
/**
* The MixedResultTypeFunctionExecutions class declares various Apache Geode {@link Function Functions}
* * using SDG's {@link Function} implementation annotation support.
*
* @author John Blum
* @see org.springframework.data.gemfire.function.annotation.FunctionId
* @see org.springframework.data.gemfire.function.annotation.OnRegion
* @since 2.6.0
*/
@OnRegion(region = "Numbers")
interface MixedResultTypeFunctionExecutions {
@FunctionId("returnSingleObject")
BigDecimal returnFive();
@FunctionId("returnList")
List<BigDecimal> returnList();
@FunctionId("returnPrimitive")
int returnPrimitive();
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2020 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
*
* https://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.function.result;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import org.apache.geode.cache.execute.Function;
import org.springframework.data.gemfire.function.annotation.GemfireFunction;
import org.springframework.stereotype.Component;
/**
* The {@link MixedResultTypeFunctions} class defines (implements) various Apache Geode {@link Function Functions}
* using SDG's {@link Function} implementation annotation support.
*
* @author John Blum
* @since 2.6.0
* @see org.apache.geode.cache.execute.Function
* @see org.springframework.data.gemfire.function.annotation.GemfireFunction
* @see org.springframework.stereotype.Component
*/
@Component
@SuppressWarnings("unused")
public class MixedResultTypeFunctions {
@GemfireFunction(id = "returnSingleObject", hasResult = true)
public BigDecimal returnSingleObject() {
return new BigDecimal(5);
}
@GemfireFunction(id = "returnList", hasResult = true)
public List<BigDecimal> returnList() {
return Collections.singletonList(new BigDecimal(10));
}
@GemfireFunction(id = "returnPrimitive", hasResult = true)
public int returnPrimitive() {
return 7;
}
}

View File

@@ -35,6 +35,7 @@ import org.apache.geode.cache.query.CqEvent;
import org.springframework.data.gemfire.fork.CqCacheServerProcess;
import org.springframework.data.gemfire.listener.adapter.ContinuousQueryListenerAdapter;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
import org.springframework.data.gemfire.tests.process.ProcessWrapper;
import org.springframework.data.gemfire.util.SpringUtils;
/**
@@ -67,9 +68,9 @@ public class ListenerContainerIntegrationTests extends ForkingClientServerIntegr
gemfireCache = new ClientCacheFactory()
.set("name", "ListenerContainerIntegrationTests")
.set("log-level", "warning")
.set("log-level", "error")
.setPoolSubscriptionEnabled(true)
.addPoolServer(DEFAULT_HOSTNAME, Integer.getInteger(GEMFIRE_POOL_SERVERS_PROPERTY))
.addPoolServer(DEFAULT_HOSTNAME, Integer.getInteger(GEMFIRE_CACHE_SERVER_PORT_PROPERTY))
.create();
String query = "SELECT * from /test-cq";
@@ -92,6 +93,8 @@ public class ListenerContainerIntegrationTests extends ForkingClientServerIntegr
@Test
public void testContainer() {
getGemFireServerProcess().ifPresent(ProcessWrapper::signal);
waitOn(() -> this.cqEvents.size() == 3, TimeUnit.SECONDS.toMillis(5));
assertThat(this.cqEvents.size()).isEqualTo(3);

View File

@@ -17,7 +17,6 @@ package org.springframework.data.gemfire.listener.adapter;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,9 +26,8 @@ import org.apache.geode.cache.query.CqQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.fork.CqCacheServerProcess;
import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -41,10 +39,11 @@ import org.springframework.test.context.junit4.SpringRunner;
* @author John Blum
* @see org.junit.Test
* @see org.apache.geode.cache.client.ClientCache
* @see org.apache.geode.cache.client.Pool
* @see org.apache.geode.cache.query.CqQuery
* @see org.springframework.data.gemfire.fork.CqCacheServerProcess
* @see org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer
* @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
@@ -52,12 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings("unused")
public class ContainerXmlConfigurationIntegrationTests extends ForkingClientServerIntegrationTestsSupport {
@BeforeClass
public static void startGemFireServer() throws Exception {
startGemFireServer(CqCacheServerProcess.class);
}
public class ContainerXmlConfigurationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private ApplicationContext applicationContext;

View File

@@ -147,7 +147,7 @@ public class GemfirePersistentEntityUnitTests {
assertThat(identifierAccessor.getIdentifier()).isEqualTo(1L);
}
@Test
@Test(expected = MappingException.class)
public void identifierForAmbiguousIdAnnotatedFieldAndIdAnnotatedPropertyEntityThrowsMappingException() {
AmbiguousIdAnnotatedFieldAndIdAnnotatedPropertyEntity entity =

View File

@@ -58,7 +58,7 @@ public class GemfireRepositoryFactoryBeanUnitTests {
}
catch (IllegalStateException expected) {
assertThat(expected).hasMessage("GemfireMappingContext");
assertThat(expected).hasMessage("GemfireMappingContext must not be null");
throw expected;
}

View File

@@ -18,7 +18,6 @@ package org.springframework.data.gemfire.repository.support;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import java.util.Collections;
import javax.annotation.Resource;
@@ -32,21 +31,16 @@ import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.data.gemfire.LocalRegionFactoryBean;
import org.springframework.data.gemfire.PartitionedRegionFactoryBean;
import org.springframework.data.gemfire.ReplicatedRegionFactoryBean;
import org.springframework.data.gemfire.config.annotation.CacheServerApplication;
import org.springframework.data.gemfire.config.annotation.ClientCacheApplication;
import org.springframework.data.gemfire.config.annotation.ClientCacheConfigurer;
import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions;
import org.springframework.data.gemfire.config.annotation.EnablePdx;
import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories;
import org.springframework.data.gemfire.support.ConnectionEndpoint;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
import org.springframework.data.repository.CrudRepository;
import org.springframework.test.context.ContextConfiguration;
@@ -81,7 +75,7 @@ public class SimpleGemfireRepositoryRegionDeleteAllIntegrationTests extends Fork
@BeforeClass
public static void startGeodeServer() throws Exception {
startGemFireServer(GeodeServerTestConfiguration.class);
startGemFireServer(GeodeServerTestConfiguration.class, "-Dspring.profiles.active=partition");
}
@Resource(name = "Users")
@@ -130,31 +124,13 @@ public class SimpleGemfireRepositoryRegionDeleteAllIntegrationTests extends Fork
@EnablePdx
@EnableEntityDefinedRegions(basePackageClasses = User.class)
@EnableGemfireRepositories(basePackageClasses = UserRepository.class)
static class GeodeClientTestConfiguration {
@Bean
static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
@Bean
ClientCacheConfigurer clientCachePoolPortConfigurer(
@Value("${" + GEMFIRE_CACHE_SERVER_PORT_PROPERTY + ":40404}") int port) {
return (bean, clientCacheFactoryBean) -> clientCacheFactoryBean.setServers(
Collections.singletonList(new ConnectionEndpoint("localhost", port)));
}
}
static class GeodeClientTestConfiguration { }
@CacheServerApplication
static class GeodeServerTestConfiguration {
public static void main(String[] args) {
AnnotationConfigApplicationContext applicationContext =
new AnnotationConfigApplicationContext(GeodeServerTestConfiguration.class);
applicationContext.registerShutdownHook();
runSpringApplication(GeodeServerTestConfiguration.class);
}
@Bean("Users")

View File

@@ -33,6 +33,7 @@ import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.gemfire.GemfireTemplate;
import org.springframework.data.gemfire.GemfireUtils;
import org.springframework.data.gemfire.mapping.GemfireMappingContext;
import org.springframework.data.gemfire.mapping.GemfirePersistentEntity;
import org.springframework.data.gemfire.repository.GemfireRepository;
@@ -62,11 +63,11 @@ import org.springframework.transaction.support.TransactionTemplate;
@RunWith(SpringRunner.class)
@ContextConfiguration
@SuppressWarnings("unused")
public class SimpleGemfireRepositoryTransactionalIntegrationTest extends IntegrationTestsSupport {
public class SimpleGemfireRepositoryTransactionalIntegrationTests extends IntegrationTestsSupport {
// TODO add additional test cases for SimpleGemfireRepository (Region operations) in the presence of Transactions!!!
static final AtomicLong ID_SEQUENCE = new AtomicLong(0L);
private static final AtomicLong ID_SEQUENCE = new AtomicLong(0L);
@Autowired
private CustomerService customerService;
@@ -74,7 +75,7 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest extends Integra
@Resource(name = "Customers")
private Region<?, ?> customers;
static Customer createCustomer(String firstName, String lastName) {
private static Customer createCustomer(String firstName, String lastName) {
Customer customer = new SerializableCustomer(firstName, lastName);
@@ -86,10 +87,12 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest extends Integra
@Before
public void setup() {
assertThat(this.customers).as("The 'Customers' Cache Region was not properly configured and initialized!")
assertThat(this.customers)
.describedAs("The 'Customers' Cache Region was not properly configured and initialized!")
.isNotNull();
assertThat(this.customers.getName()).isEqualTo("Customers");
assertThat(this.customers.getFullPath()).isEqualTo("/Customers");
assertThat(this.customers.getFullPath()).isEqualTo(GemfireUtils.toRegionPath("Customers"));
assertThat(this.customers.isEmpty()).isTrue();
}
@@ -99,7 +102,8 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest extends Integra
}
@Test
public void testDeleteAll() {
public void deleteAllIsCorrect() {
Collection<Customer> expectedCustomers = new ArrayList<>(4);
expectedCustomers.add(createCustomer("Jon", "Doe"));
@@ -129,8 +133,7 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest extends Integra
public static class SerializableCustomer extends Customer implements Serializable {
public SerializableCustomer() {
}
public SerializableCustomer() { }
public SerializableCustomer(final Long id) {
super(id);

View File

@@ -45,12 +45,10 @@ import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.data.gemfire.search.lucene.support.LuceneAccessorSupport;
/**
* Unit tests for {@link LuceneAccessor}.
* Unit Tests for {@link LuceneAccessor}.
*
* @author John Blum
* @see org.junit.Rule
* @see org.junit.Test
* @see org.junit.runner.RunWith
* @see org.mockito.Mock
* @see org.mockito.Mockito
* @see org.mockito.Spy
@@ -177,6 +175,7 @@ public class LuceneAccessorUnitTests {
@Test
public void resolveLuceneServiceLooksUpLuceneService() {
doReturn(mockCache).when(luceneAccessor).resolveCache();
doReturn(mockLuceneService).when(luceneAccessor).resolveLuceneService(eq(mockCache));
assertThat(luceneAccessor.getLuceneService()).isNull();
@@ -186,7 +185,7 @@ public class LuceneAccessorUnitTests {
verify(luceneAccessor, times(1)).resolveLuceneService(eq(mockCache));
}
@Test
@Test(expected = IllegalArgumentException.class)
public void resolveLuceneServiceThrowsIllegalArgumentExceptionWhenCacheIsNull() {
try {
@@ -226,7 +225,7 @@ public class LuceneAccessorUnitTests {
verify(mockLuceneIndex, times(1)).getName();
}
@Test
@Test(expected = IllegalStateException.class)
public void resolveIndexNameThrowsIllegalStateExceptionWhenIndexNameIsUnresolvable() {
assertThat(luceneAccessor.getIndexName()).isNullOrEmpty();

View File

@@ -45,6 +45,7 @@ import org.springframework.data.gemfire.snapshot.event.SnapshotApplicationEvent;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.util.FileSystemUtils;
import org.springframework.data.gemfire.tests.util.ThreadUtils;
import org.springframework.data.gemfire.util.ArrayUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -52,7 +53,7 @@ import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Integration Tests with test cases testing the effects of the {@link SnapshotServiceFactoryBean} using Spring
* Integration Tests testing the effects of the {@link SnapshotServiceFactoryBean} using Spring
* {@link ApplicationEvent ApplicationEvents} to trigger imports and exports of cache {@link Region} data.
*
* @author John Blum
@@ -92,9 +93,10 @@ public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTests ext
private Region<Long, Person> people;
@BeforeClass
public static void setupBeforeClass() throws Exception {
public static void setupSnapshotDirectoryAndFiles() throws Exception {
snapshotsDirectory = new File(new File(FileSystemUtils.WORKING_DIRECTORY, "gemfire"), "snapshots");
snapshotsDirectory = new File(new File(new File(FileSystemUtils.WORKING_DIRECTORY, "gemfire"),
"data"), "snapshots");
assertThat(snapshotsDirectory.isDirectory() || snapshotsDirectory.mkdirs()).isTrue();
@@ -107,10 +109,10 @@ public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTests ext
@AfterClass
public static void tearDownAfterClass() {
//FileSystemUtils.deleteRecursive(snapshotsDirectory.getParentFile());
//FileSystemUtils.deleteRecursive(snapshotsDirectory.getParentFile().getParentFile());
}
protected void assertPeople(Region<Long, Person> targetRegion, Person... people) {
private void assertPeople(Region<Long, Person> targetRegion, Person... people) {
assertThat(targetRegion.size()).isEqualTo(people.length);
@@ -118,32 +120,34 @@ public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTests ext
.forEach(person -> assertPerson(person, targetRegion.get(person.getId())));
}
protected void assertPerson(Person expectedPerson, Person actualPerson) {
private void assertPerson(Person expectedPerson, Person actualPerson) {
assertThat(actualPerson).as(String.format("Expected [%1$s]; but was [%2$s]", expectedPerson, actualPerson))
assertThat(actualPerson)
.describedAs(String.format("Expected [%1$s]; but was [%2$s]", expectedPerson, actualPerson))
.isNotNull();
assertThat(actualPerson.getId()).isEqualTo(expectedPerson.getId());
assertThat(actualPerson.getFirstname()).isEqualTo(expectedPerson.getFirstname());
assertThat(actualPerson.getLastname()).isEqualTo(expectedPerson.getLastname());
}
protected Person newPerson(String firstName, String lastName) {
private Person newPerson(String firstName, String lastName) {
return new Person(ID_SEQUENCE.incrementAndGet(), firstName, lastName);
}
protected Person put(Region<Long, Person> targetRegion, Person person) {
private Person put(Region<Long, Person> targetRegion, Person person) {
targetRegion.putIfAbsent(person.getId(), person);
return person;
}
protected void wait(int seconds, int expectedDoeSize, int expectedEveryoneSize, int expectedHandySize) {
private void wait(int seconds, int expectedDoeSize, int expectedEveryoneSize, int expectedHandySize) {
ThreadUtils.timedWait(TimeUnit.SECONDS.toMillis(seconds), 500,
() -> doe.size() < expectedDoeSize
|| everyoneElse.size() < expectedEveryoneSize
|| handy.size() < expectedHandySize);
() -> doe.size() == expectedDoeSize
|| everyoneElse.size() == expectedEveryoneSize
|| handy.size() == expectedHandySize);
}
@Test
@@ -161,7 +165,7 @@ public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTests ext
eventPublisher.publishEvent(event);
wait(5, 2, 2, 1);
wait(15, 2, 2, 1);
assertPeople(doe, jonDoe, janeDoe);
assertPeople(everyoneElse, jackBlack, joeDirt);
@@ -177,7 +181,7 @@ public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTests ext
eventPublisher.publishEvent(event);
wait(5, 5, 4, 3);
wait(15, 5, 4, 3);
assertPeople(doe, jonDoe, janeDoe, cookieDoe, pieDoe, sourDoe);
assertPeople(everyoneElse, jackBlack, joeDirt, jackHill, jillHill);
@@ -197,18 +201,18 @@ public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTests ext
assertPeople(handy, jackHandy, randyHandy, sandyHandy, mandyHandy);
}
protected static class LastNameSnapshotFilter implements SnapshotFilter<Long, Person> {
static class LastNameSnapshotFilter implements SnapshotFilter<Long, Person> {
private final String lastName;
public LastNameSnapshotFilter(String lastName) {
Assert.hasText(lastName, "'lastName' must be specified");
LastNameSnapshotFilter(String lastName) {
Assert.hasText(lastName, "lastName must be specified");
this.lastName = lastName;
}
protected String getLastName() {
Assert.state(StringUtils.hasText(lastName), "'lastName' was not properly initialized");
return lastName;
Assert.state(StringUtils.hasText(this.lastName), "lastName was not properly initialized");
return this.lastName;
}
@Override
@@ -221,9 +225,9 @@ public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTests ext
}
}
protected static class NotLastNameSnapshotFilter extends LastNameSnapshotFilter {
static class NotLastNameSnapshotFilter extends LastNameSnapshotFilter {
public NotLastNameSnapshotFilter(String lastName) {
NotLastNameSnapshotFilter(String lastName) {
super(lastName);
}
@@ -233,7 +237,7 @@ public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTests ext
}
}
protected static class SnapshotImportsMonitor {
public static class SnapshotImportsMonitor {
@Autowired
private ApplicationEventPublisher eventPublisher;
@@ -246,7 +250,10 @@ public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTests ext
boolean triggerEvent = false;
for (File snapshotFile : nullSafeArray(snapshotsDirectory.listFiles(FileSystemUtils.FileOnlyFilter.INSTANCE))) {
File[] snapshotFiles = ArrayUtils.nullSafeArray(snapshotsDirectory
.listFiles(FileSystemUtils.FileOnlyFilter.INSTANCE), File.class);
for (File snapshotFile : snapshotFiles) {
triggerEvent |= isUnprocessedSnapshotFile(snapshotFile);
}
@@ -255,20 +262,16 @@ public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTests ext
}
}
protected File[] nullSafeArray(File... files) {
return (files != null ? files : new File[0]);
}
protected boolean isUnprocessedSnapshotFile(File snapshotFile) {
private boolean isUnprocessedSnapshotFile(File snapshotFile) {
Long lastModified = snapshotFile.lastModified();
Long previousLastModified = snapshotFileLastModifiedMap.get(snapshotFile);
previousLastModified = (previousLastModified != null ? previousLastModified : lastModified);
previousLastModified = previousLastModified != null ? previousLastModified : lastModified;
snapshotFileLastModifiedMap.put(snapshotFile, lastModified);
return !previousLastModified.equals(lastModified);
return previousLastModified < lastModified;
}
}
}

View File

@@ -264,7 +264,7 @@ public class ConnectionEndpointUnitTests {
}
catch (IllegalArgumentException expected) {
assertThat(expected).hasMessage("'hostPort' must be specified");
assertThat(expected).hasMessage("Host & Port [ ] must be specified");
assertThat(expected).hasNoCause();
throw expected;
@@ -279,7 +279,7 @@ public class ConnectionEndpointUnitTests {
}
catch (IllegalArgumentException expected) {
assertThat(expected).hasMessage("'hostPort' must be specified");
assertThat(expected).hasMessage("Host & Port [] must be specified");
assertThat(expected).hasNoCause();
throw expected;
@@ -294,7 +294,7 @@ public class ConnectionEndpointUnitTests {
}
catch (IllegalArgumentException expected) {
assertThat(expected).hasMessage("'hostPort' must be specified");
assertThat(expected).hasMessage("Host & Port [null] must be specified");
assertThat(expected).hasNoCause();
throw expected;

View File

@@ -100,7 +100,7 @@ public class DeclarableSupportUnitTests {
assertThat(testDeclarableSupport.locateBeanFactory()).isSameAs(mockBeanFactoryOne);
}
@Test
@Test(expected = IllegalArgumentException.class)
public void locateBeanFactoryWithUnknownKeyHavingMultipleBeanFactoriesRegisteredThrowsIllegalArgumentException() {
GemfireBeanFactoryLocator.BEAN_FACTORIES.put("keyOne", mockBeanFactoryOne);

View File

@@ -0,0 +1,107 @@
/*
* Copyright 2012-2021 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
*
* https://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.support;
import static org.assertj.core.api.Assertions.fail;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.GemFireCheckedException;
import org.apache.geode.cache.query.FunctionDomainException;
import org.apache.geode.cache.query.QueryException;
import org.apache.geode.cache.query.QueryInvocationTargetException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.gemfire.GemfireQueryException;
import org.springframework.data.gemfire.config.annotation.ClientCacheApplication;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects;
import org.springframework.data.gemfire.util.SpringUtils;
import org.springframework.stereotype.Repository;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Tests Spring Data for Apache Geode checked persistence {@link Exception Exceptions} translation.
*
* @author David Turanski
* @author John Blum
* @see org.junit.Test
* @see org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
*/
@RunWith(SpringRunner.class)
@ContextConfiguration
@SuppressWarnings("unused")
public class GemfirePersistenceExceptionTranslationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private ApplicationContext applicationContext;
@Autowired
private TestGemFireRepository gemfireRepository;
@SuppressWarnings("all")
private void handleExceptionThrowingCall(SpringUtils.VoidReturningThrowableOperation operation) {
try {
operation.run();
fail("Should have thrown a QueryException");
}
catch (GemfireQueryException ignore) { }
catch (Throwable cause) {
fail("Should have thrown a QueryException", cause);
}
}
@Test
public void exceptionTranslationIsSuccessful() {
handleExceptionThrowingCall(() -> this.gemfireRepository.doIt(new QueryException()));
handleExceptionThrowingCall(() -> this.gemfireRepository.doIt(new FunctionDomainException("test")));
handleExceptionThrowingCall(() -> this.gemfireRepository.doIt(new QueryInvocationTargetException("test")));
}
@ClientCacheApplication
@EnableGemFireMockObjects
static class TestConfiguration {
@Bean
PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationProcessor() {
return new PersistenceExceptionTranslationPostProcessor();
}
@Bean
TestGemFireRepository gemFireRepository() {
return new TestGemFireRepository();
}
}
/**
* Wraps {@link GemFireCheckedException} in {@link RuntimeException}.
*/
@Repository
public static class TestGemFireRepository {
public void doIt(Exception cause) {
throw new RuntimeException(cause);
}
}
}

View File

@@ -1,80 +0,0 @@
/*
* Copyright 2012-2021 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
*
* https://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.support;
import static org.assertj.core.api.Assertions.fail;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.query.FunctionDomainException;
import org.apache.geode.cache.query.QueryException;
import org.apache.geode.cache.query.QueryInvocationTargetException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.GemfireQueryException;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.stereotype.Repository;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@ContextConfiguration
@SuppressWarnings("unused")
public class GemfirePersistenceExceptionTranslationTest extends IntegrationTestsSupport {
@Autowired
private ApplicationContext applicationContext;
@Autowired
private GemFireRepo1 gemfireRepo1;
@Test
public void test() {
applicationContext.getBeansOfType(BeanPostProcessor.class);
try {
gemfireRepo1.doit(new QueryException());
fail("should throw a query exception");
}
catch (GemfireQueryException ignore){ }
try {
gemfireRepo1.doit(new FunctionDomainException("test"));
fail("should throw a query exception");
}
catch (GemfireQueryException ignore) { }
try {
gemfireRepo1.doit(new QueryInvocationTargetException("test"));
fail("should throw a query exception");
}
catch (GemfireQueryException ignore) { }
}
/**
* Wraps GemfireCheckedExceptions in RuntimeException
*/
@Repository
public static class GemFireRepo1 {
public void doit(Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -97,6 +97,7 @@ public class WiringDeclarableSupportIntegrationTests extends IntegrationTestsSup
}
@Getter
@Setter
@NoArgsConstructor
@SuppressWarnings("unused")
public static class TestCacheLoader extends WiringDeclarableSupport implements CacheLoader<String, String> {

View File

@@ -19,7 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import java.io.IOException;
import java.util.Scanner;
import javax.annotation.Resource;
@@ -65,7 +64,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* @since 2.2.0
*/
@RunWith(SpringRunner.class)
@ContextConfiguration
@ContextConfiguration(locations = "AsyncEventQueueByIdXmlConfigurationIntegrationTests-context.xml")
@SuppressWarnings("unused")
public class AsyncEventQueueByIdXmlConfigurationIntegrationTests extends ForkingClientServerIntegrationTestsSupport {
@@ -106,14 +105,13 @@ public class AsyncEventQueueByIdXmlConfigurationIntegrationTests extends Forking
}
@EnableLocator
@PeerCacheApplication
@PeerCacheApplication(name = "AsyncEventQueueByIdXmlConfigurationIntegrationTestsServer")
static class GeodeServerConfiguration {
public static void main(String[] args) {
runSpringApplication(GeodeServerConfiguration.class, args);
new Scanner(System.in).nextLine();
block();
}
@Bean("TestAsyncEventQueueOne")

View File

@@ -48,7 +48,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings("unused")
public class ManualGatewayReceiverStartIntegrationTests extends IntegrationTestsSupport {
public class GatewayReceiverManualStartIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Auto")
private GatewayReceiver autoGatewayReceiver;
@@ -63,7 +63,7 @@ public class ManualGatewayReceiverStartIntegrationTests extends IntegrationTests
}
@Test
public void testAutoGatewayReceiver() {
public void autoGatewayReceiverConfigurationIsCorrect() {
assertThat(autoGatewayReceiver)
.describedAs("The 'Auto' GatewayReceiver was not properly configured or initialized!")
@@ -76,7 +76,7 @@ public class ManualGatewayReceiverStartIntegrationTests extends IntegrationTests
int gatewayReceiverPort = autoGatewayReceiver.getPort();
assertGreaterThanEqualToLessThanEqualTo(String.format(
"GatewayReceiver 'port' (%1$d) was not greater than equal to (%2$d) and less than equal to (%3$d)!",
"GatewayReceiver 'port' [%1$d] was not greater than equal to [%2$d] and less than equal to [%3$d]!",
gatewayReceiverPort, autoGatewayReceiver.getStartPort(), autoGatewayReceiver.getEndPort()),
gatewayReceiverPort, autoGatewayReceiver.getStartPort(), autoGatewayReceiver.getEndPort());
@@ -86,7 +86,7 @@ public class ManualGatewayReceiverStartIntegrationTests extends IntegrationTests
}
@Test
public void testManualGatewayReceiverConfiguration() throws IOException {
public void manualGatewayReceiverConfigurationIsCorrect() throws IOException {
assertThat(manualGatewayReceiver)
.describedAs("The 'Manual' GatewayReceiver was not properly configured or initialized!")
@@ -103,7 +103,7 @@ public class ManualGatewayReceiverStartIntegrationTests extends IntegrationTests
int gatewayReceiverPort = manualGatewayReceiver.getPort();
assertGreaterThanEqualToLessThanEqualTo(String.format(
"GatewayReceiver 'port' (%1$d) was not greater than equal to (%2$d) and less than equal to (%3$d)!",
"GatewayReceiver 'port' [%1$d] was not greater than equal to [%2$d] and less than equal to [%3$d]!",
gatewayReceiverPort, manualGatewayReceiver.getStartPort(), manualGatewayReceiver.getEndPort()),
gatewayReceiverPort, manualGatewayReceiver.getStartPort(), manualGatewayReceiver.getEndPort());

View File

@@ -18,7 +18,6 @@ package org.springframework.data.gemfire.wan;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.util.Scanner;
import javax.annotation.Resource;
@@ -76,7 +75,7 @@ public class GatewaySenderByIdXmlConfigurationIntegrationTests extends ForkingCl
System.setProperty("spring.data.gemfire.locator.port", String.valueOf(port));
geodeServer = run(GeodeServerConfiguration.class, "-Dspring.data.gemfire.locator.port=" + port);
geodeServer = run(GeodeServerApplication.class, "-Dspring.data.gemfire.locator.port=" + port);
waitForServerToStart("localhost", port);
}
@@ -104,14 +103,13 @@ public class GatewaySenderByIdXmlConfigurationIntegrationTests extends ForkingCl
}
@EnableLocator
@PeerCacheApplication
static class GeodeServerConfiguration {
@PeerCacheApplication(name = "GatewaySenderByIdXmlConfigurationIntegrationTestsServer")
static class GeodeServerApplication {
public static void main(String[] args) {
runSpringApplication(GeodeServerConfiguration.class, args);
new Scanner(System.in).nextLine();
runSpringApplication(GeodeServerApplication.class, args);
block();
}
@Bean("TestGatewaySenderOne")

View File

@@ -10,7 +10,7 @@
">
<util:properties id="gemfireProperties">
<prop key="name">springGemFireRegionDataPolicyShortcutsIntegrationTest</prop>
<prop key="name">RegionDataPolicyShortcutsIntegrationTests</prop>
<prop key="log-level">error</prop>
</util:properties>
@@ -26,14 +26,14 @@
<gfe:replicated-region id="ReplicateWithShortcut" shortcut="REPLICATE_PERSISTENT"/>
<gfe:partitioned-region id="ShortcutDefaults" shortcut="PARTITION_REDUNDANT_PERSISTENT_OVERFLOW"
cloning-enabled="false" concurrency-checks-enabled="true" disk-synchronous="false"
ignore-jta="true" initial-capacity="101" load-factor="0.85f" key-constraint="java.lang.Long"
multicast-enabled="false" total-buckets="177" value-constraint="java.lang.String"/>
cloning-enabled="false" concurrency-checks-enabled="true" disk-synchronous="false"
ignore-jta="true" initial-capacity="101" load-factor="0.85f" key-constraint="java.lang.Long"
multicast-enabled="false" total-buckets="177" value-constraint="java.lang.String"/>
<gfe:partitioned-region id="ShortcutOverrides" shortcut="PARTITION_REDUNDANT_OVERFLOW"
cloning-enabled="true" concurrency-checks-enabled="false" copies="3" disk-synchronous="true"
ignore-jta="false" initial-capacity="51" load-factor="0.72f" key-constraint="java.lang.String"
multicast-enabled="false" total-buckets="111" value-constraint="java.lang.Object">
cloning-enabled="true" concurrency-checks-enabled="false" copies="3" disk-synchronous="true"
ignore-jta="false" initial-capacity="51" load-factor="0.72f" key-constraint="java.lang.String"
multicast-enabled="false" total-buckets="111" value-constraint="java.lang.Object">
<gfe:eviction threshold="8192" type="ENTRY_COUNT" action="LOCAL_DESTROY"/>
</gfe:partitioned-region>

View File

@@ -12,10 +12,8 @@
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd
">
<bean class="org.springframework.data.gemfire.tests.mock.beans.factory.config.GemFireMockObjectsBeanPostProcessor"/>
<util:properties id="gemfireProperties">
<prop key="name">AsyncEventQueueNamespaceTest</prop>
<prop key="name">AsyncEventQueueNamespaceIntegrationTests</prop>
<prop key="log-level">error</prop>
</util:properties>

View File

@@ -9,8 +9,6 @@
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd"
default-lazy-init="true">
<bean class="org.springframework.data.gemfire.tests.mock.beans.factory.config.GemFireMockObjectsBeanPostProcessor"/>
<util:properties id="gemfireProperties">
<prop key="disable-tcp">false</prop>
<prop key="log-level">error</prop>

View File

@@ -16,6 +16,7 @@
<context:property-placeholder/>
<util:properties id="gemfireProperties">
<prop key="name">ContinuousQueryListenerContainerNamespaceIntegrationTests</prop>
<prop key="log-level">error</prop>
</util:properties>

View File

@@ -21,7 +21,7 @@
<!-- as there can be only one cache per VM -->
<util:properties id="gemfireProperties">
<prop key="name">IndexNamespaceTest</prop>
<prop key="name">IndexNamespaceIntegrationTests</prop>
<prop key="log-level">error</prop>
</util:properties>

View File

@@ -11,7 +11,7 @@
">
<util:properties id="gemfireProperties">
<prop key="name">InvalidRegionExpirationAttributesNamespaceTest</prop>
<prop key="name">InvalidRegionExpirationAttributesNamespaceIntegrationTests</prop>
<prop key="log-level">error</prop>
</util:properties>

View File

@@ -11,7 +11,7 @@
" default-lazy-init="true">
<util:properties id="gemfireProperties">
<prop key="name">LocalNamespaceConfig</prop>
<prop key="name">LocalRegionNamespaceIntegrationTests</prop>
<prop key="log-level">error</prop>
<prop key="off-heap-memory-size">64m</prop>
</util:properties>

View File

@@ -15,7 +15,7 @@
<prop key="log-level">error</prop>
</util:properties>
<bean class="org.springframework.data.gemfire.config.xml.LuceneNamespaceUnitTests$LuceneNamespaceUnitTestsBeanFactoryPostProcessor"/>
<bean class="org.springframework.data.gemfire.config.xml.LuceneNamespaceUnitTests$LuceneNamespaceUnitTestsBeanPostProcessor"/>
<gfe:cache properties-ref="gemfireProperties"/>

View File

@@ -10,15 +10,14 @@
" default-lazy-init="true">
<util:properties id="gemfireProperties">
<prop key="name">MembershipAttributesNamespaceConfig</prop>
<prop key="name">MembershipAttributesIntegrationTests</prop>
<prop key="log-level">error</prop>
</util:properties>
<gfe:cache properties-ref="gemfireProperties"/>
<gfe:replicated-region id="secure">
<gfe:membership-attributes required-roles="ROLE1,ROLE2" loss-action="limited-access"
resumption-action="reinitialize"/>
<gfe:membership-attributes required-roles="ROLE1,ROLE2" loss-action="limited-access" resumption-action="reinitialize"/>
</gfe:replicated-region>
<gfe:replicated-region id="simple"/>

View File

@@ -34,9 +34,9 @@
NOTE GemFire will switch the Region's DataPolicy when Entry Expiration Action settings
are "LOCAL_[DESTROY|INVALIDATE]" based or the Eviction Action is "LOCAL_[DESTROY|INVALIDATE]".
-->
<gfe:replicated-region id="PreloadedExample" persistent="false">
<gfe:local-region id="PreloadedExample" data-policy="PRELOADED">
<gfe:entry-ttl timeout="120" action="LOCAL_DESTROY"/>
</gfe:replicated-region>
</gfe:local-region>
<gfe:partitioned-region id="PartitionExample" persistent="false">
<gfe:entry-ttl timeout="300" action="${expiration.action}"/>

View File

@@ -11,7 +11,7 @@
">
<util:properties id="gemfireProperties">
<prop key="name">TemplateRegionsNamespaceTest</prop>
<prop key="name">TemplateRegionsNamespaceIntegrationTests</prop>
<prop key="log-level">error</prop>
</util:properties>
@@ -46,10 +46,8 @@
<gfe:cache-writer>
<bean class="org.springframework.data.gemfire.config.xml.TemplateRegionsNamespaceIntegrationTests$TestCacheWriter" p:name="B"/>
</gfe:cache-writer>
<gfe:membership-attributes required-roles="readWriteNode" loss-action="limited-access" resumption-action="none"/>
</gfe:region-template>
<!-- REPLICATE Regions -->
<gfe:replicated-region-template id="ReplicateRegionTemplate" concurrency-checks-enabled="true" concurrency-level="24"
disk-synchronous="false" index-update-type="synchronous" enable-subscription-conflation="true"
@@ -123,7 +121,6 @@
<gfe:cache-writer>
<bean class="org.springframework.data.gemfire.config.xml.TemplateRegionsNamespaceIntegrationTests$TestCacheWriter" p:name="dbWriter"/>
</gfe:cache-writer>
<gfe:membership-attributes required-roles="admin,root,supertool" loss-action="no-access" resumption-action="reinitialize"/>
<gfe:partition-listener>
<bean class="org.springframework.data.gemfire.config.xml.TemplateRegionsNamespaceIntegrationTests$TestPartitionListener" p:name="testListener"/>
</gfe:partition-listener>

View File

@@ -26,8 +26,8 @@
<gfe:transaction-writer ref="txWriter"/>
</gfe:client-cache>
<bean id="txListener1" class="org.springframework.data.gemfire.config.xml.TxEventHandlersIntegrationTests.TestTransactionListener"/>
<bean id="txListener2" class="org.springframework.data.gemfire.config.xml.TxEventHandlersIntegrationTests.TestTransactionListener"/>
<bean id="txWriter" class="org.springframework.data.gemfire.config.xml.TxEventHandlersIntegrationTests.TestTransactionWriter"/>
<bean id="txListener1" class="org.springframework.data.gemfire.config.xml.TransactionEventHandlersIntegrationTests.TestTransactionListener"/>
<bean id="txListener2" class="org.springframework.data.gemfire.config.xml.TransactionEventHandlersIntegrationTests.TestTransactionListener"/>
<bean id="txWriter" class="org.springframework.data.gemfire.config.xml.TransactionEventHandlersIntegrationTests.TestTransactionWriter"/>
</beans>

View File

@@ -1,20 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:gfe="http://www.springframework.org/schema/geode"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/geode https://www.springframework.org/schema/geode/spring-geode.xsd
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd
">
<context:property-placeholder/>
<util:properties id="gemfireProperties">
<prop key="log-level">${gemfire.log-level:error}</prop>
<prop key="name">PoolAlreadyExistsIntegrationTests</prop>
<prop key="log-level">error</prop>
</util:properties>
<gfe:client-cache properties-ref="gemfireProperties" pool-name="TestPool"/>

View File

@@ -10,7 +10,7 @@
">
<context:component-scan base-package="org.springframework.data.gemfire.function.config"
resource-pattern="**/AnnotationDrivenFunctionsTest*.class"/>
resource-pattern="**/AnnotationDrivenFunctionsIntegrationTests*.class"/>
<gfe:annotation-driven/>

View File

@@ -16,7 +16,7 @@
<context:property-placeholder/>
<util:properties id="gemfireProperties">
<prop key="name">ContainerXmlSetupIntegrationTests</prop>
<prop key="name">ContainerXmlConfigurationIntegrationTests</prop>
<prop key="log-level">error</prop>
</util:properties>

Some files were not shown because too many files have changed in this diff Show More