Additional changes for SGF-160
This commit is contained in:
@@ -16,28 +16,65 @@
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
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 com.gemstone.gemfire.cache.InterestPolicy;
|
||||
import com.gemstone.gemfire.cache.RegionAttributes;
|
||||
import com.gemstone.gemfire.cache.SubscriptionAttributes;
|
||||
|
||||
/**
|
||||
* Test to ensure subscription policy can be applied to server regions.
|
||||
*
|
||||
* @author Lyndon Adams
|
||||
* @since 13 March 2013
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("/org/springframework/data/gemfire/config/subscription-ns.xml")
|
||||
public class CacheSubscriptionTest{
|
||||
@Autowired ApplicationContext ctx;
|
||||
|
||||
@Autowired ApplicationContext context;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testRRSubscription() throws Exception {
|
||||
public void testRRSubscriptionAllPolicy() throws Exception {
|
||||
assertTrue(context.containsBean("replicALL"));
|
||||
RegionFactoryBean fb = context.getBean("&replicALL", RegionFactoryBean.class);
|
||||
RegionAttributes attrs = TestUtils.readField("attributes", fb);
|
||||
|
||||
SubscriptionAttributes sa = attrs.getSubscriptionAttributes();
|
||||
assertEquals(InterestPolicy.ALL, sa.getInterestPolicy() );
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testPRSubscription() throws Exception {
|
||||
public void testPRSubscriptionCacheContentPolicy() throws Exception {
|
||||
assertTrue(context.containsBean("partCACHE_CONTENT"));
|
||||
RegionFactoryBean fb = context.getBean("&partCACHE_CONTENT", RegionFactoryBean.class);
|
||||
RegionAttributes attrs = TestUtils.readField("attributes", fb);
|
||||
|
||||
SubscriptionAttributes sa = attrs.getSubscriptionAttributes();
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, sa.getInterestPolicy() );
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testPRSubscriptionDefaultPolicy() throws Exception {
|
||||
assertTrue(context.containsBean("partDEFAULT"));
|
||||
RegionFactoryBean fb = context.getBean("&partDEFAULT", RegionFactoryBean.class);
|
||||
RegionAttributes attrs = TestUtils.readField("attributes", fb);
|
||||
|
||||
SubscriptionAttributes sa = attrs.getSubscriptionAttributes();
|
||||
assertEquals(InterestPolicy.ALL, sa.getInterestPolicy() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,23 +2,25 @@
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
||||
default-lazy-init="true"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd">
|
||||
|
||||
<gfe:cache/>
|
||||
<gfe:replicated-region id="rr">
|
||||
<gfe:subscription type="ALL"/>
|
||||
<gfe:cache/>
|
||||
<gfe:replicated-region id="replicALL">
|
||||
<gfe:subscription type="ALL"/>
|
||||
</gfe:replicated-region>
|
||||
|
||||
<gfe:partitioned-region id="pp">
|
||||
<gfe:subscription type="CACHE_CONTENT"/>
|
||||
<gfe:eviction threshold="70"/>
|
||||
<gfe:partitioned-region id="partCACHE_CONTENT">
|
||||
<gfe:subscription type="CACHE_CONTENT"/>
|
||||
<gfe:eviction threshold="70"/>
|
||||
</gfe:partitioned-region>
|
||||
|
||||
<gfe:client-region id="cc">
|
||||
|
||||
</gfe:client-region>
|
||||
|
||||
<gfe:partitioned-region id="partDEFAULT">
|
||||
<gfe:subscription/>
|
||||
</gfe:partitioned-region>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user