Added WAN support modifications for GF 7 and general cleanup of test code

This commit is contained in:
David Turanski
2012-07-23 14:41:00 -04:00
parent 0d84ef62ad
commit 94468bec9a
60 changed files with 4707 additions and 1670 deletions

View File

@@ -59,6 +59,6 @@ public class CacheIntegrationTest extends RecreatingContextTest {
@Test
public void testCacheWithXml() throws Exception {
Cache cache = ctx.getBean("cache-with-xml", Cache.class);
ctx.getBean("cache-with-xml", Cache.class);
}
}

View File

@@ -30,6 +30,7 @@ import com.gemstone.gemfire.cache.query.SelectResults;
public class GemfireTemplateTest extends RecreatingContextTest {
private static final String MULTI_QUERY = "select * from /simple";
private static final String SINGLE_QUERY = "(select * from /simple).size";
@Override
@@ -38,28 +39,33 @@ public class GemfireTemplateTest extends RecreatingContextTest {
}
@Test
public void testFind() throws Exception {
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
SelectResults<Object> find = template.find(MULTI_QUERY);
assertNotNull(find);
}
@Test
public void testFindUnique() throws Exception {
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
Integer find = template.findUnique(SINGLE_QUERY);
assertEquals(find, Integer.valueOf(0));
public void testAll() throws Exception {
testFind();
testFindUnique();
}
@Test(expected = InvalidDataAccessApiUsageException.class)
public void testFindMultiException() throws Exception {
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
SelectResults<Object> find = template.find(SINGLE_QUERY);
template.find(SINGLE_QUERY);
}
@Test(expected = InvalidDataAccessApiUsageException.class)
public void testFindMultiOne() throws Exception {
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
SelectResults<Object> find = template.findUnique(MULTI_QUERY);
template.findUnique(MULTI_QUERY);
}
private void testFind() throws Exception {
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
SelectResults<Object> find = template.find(MULTI_QUERY);
assertNotNull(find);
}
private void testFindUnique() throws Exception {
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
Integer find = template.findUnique(SINGLE_QUERY);
assertEquals(find, Integer.valueOf(0));
}
}

View File

@@ -21,6 +21,7 @@ import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
/**
* @author Costin Leau
*/
@SuppressWarnings("rawtypes")
public class SimpleCacheListener extends CacheListenerAdapter {
}

View File

@@ -23,12 +23,15 @@ import com.gemstone.gemfire.cache.LoaderHelper;
/**
* @author Costin Leau
*/
@SuppressWarnings("rawtypes")
public class SimpleCacheLoader implements CacheLoader {
@Override
public Object load(LoaderHelper helper) throws CacheLoaderException {
return null;
}
@Override
public void close() {
}
}

View File

@@ -21,6 +21,7 @@ import com.gemstone.gemfire.cache.util.CacheWriterAdapter;
/**
* @author Costin Leau
*/
@SuppressWarnings("rawtypes")
public class SimpleCacheWriter extends CacheWriterAdapter {
}

View File

@@ -26,6 +26,7 @@ public class SimpleObjectSizer implements ObjectSizer {
private static final ObjectSizer sizer = new ObjectSizerImpl();
@Override
public int sizeof(Object o) {
return sizer.sizeof(o);
}

View File

@@ -24,16 +24,20 @@ import com.gemstone.gemfire.cache.PartitionResolver;
/**
* @author Costin Leau
*/
@SuppressWarnings("rawtypes")
public class SimplePartitionResolver implements PartitionResolver {
@Override
public String getName() {
return getClass().getName();
}
@Override
public Serializable getRoutingObject(EntryOperation opDetails) {
return getName();
}
@Override
public void close() {
}
}

View File

@@ -35,9 +35,15 @@ public class SubRegionTest extends RecreatingContextTest {
return "org/springframework/data/gemfire/basic-subregion.xml";
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testBasic() throws Exception {
public void testAll() throws Exception {
testBasic();
testContext();
testChildOnly();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private void testBasic() throws Exception {
CacheFactoryBean cfb = new CacheFactoryBean();
cfb.setUseBeanFactoryLocator(false);
cfb.afterPropertiesSet();
@@ -57,13 +63,10 @@ public class SubRegionTest extends RecreatingContextTest {
assertNotNull(parent.getSubregion("child"));
assertSame(child, parent.getSubregion("child"));
cache.close();
}
@SuppressWarnings("rawtypes")
@Test
public void testContext() throws Exception {
private void testContext() throws Exception {
Region parent = ctx.getBean("parent", Region.class);
Region child = ctx.getBean("/parent/child", Region.class);
assertNotNull(parent.getSubregion("child"));
@@ -72,7 +75,6 @@ public class SubRegionTest extends RecreatingContextTest {
}
@SuppressWarnings("rawtypes")
@Test
public void testChildOnly() throws Exception {
Region child = ctx.getBean("/parent/child", Region.class);
assertEquals("/parent/child", child.getFullPath());

View File

@@ -16,8 +16,6 @@
package org.springframework.data.gemfire;
import org.springframework.data.gemfire.WiringDeclarableSupport;
import com.gemstone.gemfire.cache.CacheLoader;
import com.gemstone.gemfire.cache.CacheLoaderException;
import com.gemstone.gemfire.cache.LoaderHelper;
@@ -27,11 +25,13 @@ import com.gemstone.gemfire.cache.LoaderHelper;
*
* @author Costin Leau
*/
@SuppressWarnings("rawtypes")
public class UserObject extends WiringDeclarableSupport implements CacheLoader {
public static UserObject THIS;
private String prop1;
private Object prop2;
public UserObject() {
@@ -39,6 +39,7 @@ public class UserObject extends WiringDeclarableSupport implements CacheLoader {
THIS = this;
}
@Override
public Object load(LoaderHelper helper) throws CacheLoaderException {
return new Object();
}

View File

@@ -40,7 +40,6 @@ import com.gemstone.gemfire.cache.RegionAttributes;
import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
import com.gemstone.gemfire.cache.util.CacheWriterAdapter;
/**
* @author Costin Leau
*/
@@ -53,10 +52,12 @@ public class RegionIntegrationTest {
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() {
}
}
@@ -68,20 +69,28 @@ public class RegionIntegrationTest {
private ApplicationContext ctx;
@Test
public void testBasicRegion() throws Exception {
public void testAll() throws Exception {
testBasicRegion();
testExistingRegion();
testRegionWithListeners();
testRegionAttributes();
}
private void testBasicRegion() throws Exception {
@SuppressWarnings("rawtypes")
Region region = ctx.getBean("basic", Region.class);
assertEquals("basic", region.getName());
}
@Test
public void testExistingRegion() throws Exception {
private void testExistingRegion() throws Exception {
@SuppressWarnings("rawtypes")
Region region = ctx.getBean("root", Region.class);
// the name property seems to be ignored
assertEquals("root", region.getName());
}
@Test
public void testRegionWithListeners() throws Exception {
@SuppressWarnings("rawtypes")
private void testRegionWithListeners() throws Exception {
Region region = ctx.getBean("listeners", Region.class);
assertEquals("listeners", region.getName());
CacheListener[] listeners = region.getAttributes().getCacheListeners();
@@ -91,17 +100,20 @@ public class RegionIntegrationTest {
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
// @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");
BeanDefinition bd = ((BeanDefinitionRegistry) ctx.getAutowireCapableBeanFactory())
.getBeanDefinition("basic-client");
System.out.println(bd.getPropertyValues().getPropertyValue("interests").getValue());
}
@Test
public void testRegionAttributes() throws Exception {
@SuppressWarnings("rawtypes")
private void testRegionAttributes() throws Exception {
Region region = ctx.getBean("attr-region", Region.class);
assertEquals("attr-region", region.getName());
RegionAttributes attr = region.getAttributes();

View File

@@ -44,23 +44,30 @@ public class CacheNamespaceTest extends RecreatingContextTest {
}
@Test
public void testBasicCache() throws Exception {
public void testAll() throws Exception {
testBasicCache();
testNamedCache();
testCacheWithXml();
// testBasicClientCache();
// testBasicClientCacheWithXml();
testHeapTunedCache();
}
private void testBasicCache() throws Exception {
assertTrue(ctx.containsBean("gemfire-cache"));
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&gemfire-cache");
assertNull(TestUtils.readField("cacheXml", cfb));
assertNull(TestUtils.readField("properties", cfb));
}
@Test
public void testNamedCache() throws Exception {
private void testNamedCache() throws Exception {
assertTrue(ctx.containsBean("cache-with-name"));
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&cache-with-name");
assertNull(TestUtils.readField("cacheXml", cfb));
assertNull(TestUtils.readField("properties", cfb));
}
@Test
public void testCacheWithXml() throws Exception {
private void testCacheWithXml() throws Exception {
assertTrue(ctx.containsBean("cache-with-xml"));
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&cache-with-xml");
Resource res = TestUtils.readField("cacheXml", cfb);
@@ -106,8 +113,7 @@ public class CacheNamespaceTest extends RecreatingContextTest {
assertEquals("gemfire-client-cache.xml", res.getFilename());
}
@Test
public void testHeapTunedCache() throws Exception {
private void testHeapTunedCache() throws Exception {
assertTrue(ctx.containsBean("heap-tuned-cache"));
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&heap-tuned-cache");
Float chp = (Float) TestUtils.readField("criticalHeapPercentage", cfb);

View File

@@ -56,23 +56,31 @@ public class ClientRegionNamespaceTest {
private ApplicationContext context;
@Test
public void testBasicClient() throws Exception {
public void testAll() throws Exception {
testBasicClient();
testBeanNames();
testPublishingClient();
testPersistent();
testOverflowToDisk();
}
private void testBasicClient() throws Exception {
assertTrue(context.containsBean("simple"));
}
@Test
public void testBeanNames() throws Exception {
private void testBeanNames() throws Exception {
assertTrue(ObjectUtils.isEmpty(context.getAliases("publisher")));
}
@Test
public void testPublishingClient() throws Exception {
@SuppressWarnings("rawtypes")
private void testPublishingClient() throws Exception {
assertTrue(context.containsBean("empty"));
ClientRegionFactoryBean fb = context.getBean("&empty", ClientRegionFactoryBean.class);
assertEquals(DataPolicy.EMPTY, TestUtils.readField("dataPolicy", fb));
}
// @Test
@SuppressWarnings("rawtypes")
public void testComplexClient() throws Exception {
assertTrue(context.containsBean("complex"));
ClientRegionFactoryBean fb = context.getBean("&complex", ClientRegionFactoryBean.class);
@@ -97,8 +105,8 @@ public class ClientRegionNamespaceTest {
assertEquals(".*", TestUtils.readField("key", regexInt));
}
@Test
public void testPersistent() throws Exception {
@SuppressWarnings("rawtypes")
private void testPersistent() throws Exception {
assertTrue(context.containsBean("persistent"));
Region region = context.getBean("persistent", Region.class);
RegionAttributes attrs = region.getAttributes();
@@ -106,8 +114,8 @@ public class ClientRegionNamespaceTest {
assertEquals(1, attrs.getDiskDirSizes()[0]);
}
@Test
public void testOverflowToDisk() throws Exception {
@SuppressWarnings("rawtypes")
private void testOverflowToDisk() throws Exception {
assertTrue(context.containsBean("overflow"));
ClientRegionFactoryBean fb = context.getBean("&overflow", ClientRegionFactoryBean.class);
assertEquals(DataPolicy.NORMAL, TestUtils.readField("dataPolicy", fb));

View File

@@ -83,7 +83,14 @@ public class DiskStoreAndEvictionRegionParsingTest {
}
@Test
public void testDiskStore() {
public void testAll() throws Exception {
testDiskStore();
testReplicaDataOptions();
testPartitionDataOptions();
testEntryTtl();
}
private void testDiskStore() {
assertEquals("diskStore1", diskStore1.getName());
assertEquals(50, diskStore1.getQueueSize());
assertEquals(true, diskStore1.getAutoCompact());
@@ -95,12 +102,13 @@ public class DiskStoreAndEvictionRegionParsingTest {
assertSame(diskStore1, cache.findDiskStore("diskStore1"));
}
@Test
public void testReplicaDataOptions() throws Exception {
@SuppressWarnings("rawtypes")
private void testReplicaDataOptions() throws Exception {
assertTrue(context.containsBean("replicated-data"));
RegionFactoryBean fb = context.getBean("&replicated-data", RegionFactoryBean.class);
assertTrue(fb instanceof ReplicatedRegionFactoryBean);
assertEquals(Scope.DISTRIBUTED_ACK, TestUtils.readField("scope", fb));
@SuppressWarnings("unused")
Region region = context.getBean("replicated-data", Region.class);
// eviction tests
RegionAttributes attrs = TestUtils.readField("attributes", fb);
@@ -111,8 +119,8 @@ public class DiskStoreAndEvictionRegionParsingTest {
assertNull(evicAttr.getObjectSizer());
}
@Test
public void testPartitionDataOptions() throws Exception {
@SuppressWarnings("rawtypes")
private void testPartitionDataOptions() throws Exception {
assertTrue(context.containsBean("partition-data"));
RegionFactoryBean fb = context.getBean("&partition-data", RegionFactoryBean.class);
assertTrue(fb instanceof PartitionedRegionFactoryBean);
@@ -129,8 +137,8 @@ public class DiskStoreAndEvictionRegionParsingTest {
assertEquals(SimpleObjectSizer.class, sizer.getClass());
}
@Test
public void testEntryTtl() throws Exception {
@SuppressWarnings("rawtypes")
private void testEntryTtl() throws Exception {
assertTrue(context.containsBean("replicated-data"));
RegionFactoryBean fb = context.getBean("&replicated-data", RegionFactoryBean.class);
RegionAttributes attrs = TestUtils.readField("attributes", fb);

View File

@@ -0,0 +1,107 @@
/*
* Copyright 2010-2012 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.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
import org.springframework.data.gemfire.RecreatingContextTest;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.wan.GatewayHubFactoryBean;
import org.springframework.data.gemfire.wan.GatewayProxy;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.util.GatewayEvent;
import com.gemstone.gemfire.cache.util.GatewayEventListener;
import com.gemstone.gemfire.cache.util.GatewayHub;
/**
* @author David Turanski
*
*/
public class GemfireV6GatewayNamespaceTest extends RecreatingContextTest {
@Override
protected String location() {
return "/org/springframework/data/gemfire/config/gateway-v6-ns.xml";
}
/*
* Faster this way
*/
@Test
public void test() throws Exception {
testGatewayHubFactoryBean();
testGatewaysInGemfire();
}
private void testGatewayHubFactoryBean() throws Exception {
GatewayHubFactoryBean gwhfb = ctx.getBean("&gateway-hub", GatewayHubFactoryBean.class);
List<GatewayProxy> gateways = TestUtils.readField("gateways", gwhfb);
assertNotNull(gateways);
assertEquals(2, gateways.size());
GatewayProxy gwp = gateways.get(0);
assertEquals("gateway", gwp.getId());
assertTrue(gwp.getListeners().get(0) instanceof GatewayListener);
gwp = gateways.get(1);
assertEquals("gateway2", gwp.getId());
List<GatewayProxy.GatewayEndpoint> endpoints = gwp.getEndpoints();
assertEquals(2, endpoints.size());
GatewayProxy.GatewayEndpoint endpoint;
endpoint = endpoints.get(0);
assertEquals("endpoint1", endpoint.getId());
assertEquals("host1", endpoint.getHost());
assertEquals(1234, endpoint.getPort());
endpoint = endpoints.get(1);
assertEquals("endpoint2", endpoint.getId());
assertEquals("host2", endpoint.getHost());
assertEquals(2345, endpoint.getPort());
}
@SuppressWarnings("rawtypes")
private void testGatewaysInGemfire() {
Cache cache = ctx.getBean("gemfire-cache", Cache.class);
GatewayHub gwh = cache.getGatewayHub("gateway-hub");
assertNotNull(gwh);
Region region = ctx.getBean("region-with-gateway", Region.class);
assertTrue(region.getAttributes().getEnableGateway());
assertEquals("gateway-hub", region.getAttributes().getGatewayHubId());
}
public static class GatewayListener implements GatewayEventListener {
@Override
public void close() {
// TODO Auto-generated method stub
}
@Override
public boolean processEvents(List<GatewayEvent> event) {
// TODO Auto-generated method stub
return false;
}
}
}

View File

@@ -0,0 +1,221 @@
/*
* Copyright 2010-2012 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.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.springframework.data.gemfire.RecreatingContextTest;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.wan.GatewaySenderFactoryBean;
import com.gemstone.gemfire.cache.AsyncEventQueue;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.util.Gateway.OrderPolicy;
import com.gemstone.gemfire.cache.wan.AsyncEvent;
import com.gemstone.gemfire.cache.wan.AsyncEventListener;
import com.gemstone.gemfire.cache.wan.GatewayEventFilter;
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
import com.gemstone.gemfire.cache.wan.GatewaySender;
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
/**
* This test is only valid for GF 7.0 and above
*
* @author David Turanski
*
*/
public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest {
@Override
protected String location() {
return "/org/springframework/data/gemfire/config/gateway-v7-ns.xml";
}
@Before
@Override
public void createCtx() {
if (ParsingUtils.GEMFIRE_VERSION.startsWith("7")) {
super.createCtx();
}
}
/*
* Faster this way
*/
@Test
public void test() throws Exception {
if (ctx != null) {
testGatewaySender();
testInnerGatewaySender();
testInnerGatewayReceiver();
testAsyncEventQueue();
}
}
/**
*
*/
private void testAsyncEventQueue() {
AsyncEventQueue aseq = ctx.getBean("async-event-queue", AsyncEventQueue.class);
assertEquals(10, aseq.getBatchSize());
assertTrue(aseq.isPersistent());
assertEquals("diskstore", aseq.getDiskStoreName());
assertEquals(50, aseq.getMaximumQueueMemory());
}
private void testGatewaySender() throws Exception {
GatewaySenderFactoryBean gwsfb = ctx.getBean("&gateway-sender", GatewaySenderFactoryBean.class);
Cache cache = TestUtils.readField("cache", gwsfb);
assertNotNull(cache);
List<GatewayEventFilter> eventFilters = TestUtils.readField("eventFilters", gwsfb);
assertNotNull(eventFilters);
assertEquals(2, eventFilters.size());
assertTrue(eventFilters.get(0) instanceof TestEventFilter);
List<GatewayTransportFilter> transportFilters = TestUtils.readField("transportFilters", gwsfb);
assertNotNull(transportFilters);
assertEquals(2, transportFilters.size());
assertTrue(transportFilters.get(0) instanceof TestTransportFilter);
assertEquals(2, TestUtils.readField("remoteDistributedSystemId", gwsfb));
assertEquals(10, TestUtils.readField("alertThreshold", gwsfb));
assertEquals(11, TestUtils.readField("batchSize", gwsfb));
assertEquals(12, TestUtils.readField("dispatcherThreads", gwsfb));
assertEquals(true, TestUtils.readField("manualStart", gwsfb));
}
private void testInnerGatewaySender() {
Region<?, ?> region = ctx.getBean("region-inner-gateway-sender", Region.class);
GatewaySender gws = ctx.getBean("gateway-sender", GatewaySender.class);
assertNotNull(region.getAttributes().getGatewaySenders());
assertEquals(2, region.getAttributes().getGatewaySenders().size());
// Isolate the inner gateway
Set<GatewaySender> gatewaySenders = region.getAttributes().getGatewaySenders();
assertTrue(gatewaySenders.remove(gws));
gatewaySenders.remove(gws);
gws = gatewaySenders.iterator().next();
List<GatewayEventFilter> eventFilters = gws.getGatewayEventFilters();
assertNotNull(eventFilters);
assertEquals(1, eventFilters.size());
assertTrue(eventFilters.get(0) instanceof TestEventFilter);
List<GatewayTransportFilter> transportFilters = gws.getGatewayTransportFilters();
assertNotNull(transportFilters);
assertEquals(1, transportFilters.size());
assertTrue(transportFilters.get(0) instanceof TestTransportFilter);
assertEquals(1, gws.getRemoteDSId());
assertEquals(true, gws.isManualStart());
assertEquals(10, gws.getAlertThreshold());
assertEquals(11, gws.getBatchSize());
assertEquals(3000, gws.getBatchTimeInterval());
assertEquals(2, gws.getDispatcherThreads());
assertEquals("diskstore", gws.getDiskStoreName());
assertTrue(gws.isBatchConflationEnabled());
assertEquals(50, gws.getMaximumQueueMemory());
assertEquals(OrderPolicy.THREAD, gws.getOrderPolicy());
assertTrue(gws.isPersistenceEnabled());
assertTrue(gws.isParallel());
assertEquals(16536, gws.getSocketBufferSize());
assertEquals(3000, gws.getSocketReadTimeout());
}
private void testInnerGatewayReceiver() {
GatewayReceiver gwr = ctx.getBean("gateway-receiver", GatewayReceiver.class);
assertEquals(12345, gwr.getStartPort());
assertEquals(23456, gwr.getEndPort());
assertEquals("192.168.0.1", gwr.getBindAddress());
assertEquals(3000, gwr.getMaximumTimeBetweenPings());
assertEquals(16536, gwr.getSocketBufferSize());
}
@SuppressWarnings("rawtypes")
public static class TestEventFilter implements GatewayEventFilter {
@Override
public void close() {
// TODO Auto-generated method stub
}
@Override
public void afterAcknowledgement(AsyncEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public boolean beforeEnqueue(AsyncEvent arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean beforeTransmit(AsyncEvent arg0) {
// TODO Auto-generated method stub
return false;
}
}
public static class TestTransportFilter implements GatewayTransportFilter {
@Override
public void close() {
// TODO Auto-generated method stub
}
@Override
public InputStream getInputStream(InputStream arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public OutputStream getOutputStream(OutputStream arg0) {
// TODO Auto-generated method stub
return null;
}
}
@SuppressWarnings("rawtypes")
public static class TestAsyncEventListener implements AsyncEventListener {
@Override
public void close() {
// TODO Auto-generated method stub
}
@Override
public boolean processEvents(List<AsyncEvent> arg0) {
// TODO Auto-generated method stub
return false;
}
}
}

View File

@@ -38,11 +38,11 @@ import com.gemstone.gemfire.cache.query.IndexType;
@ContextConfiguration("index-ns.xml")
public class IndexNamespaceTest {
private String name = "test-index";
private final String name = "test-index";
@Autowired
private ApplicationContext context;
@Before
public void setUp() throws Exception {
Cache cache = (Cache) context.getBean("gemfire-cache");
@@ -52,7 +52,12 @@ public class IndexNamespaceTest {
}
@Test
public void testBasicIndex() throws Exception {
public void testAll() throws Exception {
testBasicIndex();
testComplexIndex();
}
private void testBasicIndex() throws Exception {
Index idx = (Index) context.getBean("simple");
assertEquals("/test-index", idx.getFromClause());
@@ -62,8 +67,7 @@ public class IndexNamespaceTest {
assertEquals(IndexType.FUNCTIONAL, idx.getType());
}
@Test
public void testComplexIndex() throws Exception {
private void testComplexIndex() throws Exception {
Index idx = (Index) context.getBean("complex");
assertEquals("/test-index tsi", idx.getFromClause());

View File

@@ -49,12 +49,20 @@ public class LocalRegionNamespaceTest {
private ApplicationContext context;
@Test
public void testBasicLocal() throws Exception {
public void testAll() throws Exception {
testBasicLocal();
testComplexLocal();
testLocalWithAttributes();
testPublishingLocal();
testRegionLookup();
}
private void testBasicLocal() throws Exception {
assertTrue(context.containsBean("simple"));
}
@Test
public void testPublishingLocal() throws Exception {
@SuppressWarnings("rawtypes")
private void testPublishingLocal() throws Exception {
assertTrue(context.containsBean("pub"));
RegionFactoryBean fb = context.getBean("&pub", RegionFactoryBean.class);
assertEquals("NORMAL", TestUtils.readField("dataPolicyName", fb));
@@ -64,8 +72,8 @@ public class LocalRegionNamespaceTest {
assertFalse(attrs.getPublisher());
}
@Test
public void testComplexLocal() throws Exception {
@SuppressWarnings("rawtypes")
private void testComplexLocal() throws Exception {
assertTrue(context.containsBean("complex"));
RegionFactoryBean fb = context.getBean("&complex", RegionFactoryBean.class);
CacheListener[] listeners = TestUtils.readField("cacheListeners", fb);
@@ -77,8 +85,8 @@ public class LocalRegionNamespaceTest {
assertSame(context.getBean("c-writer"), TestUtils.readField("cacheWriter", fb));
}
@Test
public void testLocalWithAttributes() throws Exception {
@SuppressWarnings("rawtypes")
private void testLocalWithAttributes() throws Exception {
assertTrue(context.containsBean("local-with-attributes"));
Region region = context.getBean("local-with-attributes", Region.class);
RegionAttributes attrs = region.getAttributes();
@@ -90,8 +98,8 @@ public class LocalRegionNamespaceTest {
assertEquals(true, attrs.isDiskSynchronous());
}
@Test
public void testRegionLookup() throws Exception {
@SuppressWarnings("rawtypes")
private void testRegionLookup() throws Exception {
Cache cache = context.getBean(Cache.class);
Region existing = cache.createRegionFactory().create("existing");
assertTrue(context.containsBean("lookup"));

View File

@@ -48,12 +48,18 @@ public class PartitionedRegionNamespaceTest {
private ApplicationContext context;
@Test
public void testBasicPartition() throws Exception {
public void testAll() throws Exception {
testBasicPartition();
testComplexPartition();
testPartitionOptions();
}
private void testBasicPartition() throws Exception {
assertTrue(context.containsBean("simple"));
}
@Test
public void testPartitionOptions() throws Exception {
@SuppressWarnings("rawtypes")
private void testPartitionOptions() throws Exception {
assertTrue(context.containsBean("options"));
RegionFactoryBean fb = context.getBean("&options", RegionFactoryBean.class);
assertTrue(fb instanceof PartitionedRegionFactoryBean);
@@ -70,8 +76,8 @@ public class PartitionedRegionNamespaceTest {
assertSame(SimplePartitionResolver.class, pAttr.getPartitionResolver().getClass());
}
@Test
public void testComplexPartition() throws Exception {
@SuppressWarnings("rawtypes")
private void testComplexPartition() throws Exception {
assertTrue(context.containsBean("complex"));
RegionFactoryBean fb = context.getBean("&complex", RegionFactoryBean.class);
CacheListener[] listeners = TestUtils.readField("cacheListeners", fb);

View File

@@ -46,7 +46,12 @@ public class PoolNamespaceTest {
private ApplicationContext context;
@Test
public void testBasicClient() throws Exception {
public void testAll() throws Exception {
testBasicClient();
testComplexPool();
}
private void testBasicClient() throws Exception {
assertTrue(context.containsBean("gemfire-pool"));
assertEquals(context.getBean("gemfire-pool"), PoolManager.find("gemfire-pool"));
PoolFactoryBean pfb = (PoolFactoryBean) context.getBean("&gemfire-pool");
@@ -57,8 +62,7 @@ public class PoolNamespaceTest {
assertEquals(40403, locator.getPort());
}
@Test
public void testComplexPool() throws Exception {
private void testComplexPool() throws Exception {
assertTrue(context.containsBean("complex"));
PoolFactoryBean pfb = (PoolFactoryBean) context.getBean("&complex");
assertEquals(30, TestUtils.readField("retryAttempts", pfb));

View File

@@ -50,12 +50,20 @@ public class ReplicatedRegionNamespaceTest {
private ApplicationContext context;
@Test
public void testBasicReplica() throws Exception {
public void testAll() throws Exception {
testBasicReplica();
testPublishingReplica();
testComplexReplica();
testRegionLookup();
testReplicaWithAttributes();
}
private void testBasicReplica() throws Exception {
assertTrue(context.containsBean("simple"));
}
@Test
public void testPublishingReplica() throws Exception {
@SuppressWarnings("rawtypes")
private void testPublishingReplica() throws Exception {
assertTrue(context.containsBean("pub"));
RegionFactoryBean fb = context.getBean("&pub", RegionFactoryBean.class);
assertTrue(fb instanceof ReplicatedRegionFactoryBean);
@@ -65,8 +73,8 @@ public class ReplicatedRegionNamespaceTest {
assertFalse(attrs.getPublisher());
}
@Test
public void testComplexReplica() throws Exception {
@SuppressWarnings("rawtypes")
private void testComplexReplica() throws Exception {
assertTrue(context.containsBean("complex"));
RegionFactoryBean fb = context.getBean("&complex", RegionFactoryBean.class);
CacheListener[] listeners = TestUtils.readField("cacheListeners", fb);
@@ -78,8 +86,8 @@ public class ReplicatedRegionNamespaceTest {
assertSame(context.getBean("c-writer"), TestUtils.readField("cacheWriter", fb));
}
@Test
public void testReplicaWithAttributes() throws Exception {
@SuppressWarnings("rawtypes")
private void testReplicaWithAttributes() throws Exception {
assertTrue(context.containsBean("replicated-with-attributes"));
Region region = context.getBean("replicated-with-attributes", Region.class);
RegionAttributes attrs = region.getAttributes();
@@ -99,8 +107,8 @@ public class ReplicatedRegionNamespaceTest {
assertEquals(true, attrs.getMulticastEnabled());
}
@Test
public void testRegionLookup() throws Exception {
@SuppressWarnings("rawtypes")
private void testRegionLookup() throws Exception {
Cache cache = context.getBean(Cache.class);
Region existing = cache.createRegionFactory().create("existing");
assertTrue(context.containsBean("lookup"));

View File

@@ -45,68 +45,71 @@ public class SubRegionNamespaceTest {
@Autowired
private ApplicationContext context;
@SuppressWarnings("rawtypes")
@Test
public void testNestedReplicatedRegions() {
Region parent = context.getBean("parent",Region.class);
public void testAll() throws Exception {
testComplexNestedRegions();
testMixedNestedRegions();
testNestedRegionsWithSiblings();
testNestedReplicatedRegions();
}
@SuppressWarnings("rawtypes")
private void testNestedReplicatedRegions() {
Region parent = context.getBean("parent", Region.class);
Region child = context.getBean("/parent/child", Region.class);
Region grandchild = context.getBean("/parent/child/grandchild", Region.class);
assertNotNull(child);
assertEquals("/parent/child",child.getFullPath());
assertSame(child,parent.getSubregion("child"));
assertEquals("/parent/child/grandchild",grandchild.getFullPath());
assertSame(grandchild,child.getSubregion("grandchild"));
assertEquals("/parent/child", child.getFullPath());
assertSame(child, parent.getSubregion("child"));
assertEquals("/parent/child/grandchild", grandchild.getFullPath());
assertSame(grandchild, child.getSubregion("grandchild"));
}
@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
@Test
public void testMixedNestedRegions() {
private void testMixedNestedRegions() {
Cache cache = context.getBean(Cache.class);
Region parent = context.getBean("replicatedParent",Region.class);
parent.createSubregion("lookupChild",new AttributesFactory().create());
Region parent = context.getBean("replicatedParent", Region.class);
parent.createSubregion("lookupChild", new AttributesFactory().create());
Region child = context.getBean("/replicatedParent/lookupChild", Region.class);
Region grandchild = context.getBean("/replicatedParent/lookupChild/partitionedGrandchild", Region.class);
assertNotNull(child);
assertEquals("/replicatedParent/lookupChild",child.getFullPath());
assertSame(child,parent.getSubregion("lookupChild"));
assertEquals("/replicatedParent/lookupChild/partitionedGrandchild",grandchild.getFullPath());
assertSame(grandchild,child.getSubregion("partitionedGrandchild"));
assertEquals("/replicatedParent/lookupChild", child.getFullPath());
assertSame(child, parent.getSubregion("lookupChild"));
assertEquals("/replicatedParent/lookupChild/partitionedGrandchild", grandchild.getFullPath());
assertSame(grandchild, child.getSubregion("partitionedGrandchild"));
}
@SuppressWarnings("rawtypes")
@Test
public void testNestedRegionsWithSiblings() {
Region parent = context.getBean("parentWithSiblings",Region.class);
Region child1 = context.getBean("/parentWithSiblings/child1",Region.class);
assertEquals("/parentWithSiblings/child1",child1.getFullPath());
Region child2 = context.getBean("/parentWithSiblings/child2",Region.class);
assertEquals("/parentWithSiblings/child2",child2.getFullPath());
assertSame(child1,parent.getSubregion("child1"));
assertSame(child2,parent.getSubregion("child2"));
Region grandchild1 = context.getBean("/parentWithSiblings/child1/grandChild11",Region.class);
assertEquals("/parentWithSiblings/child1/grandChild11",grandchild1.getFullPath());
private void testNestedRegionsWithSiblings() {
Region parent = context.getBean("parentWithSiblings", Region.class);
Region child1 = context.getBean("/parentWithSiblings/child1", Region.class);
assertEquals("/parentWithSiblings/child1", child1.getFullPath());
Region child2 = context.getBean("/parentWithSiblings/child2", Region.class);
assertEquals("/parentWithSiblings/child2", child2.getFullPath());
assertSame(child1, parent.getSubregion("child1"));
assertSame(child2, parent.getSubregion("child2"));
Region grandchild1 = context.getBean("/parentWithSiblings/child1/grandChild11", Region.class);
assertEquals("/parentWithSiblings/child1/grandChild11", grandchild1.getFullPath());
}
@SuppressWarnings({ "unused", "rawtypes" })
@Test
public void testComplexNestedRegions() throws Exception {
Region parent = context.getBean("complexNested",Region.class);
Region child1 = context.getBean("/complexNested/child1",Region.class);
Region child2 = context.getBean("/complexNested/child2",Region.class);
Region grandchild1 = context.getBean("/complexNested/child1/grandChild11",Region.class);
SubRegionFactoryBean grandchild1fb = context.getBean("&/complexNested/child1/grandChild11",SubRegionFactoryBean.class);
private void testComplexNestedRegions() throws Exception {
Region parent = context.getBean("complexNested", Region.class);
Region child1 = context.getBean("/complexNested/child1", Region.class);
Region child2 = context.getBean("/complexNested/child2", Region.class);
Region grandchild1 = context.getBean("/complexNested/child1/grandChild11", Region.class);
SubRegionFactoryBean grandchild1fb = context.getBean("&/complexNested/child1/grandChild11",
SubRegionFactoryBean.class);
assertNotNull(grandchild1fb);
RegionAttributes attr = grandchild1fb.create();
RegionAttributes attr = grandchild1fb.create();
assertNotNull(attr);
CacheLoader cl = attr.getCacheLoader();
assertNotNull(cl);

View File

@@ -52,6 +52,7 @@ public class TxEventHandlersTest {
@Resource(name = "gemfire-cache")
Cache cache;
@SuppressWarnings("rawtypes")
@Resource(name = "local")
Region local;

View File

@@ -15,10 +15,12 @@
*/
package org.springframework.data.gemfire.mapping;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
@@ -28,7 +30,6 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.TypedValue;
import com.gemstone.bp.edu.emory.mathcs.backport.java.util.Arrays;
import com.gemstone.gemfire.pdx.PdxReader;
/**
@@ -42,7 +43,6 @@ public class PdxReaderPropertyAccessorUnitTests {
PdxReader reader;
@Test
@SuppressWarnings("unchecked")
public void appliesToPdxReadersOnly() {
List<Class<?>> classes = Arrays.asList(PdxReaderPropertyAccessor.INSTANCE.getSpecificTargetClasses());
assertThat(classes, hasItem(PdxReader.class));

View File

@@ -15,12 +15,17 @@
*/
package org.springframework.data.gemfire.repository.sample;
import org.springframework.data.annotation.Id;
import org.springframework.data.gemfire.mapping.Region;
/**
*
* @author Oliver Gierke
*/
@Region("address")
public class Address {
@Id
public String zipCode;
public String city;
}

View File

@@ -15,13 +15,13 @@
*/
package org.springframework.data.gemfire.repository.support;
import java.util.Collections;
import org.junit.Test;
import org.springframework.data.gemfire.mapping.Regions;
import org.springframework.data.gemfire.repository.sample.PersonRepository;
import org.springframework.test.context.ContextConfiguration;
import com.gemstone.bp.edu.emory.mathcs.backport.java.util.Collections;
/**
* Integration test for {@link GemfireRepositoryFactory}.
*
@@ -41,7 +41,7 @@ public class GemfireRepositoryFactoryIntegrationTests extends AbstractGemfireRep
@SuppressWarnings("unchecked")
public void throwsExceptionIfReferencedRegionIsNotConfigured() {
GemfireRepositoryFactory factory = new GemfireRepositoryFactory(Collections.emptySet(), null);
GemfireRepositoryFactory factory = new GemfireRepositoryFactory((Iterable) Collections.emptySet(), null);
factory.getRepository(PersonRepository.class);
}
}