diff --git a/src/test/java/org/springframework/data/gemfire/config/InvalidRegionDefinitionUsingBeansNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/InvalidRegionDefinitionUsingBeansNamespaceTest.java
new file mode 100644
index 00000000..25f9f07f
--- /dev/null
+++ b/src/test/java/org/springframework/data/gemfire/config/InvalidRegionDefinitionUsingBeansNamespaceTest.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.config;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * The InvalidRegionDefinitionUsingBeansNamespaceTest class is a test suite of test cases testing the definition of
+ * invalid Region beans in a Spring context. Specifically, this test class tests the specification of the Region's
+ * DataPolicy on a nested RegionAttributesFactoryBean conflicting with the 'persistent' attribute configuration
+ * on the containing RegionFactoryBean definition.
+ *
+ * @author John Blum
+ * @see org.junit.Test
+ * @see org.springframework.data.gemfire.RegionFactoryBean
+ * @since 1.6.0
+ */
+public class InvalidRegionDefinitionUsingBeansNamespaceTest {
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testInvalidDataPolicyPersistentAttributeSettings() {
+ try {
+ new ClassPathXmlApplicationContext("org/springframework/data/gemfire/config/InvalidDataPolicyPersistentAttributeSettingsBeansNamespaceTest.xml");
+ }
+ catch (BeanCreationException expected) {
+ assertTrue(expected.getCause() instanceof IllegalArgumentException);
+ assertEquals("Data Policy 'REPLICATE' is invalid when persistent is true.", expected.getCause().getMessage());
+ throw (IllegalArgumentException) expected.getCause();
+ }
+ }
+
+}
diff --git a/src/test/java/org/springframework/data/gemfire/config/RegionDefinitionUsingBeansNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/RegionDefinitionUsingBeansNamespaceTest.java
index 53fc8fa4..4a393f30 100644
--- a/src/test/java/org/springframework/data/gemfire/config/RegionDefinitionUsingBeansNamespaceTest.java
+++ b/src/test/java/org/springframework/data/gemfire/config/RegionDefinitionUsingBeansNamespaceTest.java
@@ -24,12 +24,18 @@ import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.data.gemfire.RegionFactoryBean;
+import org.springframework.data.gemfire.TestUtils;
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.DataPolicy;
+import com.gemstone.gemfire.cache.PartitionAttributes;
import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
/**
* The RawRegionBeanDefinitionTest class is a test suite of test cases testing the contract and functionality
@@ -37,6 +43,7 @@ import com.gemstone.gemfire.cache.Region;
* when used as raw bean definition in Spring XML configuration meta-data.
*
* @author John Blum
+ * @see org.junit.Test
* @see org.springframework.data.gemfire.PartitionAttributesFactoryBean
* @see org.springframework.data.gemfire.RegionAttributesFactoryBean
* @see org.springframework.data.gemfire.RegionFactoryBean
@@ -52,12 +59,18 @@ import com.gemstone.gemfire.cache.Region;
@SuppressWarnings("unused")
public class RegionDefinitionUsingBeansNamespaceTest {
+ @Autowired
+ private ApplicationContext context;
+
@Resource(name = "Example")
private Region, ?> example;
+ @Resource(name = "AnotherExample")
+ private Region, ?> anotherExample;
+
@Test
public void testExampleRegionBeanDefinitionConfiguration() {
- assertNotNull("The 'Example' Region was not properly configured and initialized!", example);
+ assertNotNull("The '/Example' Region was not properly configured and initialized!", example);
assertEquals("Example", example.getName());
assertEquals("/Example", example.getFullPath());
assertNotNull(example.getAttributes());
@@ -68,4 +81,36 @@ public class RegionDefinitionUsingBeansNamespaceTest {
assertEquals(0, example.getAttributes().getPartitionAttributes().getRecoveryDelay());
}
+ @Test
+ public void testAnotherExampleRegionFactoryBeanConfiguration() throws Exception {
+ RegionFactoryBean, ?> anotherExampleRegionFactoryBean = context.getBean("&AnotherExample",
+ RegionFactoryBean.class);
+
+ assertNotNull(anotherExampleRegionFactoryBean);
+ assertEquals(DataPolicy.PERSISTENT_PARTITION, anotherExampleRegionFactoryBean.getDataPolicy());
+ assertTrue(Boolean.TRUE.equals(TestUtils.readField("persistent", anotherExampleRegionFactoryBean)));
+
+ RegionAttributes, ?> anotherExampleRegionAttributes = TestUtils.readField("attributes",
+ anotherExampleRegionFactoryBean);
+
+ assertNotNull(anotherExampleRegionAttributes);
+ assertEquals(DataPolicy.PARTITION, anotherExampleRegionAttributes.getDataPolicy());
+
+ PartitionAttributes, ?> anotherExamplePartitionAttributes = anotherExampleRegionAttributes.getPartitionAttributes();
+
+ assertNotNull(anotherExamplePartitionAttributes);
+ assertEquals(2, anotherExamplePartitionAttributes.getRedundantCopies());
+ }
+
+ @Test
+ public void testAnotherExampleRegionDefinitionConfiguration() {
+ assertNotNull("The '/AnotherExample' Region was not properly configured and initialized!", anotherExample);
+ assertEquals("AnotherExample", anotherExample.getName());
+ assertEquals("/AnotherExample", anotherExample.getFullPath());
+ assertNotNull(anotherExample.getAttributes());
+ assertEquals(DataPolicy.PERSISTENT_PARTITION, anotherExample.getAttributes().getDataPolicy());
+ assertNotNull(anotherExample.getAttributes().getPartitionAttributes());
+ assertEquals(2, anotherExample.getAttributes().getPartitionAttributes().getRedundantCopies());
+ }
+
}
diff --git a/src/test/resources/org/springframework/data/gemfire/config/InvalidDataPolicyPersistentAttributeSettingsBeansNamespaceTest.xml b/src/test/resources/org/springframework/data/gemfire/config/InvalidDataPolicyPersistentAttributeSettingsBeansNamespaceTest.xml
new file mode 100644
index 00000000..72baa65f
--- /dev/null
+++ b/src/test/resources/org/springframework/data/gemfire/config/InvalidDataPolicyPersistentAttributeSettingsBeansNamespaceTest.xml
@@ -0,0 +1,30 @@
+
+
+
+
+ InvalidDataPolicyPersistentAttributeSettingsTest
+ 0
+ warning
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/org/springframework/data/gemfire/config/RegionDefinitionUsingBeansNamespaceTest-context.xml b/src/test/resources/org/springframework/data/gemfire/config/RegionDefinitionUsingBeansNamespaceTest-context.xml
index bbe8ec53..3e35faa2 100644
--- a/src/test/resources/org/springframework/data/gemfire/config/RegionDefinitionUsingBeansNamespaceTest-context.xml
+++ b/src/test/resources/org/springframework/data/gemfire/config/RegionDefinitionUsingBeansNamespaceTest-context.xml
@@ -11,7 +11,7 @@
">
- RawRegionBeanDefinitionTest
+ RegionDefinitionUsingBeansNamespaceTest
0
warning
@@ -31,4 +31,15 @@
+
+
+
+
+
+
+
+
+
+