SGF-289 - Enumeration restrictions (xsd:enumeration) should be avoided in the XML schema.
Removed the XSD enumeration restriction on the 'scope' attribute of the 'baseReplicatedRegionType' complexType, Region element definition in the SDG XSD allowing the use of property placeholders to specify a GemFire Cache Region's Scope for different distribution patterns. In addition, completely removed the 'scopeType' simpleType element definition in the SDG XSD.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.Scope;
|
||||
|
||||
/**
|
||||
* The ScopeConverter class is a Spring Converter and JavaBeans PropertyEditor that converts Strings
|
||||
* into GemFire Scope constant values.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport
|
||||
* @see com.gemstone.gemfire.cache.Scope
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class ScopeConverter extends AbstractPropertyEditorConverterSupport<Scope> {
|
||||
|
||||
/**
|
||||
* Converts the given String source into an instance of GemFire Scope.
|
||||
*
|
||||
* @param source the String to convert into a GemFire Scope.
|
||||
* @return a GemFire Scope for the given String.
|
||||
* @throws java.lang.IllegalArgumentException if the String is not a valid GemFire Scope.
|
||||
* @see org.springframework.data.gemfire.ScopeType#getScope(ScopeType)
|
||||
* @see org.springframework.data.gemfire.ScopeType#valueOfIgnoreCase(String)
|
||||
* @see com.gemstone.gemfire.cache.Scope#fromString(String)
|
||||
* @see #assertConverted(String, Object, Class)
|
||||
*/
|
||||
@Override
|
||||
public Scope convert(final String source) {
|
||||
try {
|
||||
return Scope.fromString(source);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
return assertConverted(source, ScopeType.getScope(ScopeType.valueOfIgnoreCase(source)), Scope.class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
124
src/main/java/org/springframework/data/gemfire/ScopeType.java
Normal file
124
src/main/java/org/springframework/data/gemfire/ScopeType.java
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 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.Scope;
|
||||
import com.gemstone.gemfire.management.internal.cli.util.spring.StringUtils;
|
||||
|
||||
/**
|
||||
* The ScopeType enum is an enumeration of GemFire Scopes.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see com.gemstone.gemfire.cache.Scope
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public enum ScopeType {
|
||||
DISTRIBUTED_ACK(Scope.DISTRIBUTED_ACK),
|
||||
DISTRIBUTED_NO_ACK(Scope.DISTRIBUTED_NO_ACK),
|
||||
GLOBAL(Scope.GLOBAL),
|
||||
LOCAL(Scope.LOCAL);
|
||||
|
||||
private final Scope gemfireScope;
|
||||
|
||||
/**
|
||||
* Constructs an instance of the ScopeType initialized with a matching GemFire Scope.
|
||||
*
|
||||
* @param gemfireScope the GemFire Scope paired with this enumerated value.
|
||||
* @see com.gemstone.gemfire.cache.Scope
|
||||
*/
|
||||
ScopeType(final Scope gemfireScope) {
|
||||
this.gemfireScope = gemfireScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Null-safe operation to extract the GemFire Scope from the given ScopeType enum value, or null if the provided
|
||||
* scopeType is null.
|
||||
*
|
||||
* @param scopeType the ScopeType enumerated value from which to extract the GemFire Scope.
|
||||
* @return the paired GemFire Scope from the given ScopeType or null if scopeType is null.
|
||||
* @see com.gemstone.gemfire.cache.Scope
|
||||
* @see #getScope()
|
||||
*/
|
||||
public static Scope getScope(final ScopeType scopeType) {
|
||||
return (scopeType != null ? scopeType.getScope() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ScopeType enumerated value for the given a GemFire Scope.
|
||||
*
|
||||
* @param scope the GemFire Scope used to lookup and match the appropriate ScopeType.
|
||||
* @return a ScopeType for the given GemFire Scope or null if no match was found.
|
||||
* @see com.gemstone.gemfire.cache.Scope
|
||||
* @see #getScope()
|
||||
* @see #values()
|
||||
*/
|
||||
public static ScopeType valueOf(final Scope scope) {
|
||||
for (ScopeType scopeType : values()) {
|
||||
if (scopeType.getScope().equals(scope)) {
|
||||
return scopeType;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ScopeType enumerated value given the case-insensitive name of the GemFire Scope.
|
||||
*
|
||||
* @param name a String name describing the ScopeType enum value.
|
||||
* @return a ScopeType for the given case-insensitive, named GemFire Scope.
|
||||
* @see java.lang.String#equalsIgnoreCase(String)
|
||||
* @see #values()
|
||||
* @see #name()
|
||||
* @see #transform(String)
|
||||
*/
|
||||
public static ScopeType valueOfIgnoreCase(String name) {
|
||||
name = transform(name);
|
||||
|
||||
for (ScopeType scopeType : values()) {
|
||||
if (scopeType.name().equalsIgnoreCase(name)) {
|
||||
return scopeType;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Null-safe operation that transforms a String name having hyphens and whitespace into a String with underscores
|
||||
* and no whitespace.
|
||||
*
|
||||
* @param name the String to transform.
|
||||
* @return a String value with underscores for hyphens and all leading/trailing whitespace trimmed, or null
|
||||
* if the given String name is null.
|
||||
*/
|
||||
private static String transform(final String name) {
|
||||
return (StringUtils.hasText(name) ? name.trim().replaceAll("-", "_") : name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the matching GemFire Scope for this enumerated value.
|
||||
*
|
||||
* @return a GemFire Scope for this enumerated value.
|
||||
* @see com.gemstone.gemfire.cache.Scope
|
||||
*/
|
||||
public Scope getScope() {
|
||||
return gemfireScope;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import org.springframework.data.gemfire.IndexMaintenancePolicyType;
|
||||
import org.springframework.data.gemfire.IndexType;
|
||||
import org.springframework.data.gemfire.IndexTypeConverter;
|
||||
import org.springframework.data.gemfire.InterestPolicyConverter;
|
||||
import org.springframework.data.gemfire.ScopeConverter;
|
||||
import org.springframework.data.gemfire.client.InterestResultPolicyConverter;
|
||||
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy;
|
||||
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicyConverter;
|
||||
@@ -36,6 +37,7 @@ import com.gemstone.gemfire.cache.EvictionAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
import com.gemstone.gemfire.cache.InterestResultPolicy;
|
||||
import com.gemstone.gemfire.cache.Scope;
|
||||
|
||||
/**
|
||||
* The CustomEditorRegistrationBeanFactoryPostProcessor class is a Spring BeanFactoryPostProcessor used to register
|
||||
@@ -58,6 +60,7 @@ public class CustomEditorRegistrationBeanFactoryPostProcessor implements BeanFac
|
||||
beanFactory.registerCustomEditor(IndexType.class, IndexTypeConverter.class);
|
||||
beanFactory.registerCustomEditor(InterestPolicy.class, InterestPolicyConverter.class);
|
||||
beanFactory.registerCustomEditor(InterestResultPolicy.class, InterestResultPolicyConverter.class);
|
||||
beanFactory.registerCustomEditor(Scope.class, ScopeConverter.class);
|
||||
beanFactory.registerCustomEditor(SubscriptionEvictionPolicy.class, SubscriptionEvictionPolicyConverter.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -360,7 +360,7 @@ abstract class ParsingUtils {
|
||||
String scopeAttributeValue = element.getAttribute("scope");
|
||||
|
||||
if (StringUtils.hasText(scopeAttributeValue)) {
|
||||
builder.addPropertyValue("scope", Scope.fromString(scopeAttributeValue.toUpperCase().replace("-", "_")));
|
||||
builder.addPropertyValue("scope", scopeAttributeValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1090,10 +1090,14 @@ as only they allow locking. GemFire default is false.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="scope" type="xsd:string">
|
||||
<xsd:attribute name="scope" type="xsd:string" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Specifies the scope for this region: distributed-ack,distributed-no-ack, global
|
||||
Specifies the Scope for this Region: distributed-ack, distributed-no-ack, global
|
||||
|
||||
Scope determines how updates to Region Entries are distributed to the other Caches in the Distributed System where
|
||||
the Region and Entry are defined. Scope also determines whether to allow remote invocation of some of
|
||||
the Region’s event handlers.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
@@ -2842,21 +2846,6 @@ The id of the function service (optional)
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<!-- -->
|
||||
<xsd:simpleType name="scopeType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Determines how updates to Region Entries are distributed to the other Caches in the Distributed System where
|
||||
the Region and Entry are defined. Scope also determines whether to allow remote invocation of some of
|
||||
the Region’s event handlers
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="distributed-ack" />
|
||||
<xsd:enumeration value="distributed-no-ack" />
|
||||
<xsd:enumeration value="global" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
<!-- -->
|
||||
<xsd:complexType name="gatewayEventFilterType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="com.gemstone.gemfire.cache.wan.GatewayEventFilter"><![CDATA[
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.gemstone.gemfire.cache.Scope;
|
||||
|
||||
/**
|
||||
* The ScopeConverterTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the ScopeConverter class.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.ScopeConverter
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class ScopeConverterTest {
|
||||
|
||||
private final ScopeConverter converter = new ScopeConverter();
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
converter.setValue(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
assertEquals(Scope.DISTRIBUTED_ACK, converter.convert("distributed-ACK"));
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, converter.convert(" Distributed_NO-aCK"));
|
||||
assertEquals(Scope.LOCAL, converter.convert("loCAL "));
|
||||
assertEquals(Scope.GLOBAL, converter.convert(" GLOBal "));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testConvertIllegalValue() {
|
||||
try {
|
||||
converter.convert("illegal-value");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("(illegal-value) is not a valid Scope!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAsText() {
|
||||
assertNull(converter.getValue());
|
||||
converter.setAsText("DisTributeD-nO_Ack");
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, converter.getValue());
|
||||
converter.setAsText("distributed-ack");
|
||||
assertEquals(Scope.DISTRIBUTED_ACK, converter.getValue());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSetAsTextWithIllegalValue() {
|
||||
try {
|
||||
assertNull(converter.getValue());
|
||||
converter.setAsText("d!5tr!but3d-n0_@ck");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("(d!5tr!but3d-n0_@ck) is not a valid Scope!", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
assertNull(converter.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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 static org.junit.Assert.assertSame;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.gemstone.gemfire.cache.Scope;
|
||||
|
||||
/**
|
||||
* The ScopeTypeTest class is a test suite of test cases testing the contract and functionality of the ScopeType enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.ScopeType
|
||||
* @see com.gemstone.gemfire.cache.Scope
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class ScopeTypeTest {
|
||||
|
||||
@Test
|
||||
public void testStaticGetScope() {
|
||||
assertEquals(Scope.GLOBAL, ScopeType.getScope(ScopeType.GLOBAL));
|
||||
assertEquals(Scope.LOCAL, ScopeType.getScope(ScopeType.LOCAL));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetScopeWithNull() {
|
||||
assertNull(ScopeType.getScope(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetScope() {
|
||||
assertEquals(Scope.DISTRIBUTED_ACK, ScopeType.DISTRIBUTED_ACK.getScope());
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, ScopeType.DISTRIBUTED_NO_ACK.getScope());
|
||||
assertEquals(Scope.LOCAL, ScopeType.LOCAL.getScope());
|
||||
assertEquals(Scope.GLOBAL, ScopeType.GLOBAL.getScope());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
try {
|
||||
for (int ordinal = 0; ordinal < Integer.MAX_VALUE; ordinal++) {
|
||||
Scope expectedScope = Scope.fromOrdinal(ordinal);
|
||||
ScopeType scopeType = ScopeType.valueOf(expectedScope);
|
||||
|
||||
assertNotNull(scopeType);
|
||||
assertSame(expectedScope, scopeType.getScope());
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertNull(ScopeType.valueOf((Scope) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(ScopeType.DISTRIBUTED_ACK, ScopeType.valueOfIgnoreCase("distributed_ack"));
|
||||
assertEquals(ScopeType.DISTRIBUTED_NO_ACK, ScopeType.valueOfIgnoreCase("Distributed_No_Ack"));
|
||||
assertEquals(ScopeType.LOCAL, ScopeType.valueOfIgnoreCase("LOCal "));
|
||||
assertEquals(ScopeType.GLOBAL, ScopeType.valueOfIgnoreCase("GLOBAL"));
|
||||
assertEquals(ScopeType.GLOBAL, ScopeType.valueOfIgnoreCase(" global "));
|
||||
assertEquals(ScopeType.DISTRIBUTED_ACK, ScopeType.valueOfIgnoreCase("DisTRIBUTEd-acK"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(ScopeType.valueOfIgnoreCase(" distributed ack "));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("D!str!but3d_N0_@ck"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("DISTRIBUTED_CANT_ACK"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("Dist_ACK"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("NOT-Distributed-ACK"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("LOCALE"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("GLO-BAL"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase(" "));
|
||||
assertNull(ScopeType.valueOfIgnoreCase(""));
|
||||
assertNull(ScopeType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import org.springframework.data.gemfire.IndexMaintenancePolicyType;
|
||||
import org.springframework.data.gemfire.IndexType;
|
||||
import org.springframework.data.gemfire.IndexTypeConverter;
|
||||
import org.springframework.data.gemfire.InterestPolicyConverter;
|
||||
import org.springframework.data.gemfire.ScopeConverter;
|
||||
import org.springframework.data.gemfire.client.InterestResultPolicyConverter;
|
||||
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy;
|
||||
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicyConverter;
|
||||
@@ -40,6 +41,7 @@ import com.gemstone.gemfire.cache.EvictionAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
import com.gemstone.gemfire.cache.InterestResultPolicy;
|
||||
import com.gemstone.gemfire.cache.Scope;
|
||||
|
||||
/**
|
||||
* The CustomEditorRegistrationBeanFactoryPostProcessorTest class...
|
||||
@@ -66,12 +68,12 @@ public class CustomEditorRegistrationBeanFactoryPostProcessorTest {
|
||||
eq(ExpirationActionConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(IndexMaintenancePolicyType.class),
|
||||
eq(IndexMaintenancePolicyConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(IndexType.class),
|
||||
eq(IndexTypeConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(IndexType.class), eq(IndexTypeConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(InterestPolicy.class),
|
||||
eq(InterestPolicyConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(InterestResultPolicy.class),
|
||||
eq(InterestResultPolicyConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(Scope.class), eq(ScopeConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(SubscriptionEvictionPolicy.class),
|
||||
eq(SubscriptionEvictionPolicyConverter.class));
|
||||
}
|
||||
|
||||
@@ -20,15 +20,12 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.Cache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.query.Index;
|
||||
|
||||
@@ -41,6 +38,9 @@ import com.gemstone.gemfire.cache.query.Index;
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.IndexFactoryBean
|
||||
* @see org.springframework.data.gemfire.config.IndexParser
|
||||
* @see org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -48,10 +48,7 @@ import com.gemstone.gemfire.cache.query.Index;
|
||||
@SuppressWarnings({ "deprecation", "unused" })
|
||||
public class IndexNamespaceTest {
|
||||
|
||||
private static final String TEST_REGION_NAME = "TestIndexRegion";
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
private static final String TEST_REGION_NAME = "IndexedRegion";
|
||||
|
||||
@Resource(name = "simple")
|
||||
private Index simple;
|
||||
@@ -59,13 +56,6 @@ public class IndexNamespaceTest {
|
||||
@Resource(name = "complex")
|
||||
private Index complex;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (cache.getRegion(TEST_REGION_NAME) == null) {
|
||||
cache.createRegionFactory().create(TEST_REGION_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicIndex() throws Exception {
|
||||
assertEquals("simple", simple.getName());
|
||||
|
||||
@@ -188,6 +188,7 @@ public class ReplicatedRegionNamespaceTest {
|
||||
assertEquals(Region.SEPARATOR + "Compressed", compressed.getFullPath());
|
||||
assertNotNull(compressed.getAttributes());
|
||||
assertEquals(DataPolicy.REPLICATE, compressed.getAttributes().getDataPolicy());
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, compressed.getAttributes().getScope());
|
||||
assertTrue(compressed.getAttributes().getCompressor() instanceof TestCompressor);
|
||||
assertEquals("XYZ", compressed.getAttributes().getCompressor().toString());
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
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">
|
||||
">
|
||||
|
||||
<util:properties id="indexConfiguration">
|
||||
<prop key="index.complex.type">HASH</prop>
|
||||
@@ -28,9 +28,11 @@
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties"/>
|
||||
|
||||
<gfe:index id="simple" expression="status" from="/TestIndexRegion" type="functional"/>
|
||||
<gfe:replicated-region id="IndexedRegion" persistent="false"/>
|
||||
|
||||
<gfe:index id="complex" name="complex-index" expression="tsi.name" from="/TestIndexRegion tsi"
|
||||
<gfe:index id="simple" expression="status" from="/IndexedRegion" type="functional"/>
|
||||
|
||||
<gfe:index id="complex" name="complex-index" expression="tsi.name" from="/IndexedRegion tsi"
|
||||
imports="import java.util" type="${index.complex.type}"/>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -55,13 +55,14 @@
|
||||
|
||||
<util:properties id="regionConfigurationSettings">
|
||||
<prop key="gemfire.index-update-type">synchronous</prop>
|
||||
<prop key="gemfire.scope">distributed-No_ACK</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:replicated-region id="Compressed" persistent="false" scope="${gemfire.scope}">
|
||||
<gfe:compressor ref="testCompressor"/>
|
||||
</gfe:replicated-region>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user