SGF-146 - improved test performance

This commit is contained in:
David Turanski
2013-01-07 18:38:04 -05:00
parent 2edbbff5ed
commit 7e96988184
58 changed files with 3989 additions and 600 deletions

View File

@@ -19,6 +19,11 @@ package org.springframework.data.gemfire;
import junit.framework.Assert;
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.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import com.gemstone.gemfire.cache.Cache;
@@ -30,12 +35,11 @@ import com.gemstone.gemfire.cache.Cache;
*
* @author Costin Leau
*/
public class CacheIntegrationTest extends RecreatingContextTest {
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/basic-cache.xml")
public class CacheIntegrationTest {
@Override
protected String location() {
return "org/springframework/data/gemfire/basic-cache.xml";
}
@Autowired ApplicationContext ctx;
@Test
public void testBasicCache() throws Exception {

View File

@@ -18,53 +18,74 @@ package org.springframework.data.gemfire;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.data.gemfire.test.StubCache;
import org.springframework.data.gemfire.test.MockRegionFactory;
import org.springframework.test.context.ContextConfiguration;
import com.gemstone.gemfire.cache.query.FunctionDomainException;
import com.gemstone.gemfire.cache.query.NameResolutionException;
import com.gemstone.gemfire.cache.query.Query;
import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
import com.gemstone.gemfire.cache.query.QueryService;
import com.gemstone.gemfire.cache.query.SelectResults;
import com.gemstone.gemfire.cache.query.TypeMismatchException;
/**
* @author Costin Leau
*/
public class GemfireTemplateTest extends RecreatingContextTest {
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/basic-template.xml")
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
protected String location() {
return "org/springframework/data/gemfire/basic-template.xml";
}
@Test
public void testAll() throws Exception {
testFind();
testFindUnique();
@Autowired GemfireTemplate template;
@SuppressWarnings("rawtypes")
@Before
public void setUp() throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException {
QueryService querySevice = MockRegionFactory.mockQueryService();
Query singleQuery = mock(Query.class);
when(singleQuery.execute(any(Object[].class))).thenReturn(0);
Query multipleQuery = mock(Query.class);
SelectResults selectResults = mock(SelectResults.class);
when(multipleQuery.execute(any(Object[].class))).thenReturn(selectResults);
when(querySevice.newQuery(SINGLE_QUERY)).thenReturn(singleQuery);
when(querySevice.newQuery(MULTI_QUERY)).thenReturn(multipleQuery);
}
@Test(expected = InvalidDataAccessApiUsageException.class)
public void testFindMultiException() throws Exception {
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
template.find(SINGLE_QUERY);
template.find(SINGLE_QUERY);
}
@Test(expected = InvalidDataAccessApiUsageException.class)
public void testFindMultiOne() throws Exception {
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
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);
@Test
public void testFind() throws Exception {
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);
@Test
public void testFindUnique() throws Exception {
Integer find = template.findUnique(SINGLE_QUERY);
assertEquals(find, Integer.valueOf(0));
}

View File

@@ -36,6 +36,7 @@ public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTest {
@Override
public void verify() {
Region region = regionFactoryBean.getRegion();
assertNotNull(region);
assertEquals(DataPolicy.DEFAULT, region.getAttributes().getDataPolicy());
}

View File

@@ -1,3 +1,18 @@
/*
* 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.*;
@@ -7,13 +22,18 @@ import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.client.ClientCache;
@RunWith(SpringJUnit4ClassRunner.class)
/**
*
* @author David Turanski
*
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("client-cache.xml")
public class ClientCacheTest {
@Resource(name="challengeQuestionsRegion")

View File

@@ -1,3 +1,18 @@
/*
* 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.assertSame;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2012 the original author or authors.
* 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.
@@ -27,8 +27,8 @@ 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.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.CacheListener;
import com.gemstone.gemfire.cache.CacheLoader;
@@ -42,8 +42,9 @@ import com.gemstone.gemfire.cache.util.CacheWriterAdapter;
/**
* @author Costin Leau
* @author David Turanski
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration(locations = { "basic-region.xml" })
public class RegionIntegrationTest {

View File

@@ -25,12 +25,16 @@ import static org.junit.Assert.assertThat;
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.core.io.Resource;
import org.springframework.data.gemfire.CacheFactoryBean;
import org.springframework.data.gemfire.GemfireBeanFactoryLocator;
import org.springframework.data.gemfire.RecreatingContextTest;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.util.ReflectionTestUtils;
import com.gemstone.gemfire.cache.Cache;
@@ -41,23 +45,13 @@ import com.gemstone.gemfire.cache.util.TimestampedEntryEvent;
/**
* @author Costin Leau
*/
public class CacheNamespaceTest extends RecreatingContextTest {
@Override
protected String location() {
return "org/springframework/data/gemfire/config/cache-ns.xml";
}
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/cache-ns.xml")
public class CacheNamespaceTest{
@Autowired ApplicationContext ctx;
@Test
public void testAll() throws Exception {
testBasicCache();
testNamedCache();
testCacheWithXml();
testHeapTunedCache();
testCacheWithGatewayConflictResolver();
}
private void testBasicCache() throws Exception {
public void testBasicCache() throws Exception {
assertTrue(ctx.containsBean("gemfireCache"));
//Check alias is registered
assertTrue(ctx.containsBean("gemfire-cache"));
@@ -67,14 +61,16 @@ public class CacheNamespaceTest extends RecreatingContextTest {
assertNull(TestUtils.readField("properties", cfb));
}
private void testNamedCache() throws Exception {
@Test
public 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));
}
private void testCacheWithXml() throws Exception {
@Test
public void testCacheWithXml() throws Exception {
assertTrue(ctx.containsBean("cache-with-xml"));
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&cache-with-xml");
Resource res = TestUtils.readField("cacheXml", cfb);
@@ -86,7 +82,8 @@ public class CacheNamespaceTest extends RecreatingContextTest {
}
private void testCacheWithGatewayConflictResolver() {
@Test
public void testCacheWithGatewayConflictResolver() {
Cache cache = ctx.getBean("cache-with-conflict-resolver", Cache.class);
assertNotNull(cache.getGatewayConflictResolver());
assertTrue(cache.getGatewayConflictResolver() instanceof TestConflictResolver);
@@ -97,7 +94,6 @@ public class CacheNamespaceTest extends RecreatingContextTest {
assertTrue(ctx.containsBean("no-bl"));
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&no-bl");
assertThat((Boolean) ReflectionTestUtils.getField(cfb, "useBeanFactoryLocator"), is(false));
assertThat(ReflectionTestUtils.getField(cfb, "factoryLocator"), is(nullValue()));
GemfireBeanFactoryLocator locator = new GemfireBeanFactoryLocator();
@@ -126,7 +122,8 @@ public class CacheNamespaceTest extends RecreatingContextTest {
assertEquals("gemfire-client-cache.xml", res.getFilename());
}
private void testHeapTunedCache() throws Exception {
@Test
public 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

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2012 the original author or authors.
* Copyright 2011-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.
@@ -20,25 +20,24 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.data.gemfire.RecreatingContextTest;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import com.gemstone.gemfire.cache.server.CacheServer;
/**
*
* @author Costin Leau
* @author David Turanski
*/
public class CacheServerNamespaceTest extends RecreatingContextTest {
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/server-ns.xml")
public class CacheServerNamespaceTest {
@Override
protected String location() {
return "org/springframework/data/gemfire/config/server-ns.xml";
}
@Test
public void testInitOrder() throws Exception {
// the test is actually executed through Init#afterPropertiesSet
}
@Autowired ApplicationContext ctx;
@Test
public void testBasicCacheServer() throws Exception {

View File

@@ -34,8 +34,8 @@ import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
import org.springframework.data.gemfire.client.Interest;
import org.springframework.data.gemfire.client.RegexInterest;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.ObjectUtils;
import com.gemstone.gemfire.cache.CacheListener;
@@ -52,22 +52,13 @@ import com.gemstone.gemfire.cache.util.ObjectSizer;
* @author Costin Leau
* @author David Turanski
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("client-ns.xml")
public class ClientRegionNamespaceTest {
@Autowired
private ApplicationContext context;
@Test
public void testAll() throws Exception {
testBasicClient();
testBeanNames();
testPublishingClient();
testPersistent();
testOverflowToDisk();
}
@AfterClass
public static void tearDown() {
@@ -82,16 +73,19 @@ public class ClientRegionNamespaceTest {
}
}
private void testBasicClient() throws Exception {
@Test
public void testBasicClient() throws Exception {
assertTrue(context.containsBean("simple"));
}
private void testBeanNames() throws Exception {
@Test
public void testBeanNames() throws Exception {
assertTrue(ObjectUtils.isEmpty(context.getAliases("publisher")));
}
@SuppressWarnings("rawtypes")
private void testPublishingClient() throws Exception {
@Test
public void testPublishingClient() throws Exception {
assertTrue(context.containsBean("empty"));
ClientRegionFactoryBean fb = context.getBean("&empty", ClientRegionFactoryBean.class);
assertEquals(DataPolicy.EMPTY, TestUtils.readField("dataPolicy", fb));
@@ -124,7 +118,8 @@ public class ClientRegionNamespaceTest {
}
@SuppressWarnings("rawtypes")
private void testPersistent() throws Exception {
@Test
public void testPersistent() throws Exception {
assertTrue(context.containsBean("persistent"));
Region region = context.getBean("persistent", Region.class);
RegionAttributes attrs = region.getAttributes();
@@ -133,7 +128,8 @@ public class ClientRegionNamespaceTest {
}
@SuppressWarnings("rawtypes")
private void testOverflowToDisk() throws Exception {
@Test
public void testOverflowToDisk() throws Exception {
assertTrue(context.containsBean("overflow"));
ClientRegionFactoryBean fb = context.getBean("&overflow", ClientRegionFactoryBean.class);
assertEquals(DataPolicy.NORMAL, TestUtils.readField("dataPolicy", fb));

View File

@@ -36,9 +36,8 @@ import org.springframework.data.gemfire.RegionFactoryBean;
import org.springframework.data.gemfire.ReplicatedRegionFactoryBean;
import org.springframework.data.gemfire.SimpleObjectSizer;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CustomExpiry;
import com.gemstone.gemfire.cache.DiskStore;
@@ -56,8 +55,9 @@ import com.gemstone.gemfire.cache.util.ObjectSizer;
/**
* @author Costin Leau
* @author David Turanski
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("diskstore-ns.xml")
public class DiskStoreAndEvictionRegionParsingTest {
@@ -96,16 +96,12 @@ public class DiskStoreAndEvictionRegionParsingTest {
}
}
@Test
public void testAll() throws Exception {
testDiskStore();
testReplicaDataOptions();
testPartitionDataOptions();
testEntryTtl();
testCustomExpiry();
}
private void testDiskStore() {
public void testDiskStore() {
assertNotNull(context.getBean("ds2"));
context.getBean("diskStore1");
assertNotNull(diskStore1);
assertEquals("diskStore1", diskStore1.getName());
assertEquals(50, diskStore1.getQueueSize());
assertEquals(true, diskStore1.getAutoCompact());
@@ -118,7 +114,8 @@ public class DiskStoreAndEvictionRegionParsingTest {
}
@SuppressWarnings("rawtypes")
private void testReplicaDataOptions() throws Exception {
@Test
public void testReplicaDataOptions() throws Exception {
assertTrue(context.containsBean("replicated-data"));
RegionFactoryBean fb = context.getBean("&replicated-data", RegionFactoryBean.class);
assertTrue(fb instanceof ReplicatedRegionFactoryBean);
@@ -135,7 +132,8 @@ public class DiskStoreAndEvictionRegionParsingTest {
}
@SuppressWarnings("rawtypes")
private void testPartitionDataOptions() throws Exception {
@Test
public void testPartitionDataOptions() throws Exception {
assertTrue(context.containsBean("partition-data"));
RegionFactoryBean fb = context.getBean("&partition-data", RegionFactoryBean.class);
assertTrue(fb instanceof PartitionedRegionFactoryBean);
@@ -153,7 +151,8 @@ public class DiskStoreAndEvictionRegionParsingTest {
}
@SuppressWarnings("rawtypes")
private void testEntryTtl() throws Exception {
@Test
public void testEntryTtl() throws Exception {
assertTrue(context.containsBean("replicated-data"));
RegionFactoryBean fb = context.getBean("&replicated-data", RegionFactoryBean.class);
RegionAttributes attrs = TestUtils.readField("attributes", fb);
@@ -177,7 +176,8 @@ public class DiskStoreAndEvictionRegionParsingTest {
@SuppressWarnings("rawtypes")
private void testCustomExpiry() throws Exception {
@Test
public void testCustomExpiry() throws Exception {
assertTrue(context.containsBean("replicated-data-custom-expiry"));
RegionFactoryBean fb = context.getBean("&replicated-data-custom-expiry", RegionFactoryBean.class);
RegionAttributes attrs = TestUtils.readField("attributes", fb);

View File

@@ -24,21 +24,27 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import org.junit.Test;
import org.springframework.data.gemfire.RecreatingContextTest;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.DynamicRegionFactory;
/**
* @author David Turanski
*
* This requires a real cache
*/
public class DynamicRegionNamespaceTest extends RecreatingContextTest {
@Override
protected String location() {
return "org/springframework/data/gemfire/config/dynamic-region-ns.xml";
}
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/dynamic-region-ns.xml")
public class DynamicRegionNamespaceTest {
@Autowired ApplicationContext ctx;
@Test
public void testBasicCache() throws Exception {
DynamicRegionFactory drf = DynamicRegionFactory.get();

View File

@@ -20,7 +20,10 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.data.gemfire.RecreatingContextTest;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import com.gemstone.gemfire.cache.execute.FunctionAdapter;
import com.gemstone.gemfire.cache.execute.FunctionContext;
@@ -29,13 +32,9 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
/**
* @author Costin Leau
*/
public class FunctionServiceNamespaceTest extends RecreatingContextTest {
@Override
protected String location() {
return "org/springframework/data/gemfire/config/function-service-ns.xml";
}
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/function-service-ns.xml")
public class FunctionServiceNamespaceTest {
@Test
public void testFunctionsRegistered() throws Exception {
assertEquals(2, FunctionService.getRegisteredFunctions().size());

View File

@@ -22,10 +22,16 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
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.RecreatingContextTest;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.data.gemfire.wan.GatewayHubFactoryBean;
import org.springframework.data.gemfire.wan.GatewayProxy;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
@@ -37,22 +43,14 @@ 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
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/gateway-v6-ns.xml")
public class GemfireV6GatewayNamespaceTest {
@Autowired ApplicationContext ctx;
@Test
public void test() throws Exception {
testGatewayHubFactoryBean();
testGatewaysInGemfire();
}
private void testGatewayHubFactoryBean() throws Exception {
public void testGatewayHubFactoryBean() throws Exception {
GatewayHubFactoryBean gwhfb = ctx.getBean("&gateway-hub", GatewayHubFactoryBean.class);
List<GatewayProxy> gateways = TestUtils.readField("gateways", gwhfb);
assertNotNull(gateways);
@@ -79,7 +77,8 @@ public class GemfireV6GatewayNamespaceTest extends RecreatingContextTest {
}
@SuppressWarnings("rawtypes")
private void testGatewaysInGemfire() {
@Test
public void testGatewaysInGemfire() {
Cache cache = ctx.getBean("gemfireCache", Cache.class);
GatewayHub gwh = cache.getGatewayHub("gateway-hub");
assertNotNull(gwh);

View File

@@ -31,13 +31,19 @@ import java.util.List;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.gemfire.RecreatingContextTest;
import org.springframework.data.gemfire.RegionFactoryBean;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.data.gemfire.wan.AsyncEventQueueFactoryBean;
import org.springframework.data.gemfire.wan.GatewaySenderFactoryBean;
import org.springframework.test.context.ContextConfiguration;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
@@ -59,38 +65,11 @@ import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
* @author David Turanski
*
*/
public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest implements BeanPostProcessor {
@Override
protected String location() {
return "/org/springframework/data/gemfire/config/gateway-v7-ns.xml";
}
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/gateway-v7-ns.xml")
public class GemfireV7GatewayNamespaceTest {
@Override
protected void configureContext() {
ctx.getBeanFactory().addBeanPostProcessor(this);
}
@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();
}
}
@Autowired ConfigurableApplicationContext ctx;
@AfterClass
public static void tearDown() {
@@ -108,7 +87,8 @@ public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest impleme
/**
*
*/
private void testAsyncEventQueue() {
@Test
public void testAsyncEventQueue() {
AsyncEventQueue aseq = ctx.getBean("async-event-queue", AsyncEventQueue.class);
assertEquals(10, aseq.getBatchSize());
assertTrue(aseq.isPersistent());
@@ -116,7 +96,8 @@ public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest impleme
assertEquals(50, aseq.getMaximumQueueMemory());
}
private void testGatewaySender() throws Exception {
@Test
public void testGatewaySender() throws Exception {
GatewaySenderFactoryBean gwsfb = ctx.getBean("&gateway-sender", GatewaySenderFactoryBean.class);
Cache cache = TestUtils.readField("cache", gwsfb);
assertNotNull(cache);
@@ -138,17 +119,13 @@ public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest impleme
}
@SuppressWarnings("rawtypes")
private void testInnerGatewaySender() throws Exception {
@Test
public void testInnerGatewaySender() throws Exception {
Region<?, ?> region = ctx.getBean("region-inner-gateway-sender", Region.class);
GatewaySender gws = ctx.getBean("gateway-sender", GatewaySender.class);
assertNotNull(region.getAttributes().getGatewaySenderIds());
assertEquals(2, region.getAttributes().getGatewaySenderIds().size());
// // Isolate the inner gateway
// Set<String> gatewaySenders = region.getAttributes().getGatewaySenderIds();
// assertTrue(gatewaySenders.remove(gws));
// gatewaySenders.remove(gws);
RegionFactoryBean rfb = ctx.getBean("&region-inner-gateway-sender", RegionFactoryBean.class);
Object[] gwsenders = TestUtils.readField("gatewaySenders", rfb);
gws = (GatewaySender)gwsenders[0];
@@ -179,7 +156,8 @@ public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest impleme
assertEquals(3000, gws.getSocketReadTimeout());
}
private void testInnerGatewayReceiver() {
@Test
public void testInnerGatewayReceiver() {
GatewayReceiver gwr = ctx.getBean("gateway-receiver", GatewayReceiver.class);
assertEquals(12345, gwr.getStartPort());
assertEquals(23456, gwr.getEndPort());
@@ -253,249 +231,6 @@ public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest impleme
}
}
public static class StubAsyncEventQueueFactory implements AsyncEventQueueFactory {
private AsyncEventListener listener;
private AsyncEventQueue asyncEventQueue = mock(AsyncEventQueue.class);
private boolean persistent;
private int maxQueueMemory;
private String diskStoreName;
private int batchSize;
private String name;
@Override
public AsyncEventQueue create(String name, AsyncEventListener listener) {
this.name = name;
this.listener = listener;
when(asyncEventQueue.getAsyncEventListener()).thenReturn(this.listener);
when(asyncEventQueue.getBatchSize()).thenReturn(this.batchSize);
when(asyncEventQueue.getDiskStoreName()).thenReturn(this.diskStoreName);
when(asyncEventQueue.isPersistent()).thenReturn(this.persistent);
when(asyncEventQueue.getId()).thenReturn(this.name);
when(asyncEventQueue.getMaximumQueueMemory()).thenReturn(this.maxQueueMemory);
return this.asyncEventQueue;
}
@Override
public AsyncEventQueueFactory setBatchSize(int batchSize) {
this.batchSize = batchSize;
return this;
}
@Override
public AsyncEventQueueFactory setDiskStoreName(String diskStoreName) {
this.diskStoreName = diskStoreName;
return this;
}
@Override
public AsyncEventQueueFactory setMaximumQueueMemory(int maxQueueMemory) {
this.maxQueueMemory = maxQueueMemory;
return this;
}
@Override
public AsyncEventQueueFactory setPersistent(boolean persistent) {
this.persistent = persistent;
return this;
}
@Override
public AsyncEventQueueFactory setParallel(boolean arg0) {
// TODO Auto-generated method stub
return null;
}
}
public static class StubGWSenderFactory implements GatewaySenderFactory {
private GatewaySender gatewaySender = mock(GatewaySender.class);
private int alertThreshold;
private boolean batchConflationEnabled;
private int batchSize;
private int batchTimeInterval;
private String diskStoreName;
private boolean diskSynchronous;
private int dispatcherThreads;
private boolean manualStart;
private int maxQueueMemory;
private OrderPolicy orderPolicy;
private boolean parallel;
private boolean persistenceEnabled;
private int socketBufferSize;
private int socketReadTimeout;
private List<GatewayEventFilter> eventFilters;
private List<GatewayTransportFilter> transportFilters;
private String name;
private int remoteSystemId;
public StubGWSenderFactory() {
this.eventFilters = new ArrayList<GatewayEventFilter>();
this.transportFilters = new ArrayList<GatewayTransportFilter>();
}
@Override
public GatewaySenderFactory addGatewayEventFilter(GatewayEventFilter filter) {
eventFilters.add(filter);
return this;
}
@Override
public GatewaySenderFactory addGatewayTransportFilter(GatewayTransportFilter filter) {
transportFilters.add(filter);
return this;
}
@Override
public GatewaySender create(String name, int remoteSystemId) {
this.name = name;
this.remoteSystemId = remoteSystemId;
when(gatewaySender.getId()).thenReturn(this.name);
when(gatewaySender.getRemoteDSId()).thenReturn(this.remoteSystemId);
when(gatewaySender.getAlertThreshold()).thenReturn(this.alertThreshold);
when(gatewaySender.getBatchSize()).thenReturn(this.batchSize);
when(gatewaySender.getBatchTimeInterval()).thenReturn(this.batchTimeInterval);
when(gatewaySender.getDiskStoreName()).thenReturn(this.diskStoreName);
when(gatewaySender.getDispatcherThreads()).thenReturn(this.dispatcherThreads);
when(gatewaySender.getGatewayEventFilters()).thenReturn(this.eventFilters);
when(gatewaySender.getGatewayTransportFilters()).thenReturn(this.transportFilters);
when(gatewaySender.getMaximumQueueMemory()).thenReturn(this.maxQueueMemory);
when(gatewaySender.getOrderPolicy()).thenReturn(this.orderPolicy);
when(gatewaySender.getSocketBufferSize()).thenReturn(this.socketBufferSize);
when(gatewaySender.getSocketReadTimeout()).thenReturn(this.socketReadTimeout);
when(gatewaySender.isManualStart()).thenReturn(this.manualStart);
when(gatewaySender.isBatchConflationEnabled()).thenReturn(this.batchConflationEnabled);
when(gatewaySender.isDiskSynchronous()).thenReturn(this.diskSynchronous);
when(gatewaySender.isParallel()).thenReturn(this.parallel);
when(gatewaySender.isPersistenceEnabled()).thenReturn(this.persistenceEnabled);
return gatewaySender;
}
@Override
public GatewaySenderFactory removeGatewayEventFilter(GatewayEventFilter filter) {
gatewaySender.removeGatewayEventFilter(filter);
return this;
}
@Override
public GatewaySenderFactory setAlertThreshold(int alertThreshold) {
this.alertThreshold = alertThreshold;
return this;
}
@Override
public GatewaySenderFactory setBatchConflationEnabled(boolean batchConflationEnabled) {
this.batchConflationEnabled = batchConflationEnabled;
return this;
}
@Override
public GatewaySenderFactory setBatchSize(int batchSize) {
this.batchSize = batchSize;
return this;
}
@Override
public GatewaySenderFactory setBatchTimeInterval(int batchTimeInterval) {
this.batchTimeInterval = batchTimeInterval;
return this;
}
@Override
public GatewaySenderFactory setDiskStoreName(String diskStoreName) {
this.diskStoreName = diskStoreName;
return this;
}
@Override
public GatewaySenderFactory setDiskSynchronous(boolean diskSynchronous) {
this.diskSynchronous = diskSynchronous;
return this;
}
@Override
public GatewaySenderFactory setDispatcherThreads(int dispatcherThreads) {
this.dispatcherThreads = dispatcherThreads;
return this;
}
@Override
public GatewaySenderFactory setManualStart(boolean manualStart) {
this.manualStart = manualStart;
return this;
}
@Override
public GatewaySenderFactory setMaximumQueueMemory(int maxQueueMemory) {
this.maxQueueMemory = maxQueueMemory;
return this;
}
@Override
public GatewaySenderFactory setOrderPolicy(OrderPolicy orderPolicy) {
this.orderPolicy = orderPolicy;
return this;
}
@Override
public GatewaySenderFactory setParallel(boolean parallel) {
this.parallel = parallel;
return this;
}
@Override
public GatewaySenderFactory setPersistenceEnabled(boolean persistenceEnabled) {
this.persistenceEnabled = persistenceEnabled;
return this;
}
@Override
public GatewaySenderFactory setSocketBufferSize(int socketBufferSize) {
this.socketBufferSize = socketBufferSize;
return this;
}
@Override
public GatewaySenderFactory setSocketReadTimeout(int socketReadTimeout) {
this.socketReadTimeout = socketReadTimeout;
return this;
}
@Override
public GatewaySenderFactory removeGatewayTransportFilter(
GatewayTransportFilter arg0) {
// TODO Auto-generated method stub
return null;
}
}
/*
* This mocks out the WAN components which are disabled in the developer edition
*/
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof GatewaySenderFactoryBean) {
((GatewaySenderFactoryBean)bean).setFactory(new StubGWSenderFactory());
}
if (bean instanceof AsyncEventQueueFactoryBean) {
((AsyncEventQueueFactoryBean)bean).setFactory(new StubAsyncEventQueueFactory());
}
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
}

View File

@@ -23,6 +23,7 @@ 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.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -34,7 +35,7 @@ import com.gemstone.gemfire.cache.query.IndexType;
*
* @author Costin Leau
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("index-ns.xml")
public class IndexNamespaceTest {
@@ -52,12 +53,7 @@ public class IndexNamespaceTest {
}
@Test
public void testAll() throws Exception {
testBasicIndex();
testComplexIndex();
}
private void testBasicIndex() throws Exception {
public void testBasicIndex() throws Exception {
Index idx = (Index) context.getBean("simple");
assertEquals("/test-index", idx.getFromClause());
@@ -67,7 +63,8 @@ public class IndexNamespaceTest {
assertEquals(IndexType.FUNCTIONAL, idx.getType());
}
private void testComplexIndex() throws Exception {
@Test
public void testComplexIndex() throws Exception {
Index idx = (Index) context.getBean("complex");
assertEquals("/test-index tsi", idx.getFromClause());

View File

@@ -19,7 +19,11 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.springframework.data.gemfire.RecreatingContextTest;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.internal.datasource.GemFireBasicDataSource;
@@ -27,13 +31,13 @@ import com.gemstone.gemfire.internal.datasource.GemFireBasicDataSource;
/**
* @author David Turanski
*
* This test requires a real cache
*/
public class JndiBindingsTest extends RecreatingContextTest {
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/jndi-binding-ns.xml")
public class JndiBindingsTest {
@Override
protected String location() {
return "org/springframework/data/gemfire/config/jndi-binding-ns.xml";
}
@Autowired ApplicationContext ctx;
@Test
public void testJndiBindings() throws Exception {

View File

@@ -18,9 +18,9 @@ package org.springframework.data.gemfire.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,8 +29,8 @@ import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.RegionFactoryBean;
import org.springframework.data.gemfire.RegionLookupFactoryBean;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.ObjectUtils;
import com.gemstone.gemfire.cache.Cache;
@@ -42,28 +42,22 @@ import com.gemstone.gemfire.cache.Scope;
/**
* @author Costin Leau
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("local-ns.xml")
public class LocalRegionNamespaceTest {
@Autowired
private ApplicationContext context;
@Test
public void testAll() throws Exception {
testBasicLocal();
testComplexLocal();
testLocalWithAttributes();
testPublishingLocal();
testRegionLookup();
}
private void testBasicLocal() throws Exception {
public void testBasicLocal() throws Exception {
assertTrue(context.containsBean("simple"));
}
@SuppressWarnings("rawtypes")
private void testPublishingLocal() throws Exception {
@Test
public void testPublishingLocal() throws Exception {
assertTrue(context.containsBean("pub"));
RegionFactoryBean fb = context.getBean("&pub", RegionFactoryBean.class);
assertNull(TestUtils.readField("dataPolicy", fb));
@@ -74,7 +68,8 @@ public class LocalRegionNamespaceTest {
}
@SuppressWarnings("rawtypes")
private void testComplexLocal() throws Exception {
@Test
public void testComplexLocal() throws Exception {
assertTrue(context.containsBean("complex"));
RegionFactoryBean fb = context.getBean("&complex", RegionFactoryBean.class);
CacheListener[] listeners = TestUtils.readField("cacheListeners", fb);
@@ -87,7 +82,8 @@ public class LocalRegionNamespaceTest {
}
@SuppressWarnings("rawtypes")
private void testLocalWithAttributes() throws Exception {
@Test
public void testLocalWithAttributes() throws Exception {
assertTrue(context.containsBean("local-with-attributes"));
Region region = context.getBean("local-with-attributes", Region.class);
RegionAttributes attrs = region.getAttributes();
@@ -100,9 +96,11 @@ public class LocalRegionNamespaceTest {
}
@SuppressWarnings("rawtypes")
private void testRegionLookup() throws Exception {
@Test
public void testRegionLookup() throws Exception {
Cache cache = context.getBean(Cache.class);
Region existing = cache.createRegionFactory().create("existing");
assertTrue(context.containsBean("lookup"));
RegionLookupFactoryBean lfb = context.getBean("&lookup", RegionLookupFactoryBean.class);
assertEquals("existing", TestUtils.readField("name", lfb));

View File

@@ -20,7 +20,12 @@ import static org.junit.Assert.assertFalse;
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.RecreatingContextTest;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import com.gemstone.gemfire.cache.LossAction;
import com.gemstone.gemfire.cache.MembershipAttributes;
@@ -32,12 +37,11 @@ import com.gemstone.gemfire.distributed.Role;
* @author David Turanski
*
*/
public class MembershipAttributesTest extends RecreatingContextTest {
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/membership-attributes-ns.xml")
public class MembershipAttributesTest {
@Override
protected String location() {
return "org/springframework/data/gemfire/config/membership-attributes-ns.xml";
}
@Autowired ApplicationContext ctx;
@Test
public void testMembershipAttributes() {

View File

@@ -30,8 +30,8 @@ import org.springframework.data.gemfire.PartitionedRegionFactoryBean;
import org.springframework.data.gemfire.RegionFactoryBean;
import org.springframework.data.gemfire.SimplePartitionResolver;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.ObjectUtils;
import com.gemstone.gemfire.cache.CacheListener;
@@ -43,28 +43,24 @@ import com.gemstone.gemfire.cache.partition.PartitionListener;
/**
* @author Costin Leau
* @author David Turanski
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("partitioned-ns.xml")
public class PartitionedRegionNamespaceTest {
@Autowired
private ApplicationContext context;
@Test
public void testAll() throws Exception {
testBasicPartition();
testComplexPartition();
testPartitionOptions();
testFixedPartition();
}
private void testBasicPartition() throws Exception {
public void testBasicPartition() throws Exception {
assertTrue(context.containsBean("simple"));
}
@SuppressWarnings("rawtypes")
private void testPartitionOptions() throws Exception {
@Test
public void testPartitionOptions() throws Exception {
assertTrue(context.containsBean("options"));
RegionFactoryBean fb = context.getBean("&options",
RegionFactoryBean.class);
@@ -84,7 +80,8 @@ public class PartitionedRegionNamespaceTest {
}
@SuppressWarnings("rawtypes")
private void testComplexPartition() throws Exception {
@Test
public void testComplexPartition() throws Exception {
assertTrue(context.containsBean("complex"));
RegionFactoryBean fb = context.getBean("&complex",
RegionFactoryBean.class);
@@ -108,6 +105,7 @@ public class PartitionedRegionNamespaceTest {
}
@SuppressWarnings("rawtypes")
@Test
public void testFixedPartition() throws Exception {
RegionFactoryBean fb = context.getBean("&fixed",
RegionFactoryBean.class);

View File

@@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.client.PoolFactoryBean;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -38,7 +39,7 @@ import com.gemstone.gemfire.cache.client.PoolManager;
/**
* @author Costin Leau
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("pool-ns.xml")
public class PoolNamespaceTest {

View File

@@ -29,8 +29,8 @@ import org.springframework.data.gemfire.RegionFactoryBean;
import org.springframework.data.gemfire.RegionLookupFactoryBean;
import org.springframework.data.gemfire.ReplicatedRegionFactoryBean;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.ObjectUtils;
import com.gemstone.gemfire.cache.Cache;
@@ -41,8 +41,9 @@ import com.gemstone.gemfire.cache.Scope;
/**
* @author Costin Leau
* @author David Turanski
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("replicated-ns.xml")
public class ReplicatedRegionNamespaceTest {
@@ -50,20 +51,13 @@ public class ReplicatedRegionNamespaceTest {
private ApplicationContext context;
@Test
public void testAll() throws Exception {
testBasicReplica();
testPublishingReplica();
testComplexReplica();
testRegionLookup();
testReplicaWithAttributes();
}
private void testBasicReplica() throws Exception {
public void testBasicReplica() throws Exception {
assertTrue(context.containsBean("simple"));
}
@SuppressWarnings("rawtypes")
private void testPublishingReplica() throws Exception {
@Test
public void testPublishingReplica() throws Exception {
assertTrue(context.containsBean("pub"));
RegionFactoryBean fb = context.getBean("&pub", RegionFactoryBean.class);
assertTrue(fb instanceof ReplicatedRegionFactoryBean);
@@ -74,7 +68,8 @@ public class ReplicatedRegionNamespaceTest {
}
@SuppressWarnings("rawtypes")
private void testComplexReplica() throws Exception {
@Test
public void testComplexReplica() throws Exception {
assertTrue(context.containsBean("complex"));
RegionFactoryBean fb = context.getBean("&complex", RegionFactoryBean.class);
CacheListener[] listeners = TestUtils.readField("cacheListeners", fb);
@@ -87,10 +82,12 @@ public class ReplicatedRegionNamespaceTest {
}
@SuppressWarnings("rawtypes")
private void testReplicaWithAttributes() throws Exception {
@Test
public void testReplicaWithAttributes() throws Exception {
assertTrue(context.containsBean("replicated-with-attributes"));
Region region = context.getBean("replicated-with-attributes", Region.class);
RegionAttributes attrs = region.getAttributes();
assertEquals(10, attrs.getInitialCapacity());
assertEquals(true, attrs.getIgnoreJTA());
assertEquals(false, attrs.getIndexMaintenanceSynchronous());
@@ -98,7 +95,7 @@ public class ReplicatedRegionNamespaceTest {
assertEquals(String.class, attrs.getValueConstraint());
assertEquals(true, attrs.isDiskSynchronous());
assertEquals(Scope.GLOBAL, attrs.getScope());
assertEquals(true, attrs.isLockGrantor());
//assertEquals(true, attrs.isLockGrantor());
assertEquals(true, attrs.getEnableAsyncConflation());
assertEquals(true, attrs.getEnableSubscriptionConflation());
assertEquals(0.50, attrs.getLoadFactor(), 0.001);
@@ -108,7 +105,8 @@ public class ReplicatedRegionNamespaceTest {
}
@SuppressWarnings("rawtypes")
private void testRegionLookup() throws Exception {
@Test
public void testRegionLookup() throws Exception {
Cache cache = context.getBean(Cache.class);
Region existing = cache.createRegionFactory().create("existing");
assertTrue(context.containsBean("lookup"));
@@ -116,4 +114,5 @@ public class ReplicatedRegionNamespaceTest {
assertEquals("existing", TestUtils.readField("name", lfb));
assertEquals(existing, context.getBean("lookup"));
}
}

View File

@@ -25,6 +25,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.SubRegionFactoryBean;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -38,23 +39,18 @@ import com.gemstone.gemfire.cache.RegionAttributes;
* @author David Turanski
*/
@SuppressWarnings("deprecation")
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("subregion-ns.xml")
public class SubRegionNamespaceTest {
@Autowired
private ApplicationContext context;
@Test
public void testAll() throws Exception {
testComplexNestedRegions();
testMixedNestedRegions();
testNestedRegionsWithSiblings();
testNestedReplicatedRegions();
}
@SuppressWarnings("rawtypes")
private void testNestedReplicatedRegions() {
@Test
public 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);
@@ -68,7 +64,8 @@ public class SubRegionNamespaceTest {
}
@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
private void testMixedNestedRegions() {
@Test
public void testMixedNestedRegions() {
Cache cache = context.getBean(Cache.class);
Region parent = context.getBean("replicatedParent", Region.class);
@@ -86,7 +83,8 @@ public class SubRegionNamespaceTest {
}
@SuppressWarnings("rawtypes")
private void testNestedRegionsWithSiblings() {
@Test
public void testNestedRegionsWithSiblings() {
Region parent = context.getBean("parentWithSiblings", Region.class);
Region child1 = context.getBean("/parentWithSiblings/child1", Region.class);
assertEquals("/parentWithSiblings/child1", child1.getFullPath());
@@ -100,7 +98,8 @@ public class SubRegionNamespaceTest {
}
@SuppressWarnings({ "unused", "rawtypes" })
private void testComplexNestedRegions() throws Exception {
@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);

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.gemfire.config;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import javax.annotation.Resource;
@@ -25,6 +26,7 @@ import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
@@ -37,7 +39,7 @@ import com.gemstone.gemfire.cache.TransactionWriterException;
* @author David Turanski
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("tx-listeners-and-writers.xml")
public class TxEventHandlersTest {
@Autowired
@@ -52,19 +54,16 @@ public class TxEventHandlersTest {
@Resource(name = "gemfireCache")
Cache cache;
@SuppressWarnings("rawtypes")
@Resource(name = "local")
Region local;
@Test
public void test() throws Exception {
cache.getCacheTransactionManager().begin();
local.put("hello", "world");
cache.getCacheTransactionManager().commit();
assertEquals("txListener1", txListener1.value);
assertEquals("txListener2", txListener2.value);
assertEquals("txWriter", txWriter.value);
TransactionListener[] listeners = cache.getCacheTransactionManager().getListeners();
assertEquals(2,listeners.length);
assertSame(txListener1,listeners[0]);
assertSame(txListener2,listeners[1]);
assertSame(txWriter,cache.getCacheTransactionManager().getWriter());
}
public static class TestListener implements TransactionListener, BeanNameAware {

View File

@@ -20,18 +20,22 @@ import static org.junit.Assert.assertFalse;
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.GemfireTransactionManager;
import org.springframework.data.gemfire.RecreatingContextTest;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.ContextConfiguration;
/**
* @author Costin Leau
*/
public class TxManagerNamespaceTest extends RecreatingContextTest {
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/tx-ns.xml")
public class TxManagerNamespaceTest {
@Override
protected String location() {
return "org/springframework/data/gemfire/config/tx-ns.xml";
}
@Autowired ApplicationContext ctx;
@Test
public void testBasicCache() throws Exception {

View File

@@ -29,7 +29,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.execute.Function;
import com.gemstone.gemfire.cache.execute.FunctionService;
/**
* @author David Turanski
*

View File

@@ -29,12 +29,12 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Region;
import org.springframework.data.gemfire.test.GemfireTestRunner;
/**
* @author David Turanski
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration(classes={TestConfig.class})
public class FunctionExecutionIntegrationTests {
@Autowired

View File

@@ -24,15 +24,14 @@ import org.springframework.data.gemfire.function.config.two.TestOnRegionFunction
import org.springframework.data.gemfire.function.execution.GemfireOnRegionFunctionTemplate;
import org.springframework.data.gemfire.function.execution.OnRegionFunctionProxyFactoryBean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import com.gemstone.gemfire.cache.Region;
/**
* @author David Turanski
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(GemfireTestRunner.class)
@ContextConfiguration
public class XmlConfiguredFunctionExecutionIntegrationTests {
@Autowired

View File

@@ -26,6 +26,7 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.data.gemfire.CacheFactoryBean;
import org.springframework.data.gemfire.RegionFactoryBean;
import org.springframework.data.gemfire.test.StubCache;
import com.gemstone.gemfire.cache.GemFireCache;
@@ -40,10 +41,8 @@ public abstract class AbstractRegionFactoryBeanTest {
@Before
public void setUp() throws Exception {
CacheFactoryBean cfb = new CacheFactoryBean();
cfb.setBeanName("gemfireCache");
cfb.setUseBeanFactoryLocator(false);
cache = cfb.getObject();
cache = new StubCache();
}
@Test

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2002-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.test;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.model.InitializationError;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
/**
* @author David Turanski
*
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration
public class GemfireTestRunnerTest {
@Test
public void test() {
}
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2002-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.test;
/**
* @author David Turanski
*
*/
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;
import org.junit.Test;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionFactory;
import com.gemstone.gemfire.cache.Scope;
public class MockRegionFactoryTest {
@Test
public void testBasicAttributes() {
RegionFactory<?,?> rf = new MockRegionFactory<Object,Object>(new StubCache()).createMockRegionFactory();
rf.setScope(Scope.LOCAL);
Region<?,?> foo = rf.create("foo");
assertEquals(Scope.LOCAL,foo.getAttributes().getScope());
}
}