SGF-289 - Enumeration restrictions (xsd:enumeration) should be avoided in the XML schema.
Removed the XSD enumeration restriction on the 'index-update-type' attribute of the 'baseRegionType' element in the Spring GemFire XML Schema (XSD).
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.After;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The IndexMaintenanceTypeConverterTest class is a test suite of test case testing the contract and functionality
|
||||
* of the IndexMaintenanceTypeConverter.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.IndexMaintenanceTypeConverter
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class IndexMaintenanceTypeConverterTest {
|
||||
|
||||
private final IndexMaintenanceTypeConverter converter = new IndexMaintenanceTypeConverter();
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
converter.setValue(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
assertEquals(IndexMaintenanceType.SYNCHRONOUS, converter.convert("Synchronous"));
|
||||
assertEquals(IndexMaintenanceType.ASYNCHRONOUS, converter.convert("asynchronous"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testConvertThrowsIllegalArgumentExceptionForInvalidStringValue() {
|
||||
try {
|
||||
converter.convert("sync");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Source (sync) is not a valid IndexMaintenanceType!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAsText() {
|
||||
converter.setAsText("aSynchronous");
|
||||
assertEquals(IndexMaintenanceType.ASYNCHRONOUS, converter.getValue());
|
||||
converter.setAsText("synchronous");
|
||||
assertEquals(IndexMaintenanceType.SYNCHRONOUS, converter.getValue());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSetAsTextThrowsIllegalArgumentException() {
|
||||
try {
|
||||
assertNull(converter.getValue());
|
||||
converter.setAsText("async");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Source (async) is not a valid IndexMaintenanceType!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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 static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.AttributesFactory;
|
||||
import com.gemstone.gemfire.cache.RegionFactory;
|
||||
|
||||
/**
|
||||
* The IndexMaintenanceTypeTest class is a test suite of test cases testing the contract and functionality of the
|
||||
* IndexMaintenanceType enum type.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.IndexMaintenanceType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class IndexMaintenanceTypeTest {
|
||||
|
||||
@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"));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testAttributesFactorySetIndexMaintenanceAsynchronous() {
|
||||
AttributesFactory mockAttributesFactory = mock(AttributesFactory.class,
|
||||
"testAttributesFactorySetIndexMaintenanceAsynchronous");
|
||||
|
||||
IndexMaintenanceType.ASYNCHRONOUS.setIndexMaintenance(mockAttributesFactory);
|
||||
|
||||
verify(mockAttributesFactory).setIndexMaintenanceSynchronous(eq(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testAttributesFactorySetIndexMaintenanceSynchronous() {
|
||||
AttributesFactory mockAttributesFactory = mock(AttributesFactory.class,
|
||||
"testAttributesFactorySetIndexMaintenanceAsynchronous");
|
||||
|
||||
IndexMaintenanceType.SYNCHRONOUS.setIndexMaintenance(mockAttributesFactory);
|
||||
|
||||
verify(mockAttributesFactory).setIndexMaintenanceSynchronous(eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionFactorySetIndexMaintenanceAsynchronous() {
|
||||
RegionFactory mockRegionFactory = mock(RegionFactory.class, "testRegionFactorySetIndexMaintenanceAsynchronous");
|
||||
|
||||
IndexMaintenanceType.ASYNCHRONOUS.setIndexMaintenance(mockRegionFactory);
|
||||
|
||||
verify(mockRegionFactory).setIndexMaintenanceSynchronous(eq(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionFactorySetIndexMaintenanceSynchronous() {
|
||||
RegionFactory mockRegionFactory = mock(RegionFactory.class, "testRegionFactorySetIndexMaintenanceSynchronous");
|
||||
|
||||
IndexMaintenanceType.SYNCHRONOUS.setIndexMaintenance(mockRegionFactory);
|
||||
|
||||
verify(mockRegionFactory).setIndexMaintenanceSynchronous(eq(true));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -147,6 +147,21 @@ public class ReplicatedRegionNamespaceTest {
|
||||
assertEquals(String.class, regionAttributes.getValueConstraint());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplicatedWithSynchronousIndexUpdates() {
|
||||
assertTrue(context.containsBean("replicated-with-synchronous-index-updates"));
|
||||
|
||||
Region region = context.getBean("replicated-with-synchronous-index-updates", Region.class);
|
||||
|
||||
assertNotNull(String.format("The '%1$s' Region was not properly configured and initialized!",
|
||||
"replicated-with-synchronous-index-updates"), region);
|
||||
|
||||
RegionAttributes regionAttributes = region.getAttributes();
|
||||
|
||||
assertNotNull(regionAttributes);
|
||||
assertTrue(regionAttributes.getIndexMaintenanceSynchronous());
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testRegionLookup() throws Exception {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?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:p="http://www.springframework.org/schema/p"
|
||||
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
|
||||
" default-lazy-init="true">
|
||||
@@ -31,6 +33,10 @@
|
||||
<gfe:cache-writer ref="c-writer"/>
|
||||
</gfe:replicated-region>
|
||||
|
||||
<bean id="c-listener" class="org.springframework.data.gemfire.SimpleCacheListener"/>
|
||||
<bean id="c-loader" class="org.springframework.data.gemfire.SimpleCacheLoader"/>
|
||||
<bean id="c-writer" class="org.springframework.data.gemfire.SimpleCacheWriter"/>
|
||||
|
||||
<gfe:replicated-region id="replicated-with-attributes"
|
||||
cloning-enabled="false"
|
||||
concurrency-level="10"
|
||||
@@ -47,13 +53,18 @@
|
||||
scope="global"
|
||||
value-constraint="java.lang.String"/>
|
||||
|
||||
<util:properties id="regionConfigurationSettings">
|
||||
<prop key="gemfire.index-update-type">synchronous</prop>
|
||||
</util:properties>
|
||||
|
||||
<context:property-placeholder properties-ref="regionConfigurationSettings"/>
|
||||
|
||||
<gfe:replicated-region id="replicated-with-synchronous-index-updates" index-update-type="${gemfire.index-update-type}"/>
|
||||
|
||||
<gfe:replicated-region id="Compressed" persistent="false">
|
||||
<gfe:compressor ref="testCompressor"/>
|
||||
</gfe:replicated-region>
|
||||
|
||||
<bean id="c-listener" class="org.springframework.data.gemfire.SimpleCacheListener"/>
|
||||
<bean id="c-loader" class="org.springframework.data.gemfire.SimpleCacheLoader"/>
|
||||
<bean id="c-writer" class="org.springframework.data.gemfire.SimpleCacheWriter"/>
|
||||
<bean id="testCompressor" class="org.springframework.data.gemfire.config.ReplicatedRegionNamespaceTest$TestCompressor" p:name="XYZ"/>
|
||||
|
||||
<gfe:lookup-region id="lookup" name="existing"/>
|
||||
|
||||
Reference in New Issue
Block a user