Added additional test case to test Client Region attribute configuration settings, including the new attributes for concurrency (concurrency-checks-enabled and concurrency-level) for SGF-310 and SGF-311.

(cherry picked from commit b68074c85c)

Signed-off-by: John Blum <jblum@pivotal.io>
This commit is contained in:
John Blum
2014-09-03 16:53:32 -07:00
parent 58c41f8e87
commit e396925776
2 changed files with 50 additions and 15 deletions

View File

@@ -60,6 +60,7 @@ import com.gemstone.gemfire.cache.util.ObjectSizer;
@ContextConfiguration(locations="/org/springframework/data/gemfire/config/client-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
@RunWith(SpringJUnit4ClassRunner.class)
@SuppressWarnings("unused")
public class ClientRegionNamespaceTest {
@Autowired
@@ -152,7 +153,29 @@ public class ClientRegionNamespaceTest {
assertTrue(TestUtils.readField("cacheWriter", factory) instanceof TestCacheWriter);
}
@SuppressWarnings("unused")
@Test
@SuppressWarnings("unchecked")
public void testClientRegionWithAttributes() {
assertTrue(context.containsBean("client-with-attributes"));
Region<Long, String> clientRegion = context.getBean("client-with-attributes", Region.class);
assertNotNull("The 'client-with-attributes' Client Region was not properly configured and initialized!", clientRegion);
assertEquals("client-with-attributes", clientRegion.getName());
assertEquals(Region.SEPARATOR + "client-with-attributes", clientRegion.getFullPath());
assertNotNull(clientRegion.getAttributes());
assertFalse(clientRegion.getAttributes().getCloningEnabled());
assertTrue(clientRegion.getAttributes().getConcurrencyChecksEnabled());
assertEquals(8, clientRegion.getAttributes().getConcurrencyLevel());
assertEquals(DataPolicy.NORMAL, clientRegion.getAttributes().getDataPolicy());
assertFalse(clientRegion.getAttributes().getDataPolicy().withPersistence());
assertEquals(64, clientRegion.getAttributes().getInitialCapacity());
assertEquals(Long.class, clientRegion.getAttributes().getKeyConstraint());
assertEquals("0.85", String.valueOf(clientRegion.getAttributes().getLoadFactor()));
assertEquals("gemfire-pool", clientRegion.getAttributes().getPoolName());
assertEquals(String.class, clientRegion.getAttributes().getValueConstraint());
}
public static final class TestCacheLoader implements CacheLoader<Object, Object> {
@Override

View File

@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
default-lazy-init="true"
xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
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">
" default-lazy-init="true">
<gfe:pool id="gemfire-pool" subscription-enabled="false">
<gfe:locator host="localhost" port="40403"/>
</gfe:pool>
<gfe:client-cache />
@@ -24,13 +27,7 @@
<gfe:eviction threshold="5"/>
</gfe:client-region>
<bean id="c-listener" class="org.springframework.data.gemfire.SimpleCacheListener"/>
<gfe:pool id="gemfire-pool" subscription-enabled="false">
<gfe:locator host="localhost" port="40403"/>
</gfe:pool>
<gfe:client-region id="persistent" name="PersistentRegion" pool-name="gemfire-pool" persistent="true" disk-store-ref="diskStore" disk-synchronous="true"/>
<gfe:client-region id="persistent" name="PersistentRegion" pool-name="gemfire-pool" persistent="true" disk-synchronous="true" disk-store-ref="diskStore"/>
<gfe:disk-store id="diskStore" queue-size="50" auto-compact="true" max-oplog-size="10" time-interval="9999">
<gfe:disk-dir location="./" max-size="1"/>
@@ -53,4 +50,19 @@
</gfe:cache-writer>
</gfe:client-region>
<gfe:client-region id="client-with-attributes"
cloning-enabled="false"
concurrency-checks-enabled="true"
concurrency-level="8"
initial-capacity="64"
key-constraint="java.lang.Long"
load-factor="0.85"
persistent="false"
pool-name="gemfire-pool"
shortcut="CACHING_PROXY"
value-constraint="java.lang.String"/>
<bean id="c-listener" class="org.springframework.data.gemfire.SimpleCacheListener"/>
<bean id="testCompressor" class="org.springframework.data.gemfire.config.ClientRegionNamespaceTest$TestCompressor" p:name="STD"/>
</beans>