Refactored tests to use Spring 3.2 @ContextConfiguration(initializers=... and moved test support classes to src/test/java. Also upgraded to Spring 3.2.1

This commit is contained in:
David Turanski
2013-02-05 08:32:19 -05:00
parent b48ff6fb34
commit c45677c99d
49 changed files with 289 additions and 688 deletions

View File

@@ -5,20 +5,20 @@ log4jVersion = 1.2.16
slf4jVersion = 1.6.4
# Common libraries
springVersion = 3.2.0.RELEASE
springVersion = 3.2.1.RELEASE
springDataCommonsVersion = 1.5.0.BUILD-SNAPSHOT
gemfireVersion = 7.0
# Testing
junitVersion = 4.8.2
mockitoVersion = 1.8.5
mockitoVersion = 1.9.0
hamcrestVersion = 1.2.1
cglibVersion = 2.2
# Manifest properties
## OSGi ranges
spring.range = "[3.0.0, 4.0.0)"
spring.range = "[3.2.0, 4.0.0)"
gemfire.range = "[6.5, 8.0)"
# --------------------

View File

@@ -1,39 +0,0 @@
/*
* Copyright 2002-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.test;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.util.StringUtils;
/**
* @author David Turanski
*
*/
class ContextLoaderUtils {
/**
*
*/
static private Log logger = LogFactory.getLog(ContextLoaderUtils.class);
static void customizeBeanFactory(DefaultListableBeanFactory beanFactory) {
if (StringUtils.hasText(System.getProperty(GemfireTestRunner.GEMFIRE_TEST_RUNNER_DISABLED))) {
String value = System.getProperty(GemfireTestRunner.GEMFIRE_TEST_RUNNER_DISABLED);
if (!(value.equalsIgnoreCase("NO") || value.equalsIgnoreCase("FALSE"))) {
logger.warn("Mocks disabled using real GemFire components:" + GemfireTestRunner.GEMFIRE_TEST_RUNNER_DISABLED + " = " + System.getProperty(GemfireTestRunner.GEMFIRE_TEST_RUNNER_DISABLED));
return;
}
}
beanFactory.addBeanPostProcessor(new GemfireTestBeanPostProcessor());
}
}

View File

@@ -1,27 +0,0 @@
/*
* Copyright 2002-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.test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
/**
* @author David Turanski
*
*/
public class GemfireAnnotationConfigContextLoader extends AnnotationConfigContextLoader {
@Override
protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory) {
ContextLoaderUtils.customizeBeanFactory(beanFactory);
}
}

View File

@@ -1,277 +0,0 @@
/*
* Copyright 2002-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.test;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextConfigurationAttributes;
import org.springframework.test.context.ContextLoader;
import org.springframework.test.context.MergedContextConfiguration;
import org.springframework.test.context.SmartContextLoader;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.test.context.support.DelegatingSmartContextLoader;
import org.springframework.test.context.support.GenericXmlContextLoader;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* @author David Turanski
*
*/
/*
* Copyright 2002-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.
*/
/**
* {@code DelegatingSmartContextLoader} is an implementation of the {@link SmartContextLoader}
* SPI that delegates to a set of <em>candidate</em> SmartContextLoaders (i.e.,
* {@link GenericXmlContextLoader} and {@link AnnotationConfigContextLoader}) to
* determine which context loader is appropriate for a given test class's configuration.
* Each candidate is given a chance to {@link #processContextConfiguration process} the
* {@link ContextConfigurationAttributes} for each class in the test class hierarchy that
* is annotated with {@link ContextConfiguration @ContextConfiguration}, and the candidate
* that supports the merged, processed configuration will be used to actually
* {@link #loadContext load} the context.
*
* <p>Placing an empty {@code @ContextConfiguration} annotation on a test class signals
* that default resource locations (i.e., XML configuration files) or default
* {@link org.springframework.context.annotation.Configuration configuration classes}
* should be detected. Furthermore, if a specific {@link ContextLoader} or
* {@link SmartContextLoader} is not explicitly declared via
* {@code @ContextConfiguration}, {@code DelegatingSmartContextLoader} will be used as
* the default loader, thus providing automatic support for either XML configuration
* files or configuration classes, but not both simultaneously.
*
* @author Sam Brannen
* @author David Turanski
* Replaces {@link DelegatingSmartContextLoader}
*/
public class GemfireSmartContextLoader implements SmartContextLoader {
private static final Log logger = LogFactory.getLog(GemfireSmartContextLoader.class);
private final SmartContextLoader xmlLoader = new GemfireXmlContextLoader();
private final SmartContextLoader annotationConfigLoader = new GemfireAnnotationConfigContextLoader();
// --- SmartContextLoader --------------------------------------------------
private static String name(SmartContextLoader loader) {
return loader.getClass().getSimpleName();
}
private static void delegateProcessing(SmartContextLoader loader, ContextConfigurationAttributes configAttributes) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Delegating to %s to process context configuration %s.", name(loader),
configAttributes));
}
loader.processContextConfiguration(configAttributes);
}
private static boolean supports(SmartContextLoader loader, MergedContextConfiguration mergedConfig) {
if (loader instanceof GemfireAnnotationConfigContextLoader) {
return ObjectUtils.isEmpty(mergedConfig.getLocations()) && !ObjectUtils.isEmpty(mergedConfig.getClasses());
}
else {
return !ObjectUtils.isEmpty(mergedConfig.getLocations()) && ObjectUtils.isEmpty(mergedConfig.getClasses());
}
}
/**
* Delegates to candidate {@code SmartContextLoaders} to process the supplied
* {@link ContextConfigurationAttributes}.
*
* <p>Delegation is based on explicit knowledge of the implementations of
* {@link GenericXmlContextLoader} and {@link AnnotationConfigContextLoader}.
* Specifically, the delegation algorithm is as follows:
*
* <ul>
* <li>If the resource locations or configuration classes in the supplied
* {@code ContextConfigurationAttributes} are not empty, the appropriate
* candidate loader will be allowed to process the configuration <em>as is</em>,
* without any checks for detection of defaults.</li>
* <li>Otherwise, {@code GenericXmlContextLoader} will be allowed to process
* the configuration in order to detect default resource locations. If
* {@code GenericXmlContextLoader} detects default resource locations,
* an {@code info} message will be logged.</li>
* <li>Subsequently, {@code AnnotationConfigContextLoader} will be allowed to
* process the configuration in order to detect default configuration classes.
* If {@code AnnotationConfigContextLoader} detects default configuration
* classes, an {@code info} message will be logged.</li>
* </ul>
*
* @param configAttributes the context configuration attributes to process
* @throws IllegalArgumentException if the supplied configuration attributes are
* <code>null</code>, or if the supplied configuration attributes include both
* resource locations and configuration classes
* @throws IllegalStateException if {@code GenericXmlContextLoader} detects default
* configuration classes; if {@code AnnotationConfigContextLoader} detects default
* resource locations; if neither candidate loader detects defaults for the supplied
* context configuration; or if both candidate loaders detect defaults for the
* supplied context configuration
*/
public void processContextConfiguration(final ContextConfigurationAttributes configAttributes) {
Assert.notNull(configAttributes, "configAttributes must not be null");
Assert.isTrue(!(configAttributes.hasLocations() && configAttributes.hasClasses()), String.format(
"Cannot process locations AND configuration classes for context "
+ "configuration %s; configure one or the other, but not both.", configAttributes));
// If the original locations or classes were not empty, there's no
// need to bother with default detection checks; just let the
// appropriate loader process the configuration.
if (configAttributes.hasLocations()) {
delegateProcessing(xmlLoader, configAttributes);
}
else if (configAttributes.hasClasses()) {
delegateProcessing(annotationConfigLoader, configAttributes);
}
else {
// Else attempt to detect defaults...
// Let the XML loader process the configuration.
delegateProcessing(xmlLoader, configAttributes);
boolean xmlLoaderDetectedDefaults = configAttributes.hasLocations();
if (xmlLoaderDetectedDefaults) {
if (logger.isInfoEnabled()) {
logger.info(String.format("%s detected default locations for context configuration %s.",
name(xmlLoader), configAttributes));
}
}
if (configAttributes.hasClasses()) {
throw new IllegalStateException(String.format(
"%s should NOT have detected default configuration classes for context configuration %s.",
name(xmlLoader), configAttributes));
}
// Now let the annotation config loader process the configuration.
delegateProcessing(annotationConfigLoader, configAttributes);
if (configAttributes.hasClasses()) {
if (logger.isInfoEnabled()) {
logger.info(String.format(
"%s detected default configuration classes for context configuration %s.",
name(annotationConfigLoader), configAttributes));
}
}
if (!xmlLoaderDetectedDefaults && configAttributes.hasLocations()) {
throw new IllegalStateException(String.format(
"%s should NOT have detected default locations for context configuration %s.",
name(annotationConfigLoader), configAttributes));
}
// If neither loader detected defaults, throw an exception.
if (!configAttributes.hasResources()) {
throw new IllegalStateException(String.format(
"Neither %s nor %s was able to detect defaults for context configuration %s.", name(xmlLoader),
name(annotationConfigLoader), configAttributes));
}
if (configAttributes.hasLocations() && configAttributes.hasClasses()) {
String message = String.format(
"Configuration error: both default locations AND default configuration classes "
+ "were detected for context configuration %s; configure one or the other, but not both.",
configAttributes);
logger.error(message);
throw new IllegalStateException(message);
}
}
}
/**
* Delegates to an appropriate candidate {@code SmartContextLoader} to load
* an {@link ApplicationContext}.
*
* <p>Delegation is based on explicit knowledge of the implementations of
* {@link GenericXmlContextLoader} and {@link AnnotationConfigContextLoader}.
* Specifically, the delegation algorithm is as follows:
*
* <ul>
* <li>If the resource locations in the supplied {@code MergedContextConfiguration}
* are not empty and the configuration classes are empty,
* {@code GenericXmlContextLoader} will load the {@code ApplicationContext}.</li>
* <li>If the configuration classes in the supplied {@code MergedContextConfiguration}
* are not empty and the resource locations are empty,
* {@code AnnotationConfigContextLoader} will load the {@code ApplicationContext}.</li>
* </ul>
*
* @param mergedConfig the merged context configuration to use to load the application context
* @throws IllegalArgumentException if the supplied merged configuration is <code>null</code>
* @throws IllegalStateException if neither candidate loader is capable of loading an
* {@code ApplicationContext} from the supplied merged context configuration
*/
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
Assert.notNull(mergedConfig, "mergedConfig must not be null");
List<SmartContextLoader> candidates = Arrays.asList(xmlLoader, annotationConfigLoader);
for (SmartContextLoader loader : candidates) {
// Determine if each loader can load a context from the
// mergedConfig. If it can, let it; otherwise, keep iterating.
if (supports(loader, mergedConfig)) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Delegating to %s to load context from %s.", name(loader), mergedConfig));
}
return loader.loadContext(mergedConfig);
}
}
throw new IllegalStateException(String.format(
"Neither %s nor %s was able to load an ApplicationContext from %s.", name(xmlLoader),
name(annotationConfigLoader), mergedConfig));
}
// --- ContextLoader -------------------------------------------------------
/**
* {@code DelegatingSmartContextLoader} does not support the
* {@link ContextLoader#processLocations(Class, String...)} method. Call
* {@link #processContextConfiguration(ContextConfigurationAttributes)} instead.
* @throws UnsupportedOperationException
*/
public String[] processLocations(Class<?> clazz, String... locations) {
throw new UnsupportedOperationException("DelegatingSmartContextLoader does not support the ContextLoader SPI. "
+ "Call processContextConfiguration(ContextConfigurationAttributes) instead.");
}
/**
* {@code DelegatingSmartContextLoader} does not support the
* {@link ContextLoader#loadContext(String...) } method. Call
* {@link #loadContext(MergedContextConfiguration)} instead.
* @throws UnsupportedOperationException
*/
public ApplicationContext loadContext(String... locations) throws Exception {
throw new UnsupportedOperationException("DelegatingSmartContextLoader does not support the ContextLoader SPI. "
+ "Call loadContext(MergedContextConfiguration) instead.");
}
}

View File

@@ -1,49 +0,0 @@
/*
* Copyright 2002-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.test;
import org.springframework.test.context.TestContextManager;
/**
* @author David Turanski
*
*/
public class GemfireTestContextManager extends TestContextManager {
private final static String GEMFIRE_CONTEXT_LOADER_CLASSNAME = GemfireSmartContextLoader.class.getName();
/**
* @param testClass
* @param defaultContextLoaderClassName
*/
public GemfireTestContextManager(Class<?> testClass, String defaultContextLoaderClassName) {
super(testClass, defaultContextLoaderClassName);
initializeTestContext();
}
/**
*
*/
private void initializeTestContext() {
registerTestExecutionListeners(new GemfireTestExecutionListener());
}
/**
* @param testClass
*/
public GemfireTestContextManager(Class<?> testClass) {
super(testClass,GEMFIRE_CONTEXT_LOADER_CLASSNAME);
initializeTestContext();
}
}

View File

@@ -1,96 +0,0 @@
/*
* Copyright 2002-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.test;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.test.context.TestContext;
import org.springframework.test.context.TestExecutionListener;
import com.gemstone.gemfire.cache.Cache;
/**
* @author David Turanski
*
*/
public class GemfireTestExecutionListener implements TestExecutionListener {
private static Log logger = LogFactory.getLog(GemfireTestExecutionListener.class);
/* (non-Javadoc)
* @see org.springframework.test.context.TestExecutionListener#beforeTestClass(org.springframework.test.context.TestContext)
*/
@Override
public void beforeTestClass(TestContext testContext) throws Exception {
}
/* (non-Javadoc)
* @see org.springframework.test.context.TestExecutionListener#prepareTestInstance(org.springframework.test.context.TestContext)
*/
@Override
public void prepareTestInstance(TestContext testContext) throws Exception {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.springframework.test.context.TestExecutionListener#beforeTestMethod(org.springframework.test.context.TestContext)
*/
@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.springframework.test.context.TestExecutionListener#afterTestMethod(org.springframework.test.context.TestContext)
*/
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.springframework.test.context.TestExecutionListener#afterTestClass(org.springframework.test.context.TestContext)
*/
@Override
public void afterTestClass(TestContext testContext) throws Exception {
// TODO Auto-generated method stub
}
public static class GemfireTestBeanPostProcessor implements BeanPostProcessor {
/* (non-Javadoc)
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
*/
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
logger.debug("I have bean " + beanName);
return bean;
}
/* (non-Javadoc)
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
*/
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
// TODO Auto-generated method stub
return null;
}
}
}

View File

@@ -1,38 +0,0 @@
/*
* Copyright 2002-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.test;
import org.junit.runners.model.InitializationError;
import org.springframework.test.context.TestContextManager;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author David Turanski
*
*/
public class GemfireTestRunner extends SpringJUnit4ClassRunner {
public static final String GEMFIRE_TEST_RUNNER_DISABLED = "org.springframework.data.gemfire.test.GemfireTestRunner.nomock";
/**
* @param clazz
* @throws InitializationError
*/
public GemfireTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
}
protected TestContextManager createTestContextManager(Class<?> testClass) {
return new GemfireTestContextManager(testClass);
}
}

View File

@@ -1,28 +0,0 @@
/*
* Copyright 2002-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.test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.test.context.support.GenericXmlContextLoader;
/**
* @author David Turanski
*
*/
public class GemfireXmlContextLoader extends GenericXmlContextLoader {
@Override
protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory) {
ContextLoaderUtils.customizeBeanFactory(beanFactory);
}
}

View File

@@ -23,7 +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.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -37,8 +37,9 @@ import com.gemstone.gemfire.cache.Cache;
*
* @author Costin Leau
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/basic-cache.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/org/springframework/data/gemfire/basic-cache.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class CacheIntegrationTest {
@Autowired ApplicationContext ctx;

View File

@@ -27,9 +27,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.data.gemfire.test.MockRegionFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.query.FunctionDomainException;
import com.gemstone.gemfire.cache.query.NameResolutionException;
@@ -42,8 +43,9 @@ import com.gemstone.gemfire.cache.query.TypeMismatchException;
/**
* @author Costin Leau
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/basic-template.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/org/springframework/data/gemfire/basic-template.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class GemfireTemplateTest {
private static final String MULTI_QUERY = "select * from /simple";

View File

@@ -22,8 +22,9 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
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;
@@ -33,8 +34,9 @@ import com.gemstone.gemfire.cache.client.ClientCache;
* @author David Turanski
*
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("client-cache.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="client-cache.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class ClientCacheTest {
@Resource(name="challengeQuestionsRegion")
Region<?,?> region;

View File

@@ -27,8 +27,9 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
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;
@@ -44,8 +45,9 @@ import com.gemstone.gemfire.cache.util.CacheWriterAdapter;
* @author Costin Leau
* @author David Turanski
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration(locations = { "basic-region.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "basic-region.xml" },
initializers=GemfireTestApplicationContextInitializer.class)
public class RegionIntegrationTest {
private static class CacheList<K, V> extends CacheListenerAdapter<K, V> {

View File

@@ -33,8 +33,9 @@ import org.springframework.data.gemfire.CacheFactoryBean;
import org.springframework.data.gemfire.GemfireBeanFactoryLocator;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.util.ReflectionTestUtils;
import com.gemstone.gemfire.cache.Cache;
@@ -45,8 +46,9 @@ import com.gemstone.gemfire.cache.util.TimestampedEntryEvent;
/**
* @author Costin Leau
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/cache-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/org/springframework/data/gemfire/config/cache-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class CacheNamespaceTest{
@Autowired ApplicationContext ctx;

View File

@@ -23,8 +23,9 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.server.CacheServer;
@@ -33,8 +34,9 @@ import com.gemstone.gemfire.cache.server.CacheServer;
* @author Costin Leau
* @author David Turanski
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/server-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/org/springframework/data/gemfire/config/server-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class CacheServerNamespaceTest {
@Autowired ApplicationContext ctx;

View File

@@ -34,8 +34,9 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
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,8 +53,9 @@ import com.gemstone.gemfire.cache.util.ObjectSizer;
* @author Costin Leau
* @author David Turanski
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("client-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="client-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class ClientRegionNamespaceTest {
@Autowired

View File

@@ -36,8 +36,10 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
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;
@@ -57,8 +59,9 @@ import com.gemstone.gemfire.cache.util.ObjectSizer;
* @author Costin Leau
* @author David Turanski
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("diskstore-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="diskstore-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class DiskStoreAndEvictionRegionParsingTest {
@Autowired

View File

@@ -27,7 +27,6 @@ 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;

View File

@@ -21,9 +21,9 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.execute.FunctionAdapter;
import com.gemstone.gemfire.cache.execute.FunctionContext;
@@ -31,9 +31,11 @@ import com.gemstone.gemfire.cache.execute.FunctionService;
/**
* @author Costin Leau
* @author David Turanski
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/function-service-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/org/springframework/data/gemfire/config/function-service-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class FunctionServiceNamespaceTest {
@Test
public void testFunctionsRegistered() throws Exception {

View File

@@ -0,0 +1,105 @@
/*
* 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.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FilenameFilter;
import java.util.List;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.springframework.data.gemfire.RecreatingContextTest;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEvent;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventListener;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
/**
* This test is only valid for GF 7.0 and above
*
* @author David Turanski
*
*/
public class GemfireAsyncEventQueueNamespaceTest extends RecreatingContextTest {
/* (non-Javadoc)
* @see org.springframework.data.gemfire.RecreatingContextTest#location()
*/
@Override
protected String location() {
return "/org/springframework/data/gemfire/config/async-event-queue-ns.xml";
}
@Override
protected void configureContext() {
//ctx.getBeanFactory().addBeanPostProcessor(new GemfireTestBeanPostProcessor());
}
@Before
@Override
public void createCtx() {
if (ParsingUtils.GEMFIRE_VERSION.startsWith("7")) {
super.createCtx();
}
}
@AfterClass
public static void tearDown() {
for (String name : new File(".").list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.startsWith("BACKUP");
}
})) {
new File(name).delete();
}
}
/**
*
*/
@Test
public 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());
}
@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

@@ -25,13 +25,12 @@ 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.test.GemfireTestApplicationContextInitializer;
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 org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
@@ -43,8 +42,9 @@ import com.gemstone.gemfire.cache.util.GatewayHub;
* @author David Turanski
*
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/gateway-v6-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/org/springframework/data/gemfire/config/gateway-v6-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class GemfireV6GatewayNamespaceTest {
@Autowired ApplicationContext ctx;

View File

@@ -28,19 +28,11 @@ 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.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.GemfireTestBeanPostProcessor;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.data.gemfire.wan.GatewaySenderFactoryBean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;

View File

@@ -23,8 +23,10 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.query.Index;
import com.gemstone.gemfire.cache.query.IndexType;
@@ -32,9 +34,11 @@ import com.gemstone.gemfire.cache.query.IndexType;
/**
*
* @author Costin Leau
* @author David Turanski
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("index-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="index-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class IndexNamespaceTest {
private final String name = "test-index";

View File

@@ -29,8 +29,9 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
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,9 +42,11 @@ import com.gemstone.gemfire.cache.Scope;
/**
* @author Costin Leau
* @author David Turanski
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("local-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="local-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class LocalRegionNamespaceTest {
@Autowired

View File

@@ -23,9 +23,9 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.LossAction;
import com.gemstone.gemfire.cache.MembershipAttributes;
@@ -37,8 +37,9 @@ import com.gemstone.gemfire.distributed.Role;
* @author David Turanski
*
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/membership-attributes-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/org/springframework/data/gemfire/config/membership-attributes-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class MembershipAttributesTest {
@Autowired ApplicationContext ctx;

View File

@@ -30,8 +30,9 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.ObjectUtils;
import com.gemstone.gemfire.cache.CacheListener;
@@ -45,8 +46,9 @@ import com.gemstone.gemfire.cache.partition.PartitionListener;
* @author Costin Leau
* @author David Turanski
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("partitioned-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="partitioned-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class PartitionedRegionNamespaceTest {
@Autowired

View File

@@ -30,7 +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.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -39,8 +39,9 @@ import com.gemstone.gemfire.cache.client.PoolManager;
/**
* @author Costin Leau
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("pool-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="pool-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class PoolNamespaceTest {
@Autowired

View File

@@ -29,8 +29,9 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.ObjectUtils;
import com.gemstone.gemfire.cache.Cache;
@@ -43,8 +44,9 @@ import com.gemstone.gemfire.cache.Scope;
* @author Costin Leau
* @author David Turanski
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("replicated-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="replicated-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class ReplicatedRegionNamespaceTest {
@Autowired

View File

@@ -25,7 +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.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -39,8 +39,9 @@ import com.gemstone.gemfire.cache.RegionAttributes;
* @author David Turanski
*/
@SuppressWarnings("deprecation")
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("subregion-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="subregion-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class SubRegionNamespaceTest {
@Autowired

View File

@@ -15,8 +15,8 @@
*/
package org.springframework.data.gemfire.config;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import javax.annotation.Resource;
@@ -24,12 +24,11 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
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;
import com.gemstone.gemfire.cache.TransactionEvent;
import com.gemstone.gemfire.cache.TransactionListener;
import com.gemstone.gemfire.cache.TransactionWriter;
@@ -39,8 +38,9 @@ import com.gemstone.gemfire.cache.TransactionWriterException;
* @author David Turanski
*
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("tx-listeners-and-writers.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="tx-listeners-and-writers.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class TxEventHandlersTest {
@Autowired
TestListener txListener1;

View File

@@ -24,15 +24,16 @@ 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.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Costin Leau
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration("/org/springframework/data/gemfire/config/tx-ns.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/org/springframework/data/gemfire/config/tx-ns.xml",
initializers=GemfireTestApplicationContextInitializer.class)
public class TxManagerNamespaceTest {
@Autowired ApplicationContext ctx;

View File

@@ -25,17 +25,18 @@ import org.springframework.data.gemfire.TestUtils;
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.data.gemfire.test.GemfireTestApplicationContextInitializer;
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(GemfireTestRunner.class)
@ContextConfiguration(classes={TestConfig.class})
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={TestConfig.class},
initializers=GemfireTestApplicationContextInitializer.class)
public class FunctionExecutionIntegrationTests {
@Autowired
ApplicationContext context;

View File

@@ -23,16 +23,18 @@ import org.springframework.data.gemfire.TestUtils;
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.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Region;
/**
* @author David Turanski
*
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(initializers=GemfireTestApplicationContextInitializer.class)
public class XmlConfiguredFunctionExecutionIntegrationTests {
@Autowired
ApplicationContext context;

View File

@@ -25,7 +25,7 @@ import org.springframework.data.gemfire.CacheFactoryBean;
import org.springframework.data.gemfire.LocalRegionFactoryBean;
import org.springframework.data.gemfire.repository.sample.Person;
import org.springframework.data.gemfire.repository.sample.PersonRepository;
import org.springframework.data.gemfire.test.GemfireTestRunner;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.data.gemfire.test.MockCacheFactoryBean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -39,8 +39,8 @@ import com.gemstone.gemfire.cache.Region;
*
* @author Oliver Gierke
*/
@RunWith(GemfireTestRunner.class)
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(initializers=GemfireTestApplicationContextInitializer.class)
public class GemfireRepositoriesRegistrarIntegrationTest {
@Configuration

View File

@@ -35,7 +35,6 @@ import org.springframework.data.gemfire.repository.sample.PersonRepository;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gemstone.gemfire.cache.Region;
import org.springframework.data.gemfire.test.GemfireTestRunner;
/**
* Integration test for {@link GemfireRepositoryFactory}.
*

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2002-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.test;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.util.StringUtils;
/**
* @author David Turanski
*
*/
public class GemfireTestApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
private static Log logger = LogFactory.getLog(GemfireTestApplicationContextInitializer.class);
public static final String GEMFIRE_TEST_RUNNER_DISABLED = "org.springframework.data.gemfire.test.GemfireTestRunner.nomock";
/* (non-Javadoc)
* @see org.springframework.context.ApplicationContextInitializer#initialize(org.springframework.context.ConfigurableApplicationContext)
*/
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
if (StringUtils.hasText(System.getProperty(GEMFIRE_TEST_RUNNER_DISABLED))) {
String value = System.getProperty(GEMFIRE_TEST_RUNNER_DISABLED);
if (!(value.equalsIgnoreCase("NO") || value.equalsIgnoreCase("FALSE"))) {
logger.warn("Mocks disabled. Using real GemFire components:" + GEMFIRE_TEST_RUNNER_DISABLED + " = " + value);
return;
}
}
applicationContext.getBeanFactory().addBeanPostProcessor(new GemfireTestBeanPostProcessor());
}
}

View File

@@ -34,12 +34,12 @@ public class GemfireTestBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof CacheFactoryBean) {
logger.info("replacing " + beanName+ " definition to mock GemFire components" );
bean = (bean instanceof ClientCacheFactoryBean)?
new MockClientCacheFactoryBean((ClientCacheFactoryBean)bean):
new MockCacheFactoryBean((CacheFactoryBean)bean);
logger.info(String.format("replacing '%s' definition with type %s",
beanName, bean.getClass().getName()));
}
else if (bean instanceof CacheServerFactoryBean) {
((CacheServerFactoryBean)bean).setCache(new StubCache());

View File

@@ -1,37 +0,0 @@
/*
* Copyright 2002-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.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,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd" default-lazy-init="true">
<util:properties id="gemprops">
<prop key="license-data-management">81083-4WY42-48948-0YM00-8J425,Y10AA-N0JDJ-J8R8T-07CFK-34RPC</prop>
</util:properties>
<gfe:cache properties-ref="gemprops"/>
<gfe:async-event-queue id="async-event-queue" batch-size="10" persistent="true" disk-store-ref="diskstore"
maximum-queue-memory="50">
<gfe:async-event-listener>
<bean class="org.springframework.data.gemfire.config.GemfireV7GatewayNamespaceTest.TestAsyncEventListener"/>
</gfe:async-event-listener>
</gfe:async-event-queue>
<gfe:disk-store id="diskstore"/>
</beans>

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire-1.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<gfe:cache/>
<gfe:local-region id="r1"/>
</beans>