DATAGEODE-110 - Polish.

This commit is contained in:
John Blum
2018-06-09 18:59:04 -07:00
parent 59d28b5d1b
commit 0454fc898a
4 changed files with 4 additions and 193 deletions

View File

@@ -41,8 +41,8 @@ public class KeyInterest<K> extends Interest<K> {
super(key, policy, durable);
}
public KeyInterest(K key, InterestResultPolicy policy, boolean durable, boolean recieveValues) {
super(key, policy, durable, recieveValues);
public KeyInterest(K key, InterestResultPolicy policy, boolean durable, boolean receiveValues) {
super(key, policy, durable, receiveValues);
}
/**
@@ -58,7 +58,7 @@ public class KeyInterest<K> extends Interest<K> {
*/
@Override
public void setType(Type type) {
logger.warn(String.format("Setting the Type [%1$s] of interest on [%2$s] is ignored",
logger.warn(String.format("Setting the Type [%1$s] of Interest on [%2$s] is ignored",
type, getClass().getName()));
}
}

View File

@@ -78,7 +78,7 @@ public class RegexInterest extends Interest<String> {
*/
@Override
public void setType(Type type) {
logger.warn(String.format("Setting the Type [%1$s] of interest on [%2$s] is ignored",
logger.warn(String.format("Setting the Type [%1$s] of Interest on [%2$s] is ignored",
type, getClass().getName()));
}
}

View File

@@ -1,125 +0,0 @@
/*
* 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.assertSame;
import java.util.Arrays;
import org.apache.geode.cache.CacheListener;
import org.apache.geode.cache.CacheLoader;
import org.apache.geode.cache.CacheLoaderException;
import org.apache.geode.cache.LoaderHelper;
import org.apache.geode.cache.PartitionAttributes;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionAttributes;
import org.apache.geode.cache.util.CacheListenerAdapter;
import org.apache.geode.cache.util.CacheWriterAdapter;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Costin Leau
* @author David Turanski
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "basic-region.xml" },
initializers=GemfireTestApplicationContextInitializer.class)
public class RegionIntegrationTest {
private static class CacheList<K, V> extends CacheListenerAdapter<K, V> {
}
private static class CacheLoad<K, V> implements CacheLoader<K, V> {
@Override
public V load(LoaderHelper<K, V> arg0) throws CacheLoaderException {
return null;
}
@Override
public void close() {
}
}
private static class CacheWrite<K, V> extends CacheWriterAdapter<K, V> {
}
@Autowired
private ApplicationContext ctx;
@Test
public void testBasicRegion() throws Exception {
@SuppressWarnings("rawtypes")
Region region = ctx.getBean("basic", Region.class);
assertEquals("basic", region.getName());
}
@Test
public void testExistingRegion() throws Exception {
@SuppressWarnings("rawtypes")
Region region = ctx.getBean("root", Region.class);
// the name property seems to be ignored
assertEquals("root", region.getName());
}
@SuppressWarnings("rawtypes")
@Test
public void testRegionWithListeners() throws Exception {
Region region = ctx.getBean("listeners", Region.class);
assertEquals("listeners", region.getName());
CacheListener[] listeners = region.getAttributes().getCacheListeners();
assertEquals(2, listeners.length);
assertSame(CacheList.class, listeners[0].getClass());
assertSame(CacheLoad.class, region.getAttributes().getCacheLoader().getClass());
assertSame(CacheWrite.class, region.getAttributes().getCacheWriter().getClass());
}
// @Test
// TODO: disabled since the interest registration requires a proper pool to
// be created, which requires another JVM to run with the server/locator
@SuppressWarnings("rawtypes")
public void testRegionInterest() throws Exception {
ClientRegionFactoryBean regionFB = (ClientRegionFactoryBean) ctx.getBean("&basic-client");
System.out.println("**** interests are " + Arrays.toString(regionFB.getInterests()));
BeanDefinition bd = ((BeanDefinitionRegistry) ctx.getAutowireCapableBeanFactory())
.getBeanDefinition("basic-client");
System.out.println(bd.getPropertyValues().getPropertyValue("interests").getValue());
}
@SuppressWarnings("rawtypes")
@Test
public void testRegionAttributes() throws Exception {
Region region = ctx.getBean("attr-region", Region.class);
assertEquals("attr-region", region.getName());
RegionAttributes attr = region.getAttributes();
assertEquals(1024, attr.getInitialCapacity());
PartitionAttributes pa = attr.getPartitionAttributes();
assertEquals(512, pa.getLocalMaxMemory());
assertEquals(1, pa.getRedundantCopies());
}
}

View File

@@ -1,64 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
default-lazy-init="true">
<!-- all beans are lazy to allow the same config to be used between multiple tests -->
<!-- as there can be only one cache per VM -->
<bean id="cache" class="org.springframework.data.gemfire.CacheFactoryBean">
<property name="properties">
<props>
<prop key="name">BasicRegionConfig</prop>
<prop key="mcast-port">0</prop>
<prop key="log-level">warning</prop>
</props>
</property>
</bean>
<bean id="basic" class="org.springframework.data.gemfire.LocalRegionFactoryBean" p:cache-ref="cache" p:name="basic"/>
<!-- find existing region -->
<bean id="root" class="org.springframework.data.gemfire.LocalRegionFactoryBean" p:cache-ref="cache"/>
<bean id="listeners" class="org.springframework.data.gemfire.LocalRegionFactoryBean" p:cache-ref="cache" p:name="listeners">
<property name="cacheListeners">
<array>
<bean class="org.springframework.data.gemfire.client.RegionIntegrationTest$CacheList"/>
<bean class="org.springframework.data.gemfire.client.RegionIntegrationTest$CacheList"/>
</array>
</property>
<property name="cacheLoader"><bean class="org.springframework.data.gemfire.client.RegionIntegrationTest$CacheLoad"/></property>
<property name="cacheWriter"><bean class="org.springframework.data.gemfire.client.RegionIntegrationTest$CacheWrite"/></property>
</bean>
<!-- client configurations -->
<bean id="basic-client" class="org.springframework.data.gemfire.client.ClientRegionFactoryBean" p:cache-ref="cache"
p:name="client-region" lazy-init="true" p:pool-name="pool">
<property name="interests">
<array>
<bean class="org.springframework.data.gemfire.client.Interest" p:key="Vlaicu" p:policy="NONE"/>
<bean class="org.springframework.data.gemfire.client.RegexInterest" p:key=".*" p:policy="KEYS" p:durable="true" p:receive-values="false"/>
</array>
</property>
</bean>
<bean id="pool" class="org.springframework.data.gemfire.client.PoolFactoryBean" p:subscription-enabled="true">
<property name="servers">
<bean class="org.springframework.data.gemfire.client.PoolConnection" p:host="localhost" p:port="40404"/>
</property>
</bean>
<!-- region with various attributes -->
<bean id="attr-region" class="org.springframework.data.gemfire.PartitionedRegionFactoryBean" p:cache-ref="cache" lazy-init="true">
<property name="attributes">
<bean class="org.springframework.data.gemfire.RegionAttributesFactoryBean" p:initial-capacity="1024">
<property name="partitionAttributes">
<bean class="org.springframework.data.gemfire.PartitionAttributesFactoryBean" p:redundant-copies="1" p:local-max-memory="512"/>
</property>
</bean>
</property>
</bean>
</beans>