Fix tests.
Resolves gh-296.
This commit is contained in:
@@ -88,6 +88,7 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.apache.geode.GemFireException
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.CacheFactory
|
||||
* @see org.apache.geode.cache.DiskStore
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.TransactionListener
|
||||
@@ -250,6 +251,7 @@ public abstract class AbstractBasicCacheFactoryBean extends AbstractFactoryBeanS
|
||||
* are copied when read (i.e. {@link Region#get(Object)}.
|
||||
* @see #getCopyOnRead()
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public boolean isCopyOnRead() {
|
||||
return Boolean.TRUE.equals(getCopyOnRead());
|
||||
}
|
||||
@@ -510,6 +512,7 @@ public abstract class AbstractBasicCacheFactoryBean extends AbstractFactoryBeanS
|
||||
* in the Spring container.
|
||||
* @see org.springframework.context.Phased#getPhase()
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
protected void setPhase(int phase) {
|
||||
this.phase = phase;
|
||||
}
|
||||
@@ -598,18 +601,30 @@ public abstract class AbstractBasicCacheFactoryBean extends AbstractFactoryBeanS
|
||||
* @param cache {@link GemFireCache} to close.
|
||||
* @see org.apache.geode.cache.GemFireCache#isClosed()
|
||||
* @see org.apache.geode.cache.GemFireCache#close()
|
||||
* @see #isNotClosed(GemFireCache)
|
||||
*/
|
||||
protected void close(@Nullable GemFireCache cache) {
|
||||
|
||||
Optional.ofNullable(cache)
|
||||
.filter(it -> !it.isClosed())
|
||||
.filter(this::isNotClosed)
|
||||
.ifPresent(GemFireCache::close);
|
||||
|
||||
setCache(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the cache bean on Spring Container shutdown.
|
||||
* Determines if the {@link GemFireCache} has not been closed yet.
|
||||
*
|
||||
* @param cache {@link GemFireCache} to evaluate.
|
||||
* @return a boolean value indicating if the {@link GemFireCache} is not yet closed.
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
*/
|
||||
protected boolean isNotClosed(@Nullable GemFireCache cache) {
|
||||
return cache == null || !cache.isClosed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the cache bean on Spring container shutdown.
|
||||
*
|
||||
* @see org.springframework.beans.factory.DisposableBean#destroy()
|
||||
* @see #close(GemFireCache)
|
||||
|
||||
@@ -13,44 +13,49 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import java.beans.PropertyEditor;
|
||||
|
||||
import org.apache.geode.cache.Scope;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* The ScopeConverter class is a Spring Converter and JavaBeans PropertyEditor that converts Strings
|
||||
* into GemFire Scope constant values.
|
||||
* The {@link ScopeConverter} class is a Spring {@link Converter} and JavaBeans {@link PropertyEditor}
|
||||
* that converts a {@link String} into a {@link Scope}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport
|
||||
* @see java.beans.PropertyEditor
|
||||
* @see org.apache.geode.cache.Scope
|
||||
* @see org.springframework.core.convert.converter.Converter
|
||||
* @see org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class ScopeConverter extends AbstractPropertyEditorConverterSupport<Scope> {
|
||||
|
||||
/**
|
||||
* Converts the given String source into an instance of GemFire Scope.
|
||||
* Converts the given {@link String} into an instance of {@link Scope}.
|
||||
*
|
||||
* @param source the String to convert into a GemFire Scope.
|
||||
* @return a GemFire Scope for the given String.
|
||||
* @throws java.lang.IllegalArgumentException if the String is not a valid GemFire Scope.
|
||||
* @see org.springframework.data.gemfire.ScopeType#getScope(ScopeType)
|
||||
* @see org.springframework.data.gemfire.ScopeType#valueOfIgnoreCase(String)
|
||||
* @see org.apache.geode.cache.Scope#fromString(String)
|
||||
* @see #assertConverted(String, Object, Class)
|
||||
* @see org.springframework.data.gemfire.ScopeType#valueOfIgnoreCase(String)
|
||||
* @see org.springframework.data.gemfire.ScopeType#getScope(ScopeType)
|
||||
*/
|
||||
@Override
|
||||
public Scope convert(final String source) {
|
||||
public @NonNull Scope convert(@Nullable String source) {
|
||||
|
||||
try {
|
||||
return Scope.fromString(source);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
catch (IllegalArgumentException cause) {
|
||||
return assertConverted(source, ScopeType.getScope(ScopeType.valueOfIgnoreCase(source)), Scope.class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.cache;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
@@ -93,7 +92,9 @@ public class CallableCacheLoaderAdapter<K, V> implements Callable<V>, CacheLoade
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
public CallableCacheLoaderAdapter(CacheLoader<K, V> delegate, K key, Region<K, V> region, Object argument) {
|
||||
|
||||
Assert.notNull(delegate, "CacheLoader must not be null");
|
||||
|
||||
this.cacheLoader = delegate;
|
||||
this.argument = argument;
|
||||
this.key = key;
|
||||
@@ -106,7 +107,7 @@ public class CallableCacheLoaderAdapter<K, V> implements Callable<V>, CacheLoade
|
||||
* @return an Object argument used by this {@link CacheLoader} when loading the value for the specified key.
|
||||
*/
|
||||
protected Object getArgument() {
|
||||
return argument;
|
||||
return this.argument;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +117,7 @@ public class CallableCacheLoaderAdapter<K, V> implements Callable<V>, CacheLoade
|
||||
* @see org.apache.geode.cache.CacheLoader
|
||||
*/
|
||||
protected CacheLoader<K, V> getCacheLoader() {
|
||||
return cacheLoader;
|
||||
return this.cacheLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +126,7 @@ public class CallableCacheLoaderAdapter<K, V> implements Callable<V>, CacheLoade
|
||||
* @return the specified key for which the value will be loaded.
|
||||
*/
|
||||
protected K getKey() {
|
||||
return key;
|
||||
return this.key;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +136,7 @@ public class CallableCacheLoaderAdapter<K, V> implements Callable<V>, CacheLoade
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
protected Region<K, V> getRegion() {
|
||||
return region;
|
||||
return this.region;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,10 +148,12 @@ public class CallableCacheLoaderAdapter<K, V> implements Callable<V>, CacheLoade
|
||||
* @see #load(LoaderHelper)
|
||||
*/
|
||||
public final V call() throws Exception {
|
||||
|
||||
Assert.state(getKey() != null, "The key for which the value is loaded for cannot be null");
|
||||
Assert.state(getRegion() != null, "The Region to load cannot be null");
|
||||
|
||||
return load(new LoaderHelper<K, V>() {
|
||||
|
||||
public V netSearch(final boolean doNetLoad) throws CacheLoaderException, TimeoutException {
|
||||
throw new UnsupportedOperationException("not implemented");
|
||||
}
|
||||
|
||||
@@ -42,6 +42,8 @@ import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.data.gemfire.ConfigurableRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.client.support.BeanFactoryPoolResolver;
|
||||
import org.springframework.data.gemfire.client.support.ComposablePoolResolver;
|
||||
import org.springframework.data.gemfire.client.support.PoolManagerPoolResolver;
|
||||
import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
import org.springframework.data.gemfire.eviction.EvictingRegionFactoryBean;
|
||||
@@ -78,6 +80,7 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.springframework.beans.factory.DisposableBean
|
||||
* @see org.springframework.beans.factory.FactoryBean
|
||||
* @see org.springframework.data.gemfire.ConfigurableRegionFactoryBean
|
||||
* @see org.springframework.data.gemfire.client.PoolResolver
|
||||
* @see org.springframework.data.gemfire.config.annotation.RegionConfigurer
|
||||
* @see org.springframework.data.gemfire.eviction.EvictingRegionFactoryBean
|
||||
* @see org.springframework.data.gemfire.expiration.ExpiringRegionFactoryBean
|
||||
@@ -90,8 +93,6 @@ public class ClientRegionFactoryBean<K, V> extends ConfigurableRegionFactoryBean
|
||||
public static final String DEFAULT_POOL_NAME = "DEFAULT";
|
||||
public static final String GEMFIRE_POOL_NAME = GemfireConstants.DEFAULT_GEMFIRE_POOL_NAME;
|
||||
|
||||
protected static final PoolResolver DEFAULT_POOL_RESOLVER = new PoolManagerPoolResolver();
|
||||
|
||||
private boolean close = false;
|
||||
private boolean destroy = false;
|
||||
|
||||
@@ -133,13 +134,28 @@ public class ClientRegionFactoryBean<K, V> extends ConfigurableRegionFactoryBean
|
||||
|
||||
private Float loadFactor;
|
||||
|
||||
private PoolResolver poolResolver = DEFAULT_POOL_RESOLVER;
|
||||
private PoolResolver defaultPoolResolver;
|
||||
private PoolResolver poolResolver;
|
||||
|
||||
private RegionAttributes<K, V> attributes;
|
||||
|
||||
private String diskStoreName;
|
||||
private String poolName;
|
||||
|
||||
/**
|
||||
* Initializes a the instance of {@link ClientRegionFactoryBean}.
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
|
||||
this.defaultPoolResolver =
|
||||
ComposablePoolResolver.compose(new BeanFactoryPoolResolver(getBeanFactory()), new PoolManagerPoolResolver());
|
||||
|
||||
this.poolResolver = defaultPoolResolver;
|
||||
|
||||
super.afterPropertiesSet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Region} with the given {@link String name}.
|
||||
*
|
||||
@@ -267,7 +283,6 @@ public class ClientRegionFactoryBean<K, V> extends ConfigurableRegionFactoryBean
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
private boolean eagerlyInitializePool(String poolName) {
|
||||
|
||||
return Optional.ofNullable(getPoolResolver().resolve(poolName))
|
||||
@@ -708,13 +723,29 @@ public class ClientRegionFactoryBean<K, V> extends ConfigurableRegionFactoryBean
|
||||
* @return the configured {@link PoolResolver}. If no {@link PoolResolver} was configured, then return the default,
|
||||
* {@link PoolManagerPoolResolver}.
|
||||
* @see org.springframework.data.gemfire.client.PoolResolver
|
||||
* @see org.springframework.data.gemfire.client.support.PoolManagerPoolResolver
|
||||
* @see #getDefaultPoolResolver()
|
||||
*/
|
||||
public @NonNull PoolResolver getPoolResolver() {
|
||||
|
||||
PoolResolver poolResolver = this.poolResolver;
|
||||
|
||||
return poolResolver != null ? poolResolver : DEFAULT_POOL_RESOLVER;
|
||||
return poolResolver != null ? poolResolver : getDefaultPoolResolver();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a reference to the configured, default {@link PoolResolver} used by this client {@link Region} to resolve
|
||||
* {@link Pool} objects if a explicit {@link PoolResolver} was not configured.
|
||||
*
|
||||
* The {@literal default} {@link PoolResolver} uses a composition of the {@link BeanFactoryPoolResolver}
|
||||
* and {@link PoolManagerPoolResolver} to fallback on.
|
||||
*
|
||||
* @return the {@literal default} {@link PoolResolver}.
|
||||
* @see org.springframework.data.gemfire.client.support.BeanFactoryPoolResolver
|
||||
* @see org.springframework.data.gemfire.client.support.PoolManagerPoolResolver
|
||||
* @see org.springframework.data.gemfire.client.PoolResolver
|
||||
*/
|
||||
public @NonNull PoolResolver getDefaultPoolResolver() {
|
||||
return this.defaultPoolResolver;
|
||||
}
|
||||
|
||||
public void setRegionIdleTimeout(ExpirationAttributes regionIdleTimeout) {
|
||||
|
||||
@@ -17,12 +17,12 @@ package org.springframework.data.gemfire.client;
|
||||
|
||||
import static java.util.stream.StreamSupport.stream;
|
||||
import static org.springframework.data.gemfire.util.ArrayUtils.nullSafeArray;
|
||||
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeCollection;
|
||||
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeIterable;
|
||||
import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newIllegalArgumentException;
|
||||
import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newIllegalStateException;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -45,7 +45,9 @@ import org.springframework.data.gemfire.config.annotation.PoolConfigurer;
|
||||
import org.springframework.data.gemfire.support.AbstractFactoryBeanSupport;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpoint;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpointList;
|
||||
import org.springframework.data.gemfire.util.CollectionUtils;
|
||||
import org.springframework.data.gemfire.util.DistributedSystemUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -110,15 +112,32 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
private long idleTimeout = PoolFactory.DEFAULT_IDLE_TIMEOUT;
|
||||
private long pingInterval = PoolFactory.DEFAULT_PING_INTERVAL;
|
||||
|
||||
private ConnectionEndpointList locators = new ConnectionEndpointList();
|
||||
private ConnectionEndpointList servers = new ConnectionEndpointList();
|
||||
private final ConnectionEndpointList locators = new ConnectionEndpointList();
|
||||
private final ConnectionEndpointList servers = new ConnectionEndpointList();
|
||||
private final ConnectionEndpointList xmlDeclaredLocators = new ConnectionEndpointList();
|
||||
private final ConnectionEndpointList xmlDeclaredServers = new ConnectionEndpointList();
|
||||
|
||||
private List<PoolConfigurer> poolConfigurers = Collections.emptyList();
|
||||
|
||||
private volatile Pool pool;
|
||||
|
||||
private PoolConfigurer compositePoolConfigurer = (beanName, bean) ->
|
||||
nullSafeCollection(this.poolConfigurers).forEach(poolConfigurer -> poolConfigurer.configure(beanName, bean));
|
||||
private final PoolConfigurer xmlDeclaredServersPoolConfigurer = (beanName, bean) ->
|
||||
bean.addServers(this.xmlDeclaredServers);
|
||||
|
||||
private final PoolConfigurer xmlDeclaredLocatorsPoolConfigurer = (beanName, bean) ->
|
||||
bean.addLocators(this.xmlDeclaredLocators);
|
||||
|
||||
private final PoolConfigurer compositePoolConfigurer = (beanName, bean) -> {
|
||||
|
||||
List<PoolConfigurer> allPoolConfigurers =
|
||||
new ArrayList<>(CollectionUtils.nullSafeSize(this.poolConfigurers) + 2);
|
||||
|
||||
allPoolConfigurers.add(this.xmlDeclaredLocatorsPoolConfigurer);
|
||||
allPoolConfigurers.add(this.xmlDeclaredServersPoolConfigurer);
|
||||
allPoolConfigurers.addAll(CollectionUtils.nullSafeCollection(this.poolConfigurers));
|
||||
|
||||
allPoolConfigurers.forEach(poolConfigurer -> poolConfigurer.configure(beanName, bean));
|
||||
};
|
||||
|
||||
private PoolFactoryInitializer poolFactoryInitializer;
|
||||
|
||||
@@ -252,10 +271,12 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
|
||||
eagerlyInitializeClientCache();
|
||||
|
||||
Pool namedPool = resolvePool(getName());
|
||||
String poolName = getName();
|
||||
|
||||
Pool namedPool = resolvePool(poolName);
|
||||
|
||||
this.pool = namedPool != null ? namedPool
|
||||
: postProcess(create(postProcess(configure(initialize(createPoolFactory()))), getName()));
|
||||
: postProcess(create(postProcess(configure(initialize(createPoolFactory()))), poolName));
|
||||
|
||||
return this.pool;
|
||||
});
|
||||
@@ -340,10 +361,10 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
it.setSubscriptionTimeoutMultiplier(this.subscriptionTimeoutMultiplier);
|
||||
it.setThreadLocalConnections(this.threadLocalConnections);
|
||||
|
||||
nullSafeCollection(this.locators).forEach(locator ->
|
||||
CollectionUtils.nullSafeCollection(this.locators).forEach(locator ->
|
||||
it.addLocator(locator.getHost(), locator.getPort()));
|
||||
|
||||
nullSafeCollection(this.servers).forEach(server ->
|
||||
CollectionUtils.nullSafeCollection(this.servers).forEach(server ->
|
||||
it.addServer(server.getHost(), server.getPort()));
|
||||
});
|
||||
|
||||
@@ -412,6 +433,8 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
*
|
||||
* @return the {@link Class type} of {@link Pool} produced by this {@link PoolFactoryBean}.
|
||||
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see java.lang.Class
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
@@ -445,19 +468,49 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
return this.compositePoolConfigurer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the {@link String name} of the {@link Pool} bean.
|
||||
*
|
||||
* @param name {@link String} containing the name for the {@link Pool} bean.
|
||||
* @see #getName()
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configured {@link String name} of the {@link Pool} bean.
|
||||
*
|
||||
* @return the configured {@link String name} of the {@link Pool} bean.
|
||||
* @see #getBeanName()
|
||||
* @see #setName(String)
|
||||
*/
|
||||
protected String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setPool(Pool pool) {
|
||||
/**
|
||||
* Configures the {@link Pool} to be returned by this {@link PoolFactoryBean}.
|
||||
*
|
||||
* @param pool the {@link Pool} to be returned by this {@link PoolFactoryBean}.
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
*/
|
||||
public void setPool(@Nullable Pool pool) {
|
||||
this.pool = pool;
|
||||
}
|
||||
|
||||
public Pool getPool() {
|
||||
/**
|
||||
* Gets the {@link Pool} configured and built by this {@link PoolFactoryBean}.
|
||||
*
|
||||
* May return a proxy {@link Pool} if the actual {@link Pool} has not yet been configured and built by
|
||||
* this {@link PoolFactoryBean}. In this case, the proxy {@link Pool} object will have the same configuration
|
||||
* as the final {@link Pool} built by this {@link PoolFactoryBean}.
|
||||
*
|
||||
* @return the {@link Pool} configured and built by this {@link PoolFactoryBean}.
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see #setPool(Pool)
|
||||
*/
|
||||
public @NonNull Pool getPool() {
|
||||
|
||||
return Optional.ofNullable(this.pool).orElseGet(() -> new PoolAdapter() {
|
||||
|
||||
@@ -666,17 +719,17 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
this.loadConditioningInterval = loadConditioningInterval;
|
||||
}
|
||||
|
||||
public void setLocators(ConnectionEndpoint[] connectionEndpoints) {
|
||||
setLocators(ConnectionEndpointList.from(connectionEndpoints));
|
||||
public void setLocators(ConnectionEndpoint[] locators) {
|
||||
setLocators(ConnectionEndpointList.from(locators));
|
||||
}
|
||||
|
||||
public void setLocators(Iterable<ConnectionEndpoint> connectionEndpoints) {
|
||||
public void setLocators(Iterable<ConnectionEndpoint> locators) {
|
||||
getLocators().clear();
|
||||
getLocators().add(connectionEndpoints);
|
||||
getLocators().add(locators);
|
||||
}
|
||||
|
||||
ConnectionEndpointList getLocators() {
|
||||
return locators;
|
||||
return this.locators;
|
||||
}
|
||||
|
||||
public void setMaxConnections(int maxConnections) {
|
||||
@@ -777,17 +830,17 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
this.serverGroup = serverGroup;
|
||||
}
|
||||
|
||||
public void setServers(ConnectionEndpoint[] connectionEndpoints) {
|
||||
setServers(ConnectionEndpointList.from(connectionEndpoints));
|
||||
public void setServers(ConnectionEndpoint[] servers) {
|
||||
setServers(ConnectionEndpointList.from(servers));
|
||||
}
|
||||
|
||||
public void setServers(Iterable<ConnectionEndpoint> connectionEndpoints) {
|
||||
public void setServers(Iterable<ConnectionEndpoint> servers) {
|
||||
getServers().clear();
|
||||
getServers().add(connectionEndpoints);
|
||||
getServers().add(servers);
|
||||
}
|
||||
|
||||
ConnectionEndpointList getServers() {
|
||||
return servers;
|
||||
return this.servers;
|
||||
}
|
||||
|
||||
public void setSocketBufferSize(int socketBufferSize) {
|
||||
@@ -835,11 +888,13 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
this.threadLocalConnections = threadLocalConnections;
|
||||
}
|
||||
|
||||
// Internal framework use only.
|
||||
public final void setLocatorsConfiguration(Object locatorsConfiguration) { }
|
||||
public void setXmlDeclaredLocators(ConnectionEndpointList xmlDeclaredLocators) {
|
||||
this.xmlDeclaredLocators.add(xmlDeclaredLocators);
|
||||
}
|
||||
|
||||
// Internal framework use only.
|
||||
public final void setServersConfiguration(Object serversConfiguration) { }
|
||||
public void setXmlDeclaredServers(ConnectionEndpointList xmlDeclaredServers) {
|
||||
this.xmlDeclaredServers.add(xmlDeclaredServers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback interface to initialize the {@link PoolFactory} used by this {@link PoolFactoryBean}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.support;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -22,6 +21,9 @@ import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.client.Pool;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -31,13 +33,16 @@ import org.springframework.data.gemfire.util.SpringUtils;
|
||||
|
||||
/**
|
||||
* {@link ClientRegionPoolBeanFactoryPostProcessor} is a Spring {@link BeanFactoryPostProcessor} implementation
|
||||
* ensuring a proper dependency is declared between a GemFire client {@link org.apache.geode.cache.Region}
|
||||
* and the GemFire client {@link org.apache.geode.cache.client.Pool} it references and uses, providing
|
||||
* the GemFire client {@link org.apache.geode.cache.client.Pool} has been defined and configured with
|
||||
* Spring (Data GemFire) configuration meta-data (e.g. XML).
|
||||
* ensuring a proper dependency is declared between a client {@link Region} and a client {@link Pool} it references
|
||||
* and uses, providing the client {@link Pool} has been defined and configured with Spring Data for Apache Geode
|
||||
* configuration metadata (e.g. XML).
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see org.springframework.beans.factory.config.BeanDefinition
|
||||
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor
|
||||
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory
|
||||
* @since 1.8.2
|
||||
*/
|
||||
public class ClientRegionPoolBeanFactoryPostProcessor extends AbstractDependencyStructuringBeanFactoryPostProcessor {
|
||||
@@ -48,7 +53,6 @@ public class ClientRegionPoolBeanFactoryPostProcessor extends AbstractDependency
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
|
||||
Set<String> clientRegionBeanNames = new HashSet<>();
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.support;
|
||||
|
||||
import java.beans.PropertyEditor;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
|
||||
import org.apache.geode.cache.EvictionAction;
|
||||
@@ -49,11 +49,13 @@ import org.springframework.data.gemfire.wan.OrderPolicyConverter;
|
||||
|
||||
/**
|
||||
* {@link CustomEditorBeanFactoryPostProcessor} is a Spring {@link BeanFactoryPostProcessor} implementation
|
||||
* used to register custom {@link java.beans.PropertyEditor PropertyEditors} / Spring {@link Converter Converters}
|
||||
* that are used to perform type conversions between String-based configuration meta-data and actual GemFire
|
||||
* or Spring Data GemFire defined (enumerated) types.
|
||||
* used to register custom {@link PropertyEditor PropertyEditors} / Spring {@link Converter Converters}
|
||||
* that are used to perform type conversions between {@link String String-based} configuration metadata
|
||||
* and actual Apache Geode or Spring Data for Apache Geode defined (enumerated) types.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.beans.PropertyEditor
|
||||
* @see java.beans.PropertyEditorSupport
|
||||
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@@ -63,7 +65,6 @@ public class CustomEditorBeanFactoryPostProcessor implements BeanFactoryPostProc
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
|
||||
beanFactory.registerCustomEditor(ConnectionEndpoint.class, StringToConnectionEndpointConverter.class);
|
||||
@@ -81,9 +82,8 @@ public class CustomEditorBeanFactoryPostProcessor implements BeanFactoryPostProc
|
||||
beanFactory.registerCustomEditor(SubscriptionEvictionPolicy.class, SubscriptionEvictionPolicyConverter.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static class ConnectionEndpointArrayToIterableConverter extends PropertyEditorSupport
|
||||
implements Converter<ConnectionEndpoint[], Iterable> {
|
||||
implements Converter<ConnectionEndpoint[], Iterable<?>> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -95,7 +95,6 @@ public class CustomEditorBeanFactoryPostProcessor implements BeanFactoryPostProc
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static class StringToConnectionEndpointConverter
|
||||
extends AbstractPropertyEditorConverterSupport<ConnectionEndpoint> {
|
||||
|
||||
@@ -103,13 +102,11 @@ public class CustomEditorBeanFactoryPostProcessor implements BeanFactoryPostProc
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public ConnectionEndpoint convert(String source) {
|
||||
return assertConverted(source, ConnectionEndpoint.parse(source), ConnectionEndpoint.class);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static class StringToConnectionEndpointListConverter
|
||||
extends AbstractPropertyEditorConverterSupport<ConnectionEndpointList> {
|
||||
|
||||
@@ -117,7 +114,6 @@ public class CustomEditorBeanFactoryPostProcessor implements BeanFactoryPostProc
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public ConnectionEndpointList convert(String source) {
|
||||
return assertConverted(source, ConnectionEndpointList.parse(0, source.split(",")),
|
||||
ConnectionEndpointList.class);
|
||||
|
||||
@@ -20,10 +20,6 @@ import java.util.Optional;
|
||||
|
||||
import org.apache.geode.internal.datasource.ConfigProperty;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
@@ -42,6 +38,10 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
|
||||
/**
|
||||
* {@link BeanDefinitionParser} for the <gfe:cache> SDG XML Namespace (XSD) element.
|
||||
*
|
||||
@@ -155,7 +155,7 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
String pdxDiskStoreName = element.getAttribute("pdx-disk-store");
|
||||
|
||||
if (!StringUtils.isEmpty(pdxDiskStoreName)) {
|
||||
if (StringUtils.hasText(pdxDiskStoreName)) {
|
||||
registerPdxDiskStoreAwareBeanFactoryPostProcessor(getRegistry(parserContext), pdxDiskStoreName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,24 +13,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.MethodInvokingBean;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
@@ -39,16 +31,19 @@ import org.springframework.data.gemfire.client.PoolFactoryBean;
|
||||
import org.springframework.data.gemfire.config.support.ClientRegionPoolBeanFactoryPostProcessor;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpoint;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpointList;
|
||||
import org.springframework.data.gemfire.util.SpringUtils;
|
||||
import org.springframework.data.gemfire.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Bean definition parser for <gfe:pool> SDG XML namespace (XSD) elements.
|
||||
* Spring {@link BeanDefinition} parser for <gfe:pool> SDG XML Namespace (XSD), schema element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.config.BeanDefinition
|
||||
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.client.PoolFactoryBean
|
||||
*/
|
||||
@@ -71,7 +66,7 @@ class PoolParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
if (INFRASTRUCTURE_COMPONENTS_REGISTERED.compareAndSet(false, true)) {
|
||||
|
||||
// Be careful to not to register this infrastructure component (just yet; requires more thought)
|
||||
// TODO: Be careful not to register this infrastructure component just yet (requires more thought).
|
||||
/*
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(
|
||||
BeanDefinitionBuilder.rootBeanDefinition(ClientCachePoolBeanFactoryPostProcessor.class)
|
||||
@@ -102,9 +97,6 @@ class PoolParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
registerInfrastructureComponents(parserContext);
|
||||
|
||||
// Be careful not to enable this dependency
|
||||
//poolBuilder.addDependsOn(GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME);
|
||||
|
||||
ParsingUtils.setPropertyValue(element, poolBuilder, "free-connection-timeout");
|
||||
ParsingUtils.setPropertyValue(element, poolBuilder, "idle-timeout");
|
||||
ParsingUtils.setPropertyValue(element, poolBuilder, "keep-alive");
|
||||
@@ -132,27 +124,27 @@ class PoolParser extends AbstractSingleBeanDefinitionParser {
|
||||
ManagedList<BeanDefinition> locators = new ManagedList<>(childElements.size());
|
||||
ManagedList<BeanDefinition> servers = new ManagedList<>(childElements.size());
|
||||
|
||||
nullSafeList(childElements).forEach(childElement -> {
|
||||
CollectionUtils.nullSafeList(childElements).forEach(childElement -> {
|
||||
|
||||
String childElementName = childElement.getLocalName();
|
||||
|
||||
if (LOCATOR_ELEMENT_NAME.equals(childElementName)) {
|
||||
locators.add(parseLocator(childElement));
|
||||
locators.add(parseLocator(childElement, parserContext));
|
||||
}
|
||||
|
||||
if (SERVER_ELEMENT_NAME.equals(childElementName)) {
|
||||
servers.add(parseServer(childElement));
|
||||
servers.add(parseServer(childElement, parserContext));
|
||||
}
|
||||
});
|
||||
|
||||
BeanDefinitionRegistry registry = resolveRegistry(parserContext);
|
||||
boolean hasLocators = parseLocators(element, parserContext, poolBuilder);
|
||||
boolean hasServers = parseServers(element, parserContext, poolBuilder);
|
||||
|
||||
boolean locatorsSet = parseLocators(element, poolBuilder, registry);
|
||||
boolean serversSet = parseServers(element, poolBuilder, registry);
|
||||
boolean noLocatorsOrServers = locators.isEmpty() && servers.isEmpty() && !hasLocators && !hasServers;
|
||||
|
||||
// If neither Locators nor Servers were explicitly configured, then setup a connection to a CacheServer
|
||||
// running on localhost, listening on the default CacheServer port, 40404
|
||||
if (childElements.isEmpty() && !(locatorsSet || serversSet)) {
|
||||
// running on localhost, listening on the default CacheServer port 40404.
|
||||
if (noLocatorsOrServers) {
|
||||
servers.add(buildConnection(DEFAULT_HOST, String.valueOf(DEFAULT_SERVER_PORT), true));
|
||||
}
|
||||
|
||||
@@ -165,10 +157,6 @@ class PoolParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
BeanDefinitionRegistry resolveRegistry(ParserContext parserContext) {
|
||||
return parserContext.getRegistry();
|
||||
}
|
||||
|
||||
BeanDefinition buildConnection(String host, String port, boolean server) {
|
||||
|
||||
BeanDefinitionBuilder connectionEndpointBuilder =
|
||||
@@ -193,90 +181,63 @@ class PoolParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
|
||||
String defaultHost(String host) {
|
||||
return StringUtils.hasText(host) ? host : DEFAULT_HOST;
|
||||
}
|
||||
|
||||
return (StringUtils.hasText(host) ? host : DEFAULT_HOST);
|
||||
int defaultPort(boolean server) {
|
||||
return server ? DEFAULT_SERVER_PORT : DEFAULT_LOCATOR_PORT;
|
||||
}
|
||||
|
||||
String defaultPort(String port, boolean server) {
|
||||
|
||||
return (StringUtils.hasText(port) ? port
|
||||
: (server ? String.valueOf(DEFAULT_SERVER_PORT) : String.valueOf(DEFAULT_LOCATOR_PORT)));
|
||||
return StringUtils.hasText(port) ? port : String.valueOf(defaultPort(server));
|
||||
}
|
||||
|
||||
BeanDefinition parseLocator(Element element) {
|
||||
@SuppressWarnings("unused")
|
||||
BeanDefinition parseLocator(Element element, ParserContext parserContext) {
|
||||
|
||||
return buildConnection(element.getAttribute(HOST_ATTRIBUTE_NAME),
|
||||
element.getAttribute(PORT_ATTRIBUTE_NAME), false);
|
||||
}
|
||||
|
||||
boolean parseLocators(Element element, BeanDefinitionBuilder poolBuilder, BeanDefinitionRegistry registry) {
|
||||
@SuppressWarnings("unused")
|
||||
boolean parseLocators(Element element, ParserContext parserContext, BeanDefinitionBuilder poolBuilder) {
|
||||
|
||||
String locatorsAttributeValue = element.getAttribute(LOCATORS_ATTRIBUTE_NAME);
|
||||
|
||||
if (StringUtils.hasText(locatorsAttributeValue)) {
|
||||
|
||||
BeanDefinitionBuilder addLocatorsMethodInvokingBeanBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(MethodInvokingBean.class);
|
||||
|
||||
addLocatorsMethodInvokingBeanBuilder.addPropertyReference("targetObject", resolveDereferencedId(element));
|
||||
addLocatorsMethodInvokingBeanBuilder.addPropertyValue("targetMethod", "addLocators");
|
||||
addLocatorsMethodInvokingBeanBuilder.addPropertyValue("arguments",
|
||||
poolBuilder.addPropertyValue("xmlDeclaredLocators",
|
||||
buildConnections(locatorsAttributeValue, false));
|
||||
|
||||
AbstractBeanDefinition addLocatorsMethodInvokingBean =
|
||||
addLocatorsMethodInvokingBeanBuilder.getBeanDefinition();
|
||||
|
||||
poolBuilder.addPropertyReference("locatorsConfiguration",
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(addLocatorsMethodInvokingBean, registry));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
BeanDefinition parseServer(Element element) {
|
||||
@SuppressWarnings("unused")
|
||||
BeanDefinition parseServer(Element element, ParserContext parserContext) {
|
||||
|
||||
return buildConnection(element.getAttribute(HOST_ATTRIBUTE_NAME),
|
||||
element.getAttribute(PORT_ATTRIBUTE_NAME), true);
|
||||
}
|
||||
|
||||
boolean parseServers(Element element, BeanDefinitionBuilder poolBuilder, BeanDefinitionRegistry registry) {
|
||||
@SuppressWarnings("unused")
|
||||
boolean parseServers(Element element, ParserContext parserContext, BeanDefinitionBuilder poolBuilder) {
|
||||
|
||||
String serversAttributeValue = element.getAttribute(SERVERS_ATTRIBUTE_NAME);
|
||||
|
||||
if (StringUtils.hasText(serversAttributeValue)) {
|
||||
|
||||
BeanDefinitionBuilder addServersMethodInvokingBeanBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(MethodInvokingBean.class);
|
||||
|
||||
addServersMethodInvokingBeanBuilder.addPropertyReference("targetObject", resolveDereferencedId(element));
|
||||
addServersMethodInvokingBeanBuilder.addPropertyValue("targetMethod", "addServers");
|
||||
addServersMethodInvokingBeanBuilder.addPropertyValue("arguments",
|
||||
poolBuilder.addPropertyValue("xmlDeclaredServers",
|
||||
buildConnections(serversAttributeValue, true));
|
||||
|
||||
AbstractBeanDefinition addServersMethodInvokingBean =
|
||||
addServersMethodInvokingBeanBuilder.getBeanDefinition();
|
||||
|
||||
poolBuilder.addPropertyReference("serversConfiguration",
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(addServersMethodInvokingBean, registry));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
String resolveId(Element element) {
|
||||
|
||||
return Optional.ofNullable(element.getAttribute(ID_ATTRIBUTE)).filter(StringUtils::hasText)
|
||||
.orElse(GemfireConstants.DEFAULT_GEMFIRE_POOL_NAME);
|
||||
}
|
||||
|
||||
String resolveDereferencedId(Element element) {
|
||||
return SpringUtils.dereferenceBean(resolveId(element));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
|
||||
throws BeanDefinitionStoreException {
|
||||
|
||||
@@ -13,19 +13,20 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.support;
|
||||
|
||||
import java.beans.PropertyEditor;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The AbstractPropertyEditorConverterSupport class is an abstract base class for Spring Converter implementations
|
||||
* that also implement the JavaBeans PropertyEditor interface.
|
||||
* The {@link AbstractPropertyEditorConverterSupport} class is an abstract base class for Spring {@link Converter}
|
||||
* implementations that also implement the JavaBeans {@link PropertyEditor} interface.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.beans.PropertyEditor
|
||||
* @see java.beans.PropertyEditorSupport
|
||||
* @see org.springframework.core.convert.converter.Converter
|
||||
* @since 1.6.0
|
||||
@@ -45,7 +46,9 @@ public abstract class AbstractPropertyEditorConverterSupport<T> extends Property
|
||||
* an instance of {@link Class type} T.
|
||||
*/
|
||||
protected T assertConverted(String source, T convertedValue, Class<T> type) {
|
||||
|
||||
Assert.notNull(convertedValue, String.format("[%1$s] is not a valid %2$s", source, type.getSimpleName()));
|
||||
|
||||
return convertedValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,18 +69,19 @@ public class ConnectionEndpoint implements Cloneable, Comparable<ConnectionEndpo
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the host and port value into a valid ConnectionEndpoint.
|
||||
* Factory method used to parse the {@link String host and port} value into a valid {@link ConnectionEndpoint}.
|
||||
*
|
||||
* @param hostPort a String value containing the host and port formatted as 'host[port]'.
|
||||
* @param defaultPort an Integer value indicating the default port to use if the port is unspecified
|
||||
* in the host and port String value.
|
||||
* @return a valid ConnectionEndpoint initialized with the host and port, or with the default port
|
||||
* if port was unspecified.
|
||||
* @param hostPort {@link String} containing the host and port formatted as {@literal host[port]}
|
||||
* or {@literal host:port}.
|
||||
* @param defaultPort {@link Integer} indicating the default port to use if the port is unspecified
|
||||
* in the {@link String host and port} value.
|
||||
* @return a valid {@link ConnectionEndpoint} initialized with the {@link String host and port},
|
||||
* or with the default port if port was unspecified.
|
||||
* @see #ConnectionEndpoint(String, int)
|
||||
*/
|
||||
public static ConnectionEndpoint parse(String hostPort, int defaultPort) {
|
||||
|
||||
Assert.hasText(hostPort, "'hostPort' must be specified");
|
||||
Assert.hasText(hostPort, String.format("Host & Port [%s] must be specified", hostPort));
|
||||
|
||||
String host = StringUtils.trimAllWhitespace(hostPort);
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.support;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
@@ -23,17 +22,22 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
import org.springframework.data.gemfire.util.CollectionUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The ConnectionEndpointList class is an Iterable collection of ConnectionEndpoint objects.
|
||||
* The {@link ConnectionEndpointList} class is an {@link Iterable} collection of {@link ConnectionEndpoint} objects.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.lang.Iterable
|
||||
* @see java.net.InetSocketAddress
|
||||
* @see java.util.AbstractList
|
||||
* @see java.util.List
|
||||
* @see org.springframework.data.gemfire.support.ConnectionEndpoint
|
||||
* @since 1.6.3
|
||||
*/
|
||||
@@ -43,11 +47,13 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
private final List<ConnectionEndpoint> connectionEndpoints;
|
||||
|
||||
/**
|
||||
* Factory method for creating a {@link ConnectionEndpointList} from an array of {@link ConnectionEndpoint}s.
|
||||
* Factory method used to create a {@link ConnectionEndpointList} from an array of
|
||||
* {@link ConnectionEndpoint ConnectionPoints}.
|
||||
*
|
||||
* @param connectionEndpoints the array of {@link ConnectionEndpoint}s used to initialize
|
||||
* the {@link ConnectionEndpointList}.
|
||||
* @return a {@link ConnectionEndpointList} initialized with the array of {@link ConnectionEndpoint}s.
|
||||
* @param connectionEndpoints array of {@link ConnectionEndpoint ConnectionPoints}
|
||||
* used to initialize a new instance of {@link ConnectionEndpointList}.
|
||||
* @return a {@link ConnectionEndpointList} initialized with the array of
|
||||
* {@link ConnectionEndpoint ConnectionPoints}.
|
||||
* @see org.springframework.data.gemfire.support.ConnectionEndpoint
|
||||
*/
|
||||
public static ConnectionEndpointList from(ConnectionEndpoint... connectionEndpoints) {
|
||||
@@ -55,11 +61,13 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an array of {@link InetSocketAddress} into an instance of {@link ConnectionEndpointList}.
|
||||
* Factory method used to create a {@link ConnectionEndpointList} from an array of
|
||||
* {@link InetSocketAddress InetSocketAddresses}.
|
||||
*
|
||||
* @param socketAddresses the array of {@link InetSocketAddress} used to initialize
|
||||
* an instance of {@link ConnectionEndpointList}.
|
||||
* @return a {@link ConnectionEndpointList} initialized with the array of {@link InetSocketAddress}.
|
||||
* @param socketAddresses array of {@link InetSocketAddress InetSocketAddresses}
|
||||
* used to initialize a new instance of {@link ConnectionEndpointList}.
|
||||
* @return a {@link ConnectionEndpointList} initialized from the array of
|
||||
* {@link InetSocketAddress InetSocketAddresses}.
|
||||
* @see java.net.InetSocketAddress
|
||||
* @see #from(Iterable)
|
||||
*/
|
||||
@@ -68,17 +76,19 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an {@link Iterable} collection of {@link InetSocketAddress} into an instance
|
||||
* of {@link ConnectionEndpointList}.
|
||||
* Factory method used to create a {@link ConnectionEndpointList} from an {@link Iterable} of
|
||||
* {@link InetSocketAddress InetSocketAddresses}.
|
||||
*
|
||||
* @param socketAddresses in {@link Iterable} collection of {@link InetSocketAddress} used to initialize
|
||||
* an instance of {@link ConnectionEndpointList}.
|
||||
* @return a {@link ConnectionEndpointList} initialized with the array of {@link InetSocketAddress}.
|
||||
* @see java.lang.Iterable
|
||||
* @param socketAddresses {@link Iterable} of {@link InetSocketAddress InetSocketAddresses}
|
||||
* used to initialize a new instance of {@link ConnectionEndpointList}.
|
||||
* @return a {@link ConnectionEndpointList} initialized from an {@link Iterable} of
|
||||
* {@link InetSocketAddress InetSocketAddresses}.
|
||||
* @see java.net.InetSocketAddress
|
||||
* @see java.lang.Iterable
|
||||
*/
|
||||
public static ConnectionEndpointList from(Iterable<InetSocketAddress> socketAddresses) {
|
||||
List<ConnectionEndpoint> connectionEndpoints = new ArrayList<ConnectionEndpoint>();
|
||||
|
||||
List<ConnectionEndpoint> connectionEndpoints = new ArrayList<>();
|
||||
|
||||
for (InetSocketAddress socketAddress : CollectionUtils.nullSafeIterable(socketAddresses)) {
|
||||
connectionEndpoints.add(ConnectionEndpoint.from(socketAddress));
|
||||
@@ -88,17 +98,34 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the array of hosts and ports in the format 'host[port]' to convert into an instance
|
||||
* of ConnectionEndpointList.
|
||||
* Parses the comma-delimited {@link String hosts and ports} in the format {@literal host[port]}
|
||||
* or {@literal host:port} to convert into an instance of {@link ConnectionEndpointList}.
|
||||
*
|
||||
* @param defaultPort the default port number to use if port is not specified in a host and port value.
|
||||
* @param hostsPorts the array of hosts and ports to parse.
|
||||
* @return a ConnectionEndpointList representing the hosts and ports in the array.
|
||||
* @param commaDelimitedHostAndPorts {@link String} containing a comma-delimited {@link String} of hosts and ports.
|
||||
* @param defaultPort {@link Integer default port number} to use if port is not specified in a host and port value.
|
||||
* @return a new {@link ConnectionEndpointList} representing the {@link String hosts and ports}.
|
||||
* @see #parse(int, String...)
|
||||
*/
|
||||
public static ConnectionEndpointList parse(String commaDelimitedHostAndPorts, int defaultPort) {
|
||||
|
||||
String[] hostsPorts = StringUtils.commaDelimitedListToStringArray(commaDelimitedHostAndPorts);
|
||||
|
||||
return parse(defaultPort, hostsPorts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the array of {@link String hosts and ports} in the format {@literal host[port]} or {@literal host:port}
|
||||
* to convert into an instance of {@link ConnectionEndpointList}.
|
||||
*
|
||||
* @param defaultPort {@link Integer default port number} to use if port is not specified in a host and port value.
|
||||
* @param hostsPorts array of {@link String hosts and ports} to parse.
|
||||
* @return a new {@link ConnectionEndpointList} representing the {@link String hosts and ports} in the array.
|
||||
* @see org.springframework.data.gemfire.support.ConnectionEndpoint#parse(String, int)
|
||||
* @see #ConnectionEndpointList(Iterable)
|
||||
*/
|
||||
public static ConnectionEndpointList parse(int defaultPort, String... hostsPorts) {
|
||||
List<ConnectionEndpoint> connectionEndpoints = new ArrayList<ConnectionEndpoint>(
|
||||
ArrayUtils.length(hostsPorts));
|
||||
|
||||
List<ConnectionEndpoint> connectionEndpoints = new ArrayList<>(ArrayUtils.length(hostsPorts));
|
||||
|
||||
for (String hostPort : ArrayUtils.nullSafeArray(hostsPorts, String.class)) {
|
||||
connectionEndpoints.add(ConnectionEndpoint.parse(hostPort, defaultPort));
|
||||
@@ -108,46 +135,59 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an empty, uninitialized instance of the ConnectionEndpointList collection.
|
||||
* Constructs a new, empty and uninitialized instance of the {@link ConnectionEndpointList}.
|
||||
*
|
||||
* @see #ConnectionEndpointList(Iterable)
|
||||
*/
|
||||
public ConnectionEndpointList() {
|
||||
this(Collections.<ConnectionEndpoint>emptyList());
|
||||
this(Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of ConnectionEndpointList initialized with the the array of ConnectionEndpoints.
|
||||
* Constructs a new instance of {@link ConnectionEndpointList} initialized with an array
|
||||
* of {@link ConnectionEndpoint ConnectionEndpoints}.
|
||||
*
|
||||
* @param connectionEndpoints is an array containing ConnectionEndpoints to add to this collection.
|
||||
* @param connectionEndpoints array of {@link ConnectionEndpoint ConnectionEndpoints} to add to this list.
|
||||
* @see org.springframework.data.gemfire.support.ConnectionEndpoint
|
||||
* @see #ConnectionEndpointList(Iterable)
|
||||
*/
|
||||
public ConnectionEndpointList(ConnectionEndpoint... connectionEndpoints) {
|
||||
public ConnectionEndpointList(@NonNull ConnectionEndpoint... connectionEndpoints) {
|
||||
this(Arrays.asList(connectionEndpoints));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of ConnectionEndpointList initialized with the Iterable collection of ConnectionEndpoints.
|
||||
* Constructs a new instance of {@link ConnectionEndpointList} initialized with the {@link Iterable} collection
|
||||
* of {@link ConnectionEndpoint ConnectionEndpoints}.
|
||||
*
|
||||
* @param connectionEndpoints the Iterable object containing ConnectionEndpoints to add to this collection.
|
||||
* @param connectionEndpoints {@link Iterable} object containing {@link ConnectionEndpoint ConnectionEndpoints}
|
||||
* to add to this list.
|
||||
* @see org.springframework.data.gemfire.support.ConnectionEndpoint
|
||||
* @see java.lang.Iterable
|
||||
* @see #add(Iterable)
|
||||
*/
|
||||
public ConnectionEndpointList(Iterable<ConnectionEndpoint> connectionEndpoints) {
|
||||
this.connectionEndpoints = new ArrayList<ConnectionEndpoint>();
|
||||
public ConnectionEndpointList(@NonNull Iterable<ConnectionEndpoint> connectionEndpoints) {
|
||||
this.connectionEndpoints = new ArrayList<>();
|
||||
add(connectionEndpoints);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
/**
|
||||
* Adds the given {@link ConnectionEndpoint} to this list.
|
||||
*
|
||||
* @param connectionEndpoint {@link ConnectionEndpoint} to add to this list.
|
||||
* @return a boolean value indicating whether this list was modified by the add operation.
|
||||
* @see org.springframework.data.gemfire.support.ConnectionEndpoint
|
||||
* @see #add(ConnectionEndpoint...)
|
||||
*/
|
||||
@Override
|
||||
public boolean add(ConnectionEndpoint connectionEndpoint) {
|
||||
return (add(ArrayUtils.asArray(connectionEndpoint)) == this);
|
||||
return add(ArrayUtils.asArray(connectionEndpoint)) == this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the array of ConnectionEndpoints to this list.
|
||||
* Adds the array of {@link ConnectionEndpoint ConnectionEndpoints} to this list.
|
||||
*
|
||||
* @param connectionEndpoints the array of ConnectionEndpoints to add to this list.
|
||||
* @return this ConnectionEndpointList to support the Builder pattern style of chaining.
|
||||
* @param connectionEndpoints array of {@link ConnectionEndpoint ConnectionEndpoints} to add to this list.
|
||||
* @return this {@link ConnectionEndpointList}.
|
||||
* @see org.springframework.data.gemfire.support.ConnectionEndpoint
|
||||
* @see #add(Iterable)
|
||||
*/
|
||||
@@ -157,14 +197,16 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the Iterable collection of ConnectionEndpoints to this list.
|
||||
* Adds the {@link Iterable} collection of {@link ConnectionEndpoint ConnectionEndpoints} to this list.
|
||||
*
|
||||
* @param connectionEndpoints the Iterable collection of ConnectionEndpoints to add to this list.
|
||||
* @return this ConnectionEndpointList to support the Builder pattern style of chaining.
|
||||
* @param connectionEndpoints {@link Iterable} collection of {@link ConnectionEndpoint ConnectionEndpoints}
|
||||
* to add to this list.
|
||||
* @return this {@link ConnectionEndpointList}.
|
||||
* @see org.springframework.data.gemfire.support.ConnectionEndpoint
|
||||
* @see #add(ConnectionEndpoint...)
|
||||
*/
|
||||
public final ConnectionEndpointList add(Iterable<ConnectionEndpoint> connectionEndpoints) {
|
||||
|
||||
for (ConnectionEndpoint connectionEndpoint : CollectionUtils.nullSafeIterable(connectionEndpoints)) {
|
||||
this.connectionEndpoints.add(connectionEndpoint);
|
||||
}
|
||||
@@ -173,25 +215,19 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current list of {@link ConnectionEndpoint}s.
|
||||
* Clears the current list of {@link ConnectionEndpoint ConnectionEndpoints}.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
this.connectionEndpoints.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all ConnectionEndpoints in this list with the specified hostname.
|
||||
*
|
||||
* @param host a String indicating the hostname to use in the match.
|
||||
* @return a ConnectionEndpointList (sub-List) containing all the ConnectionEndpoints matching the given hostname.
|
||||
* @see #findBy(int)
|
||||
*/
|
||||
public ConnectionEndpointList findBy(String host) {
|
||||
List<ConnectionEndpoint> connectionEndpoints = new ArrayList<ConnectionEndpoint>(size());
|
||||
private @NonNull ConnectionEndpointList findBy(@NonNull Predicate<ConnectionEndpoint> predicate) {
|
||||
|
||||
List<ConnectionEndpoint> connectionEndpoints = new ArrayList<>(size());
|
||||
|
||||
for (ConnectionEndpoint connectionEndpoint : this) {
|
||||
if (connectionEndpoint.getHost().equals(host)) {
|
||||
if (predicate.test(connectionEndpoint)) {
|
||||
connectionEndpoints.add(connectionEndpoint);
|
||||
}
|
||||
}
|
||||
@@ -200,22 +236,31 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all ConnectionEndpoints in this list with the specified port number.
|
||||
* Finds all {@link ConnectionEndpoint ConnectionEndpoints} in this list with the specified {@link String hostname}.
|
||||
*
|
||||
* @param port an Integer value indicating the port number to use in the match.
|
||||
* @return a ConnectionEndpointList (sub-List) containing all the ConnectionEndpoints matching the given port number.
|
||||
* @param host {@link String} indicating the hostname to use in the match.
|
||||
* @return a {@link ConnectionEndpointList} (sub-List) containing all the {@link ConnectionEndpoint ConnectionEndpoints}
|
||||
* matching the given {@link String hostname}.
|
||||
* @see #findBy(int)
|
||||
*/
|
||||
public @NonNull ConnectionEndpointList findBy(String host) {
|
||||
return findBy(connectionEndpoint -> connectionEndpoint.getHost().equals(host));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all {@link ConnectionEndpoint ConnectionEndpoints} in this list with the specified port number.
|
||||
*
|
||||
* @param port {@link Integer} value indicating the port number to use in the match.
|
||||
* @return a {@link ConnectionEndpointList} (sub-List) containing all the {@link ConnectionEndpoint ConnectionEndpoints}
|
||||
* matching the given port number.
|
||||
* @see #findBy(String)
|
||||
*/
|
||||
public ConnectionEndpointList findBy(int port) {
|
||||
List<ConnectionEndpoint> connectionEndpoints = new ArrayList<ConnectionEndpoint>(size());
|
||||
public @NonNull ConnectionEndpointList findBy(int port) {
|
||||
return findBy(connectionEndpoint -> connectionEndpoint.getPort() == port);
|
||||
}
|
||||
|
||||
for (ConnectionEndpoint connectionEndpoint : this) {
|
||||
if (connectionEndpoint.getPort() == port) {
|
||||
connectionEndpoints.add(connectionEndpoint);
|
||||
}
|
||||
}
|
||||
|
||||
return new ConnectionEndpointList(connectionEndpoints);
|
||||
private @Nullable ConnectionEndpoint findOne(@NonNull ConnectionEndpointList list) {
|
||||
return list == null || list.isEmpty() ? null : list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,9 +271,8 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
* or null if no {@link ConnectionEndpoint} exists with the given hostname.
|
||||
* @see #findBy(String)
|
||||
*/
|
||||
public ConnectionEndpoint findOne(String host) {
|
||||
ConnectionEndpointList connectionEndpoints = findBy(host);
|
||||
return (connectionEndpoints.isEmpty() ? null : connectionEndpoints.connectionEndpoints.get(0));
|
||||
public @Nullable ConnectionEndpoint findOne(String host) {
|
||||
return findOne(findBy(host));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,9 +283,8 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
* or null if no {@link ConnectionEndpoint} exists with the given port number.
|
||||
* @see #findBy(int)
|
||||
*/
|
||||
public ConnectionEndpoint findOne(int port) {
|
||||
ConnectionEndpointList connectionEndpoints = findBy(port);
|
||||
return (connectionEndpoints.isEmpty() ? null : connectionEndpoints.connectionEndpoints.get(0));
|
||||
public @Nullable ConnectionEndpoint findOne(int port) {
|
||||
return findOne(findBy(port));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,7 +298,7 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
*/
|
||||
@Override
|
||||
public ConnectionEndpoint get(int index) {
|
||||
return connectionEndpoints.get(index);
|
||||
return this.connectionEndpoints.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,7 +314,7 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
*/
|
||||
@Override
|
||||
public ConnectionEndpoint set(int index, ConnectionEndpoint element) {
|
||||
return connectionEndpoints.set(index, element);
|
||||
return this.connectionEndpoints.set(index, element);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,14 +324,15 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return connectionEndpoints.isEmpty();
|
||||
return this.connectionEndpoints.isEmpty();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public Iterator<ConnectionEndpoint> iterator() {
|
||||
return Collections.unmodifiableList(connectionEndpoints).iterator();
|
||||
public @NonNull Iterator<ConnectionEndpoint> iterator() {
|
||||
return Collections.unmodifiableList(this.connectionEndpoints).iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,7 +342,7 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return connectionEndpoints.size();
|
||||
return this.connectionEndpoints.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,9 +351,8 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
* @return an array of {@link ConnectionEndpoint}s representing this collection.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public ConnectionEndpoint[] toArray() {
|
||||
return connectionEndpoints.toArray(new ConnectionEndpoint[connectionEndpoints.size()]);
|
||||
return this.connectionEndpoints.toArray(new ConnectionEndpoint[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,7 +364,8 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
* @see java.util.List
|
||||
*/
|
||||
public List<InetSocketAddress> toInetSocketAddresses() {
|
||||
List<InetSocketAddress> inetSocketAddresses = new ArrayList<InetSocketAddress>(size());
|
||||
|
||||
List<InetSocketAddress> inetSocketAddresses = new ArrayList<>(size());
|
||||
|
||||
for (ConnectionEndpoint connectionEndpoint : this) {
|
||||
inetSocketAddresses.add(connectionEndpoint.toInetSocketAddress());
|
||||
@@ -330,7 +374,9 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
return inetSocketAddresses;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return connectionEndpoints.toString();
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* The ArrayUtils class is a utility class for working with Object arrays.
|
||||
* {@link ArrayUtils} is an abstract utility class used to work with {@link Object} arrays.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link CollectionUtils} is a utility class for working with the Java Collections Framework and classes.
|
||||
* {@link CollectionUtils} is an abstract utility class used to workin with the Java Collections Framework and classes.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.util.Collection
|
||||
|
||||
@@ -27,19 +27,21 @@ import org.springframework.dao.support.DaoSupport;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* The AutoRegionLookupDao class is a Data Access Object (DAO) encapsulating references to several GemFire Cache Regions
|
||||
* defined in native GemFire cache.xml and registered as beans in the Spring context using Spring Data GemFire's
|
||||
* auto Region lookup functionality. This class is used in the AutoRegionLookupWithComponentScanningIntegrationTests
|
||||
* class to ensure this @Repository component is auto-wired properly.
|
||||
* {@link AutoRegionLookupDao} is a Data Access Object (DAO) encapsulating references to several cache
|
||||
* {@link Region Regions} defined in native Apache Geode {@literal cache.xml} and registered as beans in the Spring
|
||||
* context using Spring Data for Apache Geode's auto {@link Region} lookup functionality.
|
||||
*
|
||||
* This class is used by the {@link AutoRegionLookupWithComponentScanningIntegrationTests} class to ensure
|
||||
* this {@link Repository @Repository} component is auto-wired properly.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.dao.support.DaoSupport
|
||||
* @see org.springframework.stereotype.Repository
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@DependsOn("gemfireCache")
|
||||
//@Lazy
|
||||
@DependsOn("gemfireCache")
|
||||
@Repository("autoRegionLookupDao")
|
||||
@SuppressWarnings("unused")
|
||||
public class AutoRegionLookupDao extends DaoSupport {
|
||||
@@ -64,14 +66,14 @@ public class AutoRegionLookupDao extends DaoSupport {
|
||||
DataPolicy expectedDataPolicy) {
|
||||
|
||||
assertThat(region)
|
||||
.describedAs("Region (%1$s) was not properly configured and initialized!", expectedName)
|
||||
.describedAs("Region [%s] was not properly configured and initialized", expectedName)
|
||||
.isNotNull();
|
||||
|
||||
assertThat(region.getName()).isEqualTo(expectedName);
|
||||
assertThat(region.getFullPath()).isEqualTo(expectedFullPath);
|
||||
|
||||
assertThat(region.getAttributes())
|
||||
.describedAs("Region (%1$s) must have RegionAttributes defined!", expectedName)
|
||||
.describedAs("Region [%s] must have RegionAttributes defined", expectedName)
|
||||
.isNotNull();
|
||||
|
||||
assertThat(region.getAttributes().getDataPolicy()).isEqualTo(expectedDataPolicy);
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -50,7 +49,6 @@ import org.springframework.data.gemfire.fork.LocatorProcess;
|
||||
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.tests.util.FileUtils;
|
||||
import org.springframework.data.gemfire.tests.util.ThreadUtils;
|
||||
import org.springframework.data.gemfire.tests.util.ThrowableUtils;
|
||||
import org.springframework.data.gemfire.tests.util.ZipUtils;
|
||||
import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
@@ -136,9 +134,8 @@ public class CacheClusterConfigurationIntegrationTests extends ForkingClientServ
|
||||
|
||||
String locatorName = "ClusterConfigLocator";
|
||||
|
||||
locatorWorkingDirectory = new File(System.getProperty("java.io.tmpdir"), locatorName.toLowerCase());
|
||||
|
||||
assertThat(locatorWorkingDirectory.isDirectory() || locatorWorkingDirectory.mkdirs()).isTrue();
|
||||
locatorWorkingDirectory =
|
||||
createDirectory(new File(System.getProperty("java.io.tmpdir"), locatorName.toLowerCase()));
|
||||
|
||||
ZipUtils.unzip(new ClassPathResource("/cluster_config.zip"), locatorWorkingDirectory);
|
||||
|
||||
@@ -160,25 +157,11 @@ public class CacheClusterConfigurationIntegrationTests extends ForkingClientServ
|
||||
|
||||
locatorProcess.registerShutdownHook();
|
||||
|
||||
waitForLocatorStart(TimeUnit.SECONDS.toMillis(30));
|
||||
waitForServerToStart("localhost", availablePort);
|
||||
|
||||
System.setProperty("spring.data.gemfire.locator.port", String.valueOf(availablePort));
|
||||
}
|
||||
|
||||
private static void waitForLocatorStart(final long milliseconds) {
|
||||
|
||||
ThreadUtils.timedWait(milliseconds, 500, new ThreadUtils.Condition() {
|
||||
|
||||
final File pidControlFile = new File(locatorWorkingDirectory,
|
||||
LocatorProcess.getLocatorProcessControlFilename());
|
||||
|
||||
@Override
|
||||
public boolean evaluate() {
|
||||
return !pidControlFile.isFile();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stopLocator() {
|
||||
|
||||
@@ -201,7 +184,8 @@ public class CacheClusterConfigurationIntegrationTests extends ForkingClientServ
|
||||
return assertRegion(actualRegion, expectedRegionName, Region.SEPARATOR+expectedRegionName);
|
||||
}
|
||||
|
||||
private Region<?, ?> assertRegion(Region<?, ?> actualRegion, String expectedRegionName, String expectedRegionFullPath) {
|
||||
private Region<?, ?> assertRegion(Region<?, ?> actualRegion, String expectedRegionName,
|
||||
String expectedRegionFullPath) {
|
||||
|
||||
assertThat(actualRegion).as(String.format("The [%s] was not properly configured and initialized!",
|
||||
expectedRegionName)).isNotNull();
|
||||
@@ -211,7 +195,8 @@ public class CacheClusterConfigurationIntegrationTests extends ForkingClientServ
|
||||
return actualRegion;
|
||||
}
|
||||
|
||||
private Region<?, ?> assertRegionAttributes(Region<?, ?> actualRegion, DataPolicy expectedDataPolicy, Scope expectedScope) {
|
||||
private Region<?, ?> assertRegionAttributes(Region<?, ?> actualRegion, DataPolicy expectedDataPolicy,
|
||||
Scope expectedScope) {
|
||||
|
||||
assertThat(actualRegion).isNotNull();
|
||||
assertThat(actualRegion.getAttributes()).isNotNull();
|
||||
|
||||
@@ -16,16 +16,27 @@
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@@ -35,13 +46,19 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(locations = "basic-cache.xml")
|
||||
@ContextConfiguration(locations = "basic-cache.xml",
|
||||
initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
// TODO: What is the purpose of this test class?
|
||||
// An Apache Geode cache instance is a Singleton!
|
||||
public class CacheIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Autowired
|
||||
@@ -56,16 +73,30 @@ public class CacheIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Test
|
||||
public void testBasicCache() {
|
||||
this.cache = this.applicationContext.getBean("default-cache",Cache.class);
|
||||
|
||||
this.cache = this.applicationContext.getBean("default-cache", Cache.class);
|
||||
|
||||
assertThat(this.cache).isNotNull();
|
||||
assertThat(this.cache.getName()).isEqualTo("default-cache");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheWithProps() {
|
||||
cache = applicationContext.getBean("cache-with-props", Cache.class);
|
||||
|
||||
this.cache = this.applicationContext.getBean("cache-with-props", Cache.class);
|
||||
|
||||
// the name property seems to be ignored
|
||||
assertThat(cache.getDistributedSystem().getName()).isEqualTo("cache-with-props");
|
||||
assertThat(cache.getName()).isEqualTo("cache-with-props");
|
||||
assertThat(this.cache).isNotNull();
|
||||
assertThat(this.cache.getName()).isEqualTo("cache-with-props");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheWithXml() {
|
||||
|
||||
this.cache = this.applicationContext.getBean("cache-with-xml", Cache.class);
|
||||
|
||||
assertThat(this.cache).isNotNull();
|
||||
assertThat(this.cache.getName()).isEqualTo("cache-with-xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,12 +104,42 @@ public class CacheIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
this.cache = this.applicationContext.getBean("named-cache", Cache.class);
|
||||
|
||||
assertThat(cache.getDistributedSystem().getName()).isEqualTo("named-cache");
|
||||
assertThat(cache.getName()).isEqualTo("named-cache");
|
||||
assertThat(this.cache).isNotNull();
|
||||
assertThat(this.cache.getName()).isEqualTo("named-cache");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheWithXml() {
|
||||
this.applicationContext.getBean("cache-with-xml", Cache.class);
|
||||
public void testPdxCache() {
|
||||
|
||||
this.cache = this.applicationContext.getBean("pdx-cache", Cache.class);
|
||||
|
||||
assertThat(this.cache).isNotNull();
|
||||
assertThat(this.cache.getName()).isEqualTo("pdx-cache");
|
||||
}
|
||||
|
||||
public static final class CacheWithXmlFactoryBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
@Nullable @Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
|
||||
if (bean instanceof CacheFactoryBean && "cache-with-xml".equals(beanName)) {
|
||||
|
||||
CacheFactoryBean cacheBean = spy((CacheFactoryBean) bean);
|
||||
|
||||
doAnswer(invocation -> {
|
||||
|
||||
GemFireCache cache = invocation.getArgument(0);
|
||||
|
||||
doNothing().when(cache).loadCacheXml(any(InputStream.class));
|
||||
|
||||
return cache;
|
||||
|
||||
}).when(cacheBean).loadCacheXml(any(GemFireCache.class));
|
||||
|
||||
bean = cacheBean;
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ import org.springframework.util.StringUtils;
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("unused")
|
||||
public class LookupPartitionRegionMutationIntegrationTest {
|
||||
public class LookupPartitionRegionMutationIntegrationTests {
|
||||
|
||||
@Resource(name = "Example")
|
||||
private Region<?, ?> example;
|
||||
@@ -56,7 +56,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Integration Tests testing the contract and integratino between natively-defined cache {@link Region Regions}
|
||||
* Integration Tests testing the contract and integration between natively-defined cache {@link Region Regions}
|
||||
* and SDG's {@link Region} lookup functionality combined with {@link Region} attribute(s) mutation.
|
||||
*
|
||||
* @author John Blum
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.springframework.util.Assert;
|
||||
* and to reproduce the issue in JIRA SGF-197.
|
||||
*
|
||||
* @author John Blum
|
||||
* @link https://jira.springsource.org/browse/SGF-197
|
||||
* @see java.io.File
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.DiskStore
|
||||
* @see org.apache.geode.cache.Region
|
||||
@@ -51,10 +51,11 @@ import org.springframework.util.Assert;
|
||||
* @see org.springframework.test.annotation.DirtiesContext
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @link https://jira.springsource.org/browse/SGF-197
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("/org/springframework/data/gemfire/pdxdiskstore-config.xml")
|
||||
@ContextConfiguration
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
@SuppressWarnings("unused")
|
||||
public class PdxDiskStoreIntegrationTests extends IntegrationTestsSupport {
|
||||
@@ -77,11 +78,11 @@ public class PdxDiskStoreIntegrationTests extends IntegrationTestsSupport {
|
||||
.isEqualTo(expectedRegionPath);
|
||||
}
|
||||
|
||||
private static File createFile(final String pathname) {
|
||||
private static File createFile(String pathname) {
|
||||
return new File(pathname);
|
||||
}
|
||||
|
||||
private static void deleteRecursive(final File path) {
|
||||
private static void deleteRecursive(File path) {
|
||||
|
||||
if (path.isDirectory()) {
|
||||
for (File file : path.listFiles()) {
|
||||
@@ -100,7 +101,7 @@ public class PdxDiskStoreIntegrationTests extends IntegrationTestsSupport {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() {
|
||||
public static void cleanupAfterClass() {
|
||||
deleteRecursive(createFile("./gemfire"));
|
||||
}
|
||||
|
||||
@@ -132,12 +133,12 @@ public class PdxDiskStoreIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
protected static class AbstractHolderSupport {
|
||||
|
||||
protected static boolean equals(final Object obj1, final Object obj2) {
|
||||
return (obj1 != null && obj1.equals(obj2));
|
||||
protected static boolean equals(Object obj1, Object obj2) {
|
||||
return obj1 != null && obj1.equals(obj2);
|
||||
}
|
||||
|
||||
protected static int hashCode(final Object obj) {
|
||||
return (obj == null ? 0 : obj.hashCode());
|
||||
protected static int hashCode(Object obj) {
|
||||
return obj == null ? 0 : obj.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +150,9 @@ public class PdxDiskStoreIntegrationTests extends IntegrationTestsSupport {
|
||||
public KeyHolder() { }
|
||||
|
||||
public KeyHolder(T key) {
|
||||
|
||||
Assert.notNull(key, "The key cannot be null!");
|
||||
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@@ -198,8 +201,7 @@ public class PdxDiskStoreIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
private T value;
|
||||
|
||||
public ValueHolder() {
|
||||
}
|
||||
public ValueHolder() { }
|
||||
|
||||
public ValueHolder(T value) {
|
||||
this.value = value;
|
||||
|
||||
@@ -27,11 +27,8 @@ import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.EvictionAction;
|
||||
import org.apache.geode.cache.EvictionAttributes;
|
||||
import org.apache.geode.cache.InterestPolicy;
|
||||
import org.apache.geode.cache.LossAction;
|
||||
import org.apache.geode.cache.MembershipAttributes;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionAttributes;
|
||||
import org.apache.geode.cache.ResumptionAction;
|
||||
import org.apache.geode.cache.Scope;
|
||||
import org.apache.geode.cache.SubscriptionAttributes;
|
||||
|
||||
@@ -55,8 +52,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(value = "complex-subregion.xml",
|
||||
initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings({ "rawtypes", "unused" })
|
||||
public class SubRegionIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@@ -125,16 +121,6 @@ public class SubRegionIntegrationTests extends IntegrationTestsSupport {
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
|
||||
assertThat(evictionAttributes.getMaximum()).isEqualTo(10000);
|
||||
|
||||
MembershipAttributes membershipAttributes = regionAttributes.getMembershipAttributes();
|
||||
|
||||
assertThat(membershipAttributes).isNotNull();
|
||||
assertThat(membershipAttributes.getRequiredRoles()).isNotNull();
|
||||
assertThat(membershipAttributes.getRequiredRoles().size()).isEqualTo(1);
|
||||
assertThat(membershipAttributes.getRequiredRoles().iterator().next().getName().equalsIgnoreCase("TEST"))
|
||||
.isTrue();
|
||||
assertThat(membershipAttributes.getLossAction()).isEqualTo(LossAction.LIMITED_ACCESS);
|
||||
assertThat(membershipAttributes.getResumptionAction()).isEqualTo(ResumptionAction.REINITIALIZE);
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = regionAttributes.getSubscriptionAttributes();
|
||||
|
||||
assertThat(subscriptionAttributes).isNotNull();
|
||||
|
||||
@@ -63,8 +63,8 @@ public class CallableCacheLoaderAdapterTest {
|
||||
|
||||
@Test
|
||||
public void constructCallableCacheLoaderAdapterWithArgumentKeyAndRegion() {
|
||||
CallableCacheLoaderAdapter<String, Object> instance =
|
||||
|
||||
CallableCacheLoaderAdapter<String, Object> instance =
|
||||
new CallableCacheLoaderAdapter<>(mockCacheLoader, "key", mockRegion, "test");
|
||||
|
||||
assertThat(instance).isNotNull();
|
||||
@@ -160,7 +160,7 @@ public class CallableCacheLoaderAdapterTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void callThrowsIllegalStateExceptionForNullRegion() throws Exception {
|
||||
|
||||
CallableCacheLoaderAdapter<String, Object> instance =
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.apache.geode.cache.Region;
|
||||
import org.springframework.cache.Cache;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link GemfireCacheManager}.
|
||||
* Unit Tests for {@link GemfireCacheManager}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
@@ -169,7 +169,7 @@ public class GemfireCacheManagerUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void assertGemFireRegionAvailableWithDestroyedGemFireRegionThrowIllegalStateException() {
|
||||
|
||||
when(mockRegion.isDestroyed()).thenReturn(true);
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
package org.springframework.data.gemfire.cache;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.internal.bytebuddy.matcher.ElementMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -284,7 +285,7 @@ public class GemfireCacheUnitTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void putIfAbsentReturnsNull() {
|
||||
|
||||
when(mockRegion.putIfAbsent(eq("key"), any())).thenReturn(null);
|
||||
doReturn(null).when(mockRegion).putIfAbsent(eq("key"), any());
|
||||
|
||||
Cache.ValueWrapper value = GemfireCache.wrap(mockRegion).putIfAbsent("key", "mockValue");
|
||||
|
||||
|
||||
@@ -15,15 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.cache.config;
|
||||
|
||||
import static org.assertj.core.api.Java6Assertions.assertThat;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -100,9 +96,6 @@ public class EnableGemfireCachingIntegrationTests extends IntegrationTestsSuppor
|
||||
|
||||
private volatile boolean cacheMiss;
|
||||
|
||||
@Resource(name = "Factorials")
|
||||
private Region<Long, Long> factorials;
|
||||
|
||||
public boolean isCacheMiss() {
|
||||
boolean cacheMiss = this.cacheMiss;
|
||||
this.cacheMiss = false;
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -33,14 +32,10 @@ import org.apache.geode.cache.CacheLoaderException;
|
||||
import org.apache.geode.cache.LoaderHelper;
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.gemfire.fork.ServerProcess;
|
||||
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.process.ProcessWrapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
/**
|
||||
* Integration Tests to test SSL configuration between a Pivotal GemFire or Apache Geode client and server
|
||||
@@ -62,23 +57,16 @@ public class ClientCacheSecurityIntegrationTests extends ForkingClientServerInte
|
||||
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
|
||||
arguments.add(String.format("-Dgemfire.name=%1$s", ClientCacheSecurityIntegrationTests.class.getSimpleName().concat("Server")));
|
||||
arguments.add(String.format("-Dgemfire.name=%1$s",
|
||||
ClientCacheSecurityIntegrationTests.class.getSimpleName().concat("Server")));
|
||||
|
||||
arguments.add(String.format("-Djavax.net.ssl.keyStore=%1$s", System.getProperty("javax.net.ssl.keyStore")));
|
||||
|
||||
arguments.add(getServerContextXmlFileLocation(ClientCacheSecurityIntegrationTests.class));
|
||||
|
||||
startGemFireServer(ServerProcess.class, arguments.toArray(new String[arguments.size()]));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
|
||||
if (Boolean.valueOf(System.getProperty("spring.gemfire.fork.clean", Boolean.TRUE.toString()))) {
|
||||
getGemFireServerProcess()
|
||||
.map(ProcessWrapper::getWorkingDirectory)
|
||||
.ifPresent(workingDirectory -> FileSystemUtils.deleteRecursively(workingDirectory));
|
||||
}
|
||||
}
|
||||
|
||||
@Resource(name = "Example")
|
||||
private Region<String, String> example;
|
||||
|
||||
@@ -99,17 +87,4 @@ public class ClientCacheSecurityIntegrationTests extends ForkingClientServerInte
|
||||
public void close() { }
|
||||
|
||||
}
|
||||
|
||||
public static class SslGemFireServer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String configLocation = args.length > 0 ? args[0]
|
||||
: "org/springframework/data/gemfire/client/ClientCacheSecurityIntegrationTests-server-context.xml";
|
||||
|
||||
ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext(configLocation);
|
||||
|
||||
applicationContext.registerShutdownHook();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,11 @@ package org.springframework.data.gemfire.client;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -33,17 +31,17 @@ import org.apache.geode.cache.CacheLoader;
|
||||
import org.apache.geode.cache.CacheLoaderException;
|
||||
import org.apache.geode.cache.LoaderHelper;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.client.Pool;
|
||||
import org.apache.geode.cache.client.PoolManager;
|
||||
|
||||
import org.springframework.data.gemfire.fork.ServerProcess;
|
||||
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.process.ProcessWrapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
/**
|
||||
* IntegrationTests with test cases testing the use of variable {@literal locators} attribute
|
||||
* on <gfe:pool/< in SDG XML namespace configuration metadata when connecting a client/server.
|
||||
* Integration Tests testing the use of variable {@literal locators} attribute on <gfe:pool/< in SDG XML Namespace
|
||||
* configuration metadata when connecting a client and server.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
@@ -56,35 +54,38 @@ import org.springframework.util.FileSystemUtils;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("all")
|
||||
@SuppressWarnings("unused")
|
||||
public class ClientCacheVariableLocatorsIntegrationTests extends ForkingClientServerIntegrationTestsSupport {
|
||||
|
||||
@BeforeClass
|
||||
public static void startGeodeServer() throws IOException {
|
||||
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
final int locatorPort = findAndReserveAvailablePort();
|
||||
|
||||
arguments.add(String.format("-Dgemfire.name=%1$s",
|
||||
ClientCacheVariableLocatorsIntegrationTests.class.getSimpleName().concat("Server")));
|
||||
System.setProperty("spring.data.gemfire.locator.port", String.valueOf(locatorPort));
|
||||
|
||||
arguments.add(getServerContextXmlFileLocation(ClientCacheVariableLocatorsIntegrationTests.class));
|
||||
|
||||
startGemFireServer(ServerProcess.class, arguments.toArray(new String[arguments.size()]));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
|
||||
if (Boolean.valueOf(System.getProperty("spring.gemfire.fork.clean", Boolean.TRUE.toString()))) {
|
||||
getGemFireServerProcess()
|
||||
.map(ProcessWrapper::getWorkingDirectory)
|
||||
.ifPresent(workingDirectory -> FileSystemUtils.deleteRecursively(workingDirectory));
|
||||
}
|
||||
startGemFireServer(ServerProcess.class,
|
||||
getServerContextXmlFileLocation(ClientCacheVariableLocatorsIntegrationTests.class));
|
||||
}
|
||||
|
||||
@Resource(name = "Example")
|
||||
private Region<String, Integer> example;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
assertThat(this.example).isNotNull();
|
||||
assertThat(this.example.getName()).isEqualTo("Example");
|
||||
assertThat(this.example.getAttributes()).isNotNull();
|
||||
assertThat(this.example.getAttributes().getPoolName()).isEqualTo("locatorPool");
|
||||
|
||||
Pool locatorPool = PoolManager.find("locatorPool");
|
||||
|
||||
assertThat(locatorPool).isNotNull();
|
||||
assertThat(locatorPool.getName()).isEqualTo("locatorPool");
|
||||
assertThat(locatorPool.getLocators()).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clientServerConnectionSuccessful() {
|
||||
|
||||
|
||||
@@ -20,11 +20,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -33,17 +35,22 @@ import org.apache.geode.cache.CacheLoader;
|
||||
import org.apache.geode.cache.CacheLoaderException;
|
||||
import org.apache.geode.cache.LoaderHelper;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.client.Pool;
|
||||
import org.apache.geode.cache.client.PoolManager;
|
||||
import org.apache.geode.cache.server.CacheServer;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.data.gemfire.fork.ServerProcess;
|
||||
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.util.CollectionUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
/**
|
||||
* Integration Tests with test cases testing the use of variable {@literal servers} attribute
|
||||
* on <gfe:pool/< in SDG XML namespace configuration metadata when connecting a client/server.
|
||||
* Integration Tests testing the use of variable {@literal servers} attribute on <gfe:pool/< in SDG XML Namespace
|
||||
* configuration metadata when connecting a client and server.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
@@ -56,35 +63,51 @@ import org.springframework.util.FileSystemUtils;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("all")
|
||||
@SuppressWarnings("unused")
|
||||
public class ClientCacheVariableServersIntegrationTests extends ForkingClientServerIntegrationTestsSupport {
|
||||
|
||||
@BeforeClass
|
||||
public static void startGeodeServer() throws IOException {
|
||||
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
final int cacheServerPortOne = findAndReserveAvailablePort();
|
||||
final int cacheServerPortTwo = findAndReserveAvailablePort();
|
||||
|
||||
arguments.add(String.format("-Dgemfire.name=%1$s",
|
||||
ClientCacheVariableServersIntegrationTests.class.getSimpleName().concat("Server")));
|
||||
System.setProperty("test.cache.server.port.one", String.valueOf(cacheServerPortOne));
|
||||
System.setProperty("test.cache.server.port.two", String.valueOf(cacheServerPortTwo));
|
||||
|
||||
List<String> arguments = new ArrayList<>();
|
||||
|
||||
arguments.add(String.format("-Dtest.cache.server.port.one=%d", cacheServerPortOne));
|
||||
arguments.add(String.format("-Dtest.cache.server.port.two=%d", cacheServerPortTwo));
|
||||
arguments.add(getServerContextXmlFileLocation(ClientCacheVariableServersIntegrationTests.class));
|
||||
|
||||
startGemFireServer(ServerProcess.class, arguments.toArray(new String[arguments.size()]));
|
||||
startGemFireServer(ServerProcess.class, arguments.toArray(new String[0]));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
|
||||
if (Boolean.parseBoolean(System.getProperty("spring.gemfire.fork.clean", Boolean.TRUE.toString()))) {
|
||||
getGemFireServerProcess()
|
||||
.map(ProcessWrapper::getWorkingDirectory)
|
||||
.ifPresent(workingDirectory -> FileSystemUtils.deleteRecursively(workingDirectory));
|
||||
}
|
||||
public static void cleanup() {
|
||||
System.clearProperty("test.cache.server.port.one");
|
||||
System.clearProperty("test.cache.server.port.two");
|
||||
}
|
||||
|
||||
@Resource(name = "Example")
|
||||
private Region<String, Integer> example;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
assertThat(this.example).isNotNull();
|
||||
assertThat(this.example.getName()).isEqualTo("Example");
|
||||
assertThat(this.example.getAttributes()).isNotNull();
|
||||
assertThat(this.example.getAttributes().getPoolName()).isEqualTo("serverPool");
|
||||
|
||||
Pool pool = PoolManager.find("serverPool");
|
||||
|
||||
assertThat(pool).isNotNull();
|
||||
assertThat(pool.getName()).isEqualTo("serverPool");
|
||||
assertThat(pool.getServers()).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clientServerConnectionSuccessful() {
|
||||
|
||||
@@ -107,4 +130,24 @@ public class ClientCacheVariableServersIntegrationTests extends ForkingClientSer
|
||||
cacheMissCounter.set(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class CacheServerConfigurationApplicationListener
|
||||
implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
|
||||
|
||||
ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
|
||||
|
||||
Map<String, CacheServer> cacheServers =
|
||||
CollectionUtils.nullSafeMap(applicationContext.getBeansOfType(CacheServer.class));
|
||||
|
||||
for (CacheServer cacheServer : cacheServers.values()) {
|
||||
System.err.printf("CacheServer host:port [%s:%d]%n",
|
||||
cacheServer.getBindAddress(), cacheServer.getPort());
|
||||
}
|
||||
|
||||
System.err.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,9 +90,6 @@ public class DurableClientCacheIntegrationTests extends ForkingClientServerInteg
|
||||
private static List<Integer> regionCacheListenerEventValues =
|
||||
Collections.synchronizedList(new ArrayList<Integer>());
|
||||
|
||||
private static final String CACHE_SERVER_PORT =
|
||||
DurableClientCacheIntegrationTests.class.getName().concat(".cache-server-port");
|
||||
|
||||
private static final String CLIENT_CACHE_INTERESTS_RESULT_POLICY =
|
||||
DurableClientCacheIntegrationTests.class.getName().concat(".interests-result-policy");
|
||||
|
||||
@@ -188,7 +185,7 @@ public class DurableClientCacheIntegrationTests extends ForkingClientServerInteg
|
||||
try {
|
||||
|
||||
ClientCache clientCache = new ClientCacheFactory()
|
||||
.addPoolServer(SERVER_HOST, Integer.getInteger(GEMFIRE_POOL_SERVERS_PROPERTY))
|
||||
.addPoolServer(SERVER_HOST, Integer.getInteger(GEMFIRE_CACHE_SERVER_PORT_PROPERTY))
|
||||
.set("name", "ClientCacheProducer")
|
||||
.set("log-level", "error")
|
||||
.create();
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.sql.DataSource;
|
||||
@@ -45,7 +44,6 @@ import org.springframework.data.gemfire.tests.integration.ForkingClientServerInt
|
||||
import org.springframework.data.gemfire.tests.process.ProcessExecutor;
|
||||
import org.springframework.data.gemfire.tests.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.tests.util.FileSystemUtils;
|
||||
import org.springframework.data.gemfire.tests.util.ThreadUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -71,7 +69,6 @@ import org.springframework.util.StringUtils;
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings({ "rawtypes", "unused"})
|
||||
// TODO: slow test!
|
||||
public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTests
|
||||
extends ForkingClientServerIntegrationTestsSupport {
|
||||
|
||||
@@ -80,16 +77,21 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
@BeforeClass
|
||||
public static void startGemFireServer() throws IOException {
|
||||
|
||||
System.setProperty("gemfire.log-level", GEMFIRE_LOG_LEVEL);
|
||||
String serverName =
|
||||
GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTests.class.getSimpleName() + "Server";
|
||||
|
||||
String serverName = "DataSourceGemFireBasedServer";
|
||||
int serverPort =findAvailablePort();
|
||||
|
||||
System.setProperty("CACHE_SERVER_PORT", String.valueOf(serverPort));
|
||||
|
||||
File serverWorkingDirectory = new File(FileSystemUtils.WORKING_DIRECTORY, serverName.toLowerCase());
|
||||
|
||||
Assert.isTrue(serverWorkingDirectory.isDirectory() || serverWorkingDirectory.mkdirs(),
|
||||
String.format("Server working directory [%s] does not exist and could not be created", serverWorkingDirectory));
|
||||
assertThat(serverWorkingDirectory.isDirectory() || serverWorkingDirectory.mkdirs())
|
||||
.describedAs("Server working directory [%s] does not exist and could not be created", serverWorkingDirectory)
|
||||
.isTrue();
|
||||
|
||||
writeAsCacheXmlFileToDirectory("gemfire-datasource-integration-test-cache.xml", serverWorkingDirectory);
|
||||
writeAsCacheXmlFileToDirectory("gemfire-datasource-integration-tests-cache.xml",
|
||||
serverWorkingDirectory);
|
||||
|
||||
Assert.isTrue(new File(serverWorkingDirectory, "cache.xml").isFile(),
|
||||
String.format("Expected a cache.xml file to exist in directory [%s]", serverWorkingDirectory));
|
||||
@@ -98,13 +100,12 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
|
||||
arguments.add(ServerLauncher.Command.START.getName());
|
||||
arguments.add(String.format("-Dgemfire.name=%s", serverName));
|
||||
arguments.add(String.format("-Dgemfire.log-level=%s", GEMFIRE_LOG_LEVEL));
|
||||
arguments.add(String.format("-DCACHE_SERVER_PORT=%d", serverPort));
|
||||
|
||||
gemfireServer = run(serverWorkingDirectory, customClasspath(),
|
||||
GemFireBasedServerProcess.class, arguments.toArray(new String[0]));
|
||||
|
||||
waitForProcessStart(TimeUnit.SECONDS.toMillis(20), gemfireServer,
|
||||
GemFireBasedServerProcess.getServerProcessControlFilename());
|
||||
waitForServerToStart("localhost", serverPort);
|
||||
}
|
||||
|
||||
private static String customClasspath() {
|
||||
@@ -128,24 +129,13 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
new FileOutputStream(new File(serverWorkingDirectory, "cache.xml")));
|
||||
}
|
||||
|
||||
private static void waitForProcessStart(long milliseconds, ProcessWrapper process, String processControlFilename) {
|
||||
|
||||
ThreadUtils.timedWait(milliseconds, TimeUnit.MILLISECONDS.toMillis(500), new ThreadUtils.Condition() {
|
||||
|
||||
private final File processControlFile = new File(process.getWorkingDirectory(), processControlFilename);
|
||||
|
||||
@Override
|
||||
public boolean evaluate() {
|
||||
return processControlFile.isFile();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stopGemFireServer() {
|
||||
|
||||
stop(gemfireServer);
|
||||
|
||||
System.clearProperty("CACHE_SERVER_PORT");
|
||||
|
||||
if (Boolean.parseBoolean(System.getProperty("spring.gemfire.fork.clean", String.valueOf(true)))) {
|
||||
org.springframework.util.FileSystemUtils.deleteRecursively(gemfireServer.getWorkingDirectory());
|
||||
}
|
||||
|
||||
@@ -18,15 +18,21 @@ package org.springframework.data.gemfire.client;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newIllegalArgumentException;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.apache.geode.cache.client.Pool;
|
||||
import org.apache.geode.cache.client.PoolFactory;
|
||||
@@ -34,19 +40,20 @@ import org.apache.geode.cache.client.PoolFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpoint;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpointList;
|
||||
import org.springframework.data.gemfire.test.support.MapBuilder;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.GemFireMockObjectsSupport;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests that test the use of property placeholders in nested <gfe:locator> and <gfe:server>
|
||||
* elements of the SDG XML namespace <gfe:pool> element along with testing property placeholders in
|
||||
* the <gfe:pool> element <code>locators</code> and <code>servers</code> attributes.
|
||||
* Integration Tests testing the use of property placeholders in nested <gfe:locator> and <gfe:server>
|
||||
* elements of the SDG XML Namespace <gfe:pool> element along with testing property placeholders
|
||||
* in the <gfe:pool> element <code>locators</code> and <code>servers</code> attributes.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.util.Properties
|
||||
@@ -66,26 +73,34 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
@SuppressWarnings("unused")
|
||||
public class SpELExpressionConfiguredPoolsIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
private static final ConnectionEndpointList anotherLocators = new ConnectionEndpointList();
|
||||
private static final ConnectionEndpointList anotherServers = new ConnectionEndpointList();
|
||||
private static final ConnectionEndpointList locators = new ConnectionEndpointList();
|
||||
private static final ConnectionEndpointList servers = new ConnectionEndpointList();
|
||||
private static final ConnectionEndpointList locatorsOne = new ConnectionEndpointList();
|
||||
private static final ConnectionEndpointList locatorsTwo = new ConnectionEndpointList();
|
||||
private static final ConnectionEndpointList serversOne = new ConnectionEndpointList();
|
||||
private static final ConnectionEndpointList serversTwo = new ConnectionEndpointList();
|
||||
|
||||
private static final Map<String, ConnectionEndpointList> poolToConnectionsMap =
|
||||
Collections.unmodifiableMap(MapBuilder.<String, ConnectionEndpointList>newMapBuilder()
|
||||
.put("locatorPoolOne", locatorsOne)
|
||||
.put("locatorPoolTwo", locatorsTwo)
|
||||
.put("serverPoolOne", serversOne)
|
||||
.put("serverPoolTwo", serversTwo)
|
||||
.build());
|
||||
|
||||
@Autowired
|
||||
@Qualifier("locatorPool")
|
||||
private Pool locatorPool;
|
||||
@Qualifier("locatorPoolOne")
|
||||
private Pool locatorPoolOne;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("serverPool")
|
||||
private Pool serverPool;
|
||||
@Qualifier("locatorPoolTwo")
|
||||
private Pool locatorPoolTwo;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("anotherLocatorPool")
|
||||
private Pool anotherLocatorPool;
|
||||
@Qualifier("serverPoolOne")
|
||||
private Pool serverPoolOne;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("anotherServerPool")
|
||||
private Pool anotherServerPool;
|
||||
@Qualifier("serverPoolTwo")
|
||||
private Pool serverPoolTwo;
|
||||
|
||||
private static void assertConnectionEndpoints(ConnectionEndpointList connectionEndpoints,
|
||||
String... expected) {
|
||||
@@ -109,38 +124,38 @@ public class SpELExpressionConfiguredPoolsIntegrationTests extends IntegrationTe
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anotherLocatorPoolFactoryConfiguration() {
|
||||
|
||||
String[] expected = { "cardboardbox[10334]", "localhost[10335]", "pobox[10334]", "safetydepositbox[10336]" };
|
||||
|
||||
assertConnectionEndpoints(anotherLocators, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anotherServerPoolFactoryConfiguration() {
|
||||
|
||||
String[] expected = { "boombox[1234]", "jambox[40404]", "toolbox[8181]" };
|
||||
|
||||
assertConnectionEndpoints(anotherServers, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void locatorPoolFactoryConfiguration() {
|
||||
public void locatorPoolOneFactoryConfiguration() {
|
||||
|
||||
String[] expected = { "backspace[10334]", "jambox[11235]", "mars[30303]", "pluto[20668]", "skullbox[12480]" };
|
||||
|
||||
assertConnectionEndpoints(locators, expected);
|
||||
assertConnectionEndpoints(locatorsOne, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serverPoolFactoryConfiguration() {
|
||||
public void locatorPoolTwoFactoryConfiguration() {
|
||||
|
||||
String[] expected = { "cardboardbox[10334]", "localhost[10335]", "pobox[10334]", "safetydepositbox[10336]" };
|
||||
|
||||
assertConnectionEndpoints(locatorsTwo, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serverPoolOneFactoryConfiguration() {
|
||||
|
||||
String[] expected = {
|
||||
"earth[4554]", "jupiter[40404]", "mars[5112]", "mercury[1234]",
|
||||
"neptune[42424]", "saturn[41414]", "uranis[0]", "venus[9876]"
|
||||
};
|
||||
|
||||
assertConnectionEndpoints(servers, expected);
|
||||
assertConnectionEndpoints(serversOne, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serverPoolTwoFactoryConfiguration() {
|
||||
|
||||
String[] expected = { "boombox[1234]", "jambox[40404]", "toolbox[8181]" };
|
||||
|
||||
assertConnectionEndpoints(serversTwo, expected);
|
||||
}
|
||||
|
||||
public static class SpELBoundBean {
|
||||
@@ -165,89 +180,55 @@ public class SpELExpressionConfiguredPoolsIntegrationTests extends IntegrationTe
|
||||
}
|
||||
}
|
||||
|
||||
public static class TestBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
|
||||
public static class TestBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
@Nullable @Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
|
||||
postProcessBeanDefinition(beanFactory, "anotherLocatorPool", AnotherLocatorPoolFactoryBean.class);
|
||||
postProcessBeanDefinition(beanFactory, "anotherServerPool", AnotherServerPoolFactoryBean.class);
|
||||
postProcessBeanDefinition(beanFactory, "locatorPool", LocatorPoolFactoryBean.class);
|
||||
postProcessBeanDefinition(beanFactory, "serverPool", ServerPoolFactoryBean.class);
|
||||
if (isPoolFactoryBean(bean, beanName)) {
|
||||
|
||||
PoolFactoryBean poolFactoryBeanSpy = spy((PoolFactoryBean) bean);
|
||||
|
||||
doReturn(true).when(poolFactoryBeanSpy).isClientCachePresent();
|
||||
|
||||
doAnswer(invocation -> {
|
||||
|
||||
ConnectionEndpointList list = poolToConnectionsMap.get(beanName);
|
||||
|
||||
PoolFactory mockPoolFactory = GemFireMockObjectsSupport.mockPoolFactory();
|
||||
|
||||
when(mockPoolFactory.addLocator(anyString(), anyInt())).thenAnswer(newAnswer(mockPoolFactory,
|
||||
connectionEndpoint -> list.add(connectionEndpoint)));
|
||||
|
||||
when(mockPoolFactory.addServer(anyString(), anyInt())).thenAnswer(newAnswer(mockPoolFactory,
|
||||
connectionEndpoint -> list.add(connectionEndpoint)));
|
||||
|
||||
return mockPoolFactory;
|
||||
|
||||
}).when(poolFactoryBeanSpy).createPoolFactory();
|
||||
|
||||
bean = poolFactoryBeanSpy;
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
private void postProcessBeanDefinition(ConfigurableListableBeanFactory beanFactory,
|
||||
String beanName, Class<?> beanType) {
|
||||
|
||||
beanFactory.getBeanDefinition(beanName).setBeanClassName(beanType.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static class AnotherLocatorPoolFactoryBean extends TestPoolFactoryBean {
|
||||
@Override ConnectionEndpointList getLocatorList() {
|
||||
return anotherLocators;
|
||||
}
|
||||
}
|
||||
|
||||
public static class AnotherServerPoolFactoryBean extends TestPoolFactoryBean {
|
||||
|
||||
@Override
|
||||
ConnectionEndpointList getServerList() {
|
||||
return anotherServers;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LocatorPoolFactoryBean extends TestPoolFactoryBean {
|
||||
|
||||
@Override
|
||||
ConnectionEndpointList getLocatorList() {
|
||||
return locators;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ServerPoolFactoryBean extends TestPoolFactoryBean {
|
||||
|
||||
@Override
|
||||
ConnectionEndpointList getServerList() {
|
||||
return servers;
|
||||
}
|
||||
}
|
||||
|
||||
static class TestPoolFactoryBean extends PoolFactoryBean {
|
||||
|
||||
ConnectionEndpointList getLocatorList() {
|
||||
throw new UnsupportedOperationException("Not Implemented");
|
||||
private boolean isPoolFactoryBean(Object bean, String beanName) {
|
||||
return bean instanceof PoolFactoryBean && poolToConnectionsMap.containsKey(beanName);
|
||||
}
|
||||
|
||||
ConnectionEndpointList getServerList() {
|
||||
throw new UnsupportedOperationException("Not Implemented");
|
||||
}
|
||||
private Answer<PoolFactory> newAnswer(PoolFactory mockPoolFactory,
|
||||
Consumer<ConnectionEndpoint> connectionEndpointConsumer) {
|
||||
|
||||
@Override
|
||||
protected PoolFactory createPoolFactory() {
|
||||
return invocation -> {
|
||||
|
||||
PoolFactory mockPoolFactory = GemFireMockObjectsSupport.mockPoolFactory();
|
||||
|
||||
when(mockPoolFactory.addLocator(anyString(), anyInt())).thenAnswer(invocation -> {
|
||||
String host = invocation.getArgument(0);
|
||||
int port = invocation.getArgument(1);
|
||||
getLocatorList().add(newConnectionEndpoint(host, port));
|
||||
|
||||
connectionEndpointConsumer.accept(newConnectionEndpoint(host, port));
|
||||
|
||||
return mockPoolFactory;
|
||||
});
|
||||
|
||||
when(mockPoolFactory.addServer(anyString(), anyInt())).thenAnswer(invocation -> {
|
||||
String host = invocation.getArgument(0);
|
||||
int port = invocation.getArgument(1);
|
||||
getServerList().add(newConnectionEndpoint(host, port));
|
||||
return mockPoolFactory;
|
||||
});
|
||||
|
||||
return mockPoolFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isClientCachePresent() {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,18 +162,15 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ForkingClien
|
||||
|
||||
private final User user;
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static GeodeClientAuthInitialize create() {
|
||||
return new GeodeClientAuthInitialize(RUN_COUNT.incrementAndGet() < 2 ? SCIENTIST : ANALYST);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public GeodeClientAuthInitialize(User user) {
|
||||
Assert.notNull(user, "User cannot be null");
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@Override
|
||||
protected Properties doGetCredentials(Properties securityProperties) {
|
||||
|
||||
@@ -185,7 +182,6 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ForkingClien
|
||||
.build();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected User getUser() {
|
||||
return this.user;
|
||||
}
|
||||
@@ -223,15 +219,15 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ForkingClien
|
||||
|
||||
@CacheServerApplication(name = "GeodeSecurityIntegrationTestsServer")
|
||||
@Import({
|
||||
ApacheShiroIniSecurityIntegrationTests.ApacheShiroIniConfiguration.class,
|
||||
ApacheGeodeSecurityManagerSecurityIntegrationTests.ApacheGeodeSecurityManagerConfiguration.class,
|
||||
ApacheShiroRealmSecurityIntegrationTests.ApacheShiroRealmConfiguration.class,
|
||||
ApacheGeodeSecurityManagerSecurityIntegrationTests.ApacheGeodeSecurityManagerConfiguration.class
|
||||
ApacheShiroIniSecurityIntegrationTests.ApacheShiroIniConfiguration.class
|
||||
})
|
||||
@Profile("apache-geode-server")
|
||||
public static class GeodeServerConfiguration {
|
||||
|
||||
public static void main(String[] args) {
|
||||
runSpringApplication(GeodeServerConfiguration.class, args);
|
||||
runSpringApplication(GeodeServerConfiguration.class, args).refresh();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@@ -244,7 +240,6 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ForkingClien
|
||||
|
||||
echoRegion.setCache(gemfireCache);
|
||||
echoRegion.setCacheLoader(echoCacheLoader());
|
||||
echoRegion.setClose(false);
|
||||
echoRegion.setPersistent(false);
|
||||
|
||||
return echoRegion;
|
||||
@@ -260,8 +255,8 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ForkingClien
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
public void close() { }
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -316,7 +311,6 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ForkingClien
|
||||
return getName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public User with(String credentials) {
|
||||
|
||||
this.credentials = credentials;
|
||||
@@ -324,7 +318,6 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ForkingClien
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public User with(Role... roles) {
|
||||
|
||||
Collections.addAll(this.roles, roles);
|
||||
@@ -344,7 +337,6 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ForkingClien
|
||||
|
||||
private final Set<ResourcePermission> permissions = new HashSet<>();
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public boolean hasPermission(ResourcePermission permission) {
|
||||
|
||||
for (ResourcePermission thisPermission : this) {
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration tests for Apache Geode Integrated Security using an application-specific, Apache Geode
|
||||
* Integration Tests for Apache Geode Integrated Security using an application-specific, Apache Geode
|
||||
* {@link org.apache.geode.security.SecurityManager}.
|
||||
*
|
||||
* @author John Blum
|
||||
@@ -52,8 +52,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class)
|
||||
@ActiveProfiles("apache-geode-client")
|
||||
@ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class)
|
||||
public class ApacheGeodeSecurityManagerSecurityIntegrationTests extends AbstractGeodeSecurityIntegrationTests {
|
||||
|
||||
protected static final String GEODE_SECURITY_MANAGER_PROPERTY_CONFIGURATION_PROFILE =
|
||||
|
||||
@@ -39,8 +39,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class)
|
||||
@ActiveProfiles("apache-geode-client")
|
||||
@ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class)
|
||||
public class ApacheShiroIniSecurityIntegrationTests extends AbstractGeodeSecurityIntegrationTests {
|
||||
|
||||
protected static final String SHIRO_INI_CONFIGURATION_PROFILE = "shiro-ini-configuration";
|
||||
|
||||
@@ -45,8 +45,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class)
|
||||
@ActiveProfiles("apache-geode-client")
|
||||
@ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class)
|
||||
public class ApacheShiroRealmSecurityIntegrationTests extends AbstractGeodeSecurityIntegrationTests {
|
||||
|
||||
protected static final String SHIRO_REALM_CONFIGURATION_PROFILE = "shiro-realm-configuration";
|
||||
|
||||
@@ -97,7 +97,11 @@ public class EnableEntityDefinedRegionsUnitTests extends IntegrationTestsSupport
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
Optional.ofNullable(this.applicationContext)
|
||||
.ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
destroyAllGemFireMockObjects();
|
||||
}
|
||||
|
||||
private <K, V> void assertRegion(Region<K, V> region, String name) {
|
||||
|
||||
@@ -61,7 +61,11 @@ public class EnableExpirationConfigurationIntegrationTests extends IntegrationTe
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
Optional.ofNullable(this.applicationContext)
|
||||
.ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
destroyAllGemFireMockObjects();
|
||||
}
|
||||
|
||||
private ConfigurableApplicationContext newApplicationContext(Class<?>... annotatedClasses) {
|
||||
|
||||
@@ -66,7 +66,11 @@ public class EnableExpirationConfigurationUnitTests extends IntegrationTestsSupp
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
Optional.ofNullable(this.applicationContext)
|
||||
.ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
destroyAllGemFireMockObjects();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "unused" })
|
||||
|
||||
@@ -59,7 +59,11 @@ public class EnableOffHeapConfigurationUnitTests extends IntegrationTestsSupport
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
Optional.ofNullable(this.applicationContext)
|
||||
.ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
destroyAllGemFireMockObjects();
|
||||
}
|
||||
|
||||
private ConfigurableApplicationContext newApplicationContext(Class<?>... annotatedClasses) {
|
||||
@@ -191,16 +195,14 @@ public class EnableOffHeapConfigurationUnitTests extends IntegrationTestsSupport
|
||||
@EnableEntityDefinedRegions(basePackageClasses = Person.class)
|
||||
@EnableOffHeap(memorySize = "8192m")
|
||||
@Import(TestRegionConfiguration.class)
|
||||
static class EnableOffHeapForAllRegionsConfiguration {
|
||||
}
|
||||
static class EnableOffHeapForAllRegionsConfiguration { }
|
||||
|
||||
@PeerCacheApplication
|
||||
@EnableGemFireMockObjects
|
||||
@EnableEntityDefinedRegions(basePackageClasses = Person.class)
|
||||
@EnableOffHeap(memorySize = "1024m", regionNames = { "People", "ExamplePartitionRegion" })
|
||||
@Import(TestRegionConfiguration.class)
|
||||
static class EnableOffHeapForSelectRegionsConfiguration {
|
||||
}
|
||||
static class EnableOffHeapForSelectRegionsConfiguration { }
|
||||
|
||||
@EnableGemFireMockObjects
|
||||
@PeerCacheApplication(
|
||||
@@ -210,6 +212,6 @@ public class EnableOffHeapConfigurationUnitTests extends IntegrationTestsSupport
|
||||
evictionOffHeapPercentage = 75.25f
|
||||
)
|
||||
@EnableOffHeap(memorySize = "1024g")
|
||||
static class OffHeapCriticalAndEvictionMemoryPercentagesConfiguration {
|
||||
}
|
||||
static class OffHeapCriticalAndEvictionMemoryPercentagesConfiguration { }
|
||||
|
||||
}
|
||||
|
||||
@@ -60,7 +60,11 @@ public class EnablePdxConfigurationIntegrationTests extends IntegrationTestsSupp
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
Optional.ofNullable(this.applicationContext)
|
||||
.ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
destroyAllGemFireMockObjects();
|
||||
}
|
||||
|
||||
private ConfigurableApplicationContext newApplicationContext(Class<?>... annotatedClasses) {
|
||||
@@ -126,8 +130,8 @@ public class EnablePdxConfigurationIntegrationTests extends IntegrationTestsSupp
|
||||
|
||||
}
|
||||
|
||||
@EnableGemFireMockObjects
|
||||
@PeerCacheApplication
|
||||
@EnableGemFireMockObjects
|
||||
@EnablePdx(diskStoreName = "TestDiskStore", serializerBeanName = "MockPdxSerializer")
|
||||
@SuppressWarnings("unused")
|
||||
static class TestEnablePdxWithDiskStoreConfiguration {
|
||||
@@ -160,8 +164,8 @@ public class EnablePdxConfigurationIntegrationTests extends IntegrationTestsSupp
|
||||
}
|
||||
}
|
||||
|
||||
@EnableGemFireMockObjects
|
||||
@ClientCacheApplication
|
||||
@EnableGemFireMockObjects
|
||||
@EnablePdx
|
||||
@SuppressWarnings("unused")
|
||||
static class TestEnablePdxConfigurationWithNoDiskStoreConfiguration {
|
||||
|
||||
@@ -75,7 +75,11 @@ public class GatewaySenderConfigurationIntegrationTests extends IntegrationTests
|
||||
|
||||
@After
|
||||
public void shutdown() {
|
||||
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
Optional.ofNullable(this.applicationContext)
|
||||
.ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
destroyAllGemFireMockObjects();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -75,7 +75,11 @@ public class GatewaySenderPropertiesIntegrationTests extends IntegrationTestsSup
|
||||
|
||||
@After
|
||||
public void shutdown() {
|
||||
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
Optional.ofNullable(this.applicationContext)
|
||||
.ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
destroyAllGemFireMockObjects();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.springframework.data.gemfire.mapping.annotation.LocalRegion;
|
||||
import org.springframework.data.gemfire.mapping.annotation.PartitionRegion;
|
||||
import org.springframework.data.gemfire.mapping.annotation.ReplicateRegion;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.beans.factory.config.GemFireMockObjectsBeanPostProcessor;
|
||||
import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
@@ -69,6 +69,8 @@ public class RegionConfigurerIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
Optional.ofNullable(this.applicationContext)
|
||||
.ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
destroyAllGemFireMockObjects();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -157,11 +159,6 @@ public class RegionConfigurerIntegrationTests extends IntegrationTestsSupport {
|
||||
@SuppressWarnings("unused")
|
||||
static class AbstractTestConfiguration {
|
||||
|
||||
@Bean
|
||||
GemFireMockObjectsBeanPostProcessor testBeanPostProcessor() {
|
||||
return new GemFireMockObjectsBeanPostProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
TestRegionConfigurer testRegionConfigurerOne() {
|
||||
return new TestRegionConfigurer();
|
||||
@@ -198,6 +195,7 @@ public class RegionConfigurerIntegrationTests extends IntegrationTestsSupport {
|
||||
}
|
||||
|
||||
@ClientCacheApplication
|
||||
@EnableGemFireMockObjects
|
||||
@EnableEntityDefinedRegions(basePackageClasses = NonEntity.class,
|
||||
excludeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION,
|
||||
classes = { LocalRegion.class, PartitionRegion.class, ReplicateRegion.class
|
||||
@@ -218,6 +216,7 @@ public class RegionConfigurerIntegrationTests extends IntegrationTestsSupport {
|
||||
}
|
||||
|
||||
@PeerCacheApplication
|
||||
@EnableGemFireMockObjects
|
||||
@EnableEntityDefinedRegions(basePackageClasses = NonEntity.class,
|
||||
excludeFilters = {
|
||||
@ComponentScan.Filter(type = FilterType.ANNOTATION,
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -55,6 +55,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
@@ -76,7 +77,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class LuceneNamespaceUnitTests extends IntegrationTestsSupport {
|
||||
|
||||
|
||||
@@ -13,39 +13,31 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Matchers.isA;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.beans.PropertyValues;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.beans.factory.config.MethodInvokingBean;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.beans.factory.xml.XmlReaderContext;
|
||||
import org.springframework.data.gemfire.client.PoolFactoryBean;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpoint;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpointList;
|
||||
@@ -54,7 +46,7 @@ import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link PoolParser}.
|
||||
* Unit Tests for {@link PoolParser}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
@@ -62,32 +54,23 @@ import org.w3c.dom.NodeList;
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.mockito.junit.MockitoJUnitRunner
|
||||
* @see org.springframework.data.gemfire.config.xml.PoolParser
|
||||
* @see org.w3c.dom.Element
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class PoolParserUnitTests {
|
||||
|
||||
@Mock
|
||||
private BeanDefinitionRegistry mockRegistry;
|
||||
|
||||
private PoolParser parser;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
PoolParser.INFRASTRUCTURE_COMPONENTS_REGISTERED.set(true);
|
||||
|
||||
this.parser = new PoolParser() {
|
||||
|
||||
@Override
|
||||
BeanDefinitionRegistry resolveRegistry(ParserContext parserContext) {
|
||||
return PoolParserUnitTests.this.mockRegistry;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
protected void assertBeanDefinition(BeanDefinition beanDefinition, String expectedHost, String expectedPort) {
|
||||
private final ParserContext parserContext =
|
||||
new ParserContext(mock(XmlReaderContext.class), mock(BeanDefinitionParserDelegate.class));
|
||||
|
||||
private final PoolParser parser = new PoolParser();
|
||||
|
||||
private void assertBeanDefinition(BeanDefinition beanDefinition, String expectedHost, String expectedPort) {
|
||||
|
||||
assertThat(beanDefinition).isNotNull();
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(ConnectionEndpoint.class.getName());
|
||||
@@ -98,59 +81,20 @@ public class PoolParserUnitTests {
|
||||
.isEqualTo(expectedPort);
|
||||
}
|
||||
|
||||
protected void assertPropertyNotPresent(BeanDefinition beanDefinition, String propertyName) {
|
||||
private void assertPropertyNotPresent(BeanDefinition beanDefinition, String propertyName) {
|
||||
assertThat(beanDefinition.getPropertyValues().contains(propertyName)).isFalse();
|
||||
}
|
||||
|
||||
protected void assertPropertyPresent(BeanDefinition beanDefinition, String propertyName) {
|
||||
private void assertPropertyPresent(BeanDefinition beanDefinition, String propertyName) {
|
||||
assertThat(beanDefinition.getPropertyValues().contains(propertyName)).isTrue();
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
protected void assertPropertyValue(BeanDefinition beanDefinition, String propertyName, Object propertyValue) {
|
||||
assertThat(beanDefinition.getPropertyValues().getPropertyValue(propertyName).getValue())
|
||||
.isEqualTo(propertyValue);
|
||||
private void assertPropertyValue(BeanDefinition beanDefinition, String propertyName, Object propertyValue) {
|
||||
assertThat(this.<Object>getPropertyValue(beanDefinition, propertyName)).isEqualTo(propertyValue);
|
||||
}
|
||||
|
||||
protected String generateBeanName(Class<?> type) {
|
||||
return generateBeanName(type.getName());
|
||||
}
|
||||
|
||||
protected String generateBeanName(String beanClassName) {
|
||||
return String.format("%1$s%2$s%3$d", beanClassName, BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR, 0);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
protected Answer<Void> newAnswer(String beanReference, String targetMethod, String host, String port) {
|
||||
|
||||
return invocation -> {
|
||||
|
||||
String generatedName = invocation.getArgument(0);
|
||||
|
||||
BeanDefinition methodInvokingBeanDefinition = invocation.getArgument(1);
|
||||
|
||||
assertThat(methodInvokingBeanDefinition).isNotNull();
|
||||
assertThat(methodInvokingBeanDefinition.getBeanClassName()).isEqualTo(MethodInvokingBean.class.getName());
|
||||
assertThat(generatedName).isEqualTo(generateBeanName(methodInvokingBeanDefinition.getBeanClassName()));
|
||||
assertPropertyValue(methodInvokingBeanDefinition, "targetObject", new RuntimeBeanReference(beanReference));
|
||||
assertPropertyValue(methodInvokingBeanDefinition, "targetMethod", targetMethod);
|
||||
|
||||
BeanDefinition argumentsDefinition = getPropertyValue(methodInvokingBeanDefinition, "arguments");
|
||||
|
||||
assertThat(argumentsDefinition.getBeanClassName()).isEqualTo(ConnectionEndpointList.class.getName());
|
||||
|
||||
ConstructorArgumentValues constructorArguments = argumentsDefinition.getConstructorArgumentValues();
|
||||
|
||||
assertThat(constructorArguments.getArgumentCount()).isEqualTo(2);
|
||||
assertThat(constructorArguments.getArgumentValue(0, Integer.class).getValue()).isEqualTo(port);
|
||||
assertThat(constructorArguments.getArgumentValue(1, String.class).getValue()).isEqualTo(host);
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
protected <T> T getPropertyValue(BeanDefinition beanDefinition, String propertyName) {
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T getPropertyValue(BeanDefinition beanDefinition, String propertyName) {
|
||||
return (T) beanDefinition.getPropertyValues().getPropertyValue(propertyName).getValue();
|
||||
}
|
||||
|
||||
@@ -307,11 +251,12 @@ public class PoolParserUnitTests {
|
||||
BeanDefinitionBuilder poolBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(this.parser.getBeanClass(mockPoolElement));
|
||||
|
||||
this.parser.doParse(mockPoolElement, null, poolBuilder);
|
||||
this.parser.doParse(mockPoolElement, this.parserContext, poolBuilder);
|
||||
|
||||
BeanDefinition poolDefinition = poolBuilder.getBeanDefinition();
|
||||
|
||||
assertThat(poolDefinition).isNotNull();
|
||||
assertThat(poolDefinition.getBeanClassName()).isEqualTo(PoolFactoryBean.class.getName());
|
||||
|
||||
PropertyValues poolPropertyValues = poolDefinition.getPropertyValues();
|
||||
|
||||
@@ -339,25 +284,16 @@ public class PoolParserUnitTests {
|
||||
|
||||
NodeList mockNodeList = mock(NodeList.class);
|
||||
|
||||
when(mockPoolElement.getAttribute(PoolParser.ID_ATTRIBUTE)).thenReturn("TestPool");
|
||||
when(mockPoolElement.getAttribute(eq(PoolParser.LOCATORS_ATTRIBUTE_NAME))).thenReturn(
|
||||
"#{T(example.app.config.GemFireProperties).locatorHostsPorts()}");
|
||||
when(mockPoolElement.getAttribute(eq(PoolParser.SERVERS_ATTRIBUTE_NAME))).thenReturn("");
|
||||
when(mockPoolElement.getChildNodes()).thenReturn(mockNodeList);
|
||||
when(mockNodeList.getLength()).thenReturn(0);
|
||||
when(this.mockRegistry.containsBeanDefinition(anyString())).thenReturn(false);
|
||||
|
||||
Answer<Void> answer = newAnswer("&TestPool", "addLocators",
|
||||
"#{T(example.app.config.GemFireProperties).locatorHostsPorts()}",
|
||||
String.valueOf(PoolParser.DEFAULT_LOCATOR_PORT));
|
||||
|
||||
doAnswer(answer).when(this.mockRegistry).registerBeanDefinition(eq(generateBeanName(MethodInvokingBean.class)),
|
||||
any(BeanDefinition.class));
|
||||
|
||||
BeanDefinitionBuilder poolBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(this.parser.getBeanClass(mockPoolElement));
|
||||
|
||||
this.parser.doParse(mockPoolElement, null, poolBuilder);
|
||||
this.parser.doParse(mockPoolElement, this.parserContext, poolBuilder);
|
||||
|
||||
BeanDefinition poolDefinition = poolBuilder.getBeanDefinition();
|
||||
|
||||
@@ -365,15 +301,11 @@ public class PoolParserUnitTests {
|
||||
assertPropertyNotPresent(poolDefinition, "locators");
|
||||
assertPropertyNotPresent(poolDefinition, "servers");
|
||||
|
||||
verify(mockPoolElement, times(1)).getAttribute(eq(PoolParser.ID_ATTRIBUTE));
|
||||
verify(mockPoolElement, times(1)).getAttribute(eq(PoolParser.LOCATORS_ATTRIBUTE_NAME));
|
||||
verify(mockPoolElement, times(1)).getAttribute(eq(PoolParser.SERVERS_ATTRIBUTE_NAME));
|
||||
verify(mockPoolElement, times(1)).getChildNodes();
|
||||
verify(mockNodeList, times(1)).getLength();
|
||||
verify(mockNodeList, never()).item(anyInt());
|
||||
verify(this.mockRegistry, times(1)).containsBeanDefinition(eq(generateBeanName(MethodInvokingBean.class)));
|
||||
verify(this.mockRegistry, times(1)).registerBeanDefinition(eq(generateBeanName(MethodInvokingBean.class)),
|
||||
isA(BeanDefinition.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -383,19 +315,11 @@ public class PoolParserUnitTests {
|
||||
|
||||
NodeList mockNodeList = mock(NodeList.class);
|
||||
|
||||
when(mockPoolElement.getAttribute(PoolParser.ID_ATTRIBUTE)).thenReturn("TestPool");
|
||||
when(mockPoolElement.getAttribute(eq(PoolParser.LOCATORS_ATTRIBUTE_NAME))).thenReturn("");
|
||||
when(mockPoolElement.getAttribute(eq(PoolParser.SERVERS_ATTRIBUTE_NAME))).thenReturn(
|
||||
"${gemfire.server.hosts-and-ports}");
|
||||
when(mockPoolElement.getChildNodes()).thenReturn(mockNodeList);
|
||||
when(mockNodeList.getLength()).thenReturn(0);
|
||||
when(this.mockRegistry.containsBeanDefinition(anyString())).thenReturn(false);
|
||||
|
||||
Answer<Void> answer = newAnswer("&TestPool", "addServers",
|
||||
"${gemfire.server.hosts-and-ports}", String.valueOf(PoolParser.DEFAULT_SERVER_PORT));
|
||||
|
||||
doAnswer(answer).when(this.mockRegistry).registerBeanDefinition(eq(generateBeanName(MethodInvokingBean.class)),
|
||||
any(BeanDefinition.class));
|
||||
|
||||
BeanDefinitionBuilder poolBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(this.parser.getBeanClass(mockPoolElement));
|
||||
@@ -408,32 +332,32 @@ public class PoolParserUnitTests {
|
||||
assertPropertyNotPresent(poolDefinition, "locators");
|
||||
assertPropertyNotPresent(poolDefinition, "servers");
|
||||
|
||||
verify(mockPoolElement, times(1)).getAttribute(eq(PoolParser.ID_ATTRIBUTE));
|
||||
verify(mockPoolElement, times(1)).getAttribute(eq(PoolParser.LOCATORS_ATTRIBUTE_NAME));
|
||||
verify(mockPoolElement, times(1)).getAttribute(eq(PoolParser.SERVERS_ATTRIBUTE_NAME));
|
||||
verify(mockPoolElement, times(1)).getChildNodes();
|
||||
verify(mockNodeList, times(1)).getLength();
|
||||
verify(mockNodeList, never()).item(anyInt());
|
||||
verify(this.mockRegistry, times(1)).containsBeanDefinition(eq(generateBeanName(MethodInvokingBean.class)));
|
||||
verify(this.mockRegistry, times(1)).registerBeanDefinition(eq(generateBeanName(MethodInvokingBean.class)),
|
||||
isA(BeanDefinition.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildConnection() {
|
||||
|
||||
assertBeanDefinition(this.parser.buildConnection("earth", "1234", true), "earth", "1234");
|
||||
assertBeanDefinition(this.parser.buildConnection("mars", " ", true), "mars",
|
||||
String.valueOf(PoolParser.DEFAULT_SERVER_PORT));
|
||||
assertBeanDefinition(this.parser.buildConnection(" ", "1234", true), PoolParser.DEFAULT_HOST, "1234");
|
||||
assertBeanDefinition(this.parser.buildConnection(" ", "", true), PoolParser.DEFAULT_HOST,
|
||||
String.valueOf(PoolParser.DEFAULT_SERVER_PORT));
|
||||
assertBeanDefinition(this.parser.buildConnection("jupiter", "9876", false), "jupiter", "9876");
|
||||
assertBeanDefinition(this.parser.buildConnection("saturn", null, false), "saturn",
|
||||
String.valueOf(PoolParser.DEFAULT_LOCATOR_PORT));
|
||||
assertBeanDefinition(this.parser.buildConnection(null, "9876", false), PoolParser.DEFAULT_HOST, "9876");
|
||||
assertBeanDefinition(this.parser.buildConnection("", " ", false), PoolParser.DEFAULT_HOST,
|
||||
String.valueOf(PoolParser.DEFAULT_LOCATOR_PORT));
|
||||
assertBeanDefinition(this.parser.buildConnection("earth", "1234", true),
|
||||
"earth", "1234");
|
||||
assertBeanDefinition(this.parser.buildConnection("mars", " ", true),
|
||||
"mars", String.valueOf(PoolParser.DEFAULT_SERVER_PORT));
|
||||
assertBeanDefinition(this.parser.buildConnection(" ", "1234", true),
|
||||
PoolParser.DEFAULT_HOST, "1234");
|
||||
assertBeanDefinition(this.parser.buildConnection(" ", "", true),
|
||||
PoolParser.DEFAULT_HOST, String.valueOf(PoolParser.DEFAULT_SERVER_PORT));
|
||||
assertBeanDefinition(this.parser.buildConnection("jupiter", "9876", false),
|
||||
"jupiter", "9876");
|
||||
assertBeanDefinition(this.parser.buildConnection("saturn", null, false),
|
||||
"saturn", String.valueOf(PoolParser.DEFAULT_LOCATOR_PORT));
|
||||
assertBeanDefinition(this.parser.buildConnection(null, "9876", false),
|
||||
PoolParser.DEFAULT_HOST, "9876");
|
||||
assertBeanDefinition(this.parser.buildConnection("", " ", false),
|
||||
PoolParser.DEFAULT_HOST, String.valueOf(PoolParser.DEFAULT_LOCATOR_PORT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -489,6 +413,16 @@ public class PoolParserUnitTests {
|
||||
assertThat(this.parser.defaultPort(null, true)).isEqualTo(String.valueOf(PoolParser.DEFAULT_SERVER_PORT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultLocatorPort() {
|
||||
assertThat(this.parser.defaultPort(false)).isEqualTo(PoolParser.DEFAULT_LOCATOR_PORT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultServerPort() {
|
||||
assertThat(this.parser.defaultPort(true)).isEqualTo(PoolParser.DEFAULT_SERVER_PORT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseLocator() {
|
||||
|
||||
@@ -497,10 +431,13 @@ public class PoolParserUnitTests {
|
||||
when(mockElement.getAttribute(eq(PoolParser.HOST_ATTRIBUTE_NAME))).thenReturn("skullbox");
|
||||
when(mockElement.getAttribute(eq(PoolParser.PORT_ATTRIBUTE_NAME))).thenReturn("1234");
|
||||
|
||||
assertBeanDefinition(this.parser.parseLocator(mockElement), "skullbox", "1234");
|
||||
assertBeanDefinition(this.parser.parseLocator(mockElement, this.parserContext),
|
||||
"skullbox", "1234");
|
||||
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.HOST_ATTRIBUTE_NAME));
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.PORT_ATTRIBUTE_NAME));
|
||||
|
||||
verifyNoMoreInteractions(mockElement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -511,11 +448,13 @@ public class PoolParserUnitTests {
|
||||
when(mockElement.getAttribute(PoolParser.HOST_ATTRIBUTE_NAME)).thenReturn("");
|
||||
when(mockElement.getAttribute(PoolParser.PORT_ATTRIBUTE_NAME)).thenReturn(null);
|
||||
|
||||
assertBeanDefinition(this.parser.parseLocator(mockElement), PoolParser.DEFAULT_HOST,
|
||||
String.valueOf(PoolParser.DEFAULT_LOCATOR_PORT));
|
||||
assertBeanDefinition(this.parser.parseLocator(mockElement, this.parserContext),
|
||||
PoolParser.DEFAULT_HOST, String.valueOf(PoolParser.DEFAULT_LOCATOR_PORT));
|
||||
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.HOST_ATTRIBUTE_NAME));
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.PORT_ATTRIBUTE_NAME));
|
||||
|
||||
verifyNoMoreInteractions(mockElement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -523,26 +462,16 @@ public class PoolParserUnitTests {
|
||||
|
||||
Element mockElement = mock(Element.class);
|
||||
|
||||
when(mockElement.getAttribute(eq(PoolParser.ID_ATTRIBUTE))).thenReturn("TestPool");
|
||||
when(mockElement.getAttribute(eq(PoolParser.LOCATORS_ATTRIBUTE_NAME)))
|
||||
.thenReturn("jupiter, saturn[1234], [9876] ");
|
||||
when(this.mockRegistry.containsBeanDefinition(anyString())).thenReturn(false);
|
||||
|
||||
Answer<Void> answer = newAnswer("&TestPool", "addLocators",
|
||||
"jupiter, saturn[1234], [9876] ", String.valueOf(PoolParser.DEFAULT_LOCATOR_PORT));
|
||||
|
||||
doAnswer(answer).when(this.mockRegistry).registerBeanDefinition(eq(generateBeanName(MethodInvokingBean.class)),
|
||||
any(BeanDefinition.class));
|
||||
|
||||
BeanDefinitionBuilder poolBuilder = BeanDefinitionBuilder.genericBeanDefinition();
|
||||
|
||||
assertThat(this.parser.parseLocators(mockElement, poolBuilder, mockRegistry)).isTrue();
|
||||
this.parser.parseLocators(mockElement, this.parserContext, poolBuilder);
|
||||
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.ID_ATTRIBUTE));
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.LOCATORS_ATTRIBUTE_NAME));
|
||||
verify(this.mockRegistry, times(1)).containsBeanDefinition(eq(generateBeanName(MethodInvokingBean.class)));
|
||||
verify(this.mockRegistry, times(1)).registerBeanDefinition(eq(generateBeanName(MethodInvokingBean.class)),
|
||||
isA(BeanDefinition.class));
|
||||
|
||||
verifyNoMoreInteractions(mockElement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -553,10 +482,13 @@ public class PoolParserUnitTests {
|
||||
when(mockElement.getAttribute(eq(PoolParser.HOST_ATTRIBUTE_NAME))).thenReturn("pluto");
|
||||
when(mockElement.getAttribute(eq(PoolParser.PORT_ATTRIBUTE_NAME))).thenReturn("9876");
|
||||
|
||||
assertBeanDefinition(this.parser.parseServer(mockElement), "pluto", "9876");
|
||||
assertBeanDefinition(this.parser.parseServer(mockElement, this.parserContext),
|
||||
"pluto", "9876");
|
||||
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.HOST_ATTRIBUTE_NAME));
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.PORT_ATTRIBUTE_NAME));
|
||||
|
||||
verifyNoMoreInteractions(mockElement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -567,11 +499,13 @@ public class PoolParserUnitTests {
|
||||
when(mockElement.getAttribute(eq(PoolParser.HOST_ATTRIBUTE_NAME))).thenReturn(" ");
|
||||
when(mockElement.getAttribute(eq(PoolParser.PORT_ATTRIBUTE_NAME))).thenReturn("");
|
||||
|
||||
assertBeanDefinition(this.parser.parseServer(mockElement), PoolParser.DEFAULT_HOST,
|
||||
String.valueOf(PoolParser.DEFAULT_SERVER_PORT));
|
||||
assertBeanDefinition(this.parser.parseServer(mockElement, this.parserContext),
|
||||
PoolParser.DEFAULT_HOST, String.valueOf(PoolParser.DEFAULT_SERVER_PORT));
|
||||
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.HOST_ATTRIBUTE_NAME));
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.PORT_ATTRIBUTE_NAME));
|
||||
|
||||
verifyNoMoreInteractions(mockElement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -579,21 +513,14 @@ public class PoolParserUnitTests {
|
||||
|
||||
Element mockElement = mock(Element.class);
|
||||
|
||||
when(mockElement.getAttribute(eq(PoolParser.ID_ATTRIBUTE))).thenReturn("TestPool");
|
||||
when(mockElement.getAttribute(eq(PoolParser.SERVERS_ATTRIBUTE_NAME))).thenReturn("mars[], venus[9876]");
|
||||
when(this.mockRegistry.containsBeanDefinition(anyString())).thenReturn(false);
|
||||
|
||||
Answer<Void> answer = newAnswer("&TestPool", "addServers",
|
||||
"mars[], venus[9876]", String.valueOf(PoolParser.DEFAULT_SERVER_PORT));
|
||||
|
||||
doAnswer(answer).when(this.mockRegistry).registerBeanDefinition(eq(generateBeanName(MethodInvokingBean.class)),
|
||||
any(BeanDefinition.class));
|
||||
|
||||
BeanDefinitionBuilder poolBuilder = BeanDefinitionBuilder.genericBeanDefinition();
|
||||
|
||||
assertThat(this.parser.parseServers(mockElement, poolBuilder, this.mockRegistry)).isTrue();
|
||||
this.parser.parseServers(mockElement, this.parserContext, poolBuilder);
|
||||
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.ID_ATTRIBUTE));
|
||||
verify(mockElement, times(1)).getAttribute(eq(PoolParser.SERVERS_ATTRIBUTE_NAME));
|
||||
|
||||
verifyNoMoreInteractions(mockElement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xsi:schemaLocation="http://geode.apache.org/schema/cache https://geode.apache.org/schema/cache/cache-1.0.xsd"
|
||||
version="1.0">
|
||||
|
||||
<cache-server hostname-for-clients="localhost" port="42082"/>
|
||||
<cache-server hostname-for-clients="localhost" port="${CACHE_SERVER_PORT}"/>
|
||||
|
||||
<region name="ServerRegion" refid="PARTITION"/>
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
|
||||
<logger name="org.springframework" level="${logback.log.level:-ERROR}"/>
|
||||
|
||||
<logger name="org.springframework.data" level="${logback.log.level:-ERROR}"/>
|
||||
|
||||
<logger name="org.springframework.data.gemfire" level="${logback.log.level:-CONFIG}"/>
|
||||
|
||||
<logger name="org.springframework.data.gemfire.config.annotation.support.RegionDataAccessTracingAspect" level="trace" additivity="false">
|
||||
<appender-ref ref="testAppender"/>
|
||||
</logger>
|
||||
|
||||
@@ -11,40 +11,40 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">LookupPartitionRegionMutationIntegrationTest</prop>
|
||||
<prop key="name">LookupPartitionRegionMutationIntegrationTests</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:cache cache-xml-location="/lookup-partition-region-mutation-cache.xml" properties-ref="gemfireProperties"/>
|
||||
|
||||
<bean id="B" class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTest.TestCacheListener"/>
|
||||
<bean id="B" class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTests.TestCacheListener"/>
|
||||
|
||||
<gfe:lookup-region id="Example" cloning-enabled="true" eviction-maximum="1000">
|
||||
<gfe:cache-listener>
|
||||
<bean class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTest.TestCacheListener"
|
||||
<bean class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTests.TestCacheListener"
|
||||
p:name="A"/>
|
||||
<ref bean="B"/>
|
||||
</gfe:cache-listener>
|
||||
<gfe:cache-loader>
|
||||
<bean class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTest$TestCacheLoader"
|
||||
<bean class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTests$TestCacheLoader"
|
||||
p:name="C"/>
|
||||
</gfe:cache-loader>
|
||||
<gfe:cache-writer>
|
||||
<bean class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTest$TestCacheWriter"
|
||||
<bean class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTests$TestCacheWriter"
|
||||
p:name="D"/>
|
||||
</gfe:cache-writer>
|
||||
<!-- <gfe:region-ttl timeout="120" action="LOCAL_DESTROY"/>-->
|
||||
<!-- <gfe:region-tti timeout="60" action="DESTROY"/>-->
|
||||
<gfe:entry-ttl timeout="30" action="DESTROY"/>
|
||||
<gfe:custom-entry-tti>
|
||||
<bean class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTest$TestCustomExpiry"
|
||||
<bean class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTests$TestCustomExpiry"
|
||||
p:name="E"/>
|
||||
</gfe:custom-entry-tti>
|
||||
<gfe:gateway-sender name="GWS" remote-distributed-system-id="123" manual-start="true"/>
|
||||
<gfe:async-event-queue name="AEQ" persistent="false" parallel="true" dispatcher-threads="8">
|
||||
<gfe:async-event-listener>
|
||||
<bean
|
||||
class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTest$TestAsyncEventListener"
|
||||
class="org.springframework.data.gemfire.LookupRegionMutationIntegrationTests$TestAsyncEventListener"
|
||||
p:name="F"/>
|
||||
</gfe:async-event-listener>
|
||||
</gfe:async-event-queue>
|
||||
@@ -11,7 +11,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">LookupRegionMutationIntegrationTest</prop>
|
||||
<prop key="name">LookupRegionMutationIntegrationTests</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">pdxDiskStoreTest</prop>
|
||||
<prop key="name">PdxDiskStoreIntegrationTests</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
<!--
|
||||
@@ -21,8 +21,8 @@
|
||||
<constructor-arg type="boolean" value="true"/>
|
||||
<constructor-arg>
|
||||
<list>
|
||||
<value>org.springframework.data.gemfire.PdxDiskStoreIntegrationTest\$KeyHolder</value>
|
||||
<value>org.springframework.data.gemfire.PdxDiskStoreIntegrationTest\$ValueHolder</value>
|
||||
<value>org.springframework.data.gemfire.PdxDiskStoreIntegrationTests\$KeyHolder</value>
|
||||
<value>org.springframework.data.gemfire.PdxDiskStoreIntegrationTests\$ValueHolder</value>
|
||||
</list>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
@@ -39,7 +39,12 @@
|
||||
</gfe:disk-store>
|
||||
-->
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties" pdx-serializer-ref="autoSerializer" pdx-persistent="true" pdx-disk-store="pdxStore"/>
|
||||
<gfe:cache properties-ref="gemfireProperties" pdx-serializer-ref="autoSerializer"
|
||||
pdx-persistent="true" pdx-disk-store="pdxStore"/>
|
||||
|
||||
<gfe:disk-store id="pdxStore" auto-compact="true" compaction-threshold="50" queue-size="50" max-oplog-size="10" time-interval="60000">
|
||||
<gfe:disk-dir location="./gemfire/pdx-store" max-size="50"/>
|
||||
</gfe:disk-store>
|
||||
|
||||
<gfe:disk-store id="dataStore" auto-compact="true" compaction-threshold="75" queue-size="50" max-oplog-size="10" time-interval="600000">
|
||||
<gfe:disk-dir location="./gemfire/data-store/" max-size="50"/>
|
||||
@@ -47,10 +52,6 @@
|
||||
|
||||
<gfe:partitioned-region id="pdxDataRegion" name="PdxData" persistent="true" disk-store-ref="dataStore" disk-synchronous="true"/>
|
||||
|
||||
<gfe:disk-store id="pdxStore" auto-compact="true" compaction-threshold="50" queue-size="50" max-oplog-size="10" time-interval="60000">
|
||||
<gfe:disk-dir location="./gemfire/pdx-store" max-size="50"/>
|
||||
</gfe:disk-store>
|
||||
|
||||
<!--
|
||||
<bean id="pdxDataTemplate" class="org.springframework.data.gemfire.GemfireTemplate" p:region-ref="pdxDataRegion"/>
|
||||
-->
|
||||
@@ -10,7 +10,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">ComplexSubRegionConfig</prop>
|
||||
<prop key="name">SubRegionIntegrationTests</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
initial-capacity="1000"
|
||||
key-constraint="java.lang.Long"
|
||||
persistent="true"
|
||||
scope="distributed-ack"
|
||||
scope="DISTRIBUTED_ACK"
|
||||
statistics="true"
|
||||
value-constraint="java.lang.String">
|
||||
<!-- NOTE Async Event Queue and Gateway Sender tests are covered in the subregionsubelement-ns.xml and associated test class -->
|
||||
@@ -39,7 +39,6 @@
|
||||
<gfe:cache-writer>
|
||||
<bean class="org.springframework.data.gemfire.SimpleCacheWriter"/>
|
||||
</gfe:cache-writer>
|
||||
<gfe:membership-attributes loss-action="limited-access" required-roles="TEST" resumption-action="reinitialize"/>
|
||||
<gfe:subscription type="CACHE_CONTENT"/>
|
||||
<gfe:eviction action="OVERFLOW_TO_DISK" threshold="10000"/>
|
||||
</gfe:replicated-region>
|
||||
@@ -4,8 +4,6 @@
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"
|
||||
default-lazy-init="true">
|
||||
|
||||
<bean class="org.springframework.data.gemfire.tests.mock.beans.factory.config.GemFireMockObjectsBeanPostProcessor"/>
|
||||
|
||||
<bean id="default-cache" class="org.springframework.data.gemfire.CacheFactoryBean">
|
||||
<property name="properties">
|
||||
<props>
|
||||
@@ -24,15 +22,6 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="named-cache" class="org.springframework.data.gemfire.CacheFactoryBean">
|
||||
<property name="properties">
|
||||
<props>
|
||||
<prop key="name">named-cache</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="cache-with-xml" class="org.springframework.data.gemfire.CacheFactoryBean">
|
||||
<property name="cacheXml" value="classpath:gemfire-cache.xml"/>
|
||||
<property name="properties">
|
||||
@@ -43,6 +32,15 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="named-cache" class="org.springframework.data.gemfire.CacheFactoryBean">
|
||||
<property name="properties">
|
||||
<props>
|
||||
<prop key="name">named-cache</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="pdx-cache" class="org.springframework.data.gemfire.CacheFactoryBean">
|
||||
<property name="properties">
|
||||
<props>
|
||||
@@ -52,4 +50,6 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.data.gemfire.CacheIntegrationTests$CacheWithXmlFactoryBeanPostProcessor"/>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
</util:properties>
|
||||
|
||||
<gfe:pool id="gemfireServerPool" max-connections="1" min-connections="1">
|
||||
<gfe:server host="${client.server.host}" port="${client.server.port}"/>
|
||||
<gfe:server host="${spring.data.gemfire.cache.server.host:localhost}"
|
||||
port="${spring.data.gemfire.cache.server.port}"/>
|
||||
</gfe:pool>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties" pool-name="gemfireServerPool"/>
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties"/>
|
||||
|
||||
<gfe:cache-server auto-startup="true" bind-address="${gemfire.server.host}" port="${gemfire.server.port}"
|
||||
max-connections="1"/>
|
||||
<gfe:cache-server auto-startup="true" bind-address="${spring.data.gemfire.cache.server.host:localhost}"
|
||||
port="${spring.data.gemfire.cache.server.port}" max-connections="1"/>
|
||||
|
||||
<gfe:replicated-region id="Example" persistent="false">
|
||||
<gfe:cache-loader>
|
||||
|
||||
@@ -4,20 +4,15 @@
|
||||
xmlns:gfe="http://www.springframework.org/schema/geode"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/geode https://www.springframework.org/schema/geode/spring-geode.xsd
|
||||
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd
|
||||
">
|
||||
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd">
|
||||
|
||||
<util:properties id="client.properties">
|
||||
<prop key="gemfire.cache.client.pool.locator.hosts-and-ports">localhost[11235]</prop>
|
||||
</util:properties>
|
||||
|
||||
<context:property-placeholder properties-ref="client.properties"/>
|
||||
<context:property-placeholder/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">ClientCacheVariableLocatorsIntegrationTestsClient</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
@@ -27,6 +22,8 @@
|
||||
key-constraint="java.lang.String" value-constraint="java.lang.Integer"/>
|
||||
|
||||
<!-- Keep the definition of this GemFire Pool bean after the Region (Example) that depends on it! -->
|
||||
<gfe:pool id="locatorPool" locators="${gemfire.cache.client.pool.locator.hosts-and-ports}"/>
|
||||
<gfe:pool id="locatorPool" locators="localhost[12345],localhost[9876]">
|
||||
<gfe:locator host="${spring.data.gemfire.locator.host:localhost}" port="${spring.data.gemfire.locator.port}"/>
|
||||
</gfe:pool>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -11,24 +11,19 @@
|
||||
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd
|
||||
">
|
||||
|
||||
<util:properties id="server.properties">
|
||||
<prop key="gemfire.cache.server.host">localhost</prop>
|
||||
<prop key="gemfire.cache.server.port">23579</prop>
|
||||
</util:properties>
|
||||
|
||||
<context:property-placeholder properties-ref="server.properties"/>
|
||||
<context:property-placeholder/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">ClientCacheVariableLocatorsTestServer</prop>
|
||||
<prop key="name">ClientCacheVariableLocatorsIntegrationTestsServer</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
<prop key="locators">localhost[11235]</prop>
|
||||
<prop key="start-locator">localhost[11235]</prop>
|
||||
<prop key="locators">localhost[${spring.data.gemfire.locator.port}]</prop>
|
||||
<prop key="start-locator">localhost[${spring.data.gemfire.locator.port}]</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties"/>
|
||||
|
||||
<gfe:cache-server bind-address="${gemfire.cache.server.host}" port="${gemfire.cache.server.port}"
|
||||
auto-startup="true" max-connections="1"/>
|
||||
<gfe:cache-server bind-address="${spring.data.gemfire.cache.server.host:localhost}"
|
||||
port="${spring.data.gemfire.cache.server.port}" max-connections="1"/>
|
||||
|
||||
<gfe:replicated-region id="Example" persistent="false" key-constraint="java.lang.String" value-constraint="java.lang.Integer">
|
||||
<gfe:cache-loader>
|
||||
|
||||
@@ -11,15 +11,10 @@
|
||||
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd
|
||||
">
|
||||
|
||||
<util:properties id="clientProperties">
|
||||
<prop key="gemfire.cache.client.pool.server.hosts-and-ports">localhost[23579],localhost[23654]</prop>
|
||||
<prop key="gemfire.cache.client.pool.server.host">localhost</prop>
|
||||
<prop key="gemfire.cache.client.pool.server.port">24448</prop>
|
||||
</util:properties>
|
||||
|
||||
<context:property-placeholder properties-ref="clientProperties"/>
|
||||
<context:property-placeholder/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">ClientCacheVariableServersIntegrationTestsClient</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
@@ -28,9 +23,9 @@
|
||||
<gfe:client-region id="Example" pool-name="serverPool" shortcut="PROXY"
|
||||
key-constraint="java.lang.String" value-constraint="java.lang.Integer"/>
|
||||
|
||||
<!-- Keep the definition of this GemFire Pool bean after the Region (Example) that depends on it! -->
|
||||
<gfe:pool id="serverPool" servers="${gemfire.cache.client.pool.server.hosts-and-ports}">
|
||||
<gfe:server host="${gemfire.cache.client.pool.server.host}" port="${gemfire.cache.client.pool.server.port}"/>
|
||||
<gfe:pool id="serverPool" servers="localhost[${test.cache.server.port.one}],localhost[${test.cache.server.port.two}]">
|
||||
<gfe:server host="${spring.data.gemfire.cache.server.host:localhost}"
|
||||
port="${spring.data.gemfire.cache.server.port}"/>
|
||||
</gfe:pool>
|
||||
|
||||
</beans>
|
||||
@@ -11,32 +11,25 @@
|
||||
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd
|
||||
">
|
||||
|
||||
<util:properties id="server.properties">
|
||||
<prop key="gemfire.cache.server.1.host">localhost</prop>
|
||||
<prop key="gemfire.cache.server.1.port">22357</prop>
|
||||
<prop key="gemfire.cache.server.2.host">localhost</prop>
|
||||
<prop key="gemfire.cache.server.2.port">23654</prop>
|
||||
<prop key="gemfire.cache.server.3.host">localhost</prop>
|
||||
<prop key="gemfire.cache.server.3.port">24448</prop>
|
||||
</util:properties>
|
||||
|
||||
<context:property-placeholder properties-ref="server.properties"/>
|
||||
<context:property-placeholder/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">ClientCacheVariableServersTestServer</prop>
|
||||
<prop key="name">ClientCacheVariableServersIntegrationTestsServer</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties"/>
|
||||
|
||||
<gfe:cache-server bind-address="${gemfire.cache.server.1.host}" port="${gemfire.cache.server.1.port}"
|
||||
auto-startup="true" max-connections="1"/>
|
||||
<!-- TODO: CacheServer bean definition is being overridden -->
|
||||
<gfe:cache-server bind-address="${test.cache.server.host.one:localhost}" port="${test.cache.server.port.one}"
|
||||
max-connections="1"/>
|
||||
|
||||
<gfe:cache-server bind-address="${gemfire.cache.server.2.host}" port="${gemfire.cache.server.2.port}"
|
||||
auto-startup="true" max-connections="1"/>
|
||||
<!-- TODO: CacheServer bean definition is being overridden -->
|
||||
<gfe:cache-server bind-address="${test.cache.server.host.two:localhost}" port="${test.cache.server.port.two}"
|
||||
max-connections="1"/>
|
||||
|
||||
<gfe:cache-server bind-address="${gemfire.cache.server.3.host}" port="${gemfire.cache.server.3.port}"
|
||||
auto-startup="true" max-connections="1"/>
|
||||
<gfe:cache-server bind-address="${spring.data.gemfire.cache.server.host:localhost}"
|
||||
port="${spring.data.gemfire.cache.server.port}" max-connections="1"/>
|
||||
|
||||
<gfe:replicated-region id="Example" persistent="false" key-constraint="java.lang.String" value-constraint="java.lang.Integer">
|
||||
<gfe:cache-loader>
|
||||
@@ -44,4 +37,6 @@
|
||||
</gfe:cache-loader>
|
||||
</gfe:replicated-region>
|
||||
|
||||
<bean class="org.springframework.data.gemfire.client.ClientCacheVariableServersIntegrationTests$CacheServerConfigurationApplicationListener"/>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="clientProperties">
|
||||
<prop key="gemfire.cache.client.durable-client-id">DurableClientCacheIntegrationTest</prop>
|
||||
<prop key="gemfire.cache.client.durable-client-id">DurableClientCacheIntegrationTests</prop>
|
||||
<prop key="gemfire.cache.client.durable-client-timeout">
|
||||
${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTests.durable-client-timeout:300}
|
||||
</prop>
|
||||
@@ -20,9 +20,7 @@
|
||||
${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTests.interests-result-policy:KEYS_VALUES}
|
||||
</prop>
|
||||
<prop key="gemfire.cache.server.host">localhost</prop>
|
||||
<prop key="gemfire.cache.server.port">
|
||||
${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTests.cache-server-port}
|
||||
</prop>
|
||||
<prop key="gemfire.cache.server.port">${spring.data.gemfire.cache.server.port}</prop>
|
||||
</util:properties>
|
||||
|
||||
<context:property-placeholder properties-ref="clientProperties"/>
|
||||
|
||||
@@ -13,14 +13,7 @@
|
||||
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd
|
||||
">
|
||||
|
||||
<util:properties id="serverProperties">
|
||||
<prop key="gemfire.cache.server.host">localhost</prop>
|
||||
<prop key="gemfire.cache.server.port">
|
||||
${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTests.cache-server-port}
|
||||
</prop>
|
||||
</util:properties>
|
||||
|
||||
<context:property-placeholder properties-ref="serverProperties"/>
|
||||
<context:property-placeholder/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">DurableClientCacheIntegrationTestServer</prop>
|
||||
@@ -29,7 +22,8 @@
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties"/>
|
||||
|
||||
<gfe:cache-server bind-address="${gemfire.cache.server.host}" port="${gemfire.cache.server.port}"/>
|
||||
<gfe:cache-server bind-address="${spring.data.gemfire.cache.server.host:localhost}"
|
||||
port="${spring.data.gemfire.cache.server.port}"/>
|
||||
|
||||
<gfe:replicated-region id="Example" persistent="false" initial-capacity="11" load-factor="0.75"
|
||||
key-constraint="java.lang.String" value-constraint="java.lang.Integer"/>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<util:properties id="client.properties">
|
||||
<prop key="client.server.host">localhost</prop>
|
||||
<prop key="client.server.port">42082</prop>
|
||||
<prop key="client.server.port">${CACHE_SERVER_PORT}</prop>
|
||||
</util:properties>
|
||||
|
||||
<context:property-placeholder properties-ref="client.properties"/>
|
||||
@@ -24,25 +24,26 @@
|
||||
|
||||
<context:property-placeholder properties-ref="clientProperties"/>
|
||||
|
||||
<bean class="org.springframework.data.gemfire.client.SpELExpressionConfiguredPoolsIntegrationTests.TestBeanFactoryPostProcessor"/>
|
||||
<bean class="org.springframework.data.gemfire.client.SpELExpressionConfiguredPoolsIntegrationTests.TestBeanPostProcessor"/>
|
||||
|
||||
<bean id="spelBean" class="org.springframework.data.gemfire.client.SpELExpressionConfiguredPoolsIntegrationTests.SpELBoundBean">
|
||||
<constructor-arg index="0" ref="clientProperties"/>
|
||||
</bean>
|
||||
|
||||
<gfe:pool id="locatorPool" locators="${gemfire.cache.client.locators.hosts-and-ports}">
|
||||
<gfe:pool id="locatorPoolOne" locators="${gemfire.cache.client.locators.hosts-and-ports}">
|
||||
<gfe:locator host="${gemfire.cache.client.locator.1.host}" port="${gemfire.cache.client.locator.1.port}"/>
|
||||
<gfe:locator host="mars" port="30303"/>
|
||||
</gfe:pool>
|
||||
|
||||
<gfe:pool id="serverPool" servers="mercury[1234],venus[9876],earth[4554],jupiter[],uranis[$Ox0+(!)*]">
|
||||
<gfe:pool id="locatorPoolTwo" locators="[10335], cardboardbox[], #{spelBean.locatorsHostsPorts()}"/>
|
||||
|
||||
<gfe:pool id="serverPoolOne" servers="mercury[1234],venus[9876],earth[4554],jupiter[],uranis[$Ox0+(!)*]">
|
||||
<gfe:server host="#{spelBean.serverTwoHost()}" port="#{spelBean.serverTwoPort()}"/>
|
||||
<gfe:server host="${gemfire.cache.client.server.1.host}" port="${gemfire.cache.client.server.1.port}"/>
|
||||
<gfe:server host="neptune" port="42424"/>
|
||||
</gfe:pool>
|
||||
|
||||
<gfe:pool id="anotherLocatorPool" locators="[10335], cardboardbox[], #{spelBean.locatorsHostsPorts()}"/>
|
||||
<gfe:pool id="serverPoolTwo" servers="${gemfire.cache.client.servers.hosts-and-ports}"/>
|
||||
|
||||
<gfe:pool id="anotherServerPool" servers="${gemfire.cache.client.servers.hosts-and-ports}"/>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<bean class="org.springframework.data.gemfire.config.support.LuceneIndexRegionBeanFactoryPostProcessorIntegrationTests.BeanProcessingOrderRecordingBeanPostProcessor"/>
|
||||
|
||||
<bean id="MockLuceneService" class="org.springframework.data.gemfire.test.mock.GemFireMockObjectsSupport"
|
||||
<bean id="MockLuceneService" class="org.springframework.data.gemfire.tests.mock.GemFireMockObjectsSupport"
|
||||
factory-method="mockLuceneService">
|
||||
<constructor-arg index="0" ref="gemfireCache"/>
|
||||
</bean>
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<bean class="org.springframework.data.gemfire.tests.mock.beans.factory.config.GemFireMockObjectsBeanPostProcessor"/>
|
||||
|
||||
<bean class="org.springframework.data.gemfire.config.xml.LuceneNamespaceUnitTests$LuceneNamespaceUnitTestsBeanFactoryPostProcessor"/>
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties"/>
|
||||
|
||||
Reference in New Issue
Block a user