SGF-588 - Reorganize and repackage additional classes in the SDG API.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2016 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.support;
|
||||
package org.springframework.data.gemfire.cache;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@@ -27,17 +27,17 @@ import org.apache.geode.cache.TimeoutException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The CallableCacheLoaderAdapter class is a {@link Callable} and GemFire {@link CacheLoader} implementation that
|
||||
* adapts the {@link Callable} interface into an instance of the {@link CacheLoader} interface. This class is useful
|
||||
* in situations where GemFire developers have several {@link CacheLoader} implementations that they wish to use
|
||||
* with Spring's Cache Abstraction.
|
||||
* The {@link CallableCacheLoaderAdapter} class is a {@link Callable} and GemFire {@link CacheLoader} implementation
|
||||
* that adapts the {@link Callable} interface into an instance of the {@link CacheLoader} interface. This class is
|
||||
* useful in situations where GemFire developers have several {@link CacheLoader} implementations that they wish to
|
||||
* use with Spring's Cache Abstraction.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.util.concurrent.Callable
|
||||
* @see org.apache.geode.cache.CacheLoader
|
||||
* @see org.apache.geode.cache.LoaderHelper
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @since 1.0.0
|
||||
* @since 1.9.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class CallableCacheLoaderAdapter<K, V> implements Callable<V>, CacheLoader<K, V> {
|
||||
@@ -196,5 +196,4 @@ public class CallableCacheLoaderAdapter<K, V> implements Callable<V>, CacheLoade
|
||||
public V load(LoaderHelper<K, V> loaderHelper) throws CacheLoaderException {
|
||||
return getCacheLoader().load(loaderHelper);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.data.gemfire.function.execution.GemfireOnServersFunctionTemplate;
|
||||
import org.springframework.data.gemfire.support.ListRegionsOnServerFunction;
|
||||
import org.springframework.data.gemfire.client.function.ListRegionsOnServerFunction;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor
|
||||
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory
|
||||
* @see org.springframework.data.gemfire.function.execution.GemfireOnServersFunctionTemplate
|
||||
* @see org.springframework.data.gemfire.support.ListRegionsOnServerFunction
|
||||
* @see ListRegionsOnServerFunction
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.client.ClientRegionFactory
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2016 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
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
* 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.support;
|
||||
package org.springframework.data.gemfire.client.function;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -32,7 +36,7 @@ import org.apache.geode.cache.execute.FunctionContext;
|
||||
@SuppressWarnings("serial")
|
||||
public class ListRegionsOnServerFunction implements Function {
|
||||
|
||||
private static final long serialVersionUID = 867530169l;
|
||||
private static final long serialVersionUID = 867530169L;
|
||||
|
||||
public static final String ID = ListRegionsOnServerFunction.class.getName();
|
||||
|
||||
@@ -91,5 +95,4 @@ public class ListRegionsOnServerFunction implements Function {
|
||||
public boolean optimizeForWrite() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.support.JSONRegionAdvice;
|
||||
import org.springframework.data.gemfire.serialization.json.JSONRegionAdvice;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.w3c.dom.Element;
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.BeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.support.JSONRegionAdvice
|
||||
* @see JSONRegionAdvice
|
||||
*/
|
||||
class GemfireRegionAutoProxyParser implements BeanDefinitionParser {
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.GemfireTransactionManager;
|
||||
import org.springframework.data.gemfire.transaction.GemfireTransactionManager;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.w3c.dom.Element;
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.GemfireTransactionManager
|
||||
* @see GemfireTransactionManager
|
||||
*/
|
||||
class TransactionManagerParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
* Copyright 2016 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.
|
||||
@@ -12,9 +12,10 @@
|
||||
* 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.support;
|
||||
package org.springframework.data.gemfire.dao;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.springframework.dao.support.DaoSupport;
|
||||
@@ -23,36 +24,25 @@ import org.springframework.data.gemfire.GemfireTemplate;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Convenient super class for GemFire data access objects. Intended for
|
||||
* GemfireTemplate usage.
|
||||
* Convenient super class for GemFire Data Access Objects (DAO) implementing the Spring
|
||||
* {@link DaoSupport} abstract class. Intended for use with {@link GemfireTemplate}.
|
||||
*
|
||||
* <p>Requires a Region to be set, providing a GemfireTemplate based on it to subclasses.
|
||||
* Can alternatively be initialized directly via a GemfireTemplate, to reuse the latter's
|
||||
* settings.
|
||||
* Requires a GemFire {@link Region} to be set, providing a {@link GemfireTemplate} based on it to subclasses.
|
||||
* Can alternatively be initialized directly via a {@link GemfireTemplate} reusing the template's settings.
|
||||
*
|
||||
* <p>This class will create its own GemfireTemplate if an Region reference is passed in.
|
||||
* A custom GemfireTemplate instance can be used through overriding <code>createGemfireTemplate</code>.
|
||||
* This class will create its own {@link GemfireTemplate} if a GemFire {@link Region} reference is passed in.
|
||||
* A custom {@link GemfireTemplate} instance can be used through overriding <code>createGemfireTemplate</code>.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.dao.support.DaoSupport
|
||||
* @see org.springframework.data.gemfire.GemfireTemplate
|
||||
*/
|
||||
public class GemfireDaoSupport extends DaoSupport {
|
||||
public abstract class GemfireDaoSupport extends DaoSupport {
|
||||
|
||||
private GemfireOperations gemfireTemplate;
|
||||
|
||||
/**
|
||||
* Sets the GemFire Cache Region to be used by this DAO. Will automatically create
|
||||
* an instance of the GemfireTemplate for the given Region.
|
||||
*
|
||||
* @param region the GemFire Cache Region upon which this DAO operates.
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see #createGemfireTemplate(org.apache.geode.cache.Region)
|
||||
*/
|
||||
public void setRegion(Region<?, ?> region) {
|
||||
this.gemfireTemplate = createGemfireTemplate(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the GemfireTemplate for this DAO explicitly as an alternative to specifying a GemFire Cache {@link Region}.
|
||||
*
|
||||
@@ -73,7 +63,19 @@ public class GemfireDaoSupport extends DaoSupport {
|
||||
* @see org.springframework.data.gemfire.GemfireTemplate
|
||||
*/
|
||||
public final GemfireOperations getGemfireTemplate() {
|
||||
return gemfireTemplate;
|
||||
return this.gemfireTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the GemFire Cache Region to be used by this DAO. Will automatically create
|
||||
* an instance of the GemfireTemplate for the given Region.
|
||||
*
|
||||
* @param region the GemFire Cache Region upon which this DAO operates.
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see #createGemfireTemplate(org.apache.geode.cache.Region)
|
||||
*/
|
||||
public void setRegion(Region<?, ?> region) {
|
||||
this.gemfireTemplate = createGemfireTemplate(region);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +88,7 @@ public class GemfireDaoSupport extends DaoSupport {
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see #setRegion
|
||||
*/
|
||||
protected GemfireOperations createGemfireTemplate(Region<?, ?> region) {
|
||||
protected GemfireTemplate createGemfireTemplate(Region<?, ?> region) {
|
||||
return new GemfireTemplate(region);
|
||||
}
|
||||
|
||||
@@ -95,7 +97,6 @@ public class GemfireDaoSupport extends DaoSupport {
|
||||
*/
|
||||
@Override
|
||||
protected final void checkDaoConfig() {
|
||||
Assert.state(gemfireTemplate != null, "A GemFire Cache Region or an instance of the GemfireTemplate is required.");
|
||||
Assert.state(gemfireTemplate != null, "A GemFire Cache Region or instance of GemfireTemplate is required");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,21 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2016 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
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
* 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.support;
|
||||
package org.springframework.data.gemfire.serialization.json;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -37,7 +41,15 @@ import org.springframework.data.gemfire.GemfireTemplate;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Spring/AspectJ AOP Aspect to adapt a GemFire {@link Region} to handle JSON data.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.pdx.JSONFormatter
|
||||
* @see org.apache.geode.pdx.PdxInstance
|
||||
* @see org.aspectj.lang.annotation.Aspect
|
||||
* @see org.aspectj.lang.annotation.Around
|
||||
*/
|
||||
@Aspect
|
||||
@SuppressWarnings("unused")
|
||||
@@ -320,5 +332,4 @@ public class JSONRegionAdvice {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -248,6 +248,7 @@ public class GemfireBeanFactoryLocator implements BeanFactoryAware, BeanNameAwar
|
||||
* the {@link #setBeanName(String)} beanName} property.
|
||||
*
|
||||
* @return the single Spring {@link BeanFactory} from the registry.
|
||||
* @throws IllegalArgumentException if more than Spring {@link BeanFactory} is registered.
|
||||
* @throws IllegalStateException if the {@link BeanFactory} with the associated
|
||||
* {@link #setBeanName(String) beanName} is not found.
|
||||
* @see org.springframework.beans.factory.BeanFactory
|
||||
@@ -259,9 +260,16 @@ public class GemfireBeanFactoryLocator implements BeanFactoryAware, BeanNameAwar
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to use the Spring {@link BeanFactory} idenified by the given {@code beanFactoryKey}.
|
||||
*
|
||||
* @param beanFactoryKey
|
||||
* @return
|
||||
* @param beanFactoryKey {@link String} containing the key used to lookup the Spring {@link BeanFactory}.
|
||||
* @return the Spring {@link BeanFactory} for the given {@code beanFactoryKey}.
|
||||
* @throws IllegalArgumentException if a Spring {@link BeanFactory} could not be found for {@code beanFactoryKey}.
|
||||
* @throws IllegalStateException if {@literal useBeanFactoryLocator} was not configured.
|
||||
* @see org.springframework.beans.factory.BeanFactory
|
||||
* @see BeanFactoryReference#newBeanFactoryReference(BeanFactory)
|
||||
* @see #resolveBeanFactory(String)
|
||||
* @see #resolveSingleBeanFactory()
|
||||
*/
|
||||
public BeanFactory useBeanFactory(String beanFactoryKey) {
|
||||
return newBeanFactoryReference(StringUtils.hasText(beanFactoryKey) ? resolveBeanFactory(beanFactoryKey)
|
||||
@@ -349,9 +357,9 @@ public class GemfireBeanFactoryLocator implements BeanFactoryAware, BeanNameAwar
|
||||
* @param beanFactory {@link BeanFactory} reference to store.
|
||||
* @return a new instance of {@link BeanFactoryReference} initialized with the given {@link BeanFactory}.
|
||||
* @see org.springframework.beans.factory.BeanFactory
|
||||
* @see #BeanFactoryReference(BeanFactory)
|
||||
* @see #GemfireBeanFactoryLocator.BeanFactoryReference(BeanFactory)
|
||||
*/
|
||||
public static BeanFactoryReference newBeanFactoryReference(BeanFactory beanFactory) {
|
||||
protected static BeanFactoryReference newBeanFactoryReference(BeanFactory beanFactory) {
|
||||
return new BeanFactoryReference(beanFactory);
|
||||
}
|
||||
|
||||
@@ -361,7 +369,7 @@ public class GemfireBeanFactoryLocator implements BeanFactoryAware, BeanNameAwar
|
||||
* @param beanFactory {@link BeanFactory} reference to store; may be {@literal null}.
|
||||
* @see org.springframework.beans.factory.BeanFactory
|
||||
*/
|
||||
public BeanFactoryReference(BeanFactory beanFactory) {
|
||||
protected BeanFactoryReference(BeanFactory beanFactory) {
|
||||
this.beanFactory.set(beanFactory);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public abstract class LazyWiringDeclarableSupport extends WiringDeclarableSuppor
|
||||
*
|
||||
* @return a boolean value indicating whether this {@link Declarable} object has been properly configured
|
||||
* and initialized by the Spring container.
|
||||
* @see #doInit(Properties)
|
||||
* @see #doInit(BeanFactory, Properties)
|
||||
* @see #assertInitialized()
|
||||
*/
|
||||
protected boolean isInitialized() {
|
||||
@@ -130,7 +130,7 @@ public abstract class LazyWiringDeclarableSupport extends WiringDeclarableSuppor
|
||||
*
|
||||
* @return a boolean value indicating whether this {@link Declarable} object has been properly configured
|
||||
* and initialized by the Spring container.
|
||||
* @see #doInit(Properties)
|
||||
* @see #doInit(BeanFactory, Properties)
|
||||
* @see #isInitialized()
|
||||
*/
|
||||
protected boolean isNotInitialized() {
|
||||
@@ -144,7 +144,7 @@ public abstract class LazyWiringDeclarableSupport extends WiringDeclarableSuppor
|
||||
*
|
||||
* @param parameters {@link Properties} containing the configured parameters parsed from GemFire's
|
||||
* configuration meta-data (e.g. {@literal cache.xml}) and passed to this {@link Declarable} object.
|
||||
* @see #doInit(Properties)
|
||||
* @see #doInit(BeanFactory, Properties)
|
||||
* @see java.util.Properties
|
||||
*/
|
||||
@Override
|
||||
@@ -188,7 +188,7 @@ public abstract class LazyWiringDeclarableSupport extends WiringDeclarableSuppor
|
||||
*
|
||||
* @param parameters {@link Properties} containing the configured parameters parsed from GemFire's
|
||||
* configuration meta-data (e.g. {@literal cache.xml}) and passed to this {@link Declarable} object.
|
||||
* @see #doInit(Properties)
|
||||
* @see #doInit(BeanFactory, Properties)
|
||||
* @see java.util.Properties
|
||||
*/
|
||||
protected void doPostInit(Properties parameters) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
* Copyright 2016 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.
|
||||
@@ -12,15 +12,16 @@
|
||||
* 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;
|
||||
package org.springframework.data.gemfire.transaction;
|
||||
|
||||
import org.springframework.transaction.TransactionException;
|
||||
|
||||
/**
|
||||
* Gemfire-specific subclass of {@link org.springframework.transaction.TransactionException}, indicating a transaction failure at commit time.
|
||||
*
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
* Copyright 2016 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.
|
||||
@@ -12,9 +12,10 @@
|
||||
* 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;
|
||||
package org.springframework.data.gemfire.transaction;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.CacheTransactionManager;
|
||||
@@ -52,20 +53,20 @@ import org.springframework.util.Assert;
|
||||
* workaround, one could use explicitly deep copy objects before making changes
|
||||
* to them to avoid unnecessary copying on every fetch.
|
||||
*
|
||||
* @see org.apache.geode.cache.CacheTransactionManager
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.Cache#setCopyOnRead(boolean)
|
||||
* @see org.apache.geode.cache.CacheTransactionManager
|
||||
* @see org.apache.geode.cache.Region#get(Object)
|
||||
* @see org.apache.geode.CopyHelper#copy(Object)
|
||||
* @see #setCopyOnRead(boolean)
|
||||
* @see org.springframework.transaction.support.AbstractPlatformTransactionManager
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @see #setCopyOnRead(boolean)
|
||||
*/
|
||||
// TODO add lenient behavior if a transaction is already started on the current
|
||||
// thread (what should happen then)
|
||||
@SuppressWarnings("serial")
|
||||
public class GemfireTransactionManager extends AbstractPlatformTransactionManager implements InitializingBean,
|
||||
ResourceTransactionManager {
|
||||
public class GemfireTransactionManager extends AbstractPlatformTransactionManager
|
||||
implements InitializingBean, ResourceTransactionManager {
|
||||
|
||||
private Cache cache;
|
||||
|
||||
@@ -112,7 +113,7 @@ public class GemfireTransactionManager extends AbstractPlatformTransactionManage
|
||||
protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException {
|
||||
CacheTransactionObject txObject = (CacheTransactionObject) transaction;
|
||||
|
||||
Cache cache = null;
|
||||
Cache cache;
|
||||
|
||||
try {
|
||||
cache = getCache();
|
||||
@@ -28,7 +28,7 @@ import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionFactory;
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.gemfire.support.AbstractRegionFactoryBeanTest;
|
||||
import org.springframework.data.gemfire.test.support.AbstractRegionFactoryBeanTests;
|
||||
|
||||
/**
|
||||
* The PartitionedRegionFactoryBeanTest class is a test suite of test cases testing the component functionality
|
||||
@@ -42,7 +42,7 @@ import org.springframework.data.gemfire.support.AbstractRegionFactoryBeanTest;
|
||||
* @since 1.3.x
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTest {
|
||||
public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
private final LocalRegionFactoryBean factoryBean = new LocalRegionFactoryBean();
|
||||
|
||||
@@ -283,5 +283,4 @@ public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTest {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, DataPolicy.PERSISTENT_REPLICATE);
|
||||
verify(mockRegionFactory).setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ import org.apache.geode.cache.SubscriptionAttributes;
|
||||
import org.apache.geode.internal.cache.GemFireCacheImpl;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.gemfire.support.AbstractRegionFactoryBeanTest;
|
||||
import org.springframework.data.gemfire.test.support.AbstractRegionFactoryBeanTests;
|
||||
import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class RegionFactoryBeanTest extends AbstractRegionFactoryBeanTest {
|
||||
public class RegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
private final RegionFactoryBean factoryBean = new TestRegionFactoryBean();
|
||||
|
||||
@@ -1053,5 +1053,4 @@ public class RegionFactoryBeanTest extends AbstractRegionFactoryBeanTest {
|
||||
|
||||
protected static class TestRegionFactoryBean<K, V> extends RegionFactoryBean<K, V> {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2016 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.support;
|
||||
package org.springframework.data.gemfire.cache;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
@@ -43,7 +43,8 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
/**
|
||||
* Tests the adaption of the {@link java.util.concurrent.Callable} in to GemFire's {@link org.apache.geode.cache.CacheLoader} interface.
|
||||
* Unit tests to test the adaption of the {@link java.util.concurrent.Callable}
|
||||
* into GemFire's {@link org.apache.geode.cache.CacheLoader} interface.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Rule
|
||||
@@ -57,7 +58,7 @@ import org.mockito.stubbing.Answer;
|
||||
* @see org.apache.geode.cache.CacheLoader
|
||||
* @see org.apache.geode.cache.LoaderHelper
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @since 1.0.0
|
||||
* @since 1.9.0
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CallableCacheLoaderAdapterTest {
|
||||
@@ -66,7 +67,7 @@ public class CallableCacheLoaderAdapterTest {
|
||||
private CacheLoader<String, Object> mockCacheLoader;
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Mock
|
||||
private LoaderHelper<String, Object> mockLoaderHelper;
|
||||
@@ -76,8 +77,8 @@ public class CallableCacheLoaderAdapterTest {
|
||||
|
||||
@Test
|
||||
public void constructCallableCacheLoaderAdapterWithArgumentKeyAndRegion() {
|
||||
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<String, Object>(
|
||||
mockCacheLoader, "key", mockRegion, "test");
|
||||
CallableCacheLoaderAdapter<String, Object> instance =
|
||||
new CallableCacheLoaderAdapter<>(mockCacheLoader, "key", mockRegion, "test");
|
||||
|
||||
assertThat(instance, is(notNullValue()));
|
||||
assertThat(instance.getCacheLoader(), is(sameInstance(mockCacheLoader)));
|
||||
@@ -88,8 +89,8 @@ public class CallableCacheLoaderAdapterTest {
|
||||
|
||||
@Test
|
||||
public void constructCallableCacheLoaderAdapterWithKeyRegionAndNoArgument() {
|
||||
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<String, Object>(
|
||||
mockCacheLoader, "key", mockRegion);
|
||||
CallableCacheLoaderAdapter<String, Object> instance =
|
||||
new CallableCacheLoaderAdapter<>(mockCacheLoader, "key", mockRegion);
|
||||
|
||||
assertThat(instance, is(notNullValue()));
|
||||
assertThat(instance.getCacheLoader(), is(sameInstance(mockCacheLoader)));
|
||||
@@ -101,7 +102,7 @@ public class CallableCacheLoaderAdapterTest {
|
||||
@Test
|
||||
public void constructCallableCacheLoaderAdapterWithNoArgumentKeyOrRegion() {
|
||||
CallableCacheLoaderAdapter<String, Object> instance =
|
||||
new CallableCacheLoaderAdapter<String, Object>(mockCacheLoader);
|
||||
new CallableCacheLoaderAdapter<>(mockCacheLoader);
|
||||
|
||||
assertThat(instance, is(notNullValue()));
|
||||
assertThat(instance.getCacheLoader(), is(sameInstance(mockCacheLoader)));
|
||||
@@ -112,25 +113,25 @@ public class CallableCacheLoaderAdapterTest {
|
||||
|
||||
@Test
|
||||
public void constructCallableCacheLoaderAdapterWithNullCacheLoader() {
|
||||
expectedException.expect(IllegalArgumentException.class);
|
||||
expectedException.expectCause(is(nullValue(Throwable.class)));
|
||||
expectedException.expectMessage("CacheLoader must not be null");
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectCause(is(nullValue(Throwable.class)));
|
||||
exception.expectMessage("CacheLoader must not be null");
|
||||
|
||||
new CallableCacheLoaderAdapter<Object, Object>(null);
|
||||
new CallableCacheLoaderAdapter<>(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void callDelegatesToLoad() throws Exception {
|
||||
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<String, Object>(
|
||||
mockCacheLoader, "key", mockRegion, "test");
|
||||
CallableCacheLoaderAdapter<String, Object> instance =
|
||||
new CallableCacheLoaderAdapter<>(mockCacheLoader, "key", mockRegion, "test");
|
||||
|
||||
when(mockCacheLoader.load(any(LoaderHelper.class))).thenAnswer(new Answer<String>() {
|
||||
public String answer(final InvocationOnMock invocation) throws Throwable {
|
||||
LoaderHelper<String, Object> loaderHelper = invocation.getArgumentAt(0, LoaderHelper.class);
|
||||
|
||||
assertThat(loaderHelper, is(notNullValue()));
|
||||
assertThat((String) loaderHelper.getArgument(), is(equalTo("test")));
|
||||
assertThat(loaderHelper.getArgument(), is(equalTo("test")));
|
||||
assertThat(loaderHelper.getKey(), is(equalTo("key")));
|
||||
assertThat(loaderHelper.getRegion(), is(sameInstance(mockRegion)));
|
||||
|
||||
@@ -138,57 +139,55 @@ public class CallableCacheLoaderAdapterTest {
|
||||
}
|
||||
});
|
||||
|
||||
assertThat((String) instance.call(), is(equalTo("mockValue")));
|
||||
assertThat(instance.call(), is(equalTo("mockValue")));
|
||||
|
||||
verify(mockCacheLoader, times(1)).load(isA(LoaderHelper.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callThrowsIllegalStateExceptionForNullKey() throws Exception {
|
||||
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<String, Object>(
|
||||
mockCacheLoader, null, mockRegion);
|
||||
CallableCacheLoaderAdapter<String, Object> instance =
|
||||
new CallableCacheLoaderAdapter<>(mockCacheLoader, null, mockRegion);
|
||||
|
||||
assertThat(instance.getKey(), is(nullValue()));
|
||||
assertThat(instance.getRegion(), is(sameInstance(mockRegion)));
|
||||
|
||||
expectedException.expect(IllegalStateException.class);
|
||||
expectedException.expectCause(is(nullValue(Throwable.class)));
|
||||
expectedException.expectMessage("The key for which the value is loaded for cannot be null");
|
||||
exception.expect(IllegalStateException.class);
|
||||
exception.expectCause(is(nullValue(Throwable.class)));
|
||||
exception.expectMessage("The key for which the value is loaded for cannot be null");
|
||||
|
||||
instance.call();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callThrowsIllegalStateExceptionForNullRegion() throws Exception {
|
||||
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<String, Object>(
|
||||
mockCacheLoader, "key", null);
|
||||
CallableCacheLoaderAdapter<String, Object> instance =
|
||||
new CallableCacheLoaderAdapter<>(mockCacheLoader, "key", null);
|
||||
|
||||
assertThat(instance.getKey(), is(equalTo("key")));
|
||||
assertThat(instance.getRegion(), is(nullValue()));
|
||||
|
||||
expectedException.expect(IllegalStateException.class);
|
||||
expectedException.expectCause(is(nullValue(Throwable.class)));
|
||||
expectedException.expectMessage("The Region to load cannot be null");
|
||||
exception.expect(IllegalStateException.class);
|
||||
exception.expectCause(is(nullValue(Throwable.class)));
|
||||
exception.expectMessage("The Region to load cannot be null");
|
||||
|
||||
instance.call();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void closeDelegatesToCacheLoaderClose() {
|
||||
new CallableCacheLoaderAdapter<String, Object>(mockCacheLoader).close();
|
||||
new CallableCacheLoaderAdapter<>(mockCacheLoader).close();
|
||||
verify(mockCacheLoader, times(1)).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadDelegatesToCacheLoaderLoad() {
|
||||
CallableCacheLoaderAdapter<String, Object> instance =
|
||||
new CallableCacheLoaderAdapter<String, Object>(mockCacheLoader);
|
||||
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<>(mockCacheLoader);
|
||||
|
||||
when(mockCacheLoader.load(eq(mockLoaderHelper))).thenReturn("test");
|
||||
|
||||
assertThat((String) instance.load(mockLoaderHelper), is(equalTo("test")));
|
||||
assertThat(instance.load(mockLoaderHelper), is(equalTo("test")));
|
||||
|
||||
verify(mockCacheLoader, times(1)).load(eq(mockLoaderHelper));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,7 +33,7 @@ import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.support.AbstractNativeCacheTests;
|
||||
import org.springframework.data.gemfire.test.support.AbstractNativeCacheTests;
|
||||
|
||||
/**
|
||||
* Integration Tests for {@link GemfireCache}.
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.data.gemfire.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.test.AbstractGemFireClientServerIntegrationTest;
|
||||
import org.springframework.data.gemfire.test.support.AbstractGemFireClientServerIntegrationTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -55,7 +55,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.test.AbstractGemFireClientServerIntegrationTest;
|
||||
import org.springframework.data.gemfire.test.support.AbstractGemFireClientServerIntegrationTest;
|
||||
import org.springframework.data.gemfire.test.support.ThreadUtils;
|
||||
import org.springframework.data.gemfire.util.DistributedSystemUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
@@ -74,7 +74,7 @@ import org.springframework.util.SocketUtils;
|
||||
* @see org.springframework.beans.factory.config.BeanPostProcessor
|
||||
* @see org.springframework.context.ConfigurableApplicationContext
|
||||
* @see org.springframework.data.gemfire.process.ProcessWrapper
|
||||
* @see org.springframework.data.gemfire.test.AbstractGemFireClientServerIntegrationTest
|
||||
* @see AbstractGemFireClientServerIntegrationTest
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
|
||||
@@ -58,7 +58,7 @@ import org.junit.rules.ExpectedException;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.data.gemfire.support.ListRegionsOnServerFunction;
|
||||
import org.springframework.data.gemfire.client.function.ListRegionsOnServerFunction;
|
||||
|
||||
/**
|
||||
* The GemfireDataSourcePostProcessor class is a test suite of test cases testing the contract and functionality
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
* Copyright 2016 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
|
||||
* 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.support;
|
||||
package org.springframework.data.gemfire.client.function;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
@@ -49,7 +50,7 @@ import org.mockito.stubbing.Answer;
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.support.ListRegionsOnServerFunction
|
||||
* @see ListRegionsOnServerFunction
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public class ListRegionsOnServerFunctionTest {
|
||||
@@ -69,14 +70,14 @@ public class ListRegionsOnServerFunctionTest {
|
||||
|
||||
ResultSender<Object> mockResultSender = mock(ResultSender.class, "MockGemFireResultSender");
|
||||
|
||||
when(mockCache.rootRegions()).thenReturn(new HashSet<Region<?, ?>>(
|
||||
when(mockCache.rootRegions()).thenReturn(new HashSet<>(
|
||||
Arrays.<Region<?, ?>>asList(mockRegionOne, mockRegionTwo, mockRegionThree)));
|
||||
when(mockRegionOne.getName()).thenReturn("One");
|
||||
when(mockRegionTwo.getName()).thenReturn("Two");
|
||||
when(mockRegionThree.getName()).thenReturn("Three");
|
||||
when(mockFunctionContext.getResultSender()).thenReturn(mockResultSender);
|
||||
|
||||
final AtomicReference<List<String>> regionNames = new AtomicReference<List<String>>(null);
|
||||
final AtomicReference<List<String>> regionNames = new AtomicReference<>(null);
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override
|
||||
@@ -118,10 +119,10 @@ public class ListRegionsOnServerFunctionTest {
|
||||
|
||||
ResultSender<Object> mockResultSender = mock(ResultSender.class, "MockGemFireResultSender");
|
||||
|
||||
when(mockCache.rootRegions()).thenReturn(Collections.<Region<?, ?>>emptySet());
|
||||
when(mockCache.rootRegions()).thenReturn(Collections.emptySet());
|
||||
when(mockFunctionContext.getResultSender()).thenReturn(mockResultSender);
|
||||
|
||||
final AtomicReference<List<String>> regionNames = new AtomicReference<List<String>>(null);
|
||||
final AtomicReference<List<String>> regionNames = new AtomicReference<>(null);
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override
|
||||
@@ -164,5 +165,4 @@ public class ListRegionsOnServerFunctionTest {
|
||||
assertThat(function.isHA(), is(false));
|
||||
assertThat(function.optimizeForWrite(), is(false));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.GemfireTransactionManager;
|
||||
import org.springframework.data.gemfire.transaction.GemfireTransactionManager;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2016 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.dao;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.data.gemfire.GemfireOperations;
|
||||
import org.springframework.data.gemfire.GemfireTemplate;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link GemfireDaoSupport}.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.junit.Rule
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mock
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.mockito.runners.MockitoJUnitRunner
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class GemfireDaoSupportUnitTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Mock
|
||||
public Region<?, ?> mockRegion;
|
||||
|
||||
@Test
|
||||
public void setAndGetGemfireTemplate() {
|
||||
GemfireTemplate expectedGemfireTemplate = new GemfireTemplate(mockRegion);
|
||||
GemfireDaoSupport dao = new TestGemfireDaoSupport();
|
||||
|
||||
assertThat(dao.getGemfireTemplate()).isNull();
|
||||
|
||||
dao.setGemfireTemplate(expectedGemfireTemplate);
|
||||
|
||||
assertThat(dao.getGemfireTemplate()).isSameAs(expectedGemfireTemplate);
|
||||
|
||||
dao.setGemfireTemplate(null);
|
||||
|
||||
assertThat(dao.getGemfireTemplate()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setRegion() {
|
||||
GemfireDaoSupport dao = new TestGemfireDaoSupport();
|
||||
|
||||
dao.setRegion(mockRegion);
|
||||
|
||||
GemfireOperations gemfireTemplate = dao.getGemfireTemplate();
|
||||
|
||||
assertThat(gemfireTemplate).isNotNull();
|
||||
assertThat(gemfireTemplate).isInstanceOf(GemfireTemplate.class);
|
||||
assertThat(((GemfireTemplate) gemfireTemplate).getRegion()).isSameAs(mockRegion);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void createProperlyInitializedGemfireDaoSupportWithTemplate() throws Exception {
|
||||
GemfireTemplate expectedGemfireTemplate = new GemfireTemplate();
|
||||
GemfireDaoSupport dao = new TestGemfireDaoSupport();
|
||||
|
||||
dao.setGemfireTemplate(expectedGemfireTemplate);
|
||||
dao.afterPropertiesSet();
|
||||
|
||||
assertThat(dao.getGemfireTemplate()).isNotNull();
|
||||
assertThat(dao.getGemfireTemplate()).isEqualTo(expectedGemfireTemplate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidGemfireDaoSupportInstanceThrowsIllegalStateException() throws Exception {
|
||||
exception.expect(IllegalStateException.class);
|
||||
exception.expectCause(is(nullValue(Throwable.class)));
|
||||
exception.expectMessage("A GemFire Cache Region or instance of GemfireTemplate is required");
|
||||
|
||||
new TestGemfireDaoSupport().afterPropertiesSet();
|
||||
}
|
||||
|
||||
private static final class TestGemfireDaoSupport extends GemfireDaoSupport {
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,21 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2016 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
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
* 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.support;
|
||||
package org.springframework.data.gemfire.serialization.json;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -34,23 +38,28 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.gemfire.GemfireOperations;
|
||||
import org.springframework.data.gemfire.repository.sample.Person;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* JSONRegionAdviceTest is a test suite of test cases testing SDG's support for storing and retrieving JSON data
|
||||
* in GemFire Cache Regions (un)marshalled using Jackson.
|
||||
* Integration test to test SDG support for storing and reading JSON data to/from
|
||||
* a GemFire Cache {@link Region} by (un)marshalled JSON data using Jackson.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.data.gemfire.GemfireOperations
|
||||
* @see org.springframework.data.gemfire.serialization.json.JSONRegionAdvice
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings({ "unchecked", "unused" })
|
||||
public class JSONRegionAdviceTest {
|
||||
|
||||
// TODO figure out why auto-proxying the Region for JSON support prevents the GemfireTemplate from being "auto-wired",
|
||||
// as a GemfireTemplate rather than GemfireOperations, resulting in a NoSuchBeanDefinitionException thrown by the
|
||||
// Spring container!?!?!?!?
|
||||
// Spring container?
|
||||
@Autowired
|
||||
private GemfireOperations template;
|
||||
|
||||
@@ -132,5 +141,4 @@ public class JSONRegionAdviceTest {
|
||||
SelectResults<String> results = template.query("firstname='Dave'");
|
||||
assertEquals(toJson(daveTuranski), results.iterator().next());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.gemfire.GemfireOperations;
|
||||
import org.springframework.data.gemfire.GemfireTemplate;
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
*/
|
||||
public class GemfireDaoSupportTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testGemfireDaoSupportWithTemplate() throws Exception {
|
||||
final AtomicBoolean flag = new AtomicBoolean(false);
|
||||
|
||||
GemfireDaoSupport dao = new GemfireDaoSupport() {
|
||||
protected void initDao() {
|
||||
flag.set(true);
|
||||
}
|
||||
};
|
||||
|
||||
GemfireOperations expectedTemplate = new GemfireTemplate();
|
||||
|
||||
dao.setGemfireTemplate(expectedTemplate);
|
||||
dao.afterPropertiesSet();
|
||||
|
||||
assertNotNull("template not created", dao.getGemfireTemplate());
|
||||
assertEquals("incorrect template", expectedTemplate, dao.getGemfireTemplate());
|
||||
assertTrue("initDao not called", flag.get());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testInvalidDaoTemplate() throws Exception {
|
||||
new GemfireDaoSupport().afterPropertiesSet();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -92,6 +92,7 @@ public class WiringDeclarableSupportIntegrationTests {
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@SuppressWarnings("all")
|
||||
public static class TestCacheLoader extends WiringDeclarableSupport implements CacheLoader<String, String> {
|
||||
|
||||
private Object propertyOne;
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
* Copyright 2016 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
|
||||
* 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;
|
||||
package org.springframework.data.gemfire.test.support;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -25,8 +26,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.springframework.data.gemfire.fork.ServerProcess;
|
||||
import org.springframework.data.gemfire.process.ProcessExecutor;
|
||||
import org.springframework.data.gemfire.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.test.support.FileSystemUtils;
|
||||
import org.springframework.data.gemfire.test.support.ThreadUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
* Copyright 2016 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.
|
||||
@@ -12,9 +12,10 @@
|
||||
* 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.support;
|
||||
package org.springframework.data.gemfire.test.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
* Copyright 2016 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.
|
||||
@@ -12,9 +12,10 @@
|
||||
* 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.support;
|
||||
package org.springframework.data.gemfire.test.support;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
@@ -33,19 +34,15 @@ import org.springframework.data.gemfire.test.StubCache;
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
*/
|
||||
public abstract class AbstractRegionFactoryBeanTest {
|
||||
public abstract class AbstractRegionFactoryBeanTests {
|
||||
|
||||
private GemFireCache cache;
|
||||
|
||||
private Map<String, RegionFactoryBeanConfig> regionFactoryBeanConfigs = new HashMap<String, RegionFactoryBeanConfig>();
|
||||
private Map<String, RegionFactoryBeanConfig> regionFactoryBeanConfigs = new HashMap<>();
|
||||
|
||||
@AfterClass
|
||||
public static void cleanUp() {
|
||||
for (String name : new File(".").list(new FilenameFilter() {
|
||||
@Override public boolean accept(File dir, String name) {
|
||||
return name.startsWith("BACKUP");
|
||||
}
|
||||
})) {
|
||||
for (String name : new File(".").list((dir, name1) -> name1.startsWith("BACKUP"))) {
|
||||
new File(name).delete();
|
||||
}
|
||||
}
|
||||
@@ -114,5 +111,4 @@ public abstract class AbstractRegionFactoryBeanTest {
|
||||
|
||||
public abstract void verify();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,10 +17,10 @@
|
||||
<bean id="cache" class="org.springframework.data.gemfire.CacheFactoryBean">
|
||||
<property name="properties" ref="gemfireProperties"/>
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.data.gemfire.GemfireTransactionManager" p:cache-ref="cache"/>
|
||||
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.data.gemfire.transaction.GemfireTransactionManager" p:cache-ref="cache"/>
|
||||
|
||||
<bean id="rollback-region" class="org.springframework.data.gemfire.LocalRegionFactoryBean" p:name="r-region" p:cache-ref="cache" p:close="false"/>
|
||||
<bean id="commit-region" class="org.springframework.data.gemfire.LocalRegionFactoryBean" p:name="c-region" p:cache-ref="cache" p:close="false"/>
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<!-- gfe-data:json-region-autoproxy replaces... -->
|
||||
<!--
|
||||
<aop:aspectj-autoproxy/>
|
||||
<bean class="org.springframework.data.gemfire.support.JSONRegionAdvice"/>
|
||||
<bean class="org.springframework.data.gemfire.serialization.json.JSONRegionAdvice"/>
|
||||
-->
|
||||
|
||||
<bean class="org.springframework.data.gemfire.GemfireTemplate" p:region-ref="jsonRegion"/>
|
||||
Reference in New Issue
Block a user