From 4fc92494aecd1bf3faaf7aa8fd9d19731ac2834d Mon Sep 17 00:00:00 2001 From: John Blum Date: Tue, 27 Jan 2015 23:51:57 -0800 Subject: [PATCH] SGF-289 - Enumeration restrictions (xsd:enumeration) should be avoided in the XML schema. Removed the XSD enumeration restriction on the 'result-policy' attribute of the 'interestType' SDG XSD complex-type definition in order to allow users to specify an Interest Policy using concrete values or properly placeholders when registering client Region Interests. --- .../data/gemfire/CacheFactoryBean.java | 4 + .../data/gemfire/InterestPolicyType.java | 1 + .../data/gemfire/client/Interest.java | 45 ++++---- .../client/InterestResultPolicyConverter.java | 51 +++++++++ .../client/InterestResultPolicyType.java | 71 ++++++++++++ .../gemfire/config/spring-gemfire-1.6.xsd | 71 +++++------- .../data/gemfire/EvictionActionTypeTest.java | 7 ++ .../data/gemfire/EvictionPolicyTypeTest.java | 14 ++- .../ExpirationActionConverterTest.java | 6 +- .../gemfire/ExpirationActionTypeTest.java | 12 +- .../IndexMaintenancePolicyConverterTest.java | 2 +- .../IndexMaintenancePolicyTypeTest.java | 3 +- .../data/gemfire/IndexTypeConverterTest.java | 6 +- .../data/gemfire/IndexTypeTest.java | 16 ++- .../gemfire/InterestPolicyConverterTest.java | 6 +- .../data/gemfire/InterestPolicyTypeTest.java | 10 +- .../InterestResultPolicyConverterTest.java | 90 +++++++++++++++ .../client/InterestResultPolicyTypeTest.java | 99 +++++++++++++++++ .../data/gemfire/client/InterestTest.java | 105 ++++++++++++++++++ .../config/ClientRegionNamespaceTest.java | 91 +++++++++++++++ .../gemfire/test/MockCacheFactoryBean.java | 6 +- .../test/MockClientCacheFactoryBean.java | 9 +- .../data/gemfire/config/client-ns.xml | 37 +++++- 23 files changed, 663 insertions(+), 99 deletions(-) create mode 100644 src/main/java/org/springframework/data/gemfire/client/InterestResultPolicyConverter.java create mode 100644 src/main/java/org/springframework/data/gemfire/client/InterestResultPolicyType.java create mode 100644 src/test/java/org/springframework/data/gemfire/client/InterestResultPolicyConverterTest.java create mode 100644 src/test/java/org/springframework/data/gemfire/client/InterestResultPolicyTypeTest.java create mode 100644 src/test/java/org/springframework/data/gemfire/client/InterestTest.java diff --git a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java index bc9c3518..a1eb459f 100644 --- a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java @@ -37,6 +37,7 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.core.io.Resource; import org.springframework.dao.DataAccessException; import org.springframework.dao.support.PersistenceExceptionTranslator; +import org.springframework.data.gemfire.client.InterestResultPolicyConverter; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.CollectionUtils; @@ -51,6 +52,7 @@ import com.gemstone.gemfire.cache.EvictionAction; import com.gemstone.gemfire.cache.ExpirationAction; import com.gemstone.gemfire.cache.GemFireCache; import com.gemstone.gemfire.cache.InterestPolicy; +import com.gemstone.gemfire.cache.InterestResultPolicy; import com.gemstone.gemfire.cache.TransactionListener; import com.gemstone.gemfire.cache.TransactionWriter; import com.gemstone.gemfire.cache.util.GatewayConflictResolver; @@ -82,6 +84,7 @@ import com.gemstone.gemfire.pdx.PdxSerializer; * @see org.springframework.beans.factory.DisposableBean * @see org.springframework.dao.support.PersistenceExceptionTranslator */ +@SuppressWarnings("unused") public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, FactoryBean, InitializingBean, DisposableBean, PersistenceExceptionTranslator { @@ -923,6 +926,7 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, beanFactory.registerCustomEditor(IndexMaintenancePolicyType.class, IndexMaintenancePolicyConverter.class); beanFactory.registerCustomEditor(IndexType.class, IndexTypeConverter.class); beanFactory.registerCustomEditor(InterestPolicy.class, InterestPolicyConverter.class); + beanFactory.registerCustomEditor(InterestResultPolicy.class, InterestResultPolicyConverter.class); } } diff --git a/src/main/java/org/springframework/data/gemfire/InterestPolicyType.java b/src/main/java/org/springframework/data/gemfire/InterestPolicyType.java index a04d56a4..d754e22f 100644 --- a/src/main/java/org/springframework/data/gemfire/InterestPolicyType.java +++ b/src/main/java/org/springframework/data/gemfire/InterestPolicyType.java @@ -22,6 +22,7 @@ import com.gemstone.gemfire.cache.InterestPolicy; * * @author Lyndon Adams * @author John Blum + * @see com.gemstone.gemfire.cache.InterestPolicy * @since 1.3.0 */ @SuppressWarnings("unused") diff --git a/src/main/java/org/springframework/data/gemfire/client/Interest.java b/src/main/java/org/springframework/data/gemfire/client/Interest.java index c0baf983..120c1c92 100644 --- a/src/main/java/org/springframework/data/gemfire/client/Interest.java +++ b/src/main/java/org/springframework/data/gemfire/client/Interest.java @@ -23,20 +23,26 @@ import org.springframework.util.Assert; import com.gemstone.gemfire.cache.InterestResultPolicy; /** - * Basic holder class for registering an interest. Useful for configuring Gemfire caches through XML - * and or JavaBeans means. + * The Interest class holds details for registering a client interest. * * @author Costin Leau + * @author John Blum + * @see org.springframework.beans.factory.InitializingBean + * @see com.gemstone.gemfire.cache.InterestResultPolicy + * @since 1.0.0 */ +@SuppressWarnings("unused") public class Interest implements InitializingBean { private static final Constants constants = new Constants(InterestResultPolicy.class); - private K key; - private InterestResultPolicy policy = InterestResultPolicy.DEFAULT; private boolean durable = false; private boolean receiveValues = true; + private InterestResultPolicy policy = InterestResultPolicy.DEFAULT; + + private K key; + public Interest() { } @@ -44,10 +50,6 @@ public class Interest implements InitializingBean { this(key, InterestResultPolicy.DEFAULT, false); } - public Interest(K key, InterestResultPolicy policy) { - this(key, policy, false); - } - public Interest(K key, String policy) { this(key, policy, false); } @@ -60,6 +62,10 @@ public class Interest implements InitializingBean { this(key, (InterestResultPolicy) constants.asObject(policy), durable, receiveValues); } + public Interest(K key, InterestResultPolicy policy) { + this(key, policy, false); + } + public Interest(K key, InterestResultPolicy policy, boolean durable) { this(key, policy, durable, true); } @@ -69,6 +75,7 @@ public class Interest implements InitializingBean { this.policy = policy; this.durable = durable; this.receiveValues = receiveValues; + afterPropertiesSet(); } @@ -81,7 +88,7 @@ public class Interest implements InitializingBean { * * @return the key */ - protected K getKey() { + public K getKey() { return key; } @@ -99,7 +106,7 @@ public class Interest implements InitializingBean { * * @return the policy */ - protected InterestResultPolicy getPolicy() { + public InterestResultPolicy getPolicy() { return policy; } @@ -114,13 +121,12 @@ public class Interest implements InitializingBean { if (policy instanceof InterestResultPolicy) { this.policy = (InterestResultPolicy) policy; } + else if (policy instanceof String) { + this.policy = (InterestResultPolicy) constants.asObject(String.valueOf(policy)); + } else { - if (policy instanceof String) { - this.policy = (InterestResultPolicy) constants.asObject((String) policy); - } - else { - throw new IllegalArgumentException("Unknown argument type for property 'policy'" + policy); - } + throw new IllegalArgumentException(String.format("Unknown argument type (%1$s) for property 'policy'!", + policy)); } } @@ -129,7 +135,7 @@ public class Interest implements InitializingBean { * * @return the durable */ - protected boolean isDurable() { + public boolean isDurable() { return durable; } @@ -147,7 +153,7 @@ public class Interest implements InitializingBean { * * @return the receiveValues */ - protected boolean isReceiveValues() { + public boolean isReceiveValues() { return receiveValues; } @@ -159,4 +165,5 @@ public class Interest implements InitializingBean { public void setReceiveValues(boolean receiveValues) { this.receiveValues = receiveValues; } -} \ No newline at end of file + +} diff --git a/src/main/java/org/springframework/data/gemfire/client/InterestResultPolicyConverter.java b/src/main/java/org/springframework/data/gemfire/client/InterestResultPolicyConverter.java new file mode 100644 index 00000000..7aead724 --- /dev/null +++ b/src/main/java/org/springframework/data/gemfire/client/InterestResultPolicyConverter.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.data.gemfire.client; + +import org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport; + +import com.gemstone.gemfire.cache.InterestResultPolicy; + +/** + * The InterestResultPolicyConverter class is a Spring Converter and JavaBeans PropertyEditor capable of converting + * a String into a GemFire InterestResultPolicyConverter. + * + * @author John Blum + * @see org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport + * @see com.gemstone.gemfire.cache.InterestResultPolicy + * @since 1.6.0 + */ +public class InterestResultPolicyConverter extends AbstractPropertyEditorConverterSupport { + + /** + * Converts the given String into an instance of GemFire InterestResultPolicy. + * + * @param source the String to convert into an InterestResultPolicy value. + * @return a GemFire InterestResultPolicy value for the given String. + * @throws java.lang.IllegalArgumentException if the String is not a valid GemFire InterestResultPolicy. + * @see org.springframework.data.gemfire.client.InterestResultPolicyType#getInterestResultPolicy(InterestResultPolicyType) + * @see org.springframework.data.gemfire.client.InterestResultPolicyType#valueOfIgnoreCase(String) + * @see #assertConverted(String, Object, Class) + * @see com.gemstone.gemfire.cache.InterestResultPolicy + */ + @Override + public InterestResultPolicy convert(final String source) { + return assertConverted(source, InterestResultPolicyType.getInterestResultPolicy( + InterestResultPolicyType.valueOfIgnoreCase(source)), InterestResultPolicy.class); + } + +} diff --git a/src/main/java/org/springframework/data/gemfire/client/InterestResultPolicyType.java b/src/main/java/org/springframework/data/gemfire/client/InterestResultPolicyType.java new file mode 100644 index 00000000..7708c5df --- /dev/null +++ b/src/main/java/org/springframework/data/gemfire/client/InterestResultPolicyType.java @@ -0,0 +1,71 @@ +/* + * 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.client; + +import com.gemstone.gemfire.cache.InterestResultPolicy; + +/** + * The InterestResultPolicyType enum is an enumeration of all client Register Interests (result) policy values. + * + * @author John Blum + * @see com.gemstone.gemfire.cache.InterestResultPolicy + * @since 1.6.0 + */ +@SuppressWarnings("unused") +public enum InterestResultPolicyType { + KEYS(InterestResultPolicy.KEYS), + KEYS_VALUES(InterestResultPolicy.KEYS_VALUES), + NONE(InterestResultPolicy.NONE); + + public static final InterestResultPolicyType DEFAULT = InterestResultPolicyType.valueOf( + InterestResultPolicy.DEFAULT); + + private final InterestResultPolicy interestResultPolicy; + + InterestResultPolicyType(final InterestResultPolicy interestResultPolicy) { + this.interestResultPolicy = interestResultPolicy; + } + + public static InterestResultPolicy getInterestResultPolicy(final InterestResultPolicyType interestResultPolicyType) { + return (interestResultPolicyType != null ? interestResultPolicyType.getInterestResultPolicy() : null); + } + + public static InterestResultPolicyType valueOf(final InterestResultPolicy interestResultPolicy) { + for (InterestResultPolicyType interestResultPolicyType : values()) { + if (interestResultPolicyType.getInterestResultPolicy().equals(interestResultPolicy)) { + return interestResultPolicyType; + } + } + + return null; + } + + public static InterestResultPolicyType valueOfIgnoreCase(final String name) { + for (InterestResultPolicyType interestResultPolicyType : values()) { + if (interestResultPolicyType.name().equalsIgnoreCase(name)) { + return interestResultPolicyType; + } + } + + return null; + } + + public InterestResultPolicy getInterestResultPolicy() { + return interestResultPolicy; + } + +} diff --git a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.6.xsd b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.6.xsd index 3048a184..f49617ce 100644 --- a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.6.xsd +++ b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.6.xsd @@ -1106,10 +1106,10 @@ The RegionShortcut for this region. Allows easy initialization of the region bas - - - + + + @@ -1373,17 +1373,17 @@ The RegionShortcut for this region. Allows easy initialization of the region bas - - - - - - - - + + + + + + + + @@ -1514,9 +1514,9 @@ The RegionShortcut for this region. Allows easy initialization of the region bas - + @@ -1822,8 +1822,7 @@ to any key in this region in the CacheServer to be pushed to the client. - + - + - + - - - - - - - - - - - - - + + + + + + @@ -2134,8 +2122,7 @@ The client subscription configuration that is used to control a clients use of s ]]> - + diff --git a/src/test/java/org/springframework/data/gemfire/EvictionActionTypeTest.java b/src/test/java/org/springframework/data/gemfire/EvictionActionTypeTest.java index dac3c92f..7cdc0507 100644 --- a/src/test/java/org/springframework/data/gemfire/EvictionActionTypeTest.java +++ b/src/test/java/org/springframework/data/gemfire/EvictionActionTypeTest.java @@ -18,6 +18,7 @@ package org.springframework.data.gemfire; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import org.junit.Test; @@ -56,6 +57,12 @@ public class EvictionActionTypeTest { assertEquals(EvictionAction.DEFAULT_EVICTION_ACTION, EvictionActionType.DEFAULT.getEvictionAction()); } + @Test + public void testDefault() { + assertEquals(EvictionAction.DEFAULT_EVICTION_ACTION, EvictionActionType.DEFAULT.getEvictionAction()); + assertSame(EvictionActionType.LOCAL_DESTROY, EvictionActionType.DEFAULT); + } + @Test public void testValueOf() { assertEquals(EvictionActionType.LOCAL_DESTROY, EvictionActionType.valueOf(EvictionAction.LOCAL_DESTROY)); diff --git a/src/test/java/org/springframework/data/gemfire/EvictionPolicyTypeTest.java b/src/test/java/org/springframework/data/gemfire/EvictionPolicyTypeTest.java index c61d1cff..010cc388 100644 --- a/src/test/java/org/springframework/data/gemfire/EvictionPolicyTypeTest.java +++ b/src/test/java/org/springframework/data/gemfire/EvictionPolicyTypeTest.java @@ -37,10 +37,10 @@ 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)); + assertEquals(EvictionAlgorithm.LRU_HEAP, EvictionPolicyType.getEvictionAlgorithm( + EvictionPolicyType.HEAP_PERCENTAGE)); + assertEquals(EvictionAlgorithm.LRU_MEMORY, EvictionPolicyType.getEvictionAlgorithm( + EvictionPolicyType.MEMORY_SIZE)); } @Test @@ -57,7 +57,7 @@ public class EvictionPolicyTypeTest { } @Test - public void testValueOfEvictionAlgorithms() { + public void testValueOf() { 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)); @@ -69,6 +69,10 @@ public class EvictionPolicyTypeTest { public void testValueOfInvalidEvictionAlgorithms() { assertNull(EvictionPolicyType.valueOf(EvictionAlgorithm.LIFO_ENTRY)); assertNull(EvictionPolicyType.valueOf(EvictionAlgorithm.LIFO_MEMORY)); + } + + @Test + public void testValueOfWithNull() { assertNull(EvictionPolicyType.valueOf((EvictionAlgorithm) null)); } diff --git a/src/test/java/org/springframework/data/gemfire/ExpirationActionConverterTest.java b/src/test/java/org/springframework/data/gemfire/ExpirationActionConverterTest.java index 2e014bd2..abac06c8 100644 --- a/src/test/java/org/springframework/data/gemfire/ExpirationActionConverterTest.java +++ b/src/test/java/org/springframework/data/gemfire/ExpirationActionConverterTest.java @@ -53,10 +53,10 @@ public class ExpirationActionConverterTest { @Test(expected = IllegalArgumentException.class) public void testConvertIllegalValue() { try { - converter.convert("invalid_value"); + converter.convert("illegal_value"); } catch (IllegalArgumentException expected) { - assertEquals("(invalid_value) is not a valid ExpirationAction!", expected.getMessage()); + assertEquals("(illegal_value) is not a valid ExpirationAction!", expected.getMessage()); throw expected; } } @@ -70,7 +70,7 @@ public class ExpirationActionConverterTest { } @Test(expected = IllegalArgumentException.class) - public void testSetAsTextThrowsIllegalArgumentException() { + public void testSetAsTextWithIllegalValue() { try { assertNull(converter.getValue()); converter.setAsText("destruction"); diff --git a/src/test/java/org/springframework/data/gemfire/ExpirationActionTypeTest.java b/src/test/java/org/springframework/data/gemfire/ExpirationActionTypeTest.java index 55d65a6d..7c546aad 100644 --- a/src/test/java/org/springframework/data/gemfire/ExpirationActionTypeTest.java +++ b/src/test/java/org/springframework/data/gemfire/ExpirationActionTypeTest.java @@ -17,7 +17,9 @@ 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; @@ -58,7 +60,7 @@ public class ExpirationActionTypeTest { @Test public void testDefault() { assertEquals(ExpirationAction.INVALIDATE, ExpirationActionType.DEFAULT.getExpirationAction()); - assertEquals(ExpirationActionType.INVALIDATE, ExpirationActionType.DEFAULT); + assertSame(ExpirationActionType.INVALIDATE, ExpirationActionType.DEFAULT); } @Test @@ -67,7 +69,6 @@ public class ExpirationActionTypeTest { assertEquals(ExpirationActionType.INVALIDATE, ExpirationActionType.valueOf(ExpirationAction.INVALIDATE)); assertEquals(ExpirationActionType.LOCAL_DESTROY, ExpirationActionType.valueOf(ExpirationAction.LOCAL_DESTROY)); assertEquals(ExpirationActionType.LOCAL_INVALIDATE, ExpirationActionType.valueOf(ExpirationAction.LOCAL_INVALIDATE)); - } @Test @@ -75,7 +76,10 @@ public class ExpirationActionTypeTest { try { for (int ordinal = 0; ordinal < Integer.MAX_VALUE; ordinal++) { ExpirationAction expirationAction = ExpirationAction.fromOrdinal(ordinal); - assertEquals(expirationAction, ExpirationActionType.valueOf(expirationAction).getExpirationAction()); + ExpirationActionType expirationActionType = ExpirationActionType.valueOf(expirationAction); + + assertNotNull(expirationActionType); + assertEquals(expirationAction, expirationActionType.getExpirationAction()); } } catch (ArrayIndexOutOfBoundsException ignore) { @@ -92,7 +96,7 @@ public class ExpirationActionTypeTest { assertEquals(ExpirationActionType.DESTROY, ExpirationActionType.valueOfIgnoreCase("destroy")); assertEquals(ExpirationActionType.INVALIDATE, ExpirationActionType.valueOfIgnoreCase("Invalidate")); assertEquals(ExpirationActionType.LOCAL_DESTROY, ExpirationActionType.valueOfIgnoreCase("LOCAL_DESTROY")); - assertEquals(ExpirationActionType.LOCAL_INVALIDATE, ExpirationActionType.valueOfIgnoreCase("Local_Invalidate")); + assertEquals(ExpirationActionType.LOCAL_INVALIDATE, ExpirationActionType.valueOfIgnoreCase("LocaL_InValidAte")); } @Test diff --git a/src/test/java/org/springframework/data/gemfire/IndexMaintenancePolicyConverterTest.java b/src/test/java/org/springframework/data/gemfire/IndexMaintenancePolicyConverterTest.java index 7a5e4d3e..2503ecd8 100644 --- a/src/test/java/org/springframework/data/gemfire/IndexMaintenancePolicyConverterTest.java +++ b/src/test/java/org/springframework/data/gemfire/IndexMaintenancePolicyConverterTest.java @@ -67,7 +67,7 @@ public class IndexMaintenancePolicyConverterTest { } @Test(expected = IllegalArgumentException.class) - public void testSetAsTextThrowsIllegalArgumentException() { + public void testSetAsTextWithIllegalValue() { try { assertNull(converter.getValue()); converter.setAsText("async"); diff --git a/src/test/java/org/springframework/data/gemfire/IndexMaintenancePolicyTypeTest.java b/src/test/java/org/springframework/data/gemfire/IndexMaintenancePolicyTypeTest.java index 2a7d6741..38bc2e92 100644 --- a/src/test/java/org/springframework/data/gemfire/IndexMaintenancePolicyTypeTest.java +++ b/src/test/java/org/springframework/data/gemfire/IndexMaintenancePolicyTypeTest.java @@ -18,6 +18,7 @@ package org.springframework.data.gemfire; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -41,7 +42,7 @@ public class IndexMaintenancePolicyTypeTest { @Test public void testDefault() { - assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.DEFAULT); + assertSame(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.DEFAULT); } @Test diff --git a/src/test/java/org/springframework/data/gemfire/IndexTypeConverterTest.java b/src/test/java/org/springframework/data/gemfire/IndexTypeConverterTest.java index d4366e07..3e6127ca 100644 --- a/src/test/java/org/springframework/data/gemfire/IndexTypeConverterTest.java +++ b/src/test/java/org/springframework/data/gemfire/IndexTypeConverterTest.java @@ -50,7 +50,7 @@ public class IndexTypeConverterTest { } @Test(expected = IllegalArgumentException.class) - public void testConvertWithInvalidValue() { + public void testConvertWithIllegalValue() { try { converter.convert("function"); } @@ -72,12 +72,16 @@ public class IndexTypeConverterTest { @Test(expected = IllegalArgumentException.class) public void testSetAsTextWithIllegalValue() { try { + assertNull(converter.getValue()); converter.setAsText("invalid"); } catch (IllegalArgumentException expected) { assertEquals("Failed to convert String (invalid) into an IndexType!", expected.getMessage()); throw expected; } + finally { + assertNull(converter.getValue()); + } } } diff --git a/src/test/java/org/springframework/data/gemfire/IndexTypeTest.java b/src/test/java/org/springframework/data/gemfire/IndexTypeTest.java index c61c1287..cf6949d9 100644 --- a/src/test/java/org/springframework/data/gemfire/IndexTypeTest.java +++ b/src/test/java/org/springframework/data/gemfire/IndexTypeTest.java @@ -36,7 +36,7 @@ import org.junit.Test; public class IndexTypeTest { @Test - public void testGetGemFireIndexType() { + public void testGetGemfireIndexType() { assertEquals(com.gemstone.gemfire.cache.query.IndexType.FUNCTIONAL, IndexType.FUNCTIONAL.getGemfireIndexType()); assertEquals(com.gemstone.gemfire.cache.query.IndexType.HASH, IndexType.HASH.getGemfireIndexType()); assertEquals(com.gemstone.gemfire.cache.query.IndexType.PRIMARY_KEY, IndexType.KEY.getGemfireIndexType()); @@ -44,13 +44,17 @@ public class IndexTypeTest { } @Test - public void testValueOfGemFireIndexType() { - assertNull(IndexType.valueOf((com.gemstone.gemfire.cache.query.IndexType) null)); + public void testValueOf() { assertEquals(IndexType.FUNCTIONAL, IndexType.valueOf(com.gemstone.gemfire.cache.query.IndexType.FUNCTIONAL)); assertEquals(IndexType.HASH, IndexType.valueOf(com.gemstone.gemfire.cache.query.IndexType.HASH)); assertEquals(IndexType.PRIMARY_KEY, IndexType.valueOf(com.gemstone.gemfire.cache.query.IndexType.PRIMARY_KEY)); } + @Test + public void testValueOfWithNull() { + assertNull(IndexType.valueOf((com.gemstone.gemfire.cache.query.IndexType) null)); + } + @Test public void testValueOfIgnoreCase() { assertEquals(IndexType.FUNCTIONAL, IndexType.valueOfIgnoreCase("functional")); @@ -61,12 +65,12 @@ public class IndexTypeTest { @Test public void testValueOfIgnoreCaseWithInvalidValues() { - assertNull(IndexType.valueOfIgnoreCase(null)); - assertNull(IndexType.valueOfIgnoreCase("")); - assertNull(IndexType.valueOfIgnoreCase(" ")); assertNull(IndexType.valueOfIgnoreCase("Prime_Index")); assertNull(IndexType.valueOfIgnoreCase("SECONDARY_INDEX")); assertNull(IndexType.valueOfIgnoreCase("unique_index")); + assertNull(IndexType.valueOfIgnoreCase(null)); + assertNull(IndexType.valueOfIgnoreCase(" ")); + assertNull(IndexType.valueOfIgnoreCase("")); } @Test diff --git a/src/test/java/org/springframework/data/gemfire/InterestPolicyConverterTest.java b/src/test/java/org/springframework/data/gemfire/InterestPolicyConverterTest.java index 245988d1..3b84ce30 100644 --- a/src/test/java/org/springframework/data/gemfire/InterestPolicyConverterTest.java +++ b/src/test/java/org/springframework/data/gemfire/InterestPolicyConverterTest.java @@ -52,12 +52,12 @@ public class InterestPolicyConverterTest { } @Test(expected = IllegalArgumentException.class) - public void testConvertIllegalValueValue() { + public void testConvertIllegalValue() { try { - converter.convert("invalid"); + converter.convert("invalid_value"); } catch (IllegalArgumentException expected) { - assertEquals("(invalid) is not a valid InterestPolicy!", expected.getMessage()); + assertEquals("(invalid_value) is not a valid InterestPolicy!", expected.getMessage()); throw expected; } } diff --git a/src/test/java/org/springframework/data/gemfire/InterestPolicyTypeTest.java b/src/test/java/org/springframework/data/gemfire/InterestPolicyTypeTest.java index be76b563..524a7cf7 100644 --- a/src/test/java/org/springframework/data/gemfire/InterestPolicyTypeTest.java +++ b/src/test/java/org/springframework/data/gemfire/InterestPolicyTypeTest.java @@ -19,6 +19,7 @@ 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; @@ -55,16 +56,17 @@ public class InterestPolicyTypeTest { @Test public void testDefault() { - assertEquals(InterestPolicy.DEFAULT, InterestPolicyType.valueOf(InterestPolicy.DEFAULT).getInterestPolicy()); - assertEquals(InterestPolicyType.CACHE_CONTENT, InterestPolicyType.DEFAULT); + assertEquals(InterestPolicy.DEFAULT, InterestPolicyType.DEFAULT.getInterestPolicy()); + assertSame(InterestPolicyType.CACHE_CONTENT, InterestPolicyType.DEFAULT); } @Test - public void testValueOfInterestPolicies() { + public void testValueOf() { try { for (byte ordinal = 0; ordinal < Byte.MAX_VALUE; ordinal++) { InterestPolicy interestPolicy = InterestPolicy.fromOrdinal(ordinal); InterestPolicyType interestPolicyType = InterestPolicyType.valueOf(interestPolicy); + assertNotNull(interestPolicyType); assertEquals(interestPolicy, interestPolicyType.getInterestPolicy()); } @@ -74,7 +76,7 @@ public class InterestPolicyTypeTest { } @Test - public void testValueOfInterestPolicyWithNull() { + public void testValueOfWithNull() { assertNull(InterestPolicyType.valueOf((InterestPolicy) null)); } diff --git a/src/test/java/org/springframework/data/gemfire/client/InterestResultPolicyConverterTest.java b/src/test/java/org/springframework/data/gemfire/client/InterestResultPolicyConverterTest.java new file mode 100644 index 00000000..759bbd31 --- /dev/null +++ b/src/test/java/org/springframework/data/gemfire/client/InterestResultPolicyConverterTest.java @@ -0,0 +1,90 @@ +/* + * 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.client; + +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.InterestResultPolicy; + +/** + * The InterestResultPolicyConverterTest class is a test suite of test cases testing the contract and functionality + * of the InterestResultPolicyConverter class. + * + * @author John Blum + * @see org.junit.Test + * @see org.springframework.data.gemfire.client.InterestResultPolicyConverter + * @see org.springframework.data.gemfire.client.InterestResultPolicyType + * @see com.gemstone.gemfire.cache.InterestResultPolicy + * @since 1.6.0 + */ +public class InterestResultPolicyConverterTest { + + private final InterestResultPolicyConverter converter = new InterestResultPolicyConverter(); + + @After + public void tearDown() { + converter.setValue(null); + } + + @Test + public void testConvert() { + assertEquals(InterestResultPolicy.NONE, converter.convert("NONE")); + assertEquals(InterestResultPolicy.KEYS, converter.convert("Keys")); + assertEquals(InterestResultPolicy.KEYS_VALUES, converter.convert("kEyS_ValUes")); + assertEquals(InterestResultPolicy.NONE, converter.convert("nONe")); + } + + @Test(expected = IllegalArgumentException.class) + public void testConvertIllegalValue() { + try { + converter.convert("illegal_value"); + } + catch (IllegalArgumentException expected) { + assertEquals("(illegal_value) is not a valid InterestResultPolicy!", expected.getMessage()); + throw expected; + } + } + + @Test + public void testSetAsText() { + assertNull(converter.getValue()); + converter.setAsText("NOne"); + assertEquals(InterestResultPolicy.NONE, converter.getValue()); + converter.setAsText("KeYs"); + assertEquals(InterestResultPolicy.KEYS, converter.getValue()); + } + + @Test(expected = IllegalArgumentException.class) + public void testSetAsTextWithIllegalValue() { + try { + assertNull(converter.getValue()); + converter.setAsText("illegal_value"); + } + catch (IllegalArgumentException expected) { + assertEquals("(illegal_value) is not a valid InterestResultPolicy!", expected.getMessage()); + throw expected; + } + finally { + assertNull(converter.getValue()); + } + } + +} diff --git a/src/test/java/org/springframework/data/gemfire/client/InterestResultPolicyTypeTest.java b/src/test/java/org/springframework/data/gemfire/client/InterestResultPolicyTypeTest.java new file mode 100644 index 00000000..27cc0c26 --- /dev/null +++ b/src/test/java/org/springframework/data/gemfire/client/InterestResultPolicyTypeTest.java @@ -0,0 +1,99 @@ +/* + * 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.client; + +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.InterestResultPolicy; + +/** + * The InterestResultPolicyTypeTest class is a test suite of test cases testing the contract and functionality + * of the InterestResultPolicyType enum. + * + * @author John Blum + * @see org.junit.Test + * @see org.springframework.data.gemfire.client.InterestResultPolicyTypeTest + * @see com.gemstone.gemfire.cache.InterestResultPolicy + * @since 1.6.0 + */ +public class InterestResultPolicyTypeTest { + + @Test + public void testStaticGetInterestResultPolicy() { + assertEquals(InterestResultPolicy.KEYS, InterestResultPolicyType.getInterestResultPolicy( + InterestResultPolicyType.KEYS)); + assertEquals(InterestResultPolicy.KEYS_VALUES, InterestResultPolicyType.getInterestResultPolicy( + InterestResultPolicyType.KEYS_VALUES)); + } + + @Test + public void testStaticGetInterestResultPolicyWithNull() { + assertNull(InterestResultPolicyType.getInterestResultPolicy(null)); + } + + @Test + public void testDefault() { + assertEquals(InterestResultPolicyType.DEFAULT, InterestResultPolicyType.valueOf(InterestResultPolicy.DEFAULT)); + assertEquals(InterestResultPolicy.DEFAULT, InterestResultPolicyType.DEFAULT.getInterestResultPolicy()); + assertSame(InterestResultPolicyType.KEYS_VALUES, InterestResultPolicyType.DEFAULT); + } + + @Test + public void testValueOf() { + try { + for (byte ordinal = 0; ordinal < Byte.MAX_VALUE; ordinal++) { + InterestResultPolicy interestResultPolicy = InterestResultPolicy.fromOrdinal(ordinal); + InterestResultPolicyType interestResultPolicyType = InterestResultPolicyType.valueOf( + interestResultPolicy); + + assertNotNull(interestResultPolicyType); + assertEquals(interestResultPolicy, interestResultPolicyType.getInterestResultPolicy()); + } + } + catch (ArrayIndexOutOfBoundsException ignore) { + } + } + + @Test + public void testValueOfWithNull() { + assertNull(InterestResultPolicyType.valueOf((InterestResultPolicy) null)); + } + + @Test + public void testValueOfIgnoreCase() { + assertEquals(InterestResultPolicyType.KEYS, InterestResultPolicyType.valueOfIgnoreCase("KEYS")); + assertEquals(InterestResultPolicyType.KEYS_VALUES, InterestResultPolicyType.valueOfIgnoreCase("Keys_Values")); + assertEquals(InterestResultPolicyType.NONE, InterestResultPolicyType.valueOfIgnoreCase("none")); + assertEquals(InterestResultPolicyType.NONE, InterestResultPolicyType.valueOfIgnoreCase("nONE")); + } + + @Test + public void testValueOfIgnoreCaseWithInvalidValues() { + assertNull(InterestResultPolicyType.valueOfIgnoreCase("keyz")); + assertNull(InterestResultPolicyType.valueOfIgnoreCase("KEY_VALUE")); + assertNull(InterestResultPolicyType.valueOfIgnoreCase("all")); + assertNull(InterestResultPolicyType.valueOfIgnoreCase(" ")); + assertNull(InterestResultPolicyType.valueOfIgnoreCase("")); + assertNull(InterestResultPolicyType.valueOfIgnoreCase(null)); + } + +} diff --git a/src/test/java/org/springframework/data/gemfire/client/InterestTest.java b/src/test/java/org/springframework/data/gemfire/client/InterestTest.java new file mode 100644 index 00000000..91b8fefe --- /dev/null +++ b/src/test/java/org/springframework/data/gemfire/client/InterestTest.java @@ -0,0 +1,105 @@ +/* + * 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.client; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.springframework.core.ConstantException; + +import com.gemstone.gemfire.cache.InterestResultPolicy; + +/** + * The InterestTest class is a test suite of test cases testing the contract and functionality of the Interest class. + * + * @author John Blum + * @see org.junit.Test + * @see org.springframework.data.gemfire.client.Interest + * @since 1.6.0 + */ +public class InterestTest { + + @Test + public void testConstruct() { + Interest interest = new Interest("aKey", "keys", true, false); + + assertEquals("aKey", interest.getKey()); + assertEquals(InterestResultPolicy.KEYS, interest.getPolicy()); + assertTrue(interest.isDurable()); + assertFalse(interest.isReceiveValues()); + } + + @Test(expected = IllegalArgumentException.class) + public void testConstructWithNullKey() { + try { + new Interest(null); + } + catch (IllegalArgumentException expected) { + assertEquals("a non-null key is required", expected.getMessage()); + throw expected; + } + } + + @Test(expected = ConstantException.class) + public void testConstructWithInvalidPolicy() { + new Interest("aKey", "INVALID"); + } + + @Test + public void testSetAndGetState() { + Interest interest = new Interest(); + + assertNull(interest.getKey()); + assertEquals(InterestResultPolicy.DEFAULT, interest.getPolicy()); + assertFalse(interest.isDurable()); + assertTrue(interest.isReceiveValues()); + + interest.setDurable(true); + interest.setKey("testKey"); + interest.setPolicy(InterestResultPolicy.KEYS_VALUES); + interest.setReceiveValues(false); + + assertEquals("testKey", interest.getKey()); + assertEquals(InterestResultPolicy.KEYS_VALUES, interest.getPolicy()); + assertTrue(interest.isDurable()); + assertFalse(interest.isReceiveValues()); + } + + @Test + public void testSetAndGetPolicy() { + Interest interest = new Interest(); + + assertEquals(InterestResultPolicy.DEFAULT, interest.getPolicy()); + + interest.setPolicy(InterestResultPolicy.NONE); + + assertEquals(InterestResultPolicy.NONE, interest.getPolicy()); + + interest.setPolicy("keys"); + + assertEquals(InterestResultPolicy.KEYS, interest.getPolicy()); + } + + @Test(expected = ConstantException.class) + public void testSetPolicyWithIllegalValue() { + new Interest().setPolicy("ILLEGAL"); + } + +} diff --git a/src/test/java/org/springframework/data/gemfire/config/ClientRegionNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/ClientRegionNamespaceTest.java index 875ef73f..8d780d6a 100644 --- a/src/test/java/org/springframework/data/gemfire/config/ClientRegionNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/ClientRegionNamespaceTest.java @@ -22,19 +22,29 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.io.File; import java.io.FilenameFilter; +import java.util.concurrent.atomic.AtomicReference; import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.data.gemfire.SimpleCacheListener; import org.springframework.data.gemfire.SimpleObjectSizer; import org.springframework.data.gemfire.TestUtils; import org.springframework.data.gemfire.client.ClientRegionFactoryBean; +import org.springframework.data.gemfire.client.Interest; import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -48,9 +58,11 @@ import com.gemstone.gemfire.cache.EvictionAction; import com.gemstone.gemfire.cache.EvictionAlgorithm; import com.gemstone.gemfire.cache.EvictionAttributes; import com.gemstone.gemfire.cache.ExpirationAction; +import com.gemstone.gemfire.cache.InterestResultPolicy; import com.gemstone.gemfire.cache.LoaderHelper; import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.RegionAttributes; +import com.gemstone.gemfire.cache.client.ClientCache; import com.gemstone.gemfire.cache.client.ClientRegionShortcut; import com.gemstone.gemfire.cache.util.CacheWriterAdapter; import com.gemstone.gemfire.compression.Compressor; @@ -245,6 +257,85 @@ public class ClientRegionNamespaceTest { assertEquals(String.class, clientRegion.getAttributes().getValueConstraint()); } + @Test + @SuppressWarnings("unchecked") + public void testClientRegionWithRegisteredInterests() throws Exception { + assertTrue(context.containsBean("client-with-interests")); + + ClientRegionFactoryBean factory = context.getBean("&client-with-interests", ClientRegionFactoryBean.class); + + assertNotNull(factory); + + Interest[] interests = TestUtils.readField("interests", factory); + + assertNotNull(interests); + assertEquals(2, interests.length); + + assertInterest(true, false, InterestResultPolicy.KEYS, getInterestWithKey(".*", interests)); + assertInterest(true, false, InterestResultPolicy.KEYS_VALUES, getInterestWithKey("keyPrefix.*", interests)); + + Region mockClientRegion = MockCacheFactoryBean.MOCK_REGION_REF.get(); + + assertNotNull(mockClientRegion); + + verify(mockClientRegion, times(1)).registerInterest(eq(".*"), eq(InterestResultPolicy.KEYS), + eq(true), eq(false)); + verify(mockClientRegion, times(1)).registerInterestRegex(eq("keyPrefix.*"), eq(InterestResultPolicy.KEYS_VALUES), + eq(true), eq(false)); + } + + protected void assertInterest(final boolean expectedDurable, final boolean expectedReceiveValues, + final InterestResultPolicy expectedPolicy, final Interest actualInterest) { + assertNotNull(actualInterest); + assertEquals(expectedDurable, actualInterest.isDurable()); + assertEquals(expectedReceiveValues, actualInterest.isReceiveValues()); + assertEquals(expectedPolicy, actualInterest.getPolicy()); + } + + protected Interest getInterestWithKey(final String key, final Interest... interests) { + for (Interest interest : interests) { + if (interest.getKey().equals(key)) { + return interest; + } + } + + return null; + } + + public static final class MockCacheFactoryBean implements FactoryBean, InitializingBean { + + protected static final AtomicReference MOCK_REGION_REF = new AtomicReference(null); + + private ClientCache mockClientCache; + + @Override + @SuppressWarnings("unchecked") + public void afterPropertiesSet() throws Exception { + mockClientCache = mock(ClientCache.class, ClientRegionNamespaceTest.class.getSimpleName() + .concat(".MockClientCache")); + + MOCK_REGION_REF.compareAndSet(null, mock(Region.class, ClientRegionNamespaceTest.class.getSimpleName() + .concat(".MockClientRegion"))); + + when(mockClientCache.getRegion(anyString())).thenReturn(MOCK_REGION_REF.get()); + } + + @Override + public ClientCache getObject() throws Exception { + return mockClientCache; + } + + @Override + public Class getObjectType() { + return ClientCache.class; + } + + @Override + public boolean isSingleton() { + return true; + } + } + public static final class TestCacheLoader implements CacheLoader { @Override diff --git a/src/test/java/org/springframework/data/gemfire/test/MockCacheFactoryBean.java b/src/test/java/org/springframework/data/gemfire/test/MockCacheFactoryBean.java index 9523526d..177134b9 100644 --- a/src/test/java/org/springframework/data/gemfire/test/MockCacheFactoryBean.java +++ b/src/test/java/org/springframework/data/gemfire/test/MockCacheFactoryBean.java @@ -30,9 +30,6 @@ public class MockCacheFactoryBean extends CacheFactoryBean { this.useBeanFactoryLocator = false; } - /** - * @param bean - */ public MockCacheFactoryBean(CacheFactoryBean cacheFactoryBean) { this(); if (cacheFactoryBean != null) { @@ -70,8 +67,9 @@ public class MockCacheFactoryBean extends CacheFactoryBean { return new CacheFactory(gemfireProperties); } + @Override protected GemFireCache fetchCache() { - ((StubCache) cache).setProperties(this.properties); + ((StubCache) cache).setProperties(getProperties()); return cache; } diff --git a/src/test/java/org/springframework/data/gemfire/test/MockClientCacheFactoryBean.java b/src/test/java/org/springframework/data/gemfire/test/MockClientCacheFactoryBean.java index 4e008ab3..bd26b303 100644 --- a/src/test/java/org/springframework/data/gemfire/test/MockClientCacheFactoryBean.java +++ b/src/test/java/org/springframework/data/gemfire/test/MockClientCacheFactoryBean.java @@ -36,9 +36,9 @@ public class MockClientCacheFactoryBean extends ClientCacheFactoryBean { this(); if (cacheFactoryBean != null) { this.factoryLocator = cacheFactoryBean.getBeanFactoryLocator(); + this.beanClassLoader = cacheFactoryBean.getBeanClassLoader(); this.beanFactory = cacheFactoryBean.getBeanFactory(); this.beanName = cacheFactoryBean.getBeanName(); - this.beanClassLoader = cacheFactoryBean.getBeanClassLoader(); this.cacheXml = cacheFactoryBean.getCacheXml(); this.copyOnRead = cacheFactoryBean.getCopyOnRead(); this.criticalHeapPercentage = cacheFactoryBean.getCriticalHeapPercentage(); @@ -54,16 +54,17 @@ public class MockClientCacheFactoryBean extends ClientCacheFactoryBean { this.pdxPersistent = cacheFactoryBean.getPdxPersistent(); this.pdxSerializer = cacheFactoryBean.getPdxSerializer(); this.properties = cacheFactoryBean.getProperties(); + this.readyForEvents = cacheFactoryBean.getReadyForEvents(); this.searchTimeout = cacheFactoryBean.getSearchTimeout(); this.transactionListeners = cacheFactoryBean.getTransactionListeners(); this.transactionWriter = cacheFactoryBean.getTransactionWriter(); - this.readyForEvents = cacheFactoryBean.getReadyForEvents(); } } - + @Override protected Object createFactory(Properties gemfireProperties) { - ((StubCache)cache).setProperties(gemfireProperties); + setProperties(gemfireProperties); return new ClientCacheFactory(gemfireProperties); } + } diff --git a/src/test/resources/org/springframework/data/gemfire/config/client-ns.xml b/src/test/resources/org/springframework/data/gemfire/config/client-ns.xml index 5cef3fb6..51cd475f 100644 --- a/src/test/resources/org/springframework/data/gemfire/config/client-ns.xml +++ b/src/test/resources/org/springframework/data/gemfire/config/client-ns.xml @@ -1,18 +1,37 @@ + + true + false + keys + Keys_VALUes + + + + + + ClientRegionNamespaceTest + 0 + warning + + - + @@ -66,6 +85,20 @@ shortcut="CACHING_PROXY" value-constraint="java.lang.String"/> + + + + + + + + + + +