diff --git a/src/test/java/org/springframework/data/gemfire/SimpleCacheListener.java b/src/test/java/org/springframework/data/gemfire/SimpleCacheListener.java new file mode 100644 index 00000000..3a90bc04 --- /dev/null +++ b/src/test/java/org/springframework/data/gemfire/SimpleCacheListener.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010 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.util.CacheListenerAdapter; + +/** + * @author Costin Leau + */ +public class SimpleCacheListener extends CacheListenerAdapter { + +} diff --git a/src/test/java/org/springframework/data/gemfire/SimpleCacheLoader.java b/src/test/java/org/springframework/data/gemfire/SimpleCacheLoader.java new file mode 100644 index 00000000..2dfb5634 --- /dev/null +++ b/src/test/java/org/springframework/data/gemfire/SimpleCacheLoader.java @@ -0,0 +1,34 @@ +/* + * Copyright 2010 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.CacheLoader; +import com.gemstone.gemfire.cache.CacheLoaderException; +import com.gemstone.gemfire.cache.LoaderHelper; + +/** + * @author Costin Leau + */ +public class SimpleCacheLoader implements CacheLoader { + + public Object load(LoaderHelper helper) throws CacheLoaderException { + return null; + } + + public void close() { + } +} diff --git a/src/test/java/org/springframework/data/gemfire/SimpleCacheWriter.java b/src/test/java/org/springframework/data/gemfire/SimpleCacheWriter.java new file mode 100644 index 00000000..4b3ae8e5 --- /dev/null +++ b/src/test/java/org/springframework/data/gemfire/SimpleCacheWriter.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010 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.util.CacheWriterAdapter; + +/** + * @author Costin Leau + */ +public class SimpleCacheWriter extends CacheWriterAdapter { + +} diff --git a/src/test/java/org/springframework/data/gemfire/config/ReplicatedRegionNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/ReplicatedRegionNamespaceTest.java index 741e6239..657f2a7d 100644 --- a/src/test/java/org/springframework/data/gemfire/config/ReplicatedRegionNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/ReplicatedRegionNamespaceTest.java @@ -16,14 +16,25 @@ package org.springframework.data.gemfire.config; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; 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.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.util.ObjectUtils; + +import com.gemstone.gemfire.cache.CacheListener; +import com.gemstone.gemfire.cache.DataPolicy; +import com.gemstone.gemfire.cache.RegionAttributes; +import com.gemstone.gemfire.cache.Scope; /** * @author Costin Leau @@ -36,7 +47,31 @@ public class ReplicatedRegionNamespaceTest { private ApplicationContext context; @Test - public void testBasicCache() throws Exception { + public void testBasicReplica() throws Exception { assertTrue(context.containsBean("simple")); } -} + + @Test + public void testPublishingReplica() throws Exception { + assertTrue(context.containsBean("pub")); + RegionFactoryBean fb = context.getBean("&pub", RegionFactoryBean.class); + assertEquals(DataPolicy.REPLICATE, TestUtils.readField("dataPolicy", fb)); + assertEquals(Scope.DISTRIBUTED_ACK, TestUtils.readField("scope", fb)); + + RegionAttributes attrs = TestUtils.readField("attributes", fb); + assertTrue(attrs.getPublisher()); + } + + @Test + public void testComplexReplica() throws Exception { + assertTrue(context.containsBean("complex")); + RegionFactoryBean fb = context.getBean("&complex", RegionFactoryBean.class); + CacheListener[] listeners = TestUtils.readField("cacheListeners", fb); + assertFalse(ObjectUtils.isEmpty(listeners)); + assertEquals(2, listeners.length); + assertSame(listeners[0], context.getBean("c-listener")); + + assertSame(context.getBean("c-loader"), TestUtils.readField("cacheLoader", fb)); + assertSame(context.getBean("c-writer"), TestUtils.readField("cacheWriter", fb)); + } +} \ No newline at end of file diff --git a/src/test/resources/org/springframework/data/gemfire/config/replicated-ns.xml b/src/test/resources/org/springframework/data/gemfire/config/replicated-ns.xml index 3c55598f..464c6ba2 100644 --- a/src/test/resources/org/springframework/data/gemfire/config/replicated-ns.xml +++ b/src/test/resources/org/springframework/data/gemfire/config/replicated-ns.xml @@ -14,4 +14,17 @@ + + + + + + + + + + + + + \ No newline at end of file