SGF-289 - Enumeration restrictions (xsd:enumeration) should be avoided in the XML schema.
Refactoring SDG enum types. Renamed the EvictionType enum to EvictionPolicyType to reflect that the enum represents an Eviction 'policy' encompassing both Eviction algorith along with the monitored resource triggering Eviction. Renamed the EvictionTypeConverter to EvictionPolicyConverter to more accurately reflect it's intent. Renamed IndexMaintenanceType enum to IndexMaintenancePolicyType to more accurately describe the purpose of the index maintenance setting reflected as a policy. Renamed IndexMaintenanceTypeConverter to IndexMaintenancePolicyConverter to more accurately reflect it's intent.
This commit is contained in:
@@ -918,9 +918,9 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware,
|
||||
ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) getBeanFactory();
|
||||
|
||||
beanFactory.registerCustomEditor(EvictionAction.class, EvictionActionConverter.class);
|
||||
beanFactory.registerCustomEditor(EvictionType.class, EvictionTypeConverter.class);
|
||||
beanFactory.registerCustomEditor(EvictionPolicyType.class, EvictionPolicyConverter.class);
|
||||
beanFactory.registerCustomEditor(ExpirationAction.class, ExpirationActionConverter.class);
|
||||
beanFactory.registerCustomEditor(IndexMaintenanceType.class, IndexMaintenanceTypeConverter.class);
|
||||
beanFactory.registerCustomEditor(IndexMaintenancePolicyType.class, IndexMaintenancePolicyConverter.class);
|
||||
beanFactory.registerCustomEditor(IndexType.class, IndexTypeConverter.class);
|
||||
beanFactory.registerCustomEditor(InterestPolicy.class, InterestPolicyConverter.class);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class EvictionAttributesFactoryBean implements FactoryBean<EvictionAttrib
|
||||
|
||||
private EvictionAttributes evictionAttributes;
|
||||
|
||||
private EvictionType type = EvictionType.ENTRY_COUNT;
|
||||
private EvictionPolicyType type = EvictionPolicyType.ENTRY_COUNT;
|
||||
|
||||
private Integer threshold = null;
|
||||
|
||||
@@ -154,9 +154,9 @@ public class EvictionAttributesFactoryBean implements FactoryBean<EvictionAttrib
|
||||
* to implement on the Region.
|
||||
*
|
||||
* @param type the type of eviction policy/algorithm to implement on the Region.
|
||||
* @see org.springframework.data.gemfire.EvictionType
|
||||
* @see EvictionPolicyType
|
||||
*/
|
||||
public void setType(final EvictionType type) {
|
||||
public void setType(final EvictionPolicyType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -164,9 +164,9 @@ public class EvictionAttributesFactoryBean implements FactoryBean<EvictionAttrib
|
||||
* Gets the eviction policy and algorithm used by the Region.
|
||||
*
|
||||
* @return the eviction policy and algorithm in use by the Region.
|
||||
* @see org.springframework.data.gemfire.EvictionType
|
||||
* @see EvictionPolicyType
|
||||
*/
|
||||
public EvictionType getType() {
|
||||
public EvictionPolicyType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ import org.springframework.data.gemfire.support.AbstractPropertyEditorConverterS
|
||||
* a corresponding EvictionType enumerated value.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.EvictionType
|
||||
* @see EvictionPolicyType
|
||||
* @see org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class EvictionTypeConverter extends AbstractPropertyEditorConverterSupport<EvictionType> {
|
||||
public class EvictionPolicyConverter extends AbstractPropertyEditorConverterSupport<EvictionPolicyType> {
|
||||
|
||||
/**
|
||||
* Converts the given String into a matching EvictionType.
|
||||
@@ -35,12 +35,12 @@ public class EvictionTypeConverter extends AbstractPropertyEditorConverterSuppor
|
||||
* @param source the String value to convert into an EvictionType.
|
||||
* @return the EvictionType matching the given String.
|
||||
* @throws java.lang.IllegalArgumentException if the String value does not represent a valid EvictionType.
|
||||
* @see org.springframework.data.gemfire.EvictionType#valueOfIgnoreCase(String)
|
||||
* @see EvictionPolicyType#valueOfIgnoreCase(String)
|
||||
* @see #assertConverted(String, Object, Class)
|
||||
*/
|
||||
@Override
|
||||
public EvictionType convert(final String source) {
|
||||
return assertConverted(source, EvictionType.valueOfIgnoreCase(source), EvictionType.class);
|
||||
public EvictionPolicyType convert(final String source) {
|
||||
return assertConverted(source, EvictionPolicyType.valueOfIgnoreCase(source), EvictionPolicyType.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,14 +19,16 @@ package org.springframework.data.gemfire;
|
||||
import com.gemstone.gemfire.cache.EvictionAlgorithm;
|
||||
|
||||
/**
|
||||
* The EvictionType enum is an enumeration of all GemFire Eviction policy types.
|
||||
* The EvictionPolicyType enum is an enumeration of all GemFire Eviction policies, where the Eviction 'policy'
|
||||
* is a combination of the Eviction algorithm mixed with the monitored resource (e.g. such as JVM HEAP memory).
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see com.gemstone.gemfire.cache.EvictionAlgorithm
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public enum EvictionType {
|
||||
public enum EvictionPolicyType {
|
||||
ENTRY_COUNT(EvictionAlgorithm.LRU_ENTRY),
|
||||
HEAP_PERCENTAGE(EvictionAlgorithm.LRU_HEAP),
|
||||
MEMORY_SIZE(EvictionAlgorithm.LRU_MEMORY),
|
||||
@@ -35,38 +37,39 @@ public enum EvictionType {
|
||||
private final EvictionAlgorithm evictionAlgorithm;
|
||||
|
||||
/**
|
||||
* Constructs an instance of the EvictionType enum initialized with the matching GemFire EvictionAlgorithm.
|
||||
* Constructs an instance of the EvictionPolicyType enum initialized with the matching GemFire EvictionAlgorithm.
|
||||
*
|
||||
* @param evictionAlgorithm the GemFire EvictionAlgorithm represented by this EvictionType enumerated value.
|
||||
* @param evictionAlgorithm the GemFire EvictionAlgorithm represented by this EvictionPolicyType enumerated value.
|
||||
* @see com.gemstone.gemfire.cache.EvictionAlgorithm
|
||||
*/
|
||||
EvictionType(final EvictionAlgorithm evictionAlgorithm) {
|
||||
EvictionPolicyType(final EvictionAlgorithm evictionAlgorithm) {
|
||||
this.evictionAlgorithm = evictionAlgorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* A null-safe operation to extract the GemFire EvictionAlgorithm from the given EvictionType enumerated value.
|
||||
* A null-safe operation to extract the GemFire EvictionAlgorithm from the given EvictionPolicyType.
|
||||
*
|
||||
* @param evictionType the EvictionType from which to extract the GemFire EvictionAlgorithm.
|
||||
* @return the GemFire EvictionAlgorithm for the corresponding EvictionType or null if evictionType is null.
|
||||
* @see #getEvictionAlgorithm()
|
||||
*/
|
||||
public static EvictionAlgorithm getEvictionAlgorithm(final EvictionType evictionType) {
|
||||
return (evictionType != null ? evictionType.getEvictionAlgorithm() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an EvictionType enumerated value matching the given GemFire EvictionAlgorithm.
|
||||
*
|
||||
* @param evictionAlgorithm the GemFire EvictionAlgorithm used to lookup and match the EvictionType.
|
||||
* @return an EvictionType matching the specified GemFire EvictionAlgorithm or null if no match was found.
|
||||
* @param evictionPolicyType the EvictionPolicyType from which to extract the GemFire EvictionAlgorithm.
|
||||
* @return the GemFire EvictionAlgorithm for the corresponding EvictionPolicyType or null if evictionType is null.
|
||||
* @see com.gemstone.gemfire.cache.EvictionAlgorithm
|
||||
* @see #getEvictionAlgorithm()
|
||||
*/
|
||||
public static EvictionType valueOf(final EvictionAlgorithm evictionAlgorithm) {
|
||||
for (EvictionType evictionType : values()) {
|
||||
if (evictionType.getEvictionAlgorithm().equals(evictionAlgorithm)) {
|
||||
return evictionType;
|
||||
public static EvictionAlgorithm getEvictionAlgorithm(final EvictionPolicyType evictionPolicyType) {
|
||||
return (evictionPolicyType != null ? evictionPolicyType.getEvictionAlgorithm() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an EvictionPolicyType enumerated value matching the given GemFire EvictionAlgorithm.
|
||||
*
|
||||
* @param evictionAlgorithm the GemFire EvictionAlgorithm used to lookup and match the EvictionPolicyType.
|
||||
* @return an EvictionPolicyType matching the specified GemFire EvictionAlgorithm or null if no match was found.
|
||||
* @see com.gemstone.gemfire.cache.EvictionAlgorithm
|
||||
* @see #getEvictionAlgorithm()
|
||||
*/
|
||||
public static EvictionPolicyType valueOf(final EvictionAlgorithm evictionAlgorithm) {
|
||||
for (EvictionPolicyType evictionPolicyType : values()) {
|
||||
if (evictionPolicyType.getEvictionAlgorithm().equals(evictionAlgorithm)) {
|
||||
return evictionPolicyType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,17 +77,17 @@ public enum EvictionType {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an EvictionType enumerated value given the named, case-insensitive eviction policy.
|
||||
* Returns an EvictionPolicyType enumerated value given the case-insensitive, named eviction policy.
|
||||
*
|
||||
* @param name a String indicating the name of the eviction policy used to match EvictionType.
|
||||
* @return an EvictionType matching the given the named, case-insensitive eviction policy.
|
||||
* @param name a String indicating the name of the eviction policy used to match EvictionPolicyType.
|
||||
* @return an EvictionPolicyType matching the given the case-insensitive, named eviction policy.
|
||||
* @see java.lang.String#equalsIgnoreCase(String)
|
||||
* @see #name()
|
||||
*/
|
||||
public static EvictionType valueOfIgnoreCase(final String name) {
|
||||
for (EvictionType evictionType : values()) {
|
||||
if (evictionType.name().equalsIgnoreCase(name)) {
|
||||
return evictionType;
|
||||
public static EvictionPolicyType valueOfIgnoreCase(final String name) {
|
||||
for (EvictionPolicyType evictionPolicyType : values()) {
|
||||
if (evictionPolicyType.name().equalsIgnoreCase(name)) {
|
||||
return evictionPolicyType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The IndexMaintenanceTypeConverter class is a Spring Converter and JavaBeans PropertyEditor capable of converting
|
||||
* a String into a specific SDG IndexMaintenancePolicyType.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.IndexMaintenancePolicyType
|
||||
* @see org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class IndexMaintenancePolicyConverter extends AbstractPropertyEditorConverterSupport<IndexMaintenancePolicyType> {
|
||||
|
||||
/**
|
||||
* Converts the given String value into an appropriate IndexMaintenancePolicyType.
|
||||
*
|
||||
* @param source the String value to convert into a IndexMaintenancePolicyType.
|
||||
* @return an IndexMaintenancePolicyType converted from the given String value.
|
||||
* @throws java.lang.IllegalArgumentException if the String is not a valid IndexMaintenancePolicyType.
|
||||
* @see org.springframework.data.gemfire.IndexMaintenancePolicyType#valueOfIgnoreCase(String)
|
||||
* @see #assertConverted(String, Object, Class)
|
||||
*/
|
||||
@Override
|
||||
public IndexMaintenancePolicyType convert(final String source) {
|
||||
return assertConverted(source, IndexMaintenancePolicyType.valueOfIgnoreCase(source),
|
||||
IndexMaintenancePolicyType.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,24 +29,26 @@ import com.gemstone.gemfire.cache.RegionFactory;
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public enum IndexMaintenanceType {
|
||||
public enum IndexMaintenancePolicyType {
|
||||
SYNCHRONOUS,
|
||||
ASYNCHRONOUS;
|
||||
|
||||
public static final IndexMaintenancePolicyType DEFAULT = IndexMaintenancePolicyType.SYNCHRONOUS;
|
||||
|
||||
/**
|
||||
* Determines the appropriate IndexMaintenanceType given a String value. This method is null-safe
|
||||
* and case-insensitive.
|
||||
* Return an IndexMaintenanceType enumerated value given a case-insensitive, named String value
|
||||
* describing the type of Index maintenance.
|
||||
*
|
||||
* @param value the String value indicating the type of Index maintenance (update).
|
||||
* @return a IndexMaintenanceType enumerated value based on the given String value, or null
|
||||
* if the String representation does not match a IndexMaintenanceType.
|
||||
* @see java.lang.Enum#name()
|
||||
* @param name the String value indicating the type of Index maintenance (update).
|
||||
* @return an IndexMaintenanceType enumerated value given a case-insensitive, named String value describing
|
||||
* the type of Index maintenance, or null if no match was found.
|
||||
* @see java.lang.String#equalsIgnoreCase(String)
|
||||
* @see #name()
|
||||
*/
|
||||
public static IndexMaintenanceType valueOfIgnoreCase(final String value) {
|
||||
for (IndexMaintenanceType indexMaintenanceType : values()) {
|
||||
if (indexMaintenanceType.name().equalsIgnoreCase(value)) {
|
||||
return indexMaintenanceType;
|
||||
public static IndexMaintenancePolicyType valueOfIgnoreCase(final String name) {
|
||||
for (IndexMaintenancePolicyType indexMaintenancePolicyType : values()) {
|
||||
if (indexMaintenancePolicyType.name().equalsIgnoreCase(name)) {
|
||||
return indexMaintenancePolicyType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +57,7 @@ public enum IndexMaintenanceType {
|
||||
|
||||
/**
|
||||
* Sets the GemFire AttributesFactory's 'indexMaintenanceSynchronous' property appropriately based on
|
||||
* this IndexMaintenanceType.
|
||||
* this IndexMaintenancePolicyType.
|
||||
*
|
||||
* @param attributesFactory the AttributesFactory instance on which to set the indexMaintenanceProperty.
|
||||
* @throws java.lang.NullPointerException if the AttributesFactory reference is null.
|
||||
@@ -68,7 +70,7 @@ public enum IndexMaintenanceType {
|
||||
|
||||
/**
|
||||
* Sets the GemFire RegionFactory's 'indexMaintenanceSynchronous' property appropriately based on
|
||||
* this IndexMaintenanceType.
|
||||
* this IndexMaintenancePolicyType.
|
||||
*
|
||||
* @param regionFactory the RegionFactory instance on which to set the indexMaintenanceProperty.
|
||||
* @throws java.lang.NullPointerException if the RegionFactory reference is null.
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* The IndexMaintenanceTypeConverter class...
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.beans.PropertyEditorSupport
|
||||
* @see org.springframework.core.convert.converter.Converter
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class IndexMaintenanceTypeConverter extends PropertyEditorSupport implements Converter<String, IndexMaintenanceType> {
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private IndexMaintenanceType assertConverted(final String source, final IndexMaintenanceType indexMaintenanceType) {
|
||||
if (indexMaintenanceType == null) {
|
||||
throw new IllegalArgumentException(String.format("Source (%1$s) is not a valid IndexMaintenanceType!",
|
||||
source));
|
||||
}
|
||||
|
||||
return indexMaintenanceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IndexMaintenanceType by parsing a given String. May raise a java.lang.IllegalArgumentException
|
||||
* if either the String is badly formatted or the text cannot be expressed as a IndexMaintenanceType.
|
||||
*
|
||||
* @param text the String value to express (convert) as a IndexMaintenanceType.
|
||||
* @throws java.lang.IllegalArgumentException if the String value does not represent a valid IndexMaintenanceType.
|
||||
* @see #convert(String)
|
||||
* @see #setValue(Object)
|
||||
*/
|
||||
@Override
|
||||
public void setAsText(final String text) throws IllegalArgumentException {
|
||||
setValue(convert(text));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given String value into an appropriate IndexMaintenanceType.
|
||||
*
|
||||
* @param source the String value to convert into a IndexMaintenanceType.
|
||||
* @return a IndexMaintenanceType for the given String value.
|
||||
* @throws java.lang.IllegalArgumentException if the String value does not represent a valid IndexMaintenanceType.
|
||||
* @see org.springframework.data.gemfire.IndexMaintenanceType#valueOfIgnoreCase(String)
|
||||
*/
|
||||
@Override
|
||||
public IndexMaintenanceType convert(final String source) {
|
||||
return assertConverted(source, IndexMaintenanceType.valueOfIgnoreCase(source));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class RegionAttributesFactoryBean extends AttributesFactory implements Fa
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setIndexUpdateType(final IndexMaintenanceType indexUpdateType) {
|
||||
public void setIndexUpdateType(final IndexMaintenancePolicyType indexUpdateType) {
|
||||
indexUpdateType.setIndexMaintenance(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1616,6 +1616,13 @@ Entity computing sizes for objects stored into the grid.
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="threshold" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The threshold (or limit) against which the eviction algorithm runs. Once the threshold is reached, eviction is performed.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="type" type="xsd:string" default="ENTRY_COUNT">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
@@ -1626,13 +1633,6 @@ MEMORY_SIZE: Considers the amount of memory consumed by the Region before perfor
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="threshold" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The threshold (or limit) against which the eviction algorithm runs. Once the threshold is reached, eviction is performed.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
<!-- -->
|
||||
<xsd:complexType name="baseDiskStoreType">
|
||||
|
||||
@@ -70,7 +70,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.setAction(null);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(1024);
|
||||
factoryBean.setType(EvictionType.ENTRY_COUNT);
|
||||
factoryBean.setType(EvictionPolicyType.ENTRY_COUNT);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
@@ -87,7 +87,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.setAction(EvictionAction.LOCAL_DESTROY);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(128);
|
||||
factoryBean.setType(EvictionType.ENTRY_COUNT);
|
||||
factoryBean.setType(EvictionPolicyType.ENTRY_COUNT);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
@@ -104,7 +104,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.setAction(EvictionAction.NONE);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(null);
|
||||
factoryBean.setType(EvictionType.ENTRY_COUNT);
|
||||
factoryBean.setType(EvictionPolicyType.ENTRY_COUNT);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
@@ -121,7 +121,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.setAction(EvictionAction.OVERFLOW_TO_DISK);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(null);
|
||||
factoryBean.setType(EvictionType.ENTRY_COUNT);
|
||||
factoryBean.setType(EvictionPolicyType.ENTRY_COUNT);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
@@ -137,7 +137,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
public void testCreateHeapPercentageEvictionAttributesWithNullAction() {
|
||||
factoryBean.setAction(null);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setType(EvictionType.HEAP_PERCENTAGE);
|
||||
factoryBean.setType(EvictionPolicyType.HEAP_PERCENTAGE);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
@@ -153,7 +153,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.setAction(EvictionAction.LOCAL_DESTROY);
|
||||
factoryBean.setObjectSizer(null);
|
||||
factoryBean.setThreshold(null);
|
||||
factoryBean.setType(EvictionType.HEAP_PERCENTAGE);
|
||||
factoryBean.setType(EvictionPolicyType.HEAP_PERCENTAGE);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
@@ -169,7 +169,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.setAction(EvictionAction.NONE);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(null);
|
||||
factoryBean.setType(EvictionType.HEAP_PERCENTAGE);
|
||||
factoryBean.setType(EvictionPolicyType.HEAP_PERCENTAGE);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
@@ -185,7 +185,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.setAction(EvictionAction.OVERFLOW_TO_DISK);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(null);
|
||||
factoryBean.setType(EvictionType.HEAP_PERCENTAGE);
|
||||
factoryBean.setType(EvictionPolicyType.HEAP_PERCENTAGE);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
@@ -201,7 +201,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
EvictionAttributesFactoryBean factoryBean = new EvictionAttributesFactoryBean();
|
||||
|
||||
try {
|
||||
factoryBean.setType(EvictionType.HEAP_PERCENTAGE);
|
||||
factoryBean.setType(EvictionPolicyType.HEAP_PERCENTAGE);
|
||||
factoryBean.setThreshold(85);
|
||||
factoryBean.afterPropertiesSet();
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
assertEquals("HEAP_PERCENTAGE (LRU_HEAP algorithm) does not support threshold (a.k.a. maximum)!",
|
||||
expected.getMessage());
|
||||
assertEquals(85, factoryBean.getThreshold().intValue());
|
||||
assertEquals(EvictionType.HEAP_PERCENTAGE, factoryBean.getType());
|
||||
assertEquals(EvictionPolicyType.HEAP_PERCENTAGE, factoryBean.getType());
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.setAction(null);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(null);
|
||||
factoryBean.setType(EvictionType.MEMORY_SIZE);
|
||||
factoryBean.setType(EvictionPolicyType.MEMORY_SIZE);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
@@ -236,7 +236,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.setAction(EvictionAction.LOCAL_DESTROY);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(1024);
|
||||
factoryBean.setType(EvictionType.MEMORY_SIZE);
|
||||
factoryBean.setType(EvictionPolicyType.MEMORY_SIZE);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
@@ -253,7 +253,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.setAction(EvictionAction.NONE);
|
||||
factoryBean.setObjectSizer(null);
|
||||
factoryBean.setThreshold(256);
|
||||
factoryBean.setType(EvictionType.MEMORY_SIZE);
|
||||
factoryBean.setType(EvictionPolicyType.MEMORY_SIZE);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
@@ -270,7 +270,7 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.setAction(EvictionAction.OVERFLOW_TO_DISK);
|
||||
factoryBean.setObjectSizer(null);
|
||||
factoryBean.setThreshold(null);
|
||||
factoryBean.setType(EvictionType.MEMORY_SIZE);
|
||||
factoryBean.setType(EvictionPolicyType.MEMORY_SIZE);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
@@ -28,12 +28,13 @@ import org.junit.Test;
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.EvictionTypeConverter
|
||||
* @see org.springframework.data.gemfire.EvictionPolicyConverter
|
||||
* @see org.springframework.data.gemfire.EvictionPolicyType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class EvictionTypeConverterTest {
|
||||
public class EvictionPolicyConverterTest {
|
||||
|
||||
private final EvictionTypeConverter converter = new EvictionTypeConverter();
|
||||
private final EvictionPolicyConverter converter = new EvictionPolicyConverter();
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@@ -42,10 +43,10 @@ public class EvictionTypeConverterTest {
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
assertEquals(EvictionType.ENTRY_COUNT, converter.convert("entry_count"));
|
||||
assertEquals(EvictionType.HEAP_PERCENTAGE, converter.convert("Heap_Percentage"));
|
||||
assertEquals(EvictionType.MEMORY_SIZE, converter.convert("MEMorY_SiZe"));
|
||||
assertEquals(EvictionType.NONE, converter.convert("NONE"));
|
||||
assertEquals(EvictionPolicyType.ENTRY_COUNT, converter.convert("entry_count"));
|
||||
assertEquals(EvictionPolicyType.HEAP_PERCENTAGE, converter.convert("Heap_Percentage"));
|
||||
assertEquals(EvictionPolicyType.MEMORY_SIZE, converter.convert("MEMorY_SiZe"));
|
||||
assertEquals(EvictionPolicyType.NONE, converter.convert("NONE"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -54,7 +55,7 @@ public class EvictionTypeConverterTest {
|
||||
converter.convert("LIFO_MEMORY");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("(LIFO_MEMORY) is not a valid EvictionType!", expected.getMessage());
|
||||
assertEquals("(LIFO_MEMORY) is not a valid EvictionPolicyType!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
@@ -63,9 +64,9 @@ public class EvictionTypeConverterTest {
|
||||
public void testSetAsText() {
|
||||
assertNull(converter.getValue());
|
||||
converter.setAsText("heap_percentage");
|
||||
assertEquals(EvictionType.HEAP_PERCENTAGE, converter.getValue());
|
||||
assertEquals(EvictionPolicyType.HEAP_PERCENTAGE, converter.getValue());
|
||||
converter.setAsText("NOne");
|
||||
assertEquals(EvictionType.NONE, converter.getValue());
|
||||
assertEquals(EvictionPolicyType.NONE, converter.getValue());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -75,7 +76,7 @@ public class EvictionTypeConverterTest {
|
||||
converter.setAsText("LRU_COUNT");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("(LRU_COUNT) is not a valid EvictionType!", expected.getMessage());
|
||||
assertEquals("(LRU_COUNT) is not a valid EvictionPolicyType!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.EvictionAlgorithm;
|
||||
|
||||
/**
|
||||
* The EvictionTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the EvictionType enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see EvictionPolicyType
|
||||
* @see com.gemstone.gemfire.cache.EvictionAlgorithm
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class EvictionPolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionAlgorithm() {
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, EvictionPolicyType
|
||||
.getEvictionAlgorithm(EvictionPolicyType.HEAP_PERCENTAGE));
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, EvictionPolicyType
|
||||
.getEvictionAlgorithm(EvictionPolicyType.MEMORY_SIZE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionAlgorithmWithNull() {
|
||||
assertNull(EvictionPolicyType.getEvictionAlgorithm(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEvictionAlgorithm() {
|
||||
assertEquals(EvictionAlgorithm.LRU_ENTRY, EvictionPolicyType.ENTRY_COUNT.getEvictionAlgorithm());
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, EvictionPolicyType.HEAP_PERCENTAGE.getEvictionAlgorithm());
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, EvictionPolicyType.MEMORY_SIZE.getEvictionAlgorithm());
|
||||
assertEquals(EvictionAlgorithm.NONE, EvictionPolicyType.NONE.getEvictionAlgorithm());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfEvictionAlgorithms() {
|
||||
assertEquals(EvictionPolicyType.ENTRY_COUNT, EvictionPolicyType.valueOf(EvictionAlgorithm.LRU_ENTRY));
|
||||
assertEquals(EvictionPolicyType.HEAP_PERCENTAGE, EvictionPolicyType.valueOf(EvictionAlgorithm.LRU_HEAP));
|
||||
assertEquals(EvictionPolicyType.MEMORY_SIZE, EvictionPolicyType.valueOf(EvictionAlgorithm.LRU_MEMORY));
|
||||
assertEquals(EvictionPolicyType.NONE, EvictionPolicyType.valueOf(EvictionAlgorithm.NONE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testValueOfInvalidEvictionAlgorithms() {
|
||||
assertNull(EvictionPolicyType.valueOf(EvictionAlgorithm.LIFO_ENTRY));
|
||||
assertNull(EvictionPolicyType.valueOf(EvictionAlgorithm.LIFO_MEMORY));
|
||||
assertNull(EvictionPolicyType.valueOf((EvictionAlgorithm) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(EvictionPolicyType.ENTRY_COUNT, EvictionPolicyType.valueOfIgnoreCase("entry_count"));
|
||||
assertEquals(EvictionPolicyType.HEAP_PERCENTAGE, EvictionPolicyType.valueOfIgnoreCase("Heap_Percentage"));
|
||||
assertEquals(EvictionPolicyType.MEMORY_SIZE, EvictionPolicyType.valueOfIgnoreCase("MEMorY_SiZe"));
|
||||
assertEquals(EvictionPolicyType.NONE, EvictionPolicyType.valueOfIgnoreCase("NONE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase("number_of_entries"));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase("heap_%"));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase("mem_size"));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase("memory_space"));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase(" "));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase(""));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +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.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.EvictionAlgorithm;
|
||||
|
||||
/**
|
||||
* The EvictionTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the EvictionType enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.EvictionType
|
||||
* @see com.gemstone.gemfire.cache.EvictionAlgorithm
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class EvictionTypeTest {
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionAlgorithm() {
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, EvictionType.getEvictionAlgorithm(EvictionType.HEAP_PERCENTAGE));
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, EvictionType.getEvictionAlgorithm(EvictionType.MEMORY_SIZE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionAlgorithmWithNull() {
|
||||
assertNull(EvictionType.getEvictionAlgorithm(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEvictionAlgorithm() {
|
||||
assertEquals(EvictionAlgorithm.LRU_ENTRY, EvictionType.ENTRY_COUNT.getEvictionAlgorithm());
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, EvictionType.HEAP_PERCENTAGE.getEvictionAlgorithm());
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, EvictionType.MEMORY_SIZE.getEvictionAlgorithm());
|
||||
assertEquals(EvictionAlgorithm.NONE, EvictionType.NONE.getEvictionAlgorithm());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfEvictionAlgorithms() {
|
||||
assertEquals(EvictionType.ENTRY_COUNT, EvictionType.valueOf(EvictionAlgorithm.LRU_ENTRY));
|
||||
assertEquals(EvictionType.HEAP_PERCENTAGE, EvictionType.valueOf(EvictionAlgorithm.LRU_HEAP));
|
||||
assertEquals(EvictionType.MEMORY_SIZE, EvictionType.valueOf(EvictionAlgorithm.LRU_MEMORY));
|
||||
assertEquals(EvictionType.NONE, EvictionType.valueOf(EvictionAlgorithm.NONE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testValueOfInvalidEvictionAlgorithms() {
|
||||
assertNull(EvictionType.valueOf(EvictionAlgorithm.LIFO_ENTRY));
|
||||
assertNull(EvictionType.valueOf(EvictionAlgorithm.LIFO_MEMORY));
|
||||
assertNull(EvictionType.valueOf((EvictionAlgorithm) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(EvictionType.ENTRY_COUNT, EvictionType.valueOfIgnoreCase("entry_count"));
|
||||
assertEquals(EvictionType.HEAP_PERCENTAGE, EvictionType.valueOfIgnoreCase("Heap_Percentage"));
|
||||
assertEquals(EvictionType.MEMORY_SIZE, EvictionType.valueOfIgnoreCase("MEMorY_SiZe"));
|
||||
assertEquals(EvictionType.NONE, EvictionType.valueOfIgnoreCase("NONE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(EvictionType.valueOfIgnoreCase("number_of_entries"));
|
||||
assertNull(EvictionType.valueOfIgnoreCase("heap_%"));
|
||||
assertNull(EvictionType.valueOfIgnoreCase("mem_size"));
|
||||
assertNull(EvictionType.valueOfIgnoreCase("memory_space"));
|
||||
assertNull(EvictionType.valueOfIgnoreCase(" "));
|
||||
assertNull(EvictionType.valueOfIgnoreCase(""));
|
||||
assertNull(EvictionType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,17 +24,17 @@ import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The IndexMaintenanceTypeConverterTest class is a test suite of test case testing the contract and functionality
|
||||
* of the IndexMaintenanceTypeConverter.
|
||||
* of the IndexMaintenancePolicyConverter class.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.IndexMaintenanceTypeConverter
|
||||
* @see org.springframework.data.gemfire.IndexMaintenancePolicyConverter
|
||||
* @see org.springframework.data.gemfire.IndexMaintenancePolicyType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class IndexMaintenanceTypeConverterTest {
|
||||
public class IndexMaintenancePolicyConverterTest {
|
||||
|
||||
private final IndexMaintenanceTypeConverter converter = new IndexMaintenanceTypeConverter();
|
||||
private final IndexMaintenancePolicyConverter converter = new IndexMaintenancePolicyConverter();
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@@ -43,17 +43,17 @@ public class IndexMaintenanceTypeConverterTest {
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
assertEquals(IndexMaintenanceType.SYNCHRONOUS, converter.convert("Synchronous"));
|
||||
assertEquals(IndexMaintenanceType.ASYNCHRONOUS, converter.convert("asynchronous"));
|
||||
assertEquals(IndexMaintenancePolicyType.ASYNCHRONOUS, converter.convert("asynchronous"));
|
||||
assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, converter.convert("Synchronous"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testConvertThrowsIllegalArgumentExceptionForInvalidStringValue() {
|
||||
public void testConvertIllegalValue() {
|
||||
try {
|
||||
converter.convert("sync");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Source (sync) is not a valid IndexMaintenanceType!", expected.getMessage());
|
||||
assertEquals("(sync) is not a valid IndexMaintenancePolicyType!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
@@ -61,9 +61,9 @@ public class IndexMaintenanceTypeConverterTest {
|
||||
@Test
|
||||
public void testSetAsText() {
|
||||
converter.setAsText("aSynchronous");
|
||||
assertEquals(IndexMaintenanceType.ASYNCHRONOUS, converter.getValue());
|
||||
converter.setAsText("synchronous");
|
||||
assertEquals(IndexMaintenanceType.SYNCHRONOUS, converter.getValue());
|
||||
assertEquals(IndexMaintenancePolicyType.ASYNCHRONOUS, converter.getValue());
|
||||
converter.setAsText("synchrONoUS");
|
||||
assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, converter.getValue());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -73,9 +73,12 @@ public class IndexMaintenanceTypeConverterTest {
|
||||
converter.setAsText("async");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Source (async) is not a valid IndexMaintenanceType!", expected.getMessage());
|
||||
assertEquals("(async) is not a valid IndexMaintenancePolicyType!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
assertNull(converter.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,30 +34,35 @@ import com.gemstone.gemfire.cache.RegionFactory;
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.IndexMaintenanceType
|
||||
* @see IndexMaintenancePolicyType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class IndexMaintenanceTypeTest {
|
||||
public class IndexMaintenancePolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(IndexMaintenanceType.SYNCHRONOUS, IndexMaintenanceType.valueOfIgnoreCase("SYNCHRONOUS"));
|
||||
assertEquals(IndexMaintenanceType.SYNCHRONOUS, IndexMaintenanceType.valueOfIgnoreCase("Synchronous"));
|
||||
assertEquals(IndexMaintenanceType.SYNCHRONOUS, IndexMaintenanceType.valueOfIgnoreCase("synchronous"));
|
||||
assertEquals(IndexMaintenanceType.SYNCHRONOUS, IndexMaintenanceType.valueOfIgnoreCase("SynCHrOnOus"));
|
||||
assertEquals(IndexMaintenanceType.ASYNCHRONOUS, IndexMaintenanceType.valueOfIgnoreCase("ASYNChronous"));
|
||||
public void testDefault() {
|
||||
assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseIsNull() {
|
||||
assertNull(IndexMaintenanceType.valueOfIgnoreCase("synchronicity"));
|
||||
assertNull(IndexMaintenanceType.valueOfIgnoreCase("SYNC"));
|
||||
assertNull(IndexMaintenanceType.valueOfIgnoreCase("ASYNC"));
|
||||
assertNull(IndexMaintenanceType.valueOfIgnoreCase("CONCURRENT"));
|
||||
assertNull(IndexMaintenanceType.valueOfIgnoreCase("parallel"));
|
||||
assertNull(IndexMaintenanceType.valueOfIgnoreCase(" "));
|
||||
assertNull(IndexMaintenanceType.valueOfIgnoreCase(""));
|
||||
assertNull(IndexMaintenanceType.valueOfIgnoreCase(null));
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.valueOfIgnoreCase("SYNCHRONOUS"));
|
||||
assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.valueOfIgnoreCase("Synchronous"));
|
||||
assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.valueOfIgnoreCase("synchronous"));
|
||||
assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.valueOfIgnoreCase("SynCHrOnOus"));
|
||||
assertEquals(IndexMaintenancePolicyType.ASYNCHRONOUS, IndexMaintenancePolicyType.valueOfIgnoreCase("ASYNChronous"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase("synchronicity"));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase("SYNC"));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase("ASYNC"));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase("Concurrent"));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase("parallel"));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase(" "));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase(""));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -66,7 +71,7 @@ public class IndexMaintenanceTypeTest {
|
||||
AttributesFactory mockAttributesFactory = mock(AttributesFactory.class,
|
||||
"testAttributesFactorySetIndexMaintenanceAsynchronous");
|
||||
|
||||
IndexMaintenanceType.ASYNCHRONOUS.setIndexMaintenance(mockAttributesFactory);
|
||||
IndexMaintenancePolicyType.ASYNCHRONOUS.setIndexMaintenance(mockAttributesFactory);
|
||||
|
||||
verify(mockAttributesFactory).setIndexMaintenanceSynchronous(eq(false));
|
||||
}
|
||||
@@ -77,7 +82,7 @@ public class IndexMaintenanceTypeTest {
|
||||
AttributesFactory mockAttributesFactory = mock(AttributesFactory.class,
|
||||
"testAttributesFactorySetIndexMaintenanceAsynchronous");
|
||||
|
||||
IndexMaintenanceType.SYNCHRONOUS.setIndexMaintenance(mockAttributesFactory);
|
||||
IndexMaintenancePolicyType.SYNCHRONOUS.setIndexMaintenance(mockAttributesFactory);
|
||||
|
||||
verify(mockAttributesFactory).setIndexMaintenanceSynchronous(eq(true));
|
||||
}
|
||||
@@ -86,7 +91,7 @@ public class IndexMaintenanceTypeTest {
|
||||
public void testRegionFactorySetIndexMaintenanceAsynchronous() {
|
||||
RegionFactory mockRegionFactory = mock(RegionFactory.class, "testRegionFactorySetIndexMaintenanceAsynchronous");
|
||||
|
||||
IndexMaintenanceType.ASYNCHRONOUS.setIndexMaintenance(mockRegionFactory);
|
||||
IndexMaintenancePolicyType.ASYNCHRONOUS.setIndexMaintenance(mockRegionFactory);
|
||||
|
||||
verify(mockRegionFactory).setIndexMaintenanceSynchronous(eq(false));
|
||||
}
|
||||
@@ -95,7 +100,7 @@ public class IndexMaintenanceTypeTest {
|
||||
public void testRegionFactorySetIndexMaintenanceSynchronous() {
|
||||
RegionFactory mockRegionFactory = mock(RegionFactory.class, "testRegionFactorySetIndexMaintenanceSynchronous");
|
||||
|
||||
IndexMaintenanceType.SYNCHRONOUS.setIndexMaintenance(mockRegionFactory);
|
||||
IndexMaintenancePolicyType.SYNCHRONOUS.setIndexMaintenance(mockRegionFactory);
|
||||
|
||||
verify(mockRegionFactory).setIndexMaintenanceSynchronous(eq(true));
|
||||
}
|
||||
Reference in New Issue
Block a user