SGF-289 - Enumeration restrictions (xsd:enumeration) should be avoided in the XML schema.
Removed the 'subscriptionPolicyType' XSD simple-type definition and subsequently, all Subscription policy enumeration restrictions on SDG Region elements in the SDG XML namespace (e.g. gfe:partitioned-region) that declare and define a Subscription policy. Renamed SubscriptionType to InterestPolicyType along with the associated test suite class. Renamed the SubscriptionTypeConverter class to InterestPolicyConverter along with the associated test suite class. Created the RegionSubscriptionAttributesNamespaceTest class to test the configuration of Subscription on GemFire Regions in the SDG XML namespace using various settings and property placeholders.
This commit is contained in:
@@ -50,6 +50,7 @@ import com.gemstone.gemfire.cache.DynamicRegionFactory;
|
||||
import com.gemstone.gemfire.cache.EvictionAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
import com.gemstone.gemfire.cache.TransactionListener;
|
||||
import com.gemstone.gemfire.cache.TransactionWriter;
|
||||
import com.gemstone.gemfire.cache.util.GatewayConflictResolver;
|
||||
@@ -921,7 +922,7 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware,
|
||||
beanFactory.registerCustomEditor(ExpirationAction.class, ExpirationActionConverter.class);
|
||||
beanFactory.registerCustomEditor(IndexMaintenanceType.class, IndexMaintenanceTypeConverter.class);
|
||||
beanFactory.registerCustomEditor(IndexType.class, IndexTypeConverter.class);
|
||||
beanFactory.registerCustomEditor(SubscriptionType.class, SubscriptionTypeConverter.class);
|
||||
beanFactory.registerCustomEditor(InterestPolicy.class, InterestPolicyConverter.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport;
|
||||
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
|
||||
/**
|
||||
* The InterestPolicyConverter class is a Spring Converter implementation and Java PropertyEditor handling
|
||||
* the conversion between Strings and GemFire InterestPolicy values.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class InterestPolicyConverter extends AbstractPropertyEditorConverterSupport<InterestPolicy> {
|
||||
|
||||
/**
|
||||
* Converts the given String into a GemFire InterestPolicy value.
|
||||
*
|
||||
* @param source the String value to convert into a GemFire InterestPolicy value.
|
||||
* @return a GemFire InterestPolicy value for the given String description of the GemFire InterestPolicy
|
||||
* @throws java.lang.IllegalArgumentException if the String is not a valid GemFire InterestPolicy.
|
||||
* @see org.springframework.data.gemfire.InterestPolicyType#getInterestPolicy(InterestPolicyType)
|
||||
* @see org.springframework.data.gemfire.InterestPolicyType#valueOfIgnoreCase(String)
|
||||
* @see #assertConverted(String, Object, Class)
|
||||
*/
|
||||
@Override
|
||||
public InterestPolicy convert(final String source) {
|
||||
return assertConverted(source, InterestPolicyType.getInterestPolicy(
|
||||
InterestPolicyType.valueOfIgnoreCase(source)), InterestPolicy.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
|
||||
/**
|
||||
* The InterestPolicyType enum is an enumeration of all the GemFire Subscription, InterestPolicy values.
|
||||
*
|
||||
* @author Lyndon Adams
|
||||
* @author John Blum
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public enum InterestPolicyType {
|
||||
ALL(InterestPolicy.ALL),
|
||||
CACHE_CONTENT(InterestPolicy.CACHE_CONTENT);
|
||||
|
||||
public static final InterestPolicyType DEFAULT = InterestPolicyType.valueOf(InterestPolicy.DEFAULT);
|
||||
|
||||
private final InterestPolicy interestPolicy;
|
||||
|
||||
/**
|
||||
* Constructs an instance of the SubscriptionType enum initialized with the matching GemFire InterestPolicy.
|
||||
*
|
||||
* @param interestPolicy a GemFire InterestPolicy corresponding to this SubscriptionType.
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
*/
|
||||
InterestPolicyType(final InterestPolicy interestPolicy) {
|
||||
this.interestPolicy = interestPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Null-safe operation to extract the GemFire InterestPolicy from the InterPolicyType enumerated value.
|
||||
*
|
||||
* @param interestPolicyType the InterestPolicyType enum from which to extract GemFire's InterestPolicy
|
||||
* @return a GemFire InterestPolicy for the given InterestPolicyType enumerated value
|
||||
* or null if InterestPolicyType is null.
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
*/
|
||||
public static InterestPolicy getInterestPolicy(final InterestPolicyType interestPolicyType) {
|
||||
return (interestPolicyType != null ? interestPolicyType.getInterestPolicy() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SubscriptionType enumerated value for the given GemFire InterestPolicy.
|
||||
*
|
||||
* @param interestPolicy the GemFire InterestPolicy used to lookup and match a SubscriptionType.
|
||||
* @return a SubscriptionType enumerated value matching the given GemFire InterestPolicy
|
||||
* or null if no matching value was found.
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
* @see #getInterestPolicy()
|
||||
*/
|
||||
public static InterestPolicyType valueOf(final InterestPolicy interestPolicy) {
|
||||
for (InterestPolicyType interestPolicyType : values()) {
|
||||
if (interestPolicyType.getInterestPolicy().equals(interestPolicy)) {
|
||||
return interestPolicyType;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SubscriptionType enumerated value for the case-insensitive, named Subscription (InterestsPolicy).
|
||||
*
|
||||
* @param value a String name used to look and match the SubscriptionType.
|
||||
* @return a SubscriptionType enumerated value for the given case-insensitive named Subscription
|
||||
* or null if no match was found.
|
||||
* @see java.lang.String#equalsIgnoreCase(String)
|
||||
* @see #name()
|
||||
*/
|
||||
public static InterestPolicyType valueOfIgnoreCase(final String value) {
|
||||
for (InterestPolicyType interestPolicyType : values()) {
|
||||
if (interestPolicyType.name().equalsIgnoreCase(value)) {
|
||||
return interestPolicyType;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the GemFire InterestPolicy corresponding to this SubscriptionType enumerated value.
|
||||
*
|
||||
* @return the GemFire InterestPolicy corresponding to this SubscriptionType.
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
*/
|
||||
public InterestPolicy getInterestPolicy() {
|
||||
return interestPolicy;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,24 +22,31 @@ import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
import com.gemstone.gemfire.cache.SubscriptionAttributes;
|
||||
|
||||
/**
|
||||
* Simple utility class used for defining nested factory-method like definitions w/o polluting the container with useless beans.
|
||||
* The SubscriptionAttributesFactoryBean class is a Spring FactoryBean used for defining and constructing
|
||||
* a GemFire SubscriptionAttributes object, which determines the Subscription policy used by Regions to
|
||||
* declared their data interests.
|
||||
*
|
||||
* @author Lyndon Adams
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.FactoryBean
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
* @see com.gemstone.gemfire.cache.SubscriptionAttributes
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public class SubscriptionAttributesFactoryBean implements FactoryBean<SubscriptionAttributes>, InitializingBean {
|
||||
|
||||
private InterestPolicy interestPolicy;
|
||||
|
||||
private SubscriptionAttributes subscriptionAttributes;
|
||||
|
||||
private SubscriptionType type;
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
subscriptionAttributes = new SubscriptionAttributes(getPolicy());
|
||||
subscriptionAttributes = new SubscriptionAttributes(getInterestPolicy());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -69,20 +76,40 @@ public class SubscriptionAttributesFactoryBean implements FactoryBean<Subscripti
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setType(SubscriptionType type) {
|
||||
this.type = type;
|
||||
/**
|
||||
* Sets GemFire's InterestPolicy specified on the SubscriptionAttributes in order to define/declare
|
||||
* the data interests and distribution of changes.
|
||||
*
|
||||
* @param interestPolicy the GemFire InterestsPolicy to set for Subscription.
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
* @see com.gemstone.gemfire.cache.SubscriptionAttributes#SubscriptionAttributes(com.gemstone.gemfire.cache.InterestPolicy)
|
||||
*/
|
||||
public void setInterestPolicy(final InterestPolicy interestPolicy) {
|
||||
this.interestPolicy = interestPolicy;
|
||||
}
|
||||
|
||||
public SubscriptionType getType() {
|
||||
return (type != null ? type : SubscriptionType.DEFAULT);
|
||||
/**
|
||||
* Gets GemFire's InterestPolicy specified on the SubscriptionAttributes which defines data interests
|
||||
* and distribution of changes.
|
||||
*
|
||||
* @return the GemFire InterestsPolicy set for Subscription.
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
* @see com.gemstone.gemfire.cache.SubscriptionAttributes#getInterestPolicy()
|
||||
*/
|
||||
public InterestPolicy getInterestPolicy() {
|
||||
return (interestPolicy != null ? interestPolicy : InterestPolicy.DEFAULT);
|
||||
}
|
||||
|
||||
/* non-Javadoc */
|
||||
@Deprecated
|
||||
public void setPolicy(InterestPolicy policy) {
|
||||
setType(SubscriptionType.valueOf(policy));
|
||||
setInterestPolicy(policy);
|
||||
}
|
||||
|
||||
/* non-Javadoc */
|
||||
@Deprecated
|
||||
public InterestPolicy getPolicy() {
|
||||
return getType().getInterestPolicy();
|
||||
return getInterestPolicy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
|
||||
/**
|
||||
* Simple enumeration for the various GemFire Subscription types.
|
||||
*
|
||||
* @author Lyndon Adams
|
||||
* @author John Blum
|
||||
* @since 1.3.0
|
||||
*/
|
||||
// TODO consider renaming this enum to InterestPolicyType
|
||||
@SuppressWarnings("unused")
|
||||
public enum SubscriptionType {
|
||||
ALL(InterestPolicy.ALL),
|
||||
DEFAULT(InterestPolicy.DEFAULT),
|
||||
CACHE_CONTENT(InterestPolicy.CACHE_CONTENT);
|
||||
|
||||
private final InterestPolicy interestPolicy;
|
||||
|
||||
/**
|
||||
* Constructs an instance of the SubscriptionType enum initialized with the corresponding GemFire
|
||||
* InterestPolicy instance.
|
||||
*
|
||||
* @param interestPolicy a GemFire InterestPolicy corresponding to this SubscriptionType.
|
||||
*/
|
||||
SubscriptionType(final InterestPolicy interestPolicy) {
|
||||
this.interestPolicy = interestPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the value of the given GemFire InterestPolicy as a SubscriptionType enumerated value.
|
||||
*
|
||||
* @param interestPolicy the GemFire InterestPolicy to evaluate.
|
||||
* @return a SubscriptionType enumerated value for the given GemFire InterestPolicy or null
|
||||
* if the GemFire InterestPolicy does not correspond to a SubscriptionType enumerated value.
|
||||
* @see #getInterestPolicy()
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
*/
|
||||
public static SubscriptionType valueOf(final InterestPolicy interestPolicy) {
|
||||
for (SubscriptionType subscriptionType : values()) {
|
||||
if (subscriptionType.getInterestPolicy().equals(interestPolicy)) {
|
||||
return subscriptionType;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the value of the given String as a SubscriptionType enumerated value. The String value's case
|
||||
* is ignored.
|
||||
*
|
||||
* @param value a String value specifying the desired SubscriptionType enumerated value.
|
||||
* @return a SubscriptionType enumerated value for the given String or null if the String value
|
||||
* does not evaluate to a SubscriptionType enumerated value.
|
||||
* @see java.lang.Enum#name()
|
||||
*/
|
||||
public static SubscriptionType valueOfIgnoreCase(final String value) {
|
||||
for (SubscriptionType subscriptionType : values()) {
|
||||
if (subscriptionType.name().equalsIgnoreCase(value)) {
|
||||
return subscriptionType;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the GemFire InterestPolicy corresponding to this SubscriptionType enumerated value.
|
||||
*
|
||||
* @return the GemFire InterestPolicy corresponding to this SubscriptionType enumerated value.
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
*/
|
||||
public InterestPolicy getInterestPolicy() {
|
||||
return interestPolicy;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The SubscriptionTypeConverter class is a Spring Converter implementation and Java PropertyEditor handling
|
||||
* the conversion between Strings and SubscriptionType enumerated values.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.beans.PropertyEditorSupport
|
||||
* @see org.springframework.core.convert.converter.Converter
|
||||
* @see org.springframework.data.gemfire.SubscriptionType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class SubscriptionTypeConverter extends PropertyEditorSupport implements Converter<String, SubscriptionType> {
|
||||
|
||||
/* non-Javadoc */
|
||||
private SubscriptionType assertConverted(final String source, final SubscriptionType subscriptionType) {
|
||||
Assert.notNull(subscriptionType, String.format("Source (%1$s) is not a valid SubscriptionType!", source));
|
||||
return subscriptionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given String into a SubscriptionType enumerated value.
|
||||
*
|
||||
* @param source the String value to convert into a corresponding SubscriptionType enumerated value.
|
||||
* @return a SubscriptionType enumerated value given a String representation.
|
||||
* @throws java.lang.IllegalArgumentException if the String does not represent a valid SubscriptionType.
|
||||
* @see #assertConverted(String, SubscriptionType)
|
||||
* @see org.springframework.data.gemfire.SubscriptionType#valueOfIgnoreCase(String)
|
||||
*/
|
||||
@Override
|
||||
public SubscriptionType convert(final String source) {
|
||||
return assertConverted(source, SubscriptionType.valueOfIgnoreCase(source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SubscriptionType by parsing the given text String. May throw a java.lang.IllegalArgumentException
|
||||
* if either the text is badly formatted or the text cannot be expressed as a SubscriptionType.
|
||||
*
|
||||
* @param text the String value to express as (convert to) a SubscriptionType.
|
||||
* @throws java.lang.IllegalArgumentException if the String value does not represent a valid SubscriptionType.
|
||||
* @see #convert(String)
|
||||
* @see #setValue(Object)
|
||||
*/
|
||||
@Override
|
||||
public void setAsText(final String text) throws IllegalArgumentException {
|
||||
setValue(convert(text));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,8 +28,8 @@ import org.springframework.core.Conventions;
|
||||
import org.springframework.data.gemfire.EvictionAttributesFactoryBean;
|
||||
import org.springframework.data.gemfire.ExpirationAttributesFactoryBean;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.InterestPolicyType;
|
||||
import org.springframework.data.gemfire.SubscriptionAttributesFactoryBean;
|
||||
import org.springframework.data.gemfire.SubscriptionType;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
@@ -230,12 +230,7 @@ abstract class ParsingUtils {
|
||||
BeanDefinitionBuilder subscriptionAttributesBuilder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
SubscriptionAttributesFactoryBean.class);
|
||||
|
||||
// do manual conversion since the enum is not public
|
||||
String type = subscriptionElement.getAttribute("type");
|
||||
|
||||
if (StringUtils.hasText(type)) {
|
||||
subscriptionAttributesBuilder.addPropertyValue("type", SubscriptionType.valueOfIgnoreCase(type));
|
||||
}
|
||||
setPropertyValue(subscriptionElement, subscriptionAttributesBuilder, "type", "interestPolicy");
|
||||
|
||||
regionAttributesBuilder.addPropertyValue("subscriptionAttributes",
|
||||
subscriptionAttributesBuilder.getBeanDefinition());
|
||||
|
||||
@@ -1029,7 +1029,7 @@ Subscription policy for the replicated region.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="type" type="subscriptionPolicyType"/>
|
||||
<xsd:attribute name="type" type="xsd:string" use="optional"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="eviction" minOccurs="0" maxOccurs="1">
|
||||
@@ -1262,7 +1262,7 @@ Subscription policy for the partitioned region.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="type" type="subscriptionPolicyType" />
|
||||
<xsd:attribute name="type" type="xsd:string" use="optional"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="eviction" minOccurs="0" maxOccurs="1">
|
||||
@@ -1635,38 +1635,6 @@ The threshold (or limit) against which the eviction algorithm runs. Once the thr
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
<!-- -->
|
||||
<xsd:simpleType name="subscriptionPolicyType">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="ALL">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
This subscriber is interested in all data. More specifically operations done in this cache and distributed operations done in remote caches.
|
||||
When combined with DataPolicy.EMPTY this region will receive events for every distributed operation but will not store the data.
|
||||
|
||||
When combined with DataPolicy.NORMAL or DataPolicy.PRELOADED this region will accept Region.create(Object, Object) operations done remotely. Without the ALL interest policy, NORMAL and PRELOADED ignore creates that the region does not have an existing entry for.
|
||||
|
||||
When combined with the replication policies this interest has no effect.
|
||||
|
||||
When combined with DataPolicy.PARTITION this interest policy causes cache listeners to be notified of changes regardless of the physical location of the data affected. That is, a listener in a VM using this policy will receive notification of all changes to the partitioned region.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:enumeration>
|
||||
<xsd:enumeration value="CACHE_CONTENT">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
This subscriber is interested in data that is already in its cache. More specifically operations done in this cache and distributed operations done in remote caches.
|
||||
When combined with DataPolicy.EMPTY this region will never receive events for distributed operations since its content is always empty. It will continue to get events for operations done locally.
|
||||
|
||||
When combined with DataPolicy.NORMAL or DataPolicy.PRELOADED this region will accept remote operations done to entries it already has in its cache.
|
||||
|
||||
When combined with the replication policies * this interest has no effect.
|
||||
|
||||
When combined with DataPolicy.PARTITION this interest policy causes cache listeners to be notified in the VM holding the affected data. That is, listeners are only notified if the affected* key-value pair is in the same process as the listener. ]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:enumeration>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
<!-- -->
|
||||
<xsd:complexType name="baseDiskStoreType">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="disk-dir" minOccurs="0" maxOccurs="unbounded">
|
||||
@@ -1969,9 +1937,9 @@ The ClientRegionShortcut for this region. Allows easy initialization of the regi
|
||||
<xsd:enumeration value="CACHING_PROXY_HEAP_LRU"/>
|
||||
<xsd:enumeration value="CACHING_PROXY_OVERFLOW"/>
|
||||
<xsd:enumeration value="LOCAL"/>
|
||||
<xsd:enumeration value="LOCAL_PERSISTENT"/>
|
||||
<xsd:enumeration value="LOCAL_HEAP_LRU"/>
|
||||
<xsd:enumeration value="LOCAL_OVERFLOW"/>
|
||||
<xsd:enumeration value="LOCAL_PERSISTENT"/>
|
||||
<xsd:enumeration value="LOCAL_PERSISTENT_OVERFLOW"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
@@ -64,7 +64,7 @@ public class EvictionActionTypeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithInvalidValue() {
|
||||
public void testValueOfWithNull() {
|
||||
assertNull(EvictionActionType.valueOf((EvictionAction) null));
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class EvictionActionTypeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValue() {
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(EvictionActionType.valueOfIgnoreCase("REMOTE_DESTROY"));
|
||||
assertNull(EvictionActionType.valueOfIgnoreCase("All"));
|
||||
assertNull(EvictionActionType.valueOfIgnoreCase(" none "));
|
||||
|
||||
@@ -57,8 +57,8 @@ public class ExpirationActionTypeTest {
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
assertEquals(ExpirationActionType.INVALIDATE, ExpirationActionType.DEFAULT);
|
||||
assertEquals(ExpirationAction.INVALIDATE, ExpirationActionType.DEFAULT.getExpirationAction());
|
||||
assertEquals(ExpirationActionType.INVALIDATE, ExpirationActionType.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -17,22 +17,26 @@
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
|
||||
/**
|
||||
* The SubscriptionTypeConverterTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the SubscriptionTypeConverter class.
|
||||
* The InterestPolicyConverterTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the InterestPolicyConverter class.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.SubscriptionTypeConverter
|
||||
* @since 1.5.0
|
||||
* @see org.springframework.data.gemfire.InterestPolicyConverter
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class SubscriptionTypeConverterTest {
|
||||
public class InterestPolicyConverterTest {
|
||||
|
||||
private SubscriptionTypeConverter converter = new SubscriptionTypeConverter();
|
||||
private InterestPolicyConverter converter = new InterestPolicyConverter();
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@@ -41,18 +45,19 @@ public class SubscriptionTypeConverterTest {
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
assertEquals(SubscriptionType.ALL, converter.convert("all"));
|
||||
assertEquals(SubscriptionType.CACHE_CONTENT, converter.convert("Cache_Content"));
|
||||
assertEquals(SubscriptionType.DEFAULT, converter.convert("DeFault"));
|
||||
assertEquals(InterestPolicy.ALL, converter.convert("all"));
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, converter.convert("Cache_Content"));
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, converter.convert("CACHE_ConTent"));
|
||||
assertEquals(InterestPolicy.ALL, converter.convert("ALL"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testConvertWithInvalidValue() {
|
||||
public void testConvertIllegalValueValue() {
|
||||
try {
|
||||
converter.convert("invalid");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Source (invalid) is not a valid SubscriptionType!", expected.getMessage());
|
||||
assertEquals("(invalid) is not a valid InterestPolicy!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
@@ -60,20 +65,24 @@ public class SubscriptionTypeConverterTest {
|
||||
@Test
|
||||
public void testSetAsText() {
|
||||
converter.setAsText("aLl");
|
||||
assertEquals(SubscriptionType.ALL, converter.getValue());
|
||||
converter.setAsText("CACHE_content");
|
||||
assertEquals(SubscriptionType.CACHE_CONTENT, converter.getValue());
|
||||
assertEquals(InterestPolicy.ALL, converter.getValue());
|
||||
converter.setAsText("Cache_CoNTeNT");
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, converter.getValue());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSetAsTextWithInvalidValue() {
|
||||
try {
|
||||
assertNull(converter.getValue());
|
||||
converter.setAsText("none");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Source (none) is not a valid SubscriptionType!", expected.getMessage());
|
||||
assertEquals("(none) is not a valid InterestPolicy!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
assertNull(converter.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
|
||||
/**
|
||||
* The InterestPolicyTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the InterestPolicyType enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.InterestPolicyType
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class InterestPolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testStaticGetInterestPolicy() {
|
||||
assertEquals(InterestPolicy.ALL, InterestPolicyType.getInterestPolicy(InterestPolicyType.ALL));
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, InterestPolicyType.getInterestPolicy(InterestPolicyType.CACHE_CONTENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetInterestPolicyWithNull() {
|
||||
assertNull(InterestPolicyType.getInterestPolicy(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInterestPolicy() {
|
||||
assertEquals(InterestPolicy.ALL, InterestPolicyType.ALL.getInterestPolicy());
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, InterestPolicyType.CACHE_CONTENT.getInterestPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
assertEquals(InterestPolicy.DEFAULT, InterestPolicyType.valueOf(InterestPolicy.DEFAULT).getInterestPolicy());
|
||||
assertEquals(InterestPolicyType.CACHE_CONTENT, InterestPolicyType.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfInterestPolicies() {
|
||||
try {
|
||||
for (byte ordinal = 0; ordinal < Byte.MAX_VALUE; ordinal++) {
|
||||
InterestPolicy interestPolicy = InterestPolicy.fromOrdinal(ordinal);
|
||||
InterestPolicyType interestPolicyType = InterestPolicyType.valueOf(interestPolicy);
|
||||
assertNotNull(interestPolicyType);
|
||||
assertEquals(interestPolicy, interestPolicyType.getInterestPolicy());
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfInterestPolicyWithNull() {
|
||||
assertNull(InterestPolicyType.valueOf((InterestPolicy) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(InterestPolicyType.ALL, InterestPolicyType.valueOfIgnoreCase("all"));
|
||||
assertEquals(InterestPolicyType.CACHE_CONTENT, InterestPolicyType.valueOfIgnoreCase("Cache_Content"));
|
||||
assertEquals(InterestPolicyType.ALL, InterestPolicyType.valueOfIgnoreCase("ALL"));
|
||||
assertEquals(InterestPolicyType.CACHE_CONTENT, InterestPolicyType.valueOfIgnoreCase("CACHE_ConTent"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase("@11"));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase("CACHE_KEYS"));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase("invalid"));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase("test"));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase(" "));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase(""));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,48 +42,28 @@ public class SubscriptionAttributesFactoryBeanTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectAndObjectTypeForSubscriptionType() throws Exception {
|
||||
public void testSetAndGetInterestPolicy() {
|
||||
SubscriptionAttributesFactoryBean factoryBean = new SubscriptionAttributesFactoryBean();
|
||||
|
||||
factoryBean.setType(SubscriptionType.CACHE_CONTENT);
|
||||
factoryBean.afterPropertiesSet();
|
||||
assertEquals(InterestPolicy.DEFAULT, factoryBean.getInterestPolicy());
|
||||
|
||||
assertEquals(SubscriptionType.CACHE_CONTENT, factoryBean.getType());
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, factoryBean.getPolicy());
|
||||
factoryBean.setInterestPolicy(InterestPolicy.CACHE_CONTENT);
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = factoryBean.getObject();
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, factoryBean.getInterestPolicy());
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, subscriptionAttributes.getInterestPolicy());
|
||||
assertTrue(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType()));
|
||||
factoryBean.setInterestPolicy(null);
|
||||
|
||||
assertEquals(InterestPolicy.DEFAULT, factoryBean.getInterestPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectAndObjectTypeForDefaultSubscriptionType() throws Exception {
|
||||
public void testGetObjectAndObjectTypeForAllInterestPolicy() throws Exception {
|
||||
SubscriptionAttributesFactoryBean factoryBean = new SubscriptionAttributesFactoryBean();
|
||||
|
||||
factoryBean.setType(null);
|
||||
factoryBean.setInterestPolicy(InterestPolicy.ALL);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
assertEquals(SubscriptionType.DEFAULT, factoryBean.getType());
|
||||
assertEquals(InterestPolicy.DEFAULT, factoryBean.getPolicy());
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.DEFAULT, subscriptionAttributes.getInterestPolicy());
|
||||
assertTrue(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectAndObjectTypeForInterestPolicy() throws Exception {
|
||||
SubscriptionAttributesFactoryBean factoryBean = new SubscriptionAttributesFactoryBean();
|
||||
|
||||
factoryBean.setPolicy(InterestPolicy.ALL);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
assertEquals(SubscriptionType.ALL, factoryBean.getType());
|
||||
assertEquals(InterestPolicy.ALL, factoryBean.getPolicy());
|
||||
assertEquals(InterestPolicy.ALL, factoryBean.getInterestPolicy());
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = factoryBean.getObject();
|
||||
|
||||
@@ -92,15 +72,45 @@ public class SubscriptionAttributesFactoryBeanTest {
|
||||
assertTrue(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectAndObjectTypeForCacheContentInterestPolicy() throws Exception {
|
||||
SubscriptionAttributesFactoryBean factoryBean = new SubscriptionAttributesFactoryBean();
|
||||
|
||||
factoryBean.setInterestPolicy(InterestPolicy.CACHE_CONTENT);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, factoryBean.getInterestPolicy());
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, subscriptionAttributes.getInterestPolicy());
|
||||
assertTrue(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectAndObjectTypeForDefaultInterestPolicy() throws Exception {
|
||||
SubscriptionAttributesFactoryBean factoryBean = new SubscriptionAttributesFactoryBean();
|
||||
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
assertEquals(InterestPolicy.DEFAULT, factoryBean.getInterestPolicy());
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.DEFAULT, subscriptionAttributes.getInterestPolicy());
|
||||
assertTrue(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectAndObjectTypeForNullInterestPolicy() throws Exception {
|
||||
SubscriptionAttributesFactoryBean factoryBean = new SubscriptionAttributesFactoryBean();
|
||||
|
||||
factoryBean.setPolicy(null);
|
||||
factoryBean.setInterestPolicy(null);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
assertEquals(SubscriptionType.DEFAULT, factoryBean.getType());
|
||||
assertEquals(InterestPolicy.DEFAULT, factoryBean.getPolicy());
|
||||
assertEquals(InterestPolicy.DEFAULT, factoryBean.getInterestPolicy());
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = factoryBean.getObject();
|
||||
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
|
||||
/**
|
||||
* The SubscriptionTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the SubscriptionType enumerated type.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.SubscriptionType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class SubscriptionTypeTest {
|
||||
|
||||
@Test
|
||||
public void testValueOfInterestPolicies() {
|
||||
try {
|
||||
for (byte ordinal = 0; ordinal < Byte.MAX_VALUE; ordinal++) {
|
||||
InterestPolicy interestPolicy = InterestPolicy.fromOrdinal(ordinal);
|
||||
SubscriptionType subscriptionType = SubscriptionType.valueOf(interestPolicy);
|
||||
assertNotNull(subscriptionType);
|
||||
assertEquals(interestPolicy, subscriptionType.getInterestPolicy());
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(SubscriptionType.ALL, SubscriptionType.valueOfIgnoreCase("all"));
|
||||
assertEquals(SubscriptionType.CACHE_CONTENT, SubscriptionType.valueOfIgnoreCase("Cache_Content"));
|
||||
assertEquals(SubscriptionType.DEFAULT, SubscriptionType.valueOfIgnoreCase("DeFault"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValue() {
|
||||
assertNull(SubscriptionType.valueOfIgnoreCase(null));
|
||||
assertNull(SubscriptionType.valueOfIgnoreCase(""));
|
||||
assertNull(SubscriptionType.valueOfIgnoreCase(" "));
|
||||
assertNull(SubscriptionType.valueOfIgnoreCase("@11"));
|
||||
assertNull(SubscriptionType.valueOfIgnoreCase("CACHE_KEYS"));
|
||||
assertNull(SubscriptionType.valueOfIgnoreCase("invalid"));
|
||||
assertNull(SubscriptionType.valueOfIgnoreCase("test"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.gemstone.gemfire.cache.DataPolicy;
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
|
||||
/**
|
||||
* The RegionSubscriptionAttributesNamespaceTest class is a test suite of test cases testing the contract
|
||||
* and functionality of declaring and defining Subscription Attributes for a Region in the Spring Data GemFire
|
||||
* XML namespace (XSD) configuration meta-data.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.data.gemfire.SubscriptionAttributesFactoryBean
|
||||
* @see org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(initializers = GemfireTestApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class RegionSubscriptionAttributesNamespaceTest {
|
||||
|
||||
@Resource(name = "NoSubscriptionRegion")
|
||||
private Region<?, ?> noSubscriptionRegion;
|
||||
|
||||
@Resource(name = "AllSubscriptionRegion")
|
||||
private Region<?, ?> allSubscriptionRegion;
|
||||
|
||||
@Resource(name = "CacheContentSubscriptionRegion")
|
||||
private Region<?, ?> cacheContentSubscriptionRegion;
|
||||
|
||||
@Resource(name = "DefaultSubscriptionRegion")
|
||||
private Region<?, ?> defaultSubscriptionRegion;
|
||||
|
||||
protected void assertSubscription(final Region<?, ?> region, final String expectedRegionName,
|
||||
final DataPolicy expectedDataPolicy, final InterestPolicy expectedInterestedPolicy) {
|
||||
assertNotNull(String.format("The '%1$s' Region was not properly configured an initialized!",
|
||||
expectedRegionName), region);
|
||||
assertEquals(expectedRegionName, region.getName());
|
||||
assertNotNull(region.getAttributes());
|
||||
assertEquals(expectedDataPolicy, region.getAttributes().getDataPolicy());
|
||||
assertNotNull(region.getAttributes().getSubscriptionAttributes());
|
||||
assertEquals(expectedInterestedPolicy, region.getAttributes().getSubscriptionAttributes().getInterestPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoSubscriptionRegion() {
|
||||
assertSubscription(noSubscriptionRegion, "NoSubscriptionRegion", DataPolicy.REPLICATE, InterestPolicy.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllSubscriptionRegion() {
|
||||
assertSubscription(allSubscriptionRegion, "AllSubscriptionRegion", DataPolicy.REPLICATE, InterestPolicy.ALL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheContentSubscriptionRegion() {
|
||||
assertSubscription(cacheContentSubscriptionRegion, "CacheContentSubscriptionRegion", DataPolicy.PARTITION,
|
||||
InterestPolicy.CACHE_CONTENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultSubscriptionRegion() {
|
||||
assertSubscription(defaultSubscriptionRegion, "DefaultSubscriptionRegion", DataPolicy.PARTITION,
|
||||
InterestPolicy.DEFAULT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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/gemfire"
|
||||
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 http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
">
|
||||
|
||||
<util:properties id="subscriptionProperties">
|
||||
<prop key="subscription.interest.policy">ALL</prop>
|
||||
</util:properties>
|
||||
|
||||
<context:property-placeholder properties-ref="subscriptionProperties"/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">RegionSubscriptionAttributesNamespaceTest</prop>
|
||||
<prop key="mcast-port">0</prop>
|
||||
<prop key="log-level">config</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties"/>
|
||||
|
||||
<gfe:replicated-region id="NoSubscriptionRegion" persistent="false"/>
|
||||
|
||||
<gfe:replicated-region id="AllSubscriptionRegion" persistent="false">
|
||||
<gfe:subscription type="${subscription.interest.policy}"/>
|
||||
</gfe:replicated-region>
|
||||
|
||||
<gfe:partitioned-region id="CacheContentSubscriptionRegion">
|
||||
<gfe:subscription type="Cache_ConTENt"/>
|
||||
</gfe:partitioned-region>
|
||||
|
||||
<gfe:partitioned-region id="DefaultSubscriptionRegion">
|
||||
<gfe:subscription/>
|
||||
</gfe:partitioned-region>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user