SGF-734 - Upgrade to Pivotal GemFire 9.4.
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -22,7 +22,7 @@
|
||||
<antlr.version>2.7.7</antlr.version>
|
||||
<apache-shiro.version>1.3.2</apache-shiro.version>
|
||||
<cache-api.version>1.0.0</cache-api.version>
|
||||
<gemfire.version>9.3.0</gemfire.version>
|
||||
<gemfire.version>9.4.0</gemfire.version>
|
||||
<google-code-findbugs.version>2.0.2</google-code-findbugs.version>
|
||||
<multithreadedtc.version>1.01</multithreadedtc.version>
|
||||
<snappy.version>0.4</snappy.version>
|
||||
|
||||
@@ -205,6 +205,7 @@ public abstract class RegionLookupFactoryBean<K, V> extends AbstractFactoryBeanS
|
||||
}
|
||||
|
||||
/**
|
||||
>>>>>>> SGF-734 - Upgrade to Pivotal GemFire 9.4.
|
||||
* Returns a reference to the {@link GemFireCache} used to create the {@link Region}.
|
||||
*
|
||||
* @return a reference to the {@link GemFireCache} used to create the {@link Region}..
|
||||
|
||||
@@ -78,7 +78,6 @@ public abstract class PoolAdapter implements Pool {
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InetSocketAddress> getOnlineLocators() {
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
@@ -143,6 +142,10 @@ public abstract class PoolAdapter implements Pool {
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public int getSubscriptionTimeoutMultiplier() {
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public boolean getThreadLocalConnections() {
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
private int subscriptionAckInterval = PoolFactory.DEFAULT_SUBSCRIPTION_ACK_INTERVAL;
|
||||
private int subscriptionMessageTrackingTimeout = PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT;
|
||||
private int subscriptionRedundancy = PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY;
|
||||
private int subscriptionTimeoutMultiplier = PoolFactory.DEFAULT_SUBSCRIPTION_TIMEOUT_MULTIPLIER;
|
||||
|
||||
private long idleTimeout = PoolFactory.DEFAULT_IDLE_TIMEOUT;
|
||||
private long pingInterval = PoolFactory.DEFAULT_PING_INTERVAL;
|
||||
@@ -124,16 +125,18 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
* @see org.apache.geode.cache.client.PoolManager
|
||||
* @see org.apache.geode.cache.client.PoolFactory
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see #resolvePoolName()
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
init(Optional.ofNullable(find(resolvePoolName())));
|
||||
}
|
||||
|
||||
Pool existingPool = find(resolvePoolName());
|
||||
@SuppressWarnings("all")
|
||||
private void init(Optional<Pool> existingPool) {
|
||||
|
||||
if (existingPool != null) {
|
||||
if (existingPool.isPresent()) {
|
||||
|
||||
this.pool = existingPool;
|
||||
this.pool = existingPool.get();
|
||||
this.springManagedPool = false;
|
||||
|
||||
logDebug(() -> String.format("A Pool with name [%s] already exists; Using existing Pool",
|
||||
@@ -308,6 +311,7 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
it.setSubscriptionEnabled(this.subscriptionEnabled);
|
||||
it.setSubscriptionMessageTrackingTimeout(this.subscriptionMessageTrackingTimeout);
|
||||
it.setSubscriptionRedundancy(this.subscriptionRedundancy);
|
||||
it.setSubscriptionTimeoutMultiplier(this.subscriptionTimeoutMultiplier);
|
||||
it.setThreadLocalConnections(this.threadLocalConnections);
|
||||
|
||||
nullSafeCollection(this.locators).forEach(locator ->
|
||||
@@ -564,6 +568,11 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
return PoolFactoryBean.this.subscriptionRedundancy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSubscriptionTimeoutMultiplier() {
|
||||
return PoolFactoryBean.this.subscriptionTimeoutMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getThreadLocalConnections() {
|
||||
return PoolFactoryBean.this.threadLocalConnections;
|
||||
@@ -737,21 +746,19 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
this.subscriptionRedundancy = subscriptionRedundancy;
|
||||
}
|
||||
|
||||
public void setSubscriptionTimeoutMultiplier(int subscriptionTimeoutMultiplier) {
|
||||
this.subscriptionTimeoutMultiplier = subscriptionTimeoutMultiplier;
|
||||
}
|
||||
|
||||
public void setThreadLocalConnections(boolean threadLocalConnections) {
|
||||
this.threadLocalConnections = threadLocalConnections;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* internal framework use only
|
||||
*/
|
||||
// Internal framework use only.
|
||||
public final void setLocatorsConfiguration(Object locatorsConfiguration) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* internal framework use only
|
||||
*/
|
||||
// Internal framework use only.
|
||||
public final void setServersConfiguration(Object serversConfiguration) {
|
||||
}
|
||||
|
||||
@@ -771,5 +778,6 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
|
||||
* @see org.apache.geode.cache.client.PoolFactory
|
||||
*/
|
||||
PoolFactory initialize(PoolFactory poolFactory);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +196,11 @@ public abstract class DefaultableDelegatingPoolAdapter {
|
||||
return defaultIfNull(defaultSubscriptionRedundancy, () -> getDelegate().getSubscriptionRedundancy());
|
||||
}
|
||||
|
||||
public int getSubscriptionTimeoutMultiplier(Integer defaultSubscriptionTimeoutMultiplier) {
|
||||
return defaultIfNull(defaultSubscriptionTimeoutMultiplier,
|
||||
() -> getDelegate().getSubscriptionTimeoutMultiplier());
|
||||
}
|
||||
|
||||
public boolean getThreadLocalConnections(Boolean defaultThreadLocalConnections) {
|
||||
return defaultIfNull(defaultThreadLocalConnections, () -> getDelegate().getThreadLocalConnections());
|
||||
}
|
||||
@@ -204,7 +209,7 @@ public abstract class DefaultableDelegatingPoolAdapter {
|
||||
getDelegate().destroy();
|
||||
}
|
||||
|
||||
public void destroy(boolean keepAlive) {
|
||||
public void destroy(final boolean keepAlive) {
|
||||
getDelegate().destroy(keepAlive);
|
||||
}
|
||||
|
||||
@@ -218,4 +223,8 @@ public abstract class DefaultableDelegatingPoolAdapter {
|
||||
PREFER_POOL
|
||||
|
||||
}
|
||||
|
||||
interface ValueProvider<T> {
|
||||
T getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,6 +258,12 @@ public abstract class DelegatingPoolAdapter extends FactoryDefaultsPoolAdapter {
|
||||
.orElseGet(super::getSubscriptionRedundancy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSubscriptionTimeoutMultiplier() {
|
||||
return Optional.ofNullable(getDelegate()).map(Pool::getSubscriptionTimeoutMultiplier)
|
||||
.orElseGet(super::getSubscriptionTimeoutMultiplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getThreadLocalConnections() {
|
||||
|
||||
|
||||
@@ -161,6 +161,11 @@ public abstract class FactoryDefaultsPoolAdapter extends PoolAdapter {
|
||||
return PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSubscriptionTimeoutMultiplier() {
|
||||
return PoolFactory.DEFAULT_SUBSCRIPTION_TIMEOUT_MULTIPLIER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getThreadLocalConnections() {
|
||||
return PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS;
|
||||
|
||||
@@ -49,8 +49,8 @@ class LocalRegionParser extends AbstractRegionParser {
|
||||
|
||||
validateDataPolicyShortcutAttributesMutualExclusion(element, parserContext);
|
||||
|
||||
BeanDefinitionBuilder regionAttributesBuilder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
RegionAttributesFactoryBean.class);
|
||||
BeanDefinitionBuilder regionAttributesBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(RegionAttributesFactoryBean.class);
|
||||
|
||||
doParseRegionConfiguration(element, parserContext, builder, regionAttributesBuilder, subRegion);
|
||||
|
||||
|
||||
@@ -123,6 +123,7 @@ class PoolParser extends AbstractSingleBeanDefinitionParser {
|
||||
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-enabled");
|
||||
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-message-tracking-timeout");
|
||||
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-redundancy");
|
||||
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-timeout-multiplier");
|
||||
ParsingUtils.setPropertyValue(element, poolBuilder, "thread-local-connections");
|
||||
|
||||
List<Element> childElements = DomUtils.getChildElements(element);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.Assert;
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
abstract class AbstractFunctionExecution {
|
||||
|
||||
private final static String NO_RESULT_MESSAGE = "Cannot return any result as the Function#hasResult() is false";
|
||||
@@ -60,14 +61,13 @@ abstract class AbstractFunctionExecution {
|
||||
|
||||
public AbstractFunctionExecution(String functionId, Object... args) {
|
||||
|
||||
Assert.hasText(functionId, "FunctionId cannot be null or empty");
|
||||
Assert.hasText(functionId, "Function ID must not be null or empty");
|
||||
|
||||
this.functionId = functionId;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
AbstractFunctionExecution() {
|
||||
}
|
||||
AbstractFunctionExecution() { }
|
||||
|
||||
Object[] getArgs() {
|
||||
return this.args;
|
||||
|
||||
@@ -15,10 +15,16 @@ package org.springframework.data.gemfire.function.execution;
|
||||
|
||||
import org.apache.geode.cache.RegionService;
|
||||
import org.apache.geode.cache.client.Pool;
|
||||
import org.apache.geode.cache.execute.Execution;
|
||||
import org.apache.geode.cache.execute.Function;
|
||||
|
||||
/**
|
||||
* Creates an {@literal OnServer} {@link Function} {@link Execution} initialized with
|
||||
* either {@link RegionService cache} or {@link Pool}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.function.execution.AbstractFunctionTemplate
|
||||
*/
|
||||
public class GemfireOnServerFunctionTemplate extends AbstractFunctionTemplate {
|
||||
|
||||
@@ -37,7 +43,6 @@ public class GemfireOnServerFunctionTemplate extends AbstractFunctionTemplate {
|
||||
|
||||
@Override
|
||||
protected AbstractFunctionExecution getFunctionExecution() {
|
||||
return (pool != null ? new PoolServerFunctionExecution(this.pool) : new ServerFunctionExecution(this.cache));
|
||||
return pool != null ? new PoolServerFunctionExecution(this.pool) : new ServerFunctionExecution(this.cache);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,47 +20,58 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Creates a GemFire {@link Execution} using {code}FunctionService.onServer(Pool pool){code}
|
||||
* @author David Turanski
|
||||
* Creates an {@link Execution} from {@link FunctionService#onServer(Pool)}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
* @see org.springframework.data.gemfire.function.execution.AbstractFunctionExecution
|
||||
*/
|
||||
class PoolServerFunctionExecution extends AbstractFunctionExecution implements InitializingBean {
|
||||
|
||||
|
||||
private Pool pool;
|
||||
private String poolname;
|
||||
|
||||
private String poolName;
|
||||
|
||||
/**
|
||||
* @param pool the {@link Pool}
|
||||
* Constructs a new instance of {@link PoolServerFunctionExecution} initialized with the given {@link Pool}.
|
||||
*
|
||||
* @param pool {@link Pool} used to initialize the {@link Execution}.
|
||||
* @throws IllegalArgumentException if {@link Pool} is {@literal null}.
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
*/
|
||||
public PoolServerFunctionExecution(Pool pool) {
|
||||
super();
|
||||
Assert.notNull(pool, "pool cannot be null");
|
||||
|
||||
Assert.notNull(pool, "Pool must not be null");
|
||||
|
||||
this.pool = pool;
|
||||
}
|
||||
|
||||
public PoolServerFunctionExecution(String poolname) {
|
||||
super();
|
||||
Assert.notNull(poolname, "pool name cannot be null");
|
||||
this.poolname = poolname;
|
||||
/**
|
||||
* Constructs a new instance of {@link PoolServerFunctionExecution} initialized with
|
||||
* the given {@link String name} of the {@link Pool}.
|
||||
*
|
||||
* @param poolName {@link String} containing the name of the {@link Pool}
|
||||
* used to initialize the {@link Execution}.
|
||||
* @throws IllegalArgumentException if {@link String poolName} is {@literal null} or empty.
|
||||
*/
|
||||
public PoolServerFunctionExecution(String poolName) {
|
||||
|
||||
Assert.hasText(poolName, "Pool name must not be null or empty");
|
||||
|
||||
this.poolName = poolName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Execution getExecution() {
|
||||
return FunctionService.onServer(this.pool);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
this.pool = PoolManager.find(poolname);
|
||||
Assert.notNull(pool," pool " + poolname+ " does not exist");
|
||||
|
||||
this.pool = PoolManager.find(this.poolName);
|
||||
|
||||
Assert.notNull(this.pool,String.format("Pool [%s] not found", this.poolName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2666,6 +2666,7 @@ Comma-delimited list of Server endpoints used by this Pool in the form of: host1
|
||||
<xsd:attribute name="subscription-enabled" type="xsd:string" use="optional"/>
|
||||
<xsd:attribute name="subscription-message-tracking-timeout" type="xsd:string" use="optional"/>
|
||||
<xsd:attribute name="subscription-redundancy" type="xsd:string" use="optional"/>
|
||||
<xsd:attribute name="subscription-timeout-multiplier" type="xsd:string" use="optional"/>
|
||||
<xsd:attribute name="thread-local-connections" type="xsd:string" use="optional"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
@@ -57,13 +57,13 @@ import org.junit.Test;
|
||||
*/
|
||||
public class LookupRegionFactoryBeanTest {
|
||||
|
||||
protected AsyncEventQueue mockAsyncEventQueue(final String id) {
|
||||
private AsyncEventQueue mockAsyncEventQueue(final String id) {
|
||||
AsyncEventQueue mockQueue = mock(AsyncEventQueue.class, String.format("MockAsyncEventQueue.%1$s", id));
|
||||
when(mockQueue.getId()).thenReturn(id);
|
||||
return mockQueue;
|
||||
}
|
||||
|
||||
protected GatewaySender mockGatewaySender(final String id) {
|
||||
private GatewaySender mockGatewaySender(final String id) {
|
||||
GatewaySender mockGatewaySender = mock(GatewaySender.class, String.format("MockGatewaySender.%1$s", id));
|
||||
when(mockGatewaySender.getId()).thenReturn(id);
|
||||
return mockGatewaySender;
|
||||
@@ -72,6 +72,7 @@ public class LookupRegionFactoryBeanTest {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testAfterPropertiesSet() throws Exception {
|
||||
|
||||
Cache mockCache = mock(Cache.class, "testAfterPropertiesSet.MockCache");
|
||||
|
||||
Region<Object, Object> mockRegion = mock(Region.class, "testAfterPropertiesSet.MockRegion");
|
||||
@@ -163,24 +164,25 @@ public class LookupRegionFactoryBeanTest {
|
||||
@Test(expected = IllegalStateException.class)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testAfterPropertiesSetWhenRegionStatisticsDisabledAndExpirationSpecified() throws Exception {
|
||||
Cache mockCache = mock(Cache.class, "testAfterPropertiesSetWhenRegionStatisticsDisabledAndExpirationSpecified.MockCache");
|
||||
|
||||
Region<Object, Object> mockRegion = mock(Region.class, "testAfterPropertiesSetWhenRegionStatisticsDisabledAndExpirationSpecified.MockRegion");
|
||||
Cache mockCache = mock(Cache.class);
|
||||
|
||||
RegionAttributes<Object, Object> mockRegionAttributes = mock(RegionAttributes.class,
|
||||
"testAfterPropertiesSetWhenRegionStatisticsDisabledAndExpirationSpecified.MockRegionAttributes");
|
||||
Region<Object, Object> mockRegion = mock(Region.class);
|
||||
|
||||
AttributesMutator mockAttributesMutator = mock(AttributesMutator.class,
|
||||
"testAfterPropertiesSetWhenRegionStatisticsDisabledAndExpirationSpecified.MockAttributesMutator");
|
||||
RegionAttributes<Object, Object> mockRegionAttributes = mock(RegionAttributes.class);
|
||||
|
||||
ExpirationAttributes mockExpirationAttributesEntryTtl = mock(ExpirationAttributes.class,
|
||||
"testAfterPropertiesSetWhenRegionStatisticsDisabledAndExpirationSpecified.MockExpirationAttributes.Entry.TTL");
|
||||
AttributesMutator mockAttributesMutator = mock(AttributesMutator.class);
|
||||
|
||||
EvictionAttributesMutator mockEvictionAttributesMutator = mock(EvictionAttributesMutator.class);
|
||||
|
||||
ExpirationAttributes mockExpirationAttributesEntryTtl = mock(ExpirationAttributes.class);
|
||||
|
||||
when(mockCache.getRegion(eq("Example"))).thenReturn(mockRegion);
|
||||
when(mockRegion.getFullPath()).thenReturn("/Example");
|
||||
when(mockRegion.getName()).thenReturn("Example");
|
||||
when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes);
|
||||
when(mockRegion.getAttributesMutator()).thenReturn(mockAttributesMutator);
|
||||
when(mockAttributesMutator.getEvictionAttributesMutator()).thenReturn(mockEvictionAttributesMutator);
|
||||
when(mockRegionAttributes.getStatisticsEnabled()).thenReturn(false);
|
||||
|
||||
LookupRegionFactoryBean factoryBean = new LookupRegionFactoryBean();
|
||||
@@ -207,6 +209,7 @@ public class LookupRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testIsLookupEnabledAlways() {
|
||||
|
||||
LookupRegionFactoryBean factoryBean = new LookupRegionFactoryBean();
|
||||
|
||||
assertTrue(factoryBean.isLookupEnabled());
|
||||
@@ -215,5 +218,4 @@ public class LookupRegionFactoryBeanTest {
|
||||
|
||||
assertTrue(factoryBean.isLookupEnabled());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class LookupRegionMutationIntegrationTest {
|
||||
|
||||
private Collection<String> toStrings(Object[] objects) {
|
||||
|
||||
List<String> cacheListenerNames = new ArrayList<String>(objects.length);
|
||||
List<String> cacheListenerNames = new ArrayList<>(objects.length);
|
||||
|
||||
for (Object object : objects) {
|
||||
cacheListenerNames.add(object.toString());
|
||||
@@ -141,17 +141,25 @@ public class LookupRegionMutationIntegrationTest {
|
||||
return cacheListenerNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="https://issues.apache.org/jira/browse/GEODE-5039">EvictionAttributesMutator.setMaximum does not work</a>
|
||||
*/
|
||||
@Test
|
||||
public void testRegionConfiguration() {
|
||||
public void regionConfigurationIsCorrect() {
|
||||
|
||||
assertRegionAttributes(example, "Example", DataPolicy.REPLICATE);
|
||||
assertRegionAttributes(example, "Example", DataPolicy.NORMAL);
|
||||
assertEquals(13, example.getAttributes().getInitialCapacity());
|
||||
assertEquals(0.85f, example.getAttributes().getLoadFactor(), 0.0f);
|
||||
assertCacheListeners(example.getAttributes().getCacheListeners(), Arrays.asList("A", "B"));
|
||||
assertGemFireComponent(example.getAttributes().getCacheLoader(), "C");
|
||||
assertGemFireComponent(example.getAttributes().getCacheWriter(), "D");
|
||||
// TODO: re-instate the original assertion after Apache Geode fixes bug GEODE-5039!
|
||||
/*
|
||||
assertEvictionAttributes(example.getAttributes().getEvictionAttributes(), EvictionAction.OVERFLOW_TO_DISK,
|
||||
EvictionAlgorithm.LRU_ENTRY, 1000);
|
||||
*/
|
||||
assertEvictionAttributes(example.getAttributes().getEvictionAttributes(), EvictionAction.OVERFLOW_TO_DISK,
|
||||
EvictionAlgorithm.LRU_ENTRY, 500);
|
||||
assertExpirationAttributes(example.getAttributes().getRegionTimeToLive(), "Region TTL",
|
||||
120, ExpirationAction.LOCAL_DESTROY);
|
||||
assertExpirationAttributes(example.getAttributes().getRegionIdleTimeout(), "Region TTI",
|
||||
@@ -167,12 +175,12 @@ public class LookupRegionMutationIntegrationTest {
|
||||
assertEquals("AEQ", example.getAttributes().getAsyncEventQueueIds().iterator().next());
|
||||
}
|
||||
|
||||
protected interface Nameable extends BeanNameAware {
|
||||
interface Nameable extends BeanNameAware {
|
||||
String getName();
|
||||
void setName(String name);
|
||||
}
|
||||
|
||||
protected static abstract class AbstractNameable implements Nameable {
|
||||
static abstract class AbstractNameable implements Nameable {
|
||||
|
||||
private String name;
|
||||
|
||||
@@ -214,12 +222,12 @@ public class LookupRegionMutationIntegrationTest {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanName(final String name) {
|
||||
public void setBeanName(String name) {
|
||||
if (!StringUtils.hasText(this.name)) {
|
||||
setName(name);
|
||||
}
|
||||
|
||||
@@ -370,6 +370,7 @@ public class PoolFactoryBeanTest {
|
||||
poolFactoryBean.setSubscriptionEnabled(true);
|
||||
poolFactoryBean.setSubscriptionMessageTrackingTimeout(20000);
|
||||
poolFactoryBean.setSubscriptionRedundancy(2);
|
||||
poolFactoryBean.setSubscriptionTimeoutMultiplier(4);
|
||||
poolFactoryBean.setThreadLocalConnections(false);
|
||||
|
||||
Pool pool = poolFactoryBean.getPool();
|
||||
@@ -397,6 +398,7 @@ public class PoolFactoryBeanTest {
|
||||
assertThat(pool.getSubscriptionEnabled(), is(equalTo(true)));
|
||||
assertThat(pool.getSubscriptionMessageTrackingTimeout(), is(equalTo(20000)));
|
||||
assertThat(pool.getSubscriptionRedundancy(), is(equalTo(2)));
|
||||
assertThat(pool.getSubscriptionTimeoutMultiplier(), is(equalTo(4)));
|
||||
assertThat(pool.getThreadLocalConnections(), is(equalTo(false)));
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ import org.springframework.data.gemfire.GemfireUtils;
|
||||
* @see org.junit.rules.ExpectedException
|
||||
* @see org.mockito.Mock
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.mockito.runners.MockitoJUnitRunner
|
||||
* @see org.mockito.junit.MockitoJUnitRunner
|
||||
* @see org.springframework.data.gemfire.client.support.DefaultableDelegatingPoolAdapter
|
||||
* @since 1.8.0
|
||||
*/
|
||||
@@ -106,6 +106,7 @@ public class DefaultableDelegatingPoolAdapterTest {
|
||||
when(this.mockPool.getSubscriptionEnabled()).thenReturn(true);
|
||||
when(this.mockPool.getSubscriptionMessageTrackingTimeout()).thenReturn(20000);
|
||||
when(this.mockPool.getSubscriptionRedundancy()).thenReturn(2);
|
||||
when(this.mockPool.getSubscriptionTimeoutMultiplier()).thenReturn(3);
|
||||
when(this.mockPool.getThreadLocalConnections()).thenReturn(false);
|
||||
|
||||
setupPoolAdapter();
|
||||
@@ -337,6 +338,7 @@ public class DefaultableDelegatingPoolAdapterTest {
|
||||
assertThat(this.poolAdapter.getSubscriptionEnabled(false), is(equalTo(false)));
|
||||
assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(15000), is(equalTo(15000)));
|
||||
assertThat(this.poolAdapter.getSubscriptionRedundancy(1), is(equalTo(1)));
|
||||
assertThat(this.poolAdapter.getSubscriptionTimeoutMultiplier(1), is(equalTo(1)));
|
||||
assertThat(this.poolAdapter.getThreadLocalConnections(true), is(equalTo(true)));
|
||||
|
||||
verify(this.mockPool, times(1)).getName();
|
||||
@@ -376,7 +378,8 @@ public class DefaultableDelegatingPoolAdapterTest {
|
||||
assertThat(this.poolAdapter.getSubscriptionAckInterval(50), is(equalTo(50)));
|
||||
assertThat(this.poolAdapter.getSubscriptionEnabled(true), is(equalTo(true)));
|
||||
assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(null), is(equalTo(20000)));
|
||||
assertThat(this.poolAdapter.getSubscriptionRedundancy(null), is(equalTo(2)));
|
||||
assertThat(this.poolAdapter.getSubscriptionRedundancy(1), is(equalTo(1)));
|
||||
assertThat(this.poolAdapter.getSubscriptionTimeoutMultiplier(null), is(equalTo(3)));
|
||||
assertThat(this.poolAdapter.getThreadLocalConnections(null), is(equalTo(false)));
|
||||
|
||||
verify(this.mockPool, times(1)).getFreeConnectionTimeout();
|
||||
@@ -392,7 +395,7 @@ public class DefaultableDelegatingPoolAdapterTest {
|
||||
verify(this.mockPool, times(1)).getSocketConnectTimeout();
|
||||
verify(this.mockPool, times(1)).getStatisticInterval();
|
||||
verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout();
|
||||
verify(this.mockPool, times(1)).getSubscriptionRedundancy();
|
||||
verify(this.mockPool, times(1)).getSubscriptionTimeoutMultiplier();
|
||||
verify(this.mockPool, times(1)).getThreadLocalConnections();
|
||||
verifyNoMoreInteractions(this.mockPool);
|
||||
}
|
||||
@@ -429,6 +432,7 @@ public class DefaultableDelegatingPoolAdapterTest {
|
||||
assertThat(this.poolAdapter.getSubscriptionEnabled(null), is(equalTo(true)));
|
||||
assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(null), is(equalTo(20000)));
|
||||
assertThat(this.poolAdapter.getSubscriptionRedundancy(null), is(equalTo(2)));
|
||||
assertThat(this.poolAdapter.getSubscriptionTimeoutMultiplier(null), is(equalTo(3)));
|
||||
assertThat(this.poolAdapter.getThreadLocalConnections(null), is(equalTo(false)));
|
||||
|
||||
verify(this.mockPool, times(1)).getFreeConnectionTimeout();
|
||||
@@ -454,6 +458,7 @@ public class DefaultableDelegatingPoolAdapterTest {
|
||||
verify(this.mockPool, times(1)).getSubscriptionEnabled();
|
||||
verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout();
|
||||
verify(this.mockPool, times(1)).getSubscriptionRedundancy();
|
||||
verify(this.mockPool, times(1)).getSubscriptionTimeoutMultiplier();
|
||||
verify(this.mockPool, times(1)).getThreadLocalConnections();
|
||||
verifyNoMoreInteractions(this.mockPool);
|
||||
}
|
||||
@@ -489,6 +494,7 @@ public class DefaultableDelegatingPoolAdapterTest {
|
||||
assertThat(this.poolAdapter.getSubscriptionEnabled(false), is(equalTo(true)));
|
||||
assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(30000), is(equalTo(20000)));
|
||||
assertThat(this.poolAdapter.getSubscriptionRedundancy(1), is(equalTo(2)));
|
||||
assertThat(this.poolAdapter.getSubscriptionTimeoutMultiplier(2), is(equalTo(3)));
|
||||
assertThat(this.poolAdapter.getThreadLocalConnections(true), is(equalTo(false)));
|
||||
|
||||
verify(this.mockPool, times(1)).getFreeConnectionTimeout();
|
||||
@@ -514,6 +520,7 @@ public class DefaultableDelegatingPoolAdapterTest {
|
||||
verify(this.mockPool, times(1)).getSubscriptionEnabled();
|
||||
verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout();
|
||||
verify(this.mockPool, times(1)).getSubscriptionRedundancy();
|
||||
verify(this.mockPool, times(1)).getSubscriptionTimeoutMultiplier();
|
||||
verify(this.mockPool, times(1)).getThreadLocalConnections();
|
||||
verifyNoMoreInteractions(this.mockPool);
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ public class DelegatingPoolAdapterTest {
|
||||
when(this.mockPool.getSubscriptionEnabled()).thenReturn(true);
|
||||
when(this.mockPool.getSubscriptionMessageTrackingTimeout()).thenReturn(60000);
|
||||
when(this.mockPool.getSubscriptionRedundancy()).thenReturn(2);
|
||||
when(this.mockPool.getSubscriptionTimeoutMultiplier()).thenReturn(3);
|
||||
when(this.mockPool.getThreadLocalConnections()).thenReturn(false);
|
||||
}
|
||||
|
||||
@@ -143,6 +144,7 @@ public class DelegatingPoolAdapterTest {
|
||||
assertThat(pool.getSubscriptionEnabled(), is(equalTo(true)));
|
||||
assertThat(pool.getSubscriptionMessageTrackingTimeout(), is(equalTo(60000)));
|
||||
assertThat(pool.getSubscriptionRedundancy(), is(equalTo(2)));
|
||||
assertThat(pool.getSubscriptionTimeoutMultiplier(), is(equalTo(3)));
|
||||
assertThat(pool.getThreadLocalConnections(), is(equalTo(false)));
|
||||
|
||||
verify(this.mockPool, times(1)).isDestroyed();
|
||||
@@ -169,6 +171,7 @@ public class DelegatingPoolAdapterTest {
|
||||
verify(this.mockPool, times(1)).getSubscriptionEnabled();
|
||||
verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout();
|
||||
verify(this.mockPool, times(1)).getSubscriptionRedundancy();
|
||||
verify(this.mockPool, times(1)).getSubscriptionTimeoutMultiplier();
|
||||
verify(this.mockPool, times(1)).getThreadLocalConnections();
|
||||
}
|
||||
|
||||
@@ -214,6 +217,7 @@ public class DelegatingPoolAdapterTest {
|
||||
assertThat(pool.getSubscriptionEnabled(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_ENABLED)));
|
||||
assertThat(pool.getSubscriptionMessageTrackingTimeout(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT)));
|
||||
assertThat(pool.getSubscriptionRedundancy(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY)));
|
||||
assertThat(pool.getSubscriptionTimeoutMultiplier(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_TIMEOUT_MULTIPLIER)));
|
||||
assertThat(pool.getThreadLocalConnections(), is(equalTo(PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS)));
|
||||
|
||||
verifyZeroInteractions(this.mockPool);
|
||||
|
||||
@@ -78,6 +78,7 @@ public class FactoryDefaultsPoolAdapterTest {
|
||||
assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(),
|
||||
is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT)));
|
||||
assertThat(this.poolAdapter.getSubscriptionRedundancy(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY)));
|
||||
assertThat(this.poolAdapter.getSubscriptionTimeoutMultiplier(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_TIMEOUT_MULTIPLIER)));
|
||||
assertThat(this.poolAdapter.getThreadLocalConnections(), is(equalTo(PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS)));
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* The LocalRegionNamespaceTest class is a test suite of test cases testing the contract and functionality
|
||||
* of GemFire's Local Region support in SDG.
|
||||
* Unit tests for the Local Region Namespace.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
@@ -56,6 +55,7 @@ import org.springframework.util.ObjectUtils;
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(locations="local-ns.xml",
|
||||
initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class LocalRegionNamespaceTest {
|
||||
|
||||
@Autowired
|
||||
@@ -66,6 +66,8 @@ public class LocalRegionNamespaceTest {
|
||||
|
||||
assertTrue(applicationContext.containsBean("simple"));
|
||||
|
||||
assertTrue(applicationContext.containsBean("simple"));
|
||||
|
||||
Region<?, ?> simple = applicationContext.getBean("simple", Region.class);
|
||||
|
||||
assertNotNull("The 'simple' Region was not properly configured or initialized!", simple);
|
||||
|
||||
@@ -51,8 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* The PartitionRegionNamespaceTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the GemFire Partition Region support in SDG.
|
||||
* Unit tests for the Partitioned Region Namespace.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.data.gemfire.support.ConnectionEndpoint;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpointList;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link PoolParser} and {@link PoolFactoryBean}.
|
||||
@@ -46,7 +46,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @see org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(locations = "pool-ns.xml", initializers = GemfireTestApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class PoolNamespaceTest {
|
||||
@@ -55,7 +55,7 @@ public class PoolNamespaceTest {
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
protected void assertConnectionEndpoint(ConnectionEndpointList connectionEndpoints,
|
||||
String expectedHost, int expectedPort) {
|
||||
String expectedHost, int expectedPort) {
|
||||
|
||||
assertThat(connectionEndpoints).isNotNull();
|
||||
assertThat(connectionEndpoints.size()).isEqualTo(1);
|
||||
@@ -77,6 +77,7 @@ public class PoolNamespaceTest {
|
||||
|
||||
@Test
|
||||
public void gemfirePoolIsConfiguredProperly() throws Exception {
|
||||
|
||||
assertThat(applicationContext.containsBean("gemfirePool")).isTrue();
|
||||
assertThat(applicationContext.containsBean("gemfire-pool")).isTrue();
|
||||
|
||||
@@ -89,6 +90,7 @@ public class PoolNamespaceTest {
|
||||
|
||||
@Test
|
||||
public void simplePoolIsConfiguredProperly() throws Exception {
|
||||
|
||||
assertThat(applicationContext.containsBean("simple")).isTrue();
|
||||
|
||||
PoolFactoryBean poolFactoryBean = applicationContext.getBean("&simple", PoolFactoryBean.class);
|
||||
@@ -104,6 +106,7 @@ public class PoolNamespaceTest {
|
||||
|
||||
@Test
|
||||
public void locatorPoolIsConfiguredProperly() throws Exception {
|
||||
|
||||
assertThat(applicationContext.containsBean("locator")).isTrue();
|
||||
|
||||
PoolFactoryBean poolFactoryBean = applicationContext.getBean("&locator", PoolFactoryBean.class);
|
||||
@@ -125,6 +128,7 @@ public class PoolNamespaceTest {
|
||||
|
||||
@Test
|
||||
public void serverPoolIsConfiguredProperly() throws Exception {
|
||||
|
||||
assertThat(applicationContext.containsBean("server")).isTrue();
|
||||
|
||||
PoolFactoryBean poolFactoryBean = applicationContext.getBean("&server", PoolFactoryBean.class);
|
||||
@@ -149,6 +153,7 @@ public class PoolNamespaceTest {
|
||||
assertThat(pool.getSubscriptionEnabled()).isTrue();
|
||||
assertThat(pool.getSubscriptionMessageTrackingTimeout()).isEqualTo(30000);
|
||||
assertThat(pool.getSubscriptionRedundancy()).isEqualTo(2);
|
||||
assertThat(pool.getSubscriptionTimeoutMultiplier()).isEqualTo(3);
|
||||
assertThat(pool.getThreadLocalConnections()).isFalse();
|
||||
|
||||
ConnectionEndpointList servers = TestUtils.readField("servers", poolFactoryBean);
|
||||
@@ -164,6 +169,7 @@ public class PoolNamespaceTest {
|
||||
|
||||
@Test
|
||||
public void locatorsPoolIsConfiguredProperly() throws Exception {
|
||||
|
||||
assertThat(applicationContext.containsBean("locators")).isTrue();
|
||||
|
||||
PoolFactoryBean poolFactoryBean = applicationContext.getBean("&locators", PoolFactoryBean.class);
|
||||
@@ -183,6 +189,7 @@ public class PoolNamespaceTest {
|
||||
|
||||
@Test
|
||||
public void serversPoolIsConfiguredProperly() throws Exception {
|
||||
|
||||
assertThat(applicationContext.containsBean("servers")).isTrue();
|
||||
|
||||
PoolFactoryBean poolFactoryBean = applicationContext.getBean("&servers", PoolFactoryBean.class);
|
||||
|
||||
@@ -158,6 +158,7 @@ public class PoolParserUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("all")
|
||||
public void doParse() {
|
||||
|
||||
Element mockPoolElement = mock(Element.class, "testDoParse.MockPoolElement");
|
||||
@@ -186,6 +187,7 @@ public class PoolParserUnitTests {
|
||||
when(mockPoolElement.getAttribute(eq("subscription-enabled"))).thenReturn("true");
|
||||
when(mockPoolElement.getAttribute(eq("subscription-message-tracking-timeout"))).thenReturn("30000");
|
||||
when(mockPoolElement.getAttribute(eq("subscription-redundancy"))).thenReturn("2");
|
||||
when(mockPoolElement.getAttribute(eq("subscription-timeout-multiplier"))).thenReturn("3");
|
||||
when(mockPoolElement.getAttribute(eq("thread-local-connections"))).thenReturn("false");
|
||||
when(mockPoolElement.getAttribute(PoolParser.LOCATORS_ATTRIBUTE_NAME)).thenReturn(null);
|
||||
when(mockPoolElement.getAttribute(PoolParser.SERVERS_ATTRIBUTE_NAME)).thenReturn(null);
|
||||
@@ -232,6 +234,7 @@ public class PoolParserUnitTests {
|
||||
assertPropertyValue(poolDefinition, "subscriptionEnabled", "true");
|
||||
assertPropertyValue(poolDefinition, "subscriptionMessageTrackingTimeout", "30000");
|
||||
assertPropertyValue(poolDefinition, "subscriptionRedundancy", "2");
|
||||
assertPropertyValue(poolDefinition, "subscriptionTimeoutMultiplier", "3");
|
||||
assertPropertyValue(poolDefinition, "threadLocalConnections", "false");
|
||||
assertPropertyPresent(poolDefinition, "locators");
|
||||
assertPropertyPresent(poolDefinition, "servers");
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* The RegionEvictionAttributesNamespaceTest class is a test suite of test cases testing the use of
|
||||
@@ -44,7 +44,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @since 1.3.4
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(initializers = GemfireTestApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class RegionEvictionAttributesNamespaceTest {
|
||||
@@ -69,6 +69,7 @@ public class RegionEvictionAttributesNamespaceTest {
|
||||
|
||||
@Test
|
||||
public void testEntryCountRegionEvictionAttributes() {
|
||||
|
||||
assertNotNull(one);
|
||||
assertNotNull(one.getAttributes());
|
||||
assertEquals(DataPolicy.REPLICATE, one.getAttributes().getDataPolicy());
|
||||
@@ -88,8 +89,9 @@ public class RegionEvictionAttributesNamespaceTest {
|
||||
two.getAttributes().getEvictionAttributes().getMaximum());
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test
|
||||
public void testHeapPercentageRegionEvictionAttributes() {
|
||||
|
||||
assertNotNull(three);
|
||||
assertNotNull(three.getAttributes());
|
||||
assertEquals(DataPolicy.REPLICATE, three.getAttributes().getDataPolicy());
|
||||
@@ -103,18 +105,12 @@ public class RegionEvictionAttributesNamespaceTest {
|
||||
assertNotNull(four.getAttributes().getEvictionAttributes());
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, four.getAttributes().getEvictionAttributes().getAction());
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, three.getAttributes().getEvictionAttributes().getAlgorithm());
|
||||
|
||||
try {
|
||||
four.getAttributes().getEvictionAttributes().getMaximum();
|
||||
}
|
||||
catch (UnsupportedOperationException expected) {
|
||||
assertEquals("LRUHeap does not support a maximum", expected.getMessage());
|
||||
throw expected;
|
||||
}
|
||||
assertEquals(0, four.getAttributes().getEvictionAttributes().getMaximum());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMemorySizeRegionEvictionAttributes() {
|
||||
|
||||
assertNotNull(five);
|
||||
assertNotNull(five.getAttributes());
|
||||
assertEquals(DataPolicy.REPLICATE, five.getAttributes().getDataPolicy());
|
||||
@@ -130,8 +126,8 @@ public class RegionEvictionAttributesNamespaceTest {
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, six.getAttributes().getEvictionAttributes().getAction());
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, six.getAttributes().getEvictionAttributes().getAlgorithm());
|
||||
|
||||
int expectedMaximum = (Boolean.getBoolean("org.springframework.data.gemfire.test.GemfireTestRunner.nomock")
|
||||
? 512 : 256);
|
||||
int expectedMaximum =
|
||||
Boolean.getBoolean("org.springframework.data.gemfire.test.GemfireTestRunner.nomock") ? 512 : 256;
|
||||
|
||||
assertEquals(expectedMaximum, six.getAttributes().getEvictionAttributes().getMaximum());
|
||||
}
|
||||
|
||||
@@ -46,8 +46,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* The ReplicatedRegionNamespaceTest class is a test suite of test cases testing the contract and functionality
|
||||
* of GemFire Replicated Region support in SDG.
|
||||
* Unit tests for the Replicated Region Namespace.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
|
||||
@@ -56,7 +56,7 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.mockito.runners.MockitoJUnitRunner
|
||||
* @see org.mockito.junit.MockitoJUnitRunner
|
||||
* @see org.springframework.data.gemfire.function.execution.AbstractFunctionExecution
|
||||
* @see org.apache.geode.cache.execute.Execution
|
||||
* @since 1.7.0
|
||||
@@ -65,13 +65,11 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
public class AbstractFunctionExecutionTest {
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Mock
|
||||
private Execution mockExecution;
|
||||
|
||||
// TODO: add more tests!!!
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void executeWithResults() throws Exception {
|
||||
@@ -99,7 +97,7 @@ public class AbstractFunctionExecutionTest {
|
||||
.setArgs(args).setTimeout(500).execute();
|
||||
|
||||
assertThat(actualResults, is(notNullValue()));
|
||||
assertThat(actualResults, is(equalTo((Iterable<Object>) results)));
|
||||
assertThat(actualResults, is(equalTo(results)));
|
||||
|
||||
verify(mockExecution, times(1)).setArguments(eq(args));
|
||||
verify(mockExecution, never()).withCollector(any(ResultCollector.class));
|
||||
@@ -112,10 +110,13 @@ public class AbstractFunctionExecutionTest {
|
||||
|
||||
@Test
|
||||
public void executeAndExtractWithSingleResult() {
|
||||
final List<String> results = Collections.singletonList("test");
|
||||
|
||||
List<String> results = Collections.singletonList("test");
|
||||
|
||||
AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() {
|
||||
@Override protected Execution getExecution() {
|
||||
|
||||
@Override
|
||||
protected Execution getExecution() {
|
||||
return mockExecution;
|
||||
}
|
||||
|
||||
@@ -130,10 +131,13 @@ public class AbstractFunctionExecutionTest {
|
||||
|
||||
@Test
|
||||
public void executeAndExtractWithMultipleResults() {
|
||||
final List<String> results = Arrays.asList("one", "two", "three");
|
||||
|
||||
List<String> results = Arrays.asList("one", "two", "three");
|
||||
|
||||
AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() {
|
||||
@Override protected Execution getExecution() {
|
||||
|
||||
@Override
|
||||
protected Execution getExecution() {
|
||||
return mockExecution;
|
||||
}
|
||||
|
||||
@@ -148,8 +152,11 @@ public class AbstractFunctionExecutionTest {
|
||||
|
||||
@Test
|
||||
public void executeAndExtractWithNullResults() {
|
||||
|
||||
AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() {
|
||||
@Override protected Execution getExecution() {
|
||||
|
||||
@Override
|
||||
protected Execution getExecution() {
|
||||
return mockExecution;
|
||||
}
|
||||
|
||||
@@ -164,8 +171,11 @@ public class AbstractFunctionExecutionTest {
|
||||
|
||||
@Test
|
||||
public void executeAndExtractWithNoResults() {
|
||||
|
||||
AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() {
|
||||
@Override protected Execution getExecution() {
|
||||
|
||||
@Override
|
||||
protected Execution getExecution() {
|
||||
return mockExecution;
|
||||
}
|
||||
|
||||
@@ -194,11 +204,10 @@ public class AbstractFunctionExecutionTest {
|
||||
}
|
||||
};
|
||||
|
||||
expectedException.expect(FunctionException.class);
|
||||
expectedException.expectCause(isA(IllegalArgumentException.class));
|
||||
expectedException.expectMessage(containsString("Execution of Function with ID [TestFunction] failed"));
|
||||
exception.expect(FunctionException.class);
|
||||
exception.expectCause(isA(IllegalArgumentException.class));
|
||||
exception.expectMessage(containsString("Execution of Function with ID [TestFunction] failed"));
|
||||
|
||||
functionExecution.setFunctionId("TestFunction").executeAndExtract();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ public class FunctionExecutionIntegrationTests extends ClientServerIntegrationTe
|
||||
|
||||
@BeforeClass
|
||||
public static void startGemFireServer() throws Exception {
|
||||
|
||||
availablePort = findAvailablePort();
|
||||
|
||||
gemfireServer = run(FunctionCacheServerProcess.class,
|
||||
@@ -67,24 +68,35 @@ public class FunctionExecutionIntegrationTests extends ClientServerIntegrationTe
|
||||
|
||||
@Before
|
||||
public void setupGemFireClient() {
|
||||
gemfireCache = new ClientCacheFactory()
|
||||
.set("name", "FunctionExecutionIntegrationTests")
|
||||
.set("log-level", "warning")
|
||||
|
||||
this.gemfireCache = new ClientCacheFactory()
|
||||
.set("name", FunctionExecutionIntegrationTests.class.getSimpleName())
|
||||
.set("log-level", "error")
|
||||
.setPoolSubscriptionEnabled(true)
|
||||
.addPoolServer("localhost", availablePort)
|
||||
.create();
|
||||
|
||||
gemfirePool = PoolManager.find("DEFAULT");
|
||||
assertThat(this.gemfireCache).isNotNull();
|
||||
assertThat(this.gemfireCache.getName()).isEqualTo(FunctionExecutionIntegrationTests.class.getSimpleName());
|
||||
|
||||
gemfireRegion = gemfireCache.<String, String>createClientRegionFactory(ClientRegionShortcut.PROXY)
|
||||
this.gemfireRegion = this.gemfireCache.<String, String>createClientRegionFactory(ClientRegionShortcut.PROXY)
|
||||
.create("test-function");
|
||||
|
||||
assertThat(this.gemfireRegion).isNotNull();
|
||||
assertThat(this.gemfireRegion.getName()).isEqualTo("test-function");
|
||||
|
||||
this.gemfirePool = PoolManager.find("DEFAULT");
|
||||
|
||||
assertThat(this.gemfirePool).isNotNull();
|
||||
assertThat(this.gemfirePool.getName()).isEqualTo("DEFAULT");
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDownGemFireClient() {
|
||||
if (gemfireCache != null) {
|
||||
|
||||
if (this.gemfireCache != null) {
|
||||
try {
|
||||
gemfireCache.close();
|
||||
this.gemfireCache.close();
|
||||
}
|
||||
catch (CacheClosedException ignore) {
|
||||
}
|
||||
@@ -93,6 +105,7 @@ public class FunctionExecutionIntegrationTests extends ClientServerIntegrationTe
|
||||
|
||||
@Test
|
||||
public void basicFunctionExecutionsAreCorrect() {
|
||||
|
||||
verifyFunctionExecution(new PoolServerFunctionExecution(gemfirePool));
|
||||
verifyFunctionExecution(new RegionFunctionExecution(gemfireRegion));
|
||||
verifyFunctionExecution(new ServerFunctionExecution(gemfireCache));
|
||||
@@ -100,7 +113,9 @@ public class FunctionExecutionIntegrationTests extends ClientServerIntegrationTe
|
||||
}
|
||||
|
||||
private void verifyFunctionExecution(AbstractFunctionExecution functionExecution) {
|
||||
|
||||
Iterable<String> results = functionExecution.setArgs("1", "2", "3").setFunctionId("echoFunction").execute();
|
||||
|
||||
int count = 1;
|
||||
|
||||
for (String result : results) {
|
||||
|
||||
@@ -15,7 +15,6 @@ package org.springframework.data.gemfire.function.execution;
|
||||
|
||||
import static org.assertj.core.api.Java6Assertions.assertThat;
|
||||
|
||||
import org.apache.geode.cache.CacheClosedException;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.client.ClientCacheFactory;
|
||||
@@ -27,6 +26,7 @@ import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.fork.FunctionCacheServerProcess;
|
||||
import org.springframework.data.gemfire.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.test.support.ClientServerIntegrationTestsSupport;
|
||||
@@ -48,6 +48,7 @@ public class GemfireFunctionTemplateIntegrationTests extends ClientServerIntegra
|
||||
|
||||
@BeforeClass
|
||||
public static void startGemFireServer() throws Exception {
|
||||
|
||||
availablePort = findAvailablePort();
|
||||
|
||||
gemfireServer = run(FunctionCacheServerProcess.class,
|
||||
@@ -66,32 +67,37 @@ public class GemfireFunctionTemplateIntegrationTests extends ClientServerIntegra
|
||||
|
||||
@Before
|
||||
public void setupGemFireClient() {
|
||||
gemfireCache = new ClientCacheFactory()
|
||||
.set("name", "GemfireFunctionTemplateIntegrationTests")
|
||||
.set("log-level", "warning")
|
||||
|
||||
this.gemfireCache = new ClientCacheFactory()
|
||||
.set("name", GemfireFunctionTemplateIntegrationTests.class.getSimpleName())
|
||||
.set("log-level", "error")
|
||||
.setPoolSubscriptionEnabled(true)
|
||||
.addPoolServer("localhost", availablePort)
|
||||
.create();
|
||||
|
||||
gemfirePool = PoolManager.find("DEFAULT");
|
||||
assertThat(this.gemfireCache).isNotNull();
|
||||
assertThat(this.gemfireCache.getName()).isEqualTo(GemfireFunctionTemplateIntegrationTests.class.getSimpleName());
|
||||
|
||||
gemfireRegion = gemfireCache.<String, String>createClientRegionFactory(ClientRegionShortcut.PROXY)
|
||||
this.gemfireRegion = this.gemfireCache.<String, String>createClientRegionFactory(ClientRegionShortcut.PROXY)
|
||||
.create("test-function");
|
||||
|
||||
assertThat(this.gemfireRegion).isNotNull();
|
||||
assertThat(this.gemfireRegion.getName()).isEqualTo("test-function");
|
||||
|
||||
this.gemfirePool = PoolManager.find("DEFAULT");
|
||||
|
||||
assertThat(this.gemfirePool).isNotNull();
|
||||
assertThat(this.gemfirePool.getName()).isEqualTo("DEFAULT");
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDownGemFireClient() {
|
||||
if (gemfireCache != null) {
|
||||
try {
|
||||
gemfireCache.close();
|
||||
}
|
||||
catch (CacheClosedException ignore) {
|
||||
}
|
||||
}
|
||||
GemfireUtils.close(this.gemfireCache);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunctionTemplates() {
|
||||
|
||||
verifyFunctionTemplateExecution(new GemfireOnRegionFunctionTemplate(gemfireRegion));
|
||||
verifyFunctionTemplateExecution(new GemfireOnServerFunctionTemplate(gemfireCache));
|
||||
verifyFunctionTemplateExecution(new GemfireOnServerFunctionTemplate(gemfirePool));
|
||||
@@ -100,7 +106,9 @@ public class GemfireFunctionTemplateIntegrationTests extends ClientServerIntegra
|
||||
}
|
||||
|
||||
private void verifyFunctionTemplateExecution(GemfireFunctionOperations functionTemplate) {
|
||||
|
||||
Iterable<String> results = functionTemplate.execute("echoFunction", "1", "2", "3");
|
||||
|
||||
int count = 1;
|
||||
|
||||
for (String result : results) {
|
||||
|
||||
@@ -2056,9 +2056,9 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
return rememberMockedRegion(mockRegion);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("all")
|
||||
private static <K, V> RegionAttributes<K, V> mockRegionAttributes(Region<K, V> mockRegion,
|
||||
RegionAttributes<K, V> baseRegionAttributes) {
|
||||
RegionAttributes<K, V> baseRegionAttributes) {
|
||||
|
||||
AttributesMutator<K, V> mockAttributesMutator = mock(AttributesMutator.class);
|
||||
|
||||
@@ -2461,7 +2461,13 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
when(mockRegionFactory.setMulticastEnabled(anyBoolean()))
|
||||
.thenAnswer(newSetter(multicastEnabled, mockRegionFactory));
|
||||
|
||||
when(mockRegionFactory.setOffHeap(anyBoolean())).thenAnswer(newSetter(offHeap, mockRegionFactory));
|
||||
//when(mockRegionFactory.setOffHeap(anyBoolean())).thenAnswer(newSetter(offHeap, mockRegionFactory));
|
||||
|
||||
when(mockRegionFactory.setOffHeap(anyBoolean())).thenAnswer(invocation -> {
|
||||
Boolean value = invocation.getArgument(0);
|
||||
offHeap.set(value);
|
||||
return mockRegionFactory;
|
||||
});
|
||||
|
||||
when(mockRegionFactory.setPartitionAttributes(any(PartitionAttributes.class)))
|
||||
.thenAnswer(newSetter(partitionAttributes, mockRegionFactory));
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE cache PUBLIC "-//GemStone Systems, Inc.//GemFire Declarative Caching 8.0//EN"
|
||||
"http://www.gemstone.com/dtd/cache8_0.dtd">
|
||||
<cache>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<cache xmlns="http://geode.apache.org/schema/cache"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
|
||||
version="1.0">
|
||||
|
||||
<region name="Example">
|
||||
<region-attributes data-policy="replicate" cloning-enabled="false" initial-capacity="13" load-factor="0.85"
|
||||
<region-attributes data-policy="normal" cloning-enabled="false" initial-capacity="13" load-factor="0.85"
|
||||
statistics-enabled="true">
|
||||
<eviction-attributes>
|
||||
<lru-entry-count action="overflow-to-disk" maximum="500"/>
|
||||
</eviction-attributes>
|
||||
</region-attributes>
|
||||
</region>
|
||||
|
||||
</cache>
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">LocalNamespaceConfig</prop>
|
||||
<prop key="mcast-port">0</prop>
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
<prop key="off-heap-memory-size">64m</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
ping-interval="5000" pr-single-hop-enabled="false" read-timeout="500" retry-attempts="5"
|
||||
server-group="TestGroup" socket-buffer-size="65536" statistic-interval="250"
|
||||
subscription-ack-interval="250" subscription-enabled="true" subscription-message-tracking-timeout="30000"
|
||||
subscription-redundancy="2" thread-local-connections="false">
|
||||
subscription-redundancy="2" subscription-timeout-multiplier="3" thread-local-connections="false">
|
||||
<gfe:server host="localhost" port="${gfe.port.4}"/>
|
||||
<gfe:server host="localhost" port="50505"/>
|
||||
</gfe:pool>
|
||||
|
||||
Reference in New Issue
Block a user