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:
@@ -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