SGF-734 - Upgrade to Pivotal GemFire 9.4.

This commit is contained in:
John Blum
2018-04-10 15:32:41 -07:00
parent 1113a1d0e4
commit cb74e3909d
32 changed files with 250 additions and 128 deletions

View File

@@ -22,7 +22,7 @@
<antlr.version>2.7.7</antlr.version> <antlr.version>2.7.7</antlr.version>
<apache-shiro.version>1.3.2</apache-shiro.version> <apache-shiro.version>1.3.2</apache-shiro.version>
<cache-api.version>1.0.0</cache-api.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> <google-code-findbugs.version>2.0.2</google-code-findbugs.version>
<multithreadedtc.version>1.01</multithreadedtc.version> <multithreadedtc.version>1.01</multithreadedtc.version>
<snappy.version>0.4</snappy.version> <snappy.version>0.4</snappy.version>

View File

@@ -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}. * 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}.. * @return a reference to the {@link GemFireCache} used to create the {@link Region}..

View File

@@ -78,7 +78,6 @@ public abstract class PoolAdapter implements Pool {
throw new UnsupportedOperationException(NOT_IMPLEMENTED); throw new UnsupportedOperationException(NOT_IMPLEMENTED);
} }
@Override
public List<InetSocketAddress> getOnlineLocators() { public List<InetSocketAddress> getOnlineLocators() {
throw new UnsupportedOperationException(NOT_IMPLEMENTED); throw new UnsupportedOperationException(NOT_IMPLEMENTED);
} }
@@ -143,6 +142,10 @@ public abstract class PoolAdapter implements Pool {
throw new UnsupportedOperationException(NOT_IMPLEMENTED); throw new UnsupportedOperationException(NOT_IMPLEMENTED);
} }
public int getSubscriptionTimeoutMultiplier() {
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
}
public boolean getThreadLocalConnections() { public boolean getThreadLocalConnections() {
throw new UnsupportedOperationException(NOT_IMPLEMENTED); throw new UnsupportedOperationException(NOT_IMPLEMENTED);
} }

View File

@@ -98,6 +98,7 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
private int subscriptionAckInterval = PoolFactory.DEFAULT_SUBSCRIPTION_ACK_INTERVAL; private int subscriptionAckInterval = PoolFactory.DEFAULT_SUBSCRIPTION_ACK_INTERVAL;
private int subscriptionMessageTrackingTimeout = PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT; private int subscriptionMessageTrackingTimeout = PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT;
private int subscriptionRedundancy = PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY; private int subscriptionRedundancy = PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY;
private int subscriptionTimeoutMultiplier = PoolFactory.DEFAULT_SUBSCRIPTION_TIMEOUT_MULTIPLIER;
private long idleTimeout = PoolFactory.DEFAULT_IDLE_TIMEOUT; private long idleTimeout = PoolFactory.DEFAULT_IDLE_TIMEOUT;
private long pingInterval = PoolFactory.DEFAULT_PING_INTERVAL; 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.PoolManager
* @see org.apache.geode.cache.client.PoolFactory * @see org.apache.geode.cache.client.PoolFactory
* @see org.apache.geode.cache.client.Pool * @see org.apache.geode.cache.client.Pool
* @see #resolvePoolName()
*/ */
@Override @Override
public void afterPropertiesSet() throws Exception { 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; this.springManagedPool = false;
logDebug(() -> String.format("A Pool with name [%s] already exists; Using existing Pool", 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.setSubscriptionEnabled(this.subscriptionEnabled);
it.setSubscriptionMessageTrackingTimeout(this.subscriptionMessageTrackingTimeout); it.setSubscriptionMessageTrackingTimeout(this.subscriptionMessageTrackingTimeout);
it.setSubscriptionRedundancy(this.subscriptionRedundancy); it.setSubscriptionRedundancy(this.subscriptionRedundancy);
it.setSubscriptionTimeoutMultiplier(this.subscriptionTimeoutMultiplier);
it.setThreadLocalConnections(this.threadLocalConnections); it.setThreadLocalConnections(this.threadLocalConnections);
nullSafeCollection(this.locators).forEach(locator -> nullSafeCollection(this.locators).forEach(locator ->
@@ -564,6 +568,11 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
return PoolFactoryBean.this.subscriptionRedundancy; return PoolFactoryBean.this.subscriptionRedundancy;
} }
@Override
public int getSubscriptionTimeoutMultiplier() {
return PoolFactoryBean.this.subscriptionTimeoutMultiplier;
}
@Override @Override
public boolean getThreadLocalConnections() { public boolean getThreadLocalConnections() {
return PoolFactoryBean.this.threadLocalConnections; return PoolFactoryBean.this.threadLocalConnections;
@@ -737,21 +746,19 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
this.subscriptionRedundancy = subscriptionRedundancy; this.subscriptionRedundancy = subscriptionRedundancy;
} }
public void setSubscriptionTimeoutMultiplier(int subscriptionTimeoutMultiplier) {
this.subscriptionTimeoutMultiplier = subscriptionTimeoutMultiplier;
}
public void setThreadLocalConnections(boolean threadLocalConnections) { public void setThreadLocalConnections(boolean threadLocalConnections) {
this.threadLocalConnections = threadLocalConnections; this.threadLocalConnections = threadLocalConnections;
} }
/* // Internal framework use only.
* (non-Javadoc)
* internal framework use only
*/
public final void setLocatorsConfiguration(Object locatorsConfiguration) { public final void setLocatorsConfiguration(Object locatorsConfiguration) {
} }
/* // Internal framework use only.
* (non-Javadoc)
* internal framework use only
*/
public final void setServersConfiguration(Object serversConfiguration) { public final void setServersConfiguration(Object serversConfiguration) {
} }
@@ -771,5 +778,6 @@ public class PoolFactoryBean extends AbstractFactoryBeanSupport<Pool> implements
* @see org.apache.geode.cache.client.PoolFactory * @see org.apache.geode.cache.client.PoolFactory
*/ */
PoolFactory initialize(PoolFactory poolFactory); PoolFactory initialize(PoolFactory poolFactory);
} }
} }

View File

@@ -196,6 +196,11 @@ public abstract class DefaultableDelegatingPoolAdapter {
return defaultIfNull(defaultSubscriptionRedundancy, () -> getDelegate().getSubscriptionRedundancy()); return defaultIfNull(defaultSubscriptionRedundancy, () -> getDelegate().getSubscriptionRedundancy());
} }
public int getSubscriptionTimeoutMultiplier(Integer defaultSubscriptionTimeoutMultiplier) {
return defaultIfNull(defaultSubscriptionTimeoutMultiplier,
() -> getDelegate().getSubscriptionTimeoutMultiplier());
}
public boolean getThreadLocalConnections(Boolean defaultThreadLocalConnections) { public boolean getThreadLocalConnections(Boolean defaultThreadLocalConnections) {
return defaultIfNull(defaultThreadLocalConnections, () -> getDelegate().getThreadLocalConnections()); return defaultIfNull(defaultThreadLocalConnections, () -> getDelegate().getThreadLocalConnections());
} }
@@ -204,7 +209,7 @@ public abstract class DefaultableDelegatingPoolAdapter {
getDelegate().destroy(); getDelegate().destroy();
} }
public void destroy(boolean keepAlive) { public void destroy(final boolean keepAlive) {
getDelegate().destroy(keepAlive); getDelegate().destroy(keepAlive);
} }
@@ -218,4 +223,8 @@ public abstract class DefaultableDelegatingPoolAdapter {
PREFER_POOL PREFER_POOL
} }
interface ValueProvider<T> {
T getValue();
}
} }

View File

@@ -258,6 +258,12 @@ public abstract class DelegatingPoolAdapter extends FactoryDefaultsPoolAdapter {
.orElseGet(super::getSubscriptionRedundancy); .orElseGet(super::getSubscriptionRedundancy);
} }
@Override
public int getSubscriptionTimeoutMultiplier() {
return Optional.ofNullable(getDelegate()).map(Pool::getSubscriptionTimeoutMultiplier)
.orElseGet(super::getSubscriptionTimeoutMultiplier);
}
@Override @Override
public boolean getThreadLocalConnections() { public boolean getThreadLocalConnections() {

View File

@@ -161,6 +161,11 @@ public abstract class FactoryDefaultsPoolAdapter extends PoolAdapter {
return PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY; return PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY;
} }
@Override
public int getSubscriptionTimeoutMultiplier() {
return PoolFactory.DEFAULT_SUBSCRIPTION_TIMEOUT_MULTIPLIER;
}
@Override @Override
public boolean getThreadLocalConnections() { public boolean getThreadLocalConnections() {
return PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS; return PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS;

View File

@@ -49,8 +49,8 @@ class LocalRegionParser extends AbstractRegionParser {
validateDataPolicyShortcutAttributesMutualExclusion(element, parserContext); validateDataPolicyShortcutAttributesMutualExclusion(element, parserContext);
BeanDefinitionBuilder regionAttributesBuilder = BeanDefinitionBuilder.genericBeanDefinition( BeanDefinitionBuilder regionAttributesBuilder =
RegionAttributesFactoryBean.class); BeanDefinitionBuilder.genericBeanDefinition(RegionAttributesFactoryBean.class);
doParseRegionConfiguration(element, parserContext, builder, regionAttributesBuilder, subRegion); doParseRegionConfiguration(element, parserContext, builder, regionAttributesBuilder, subRegion);

View File

@@ -123,6 +123,7 @@ class PoolParser extends AbstractSingleBeanDefinitionParser {
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-enabled"); ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-enabled");
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-message-tracking-timeout"); ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-message-tracking-timeout");
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-redundancy"); ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-redundancy");
ParsingUtils.setPropertyValue(element, poolBuilder, "subscription-timeout-multiplier");
ParsingUtils.setPropertyValue(element, poolBuilder, "thread-local-connections"); ParsingUtils.setPropertyValue(element, poolBuilder, "thread-local-connections");
List<Element> childElements = DomUtils.getChildElements(element); List<Element> childElements = DomUtils.getChildElements(element);

View File

@@ -33,6 +33,7 @@ import org.springframework.util.Assert;
* @author David Turanski * @author David Turanski
* @author John Blum * @author John Blum
*/ */
@SuppressWarnings("unused")
abstract class AbstractFunctionExecution { abstract class AbstractFunctionExecution {
private final static String NO_RESULT_MESSAGE = "Cannot return any result as the Function#hasResult() is false"; 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) { 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.functionId = functionId;
this.args = args; this.args = args;
} }
AbstractFunctionExecution() { AbstractFunctionExecution() { }
}
Object[] getArgs() { Object[] getArgs() {
return this.args; return this.args;

View File

@@ -15,10 +15,16 @@ package org.springframework.data.gemfire.function.execution;
import org.apache.geode.cache.RegionService; import org.apache.geode.cache.RegionService;
import org.apache.geode.cache.client.Pool; 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 David Turanski
* @author John Blum * @author John Blum
* @see org.springframework.data.gemfire.function.execution.AbstractFunctionTemplate
*/ */
public class GemfireOnServerFunctionTemplate extends AbstractFunctionTemplate { public class GemfireOnServerFunctionTemplate extends AbstractFunctionTemplate {
@@ -37,7 +43,6 @@ public class GemfireOnServerFunctionTemplate extends AbstractFunctionTemplate {
@Override @Override
protected AbstractFunctionExecution getFunctionExecution() { 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);
} }
} }

View File

@@ -20,47 +20,58 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
* Creates a GemFire {@link Execution} using {code}FunctionService.onServer(Pool pool){code} * Creates an {@link Execution} from {@link FunctionService#onServer(Pool)}.
* @author David Turanski
* *
* @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 { class PoolServerFunctionExecution extends AbstractFunctionExecution implements InitializingBean {
private Pool pool; 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) { public PoolServerFunctionExecution(Pool pool) {
super();
Assert.notNull(pool, "pool cannot be null"); Assert.notNull(pool, "Pool must not be null");
this.pool = pool; this.pool = pool;
} }
public PoolServerFunctionExecution(String poolname) { /**
super(); * Constructs a new instance of {@link PoolServerFunctionExecution} initialized with
Assert.notNull(poolname, "pool name cannot be null"); * the given {@link String name} of the {@link Pool}.
this.poolname = poolname; *
* @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 @Override
protected Execution getExecution() { protected Execution getExecution() {
return FunctionService.onServer(this.pool); return FunctionService.onServer(this.pool);
} }
/* (non-Javadoc)
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override @Override
public void afterPropertiesSet() throws Exception { 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));
} }
} }

View File

@@ -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-enabled" type="xsd:string" use="optional"/>
<xsd:attribute name="subscription-message-tracking-timeout" 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-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:attribute name="thread-local-connections" type="xsd:string" use="optional"/>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>

View File

@@ -57,13 +57,13 @@ import org.junit.Test;
*/ */
public class LookupRegionFactoryBeanTest { 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)); AsyncEventQueue mockQueue = mock(AsyncEventQueue.class, String.format("MockAsyncEventQueue.%1$s", id));
when(mockQueue.getId()).thenReturn(id); when(mockQueue.getId()).thenReturn(id);
return mockQueue; 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)); GatewaySender mockGatewaySender = mock(GatewaySender.class, String.format("MockGatewaySender.%1$s", id));
when(mockGatewaySender.getId()).thenReturn(id); when(mockGatewaySender.getId()).thenReturn(id);
return mockGatewaySender; return mockGatewaySender;
@@ -72,6 +72,7 @@ public class LookupRegionFactoryBeanTest {
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testAfterPropertiesSet() throws Exception { public void testAfterPropertiesSet() throws Exception {
Cache mockCache = mock(Cache.class, "testAfterPropertiesSet.MockCache"); Cache mockCache = mock(Cache.class, "testAfterPropertiesSet.MockCache");
Region<Object, Object> mockRegion = mock(Region.class, "testAfterPropertiesSet.MockRegion"); Region<Object, Object> mockRegion = mock(Region.class, "testAfterPropertiesSet.MockRegion");
@@ -163,24 +164,25 @@ public class LookupRegionFactoryBeanTest {
@Test(expected = IllegalStateException.class) @Test(expected = IllegalStateException.class)
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testAfterPropertiesSetWhenRegionStatisticsDisabledAndExpirationSpecified() throws Exception { 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, Region<Object, Object> mockRegion = mock(Region.class);
"testAfterPropertiesSetWhenRegionStatisticsDisabledAndExpirationSpecified.MockRegionAttributes");
AttributesMutator mockAttributesMutator = mock(AttributesMutator.class, RegionAttributes<Object, Object> mockRegionAttributes = mock(RegionAttributes.class);
"testAfterPropertiesSetWhenRegionStatisticsDisabledAndExpirationSpecified.MockAttributesMutator");
ExpirationAttributes mockExpirationAttributesEntryTtl = mock(ExpirationAttributes.class, AttributesMutator mockAttributesMutator = mock(AttributesMutator.class);
"testAfterPropertiesSetWhenRegionStatisticsDisabledAndExpirationSpecified.MockExpirationAttributes.Entry.TTL");
EvictionAttributesMutator mockEvictionAttributesMutator = mock(EvictionAttributesMutator.class);
ExpirationAttributes mockExpirationAttributesEntryTtl = mock(ExpirationAttributes.class);
when(mockCache.getRegion(eq("Example"))).thenReturn(mockRegion); when(mockCache.getRegion(eq("Example"))).thenReturn(mockRegion);
when(mockRegion.getFullPath()).thenReturn("/Example"); when(mockRegion.getFullPath()).thenReturn("/Example");
when(mockRegion.getName()).thenReturn("Example"); when(mockRegion.getName()).thenReturn("Example");
when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes);
when(mockRegion.getAttributesMutator()).thenReturn(mockAttributesMutator); when(mockRegion.getAttributesMutator()).thenReturn(mockAttributesMutator);
when(mockAttributesMutator.getEvictionAttributesMutator()).thenReturn(mockEvictionAttributesMutator);
when(mockRegionAttributes.getStatisticsEnabled()).thenReturn(false); when(mockRegionAttributes.getStatisticsEnabled()).thenReturn(false);
LookupRegionFactoryBean factoryBean = new LookupRegionFactoryBean(); LookupRegionFactoryBean factoryBean = new LookupRegionFactoryBean();
@@ -207,6 +209,7 @@ public class LookupRegionFactoryBeanTest {
@Test @Test
public void testIsLookupEnabledAlways() { public void testIsLookupEnabledAlways() {
LookupRegionFactoryBean factoryBean = new LookupRegionFactoryBean(); LookupRegionFactoryBean factoryBean = new LookupRegionFactoryBean();
assertTrue(factoryBean.isLookupEnabled()); assertTrue(factoryBean.isLookupEnabled());
@@ -215,5 +218,4 @@ public class LookupRegionFactoryBeanTest {
assertTrue(factoryBean.isLookupEnabled()); assertTrue(factoryBean.isLookupEnabled());
} }
} }

View File

@@ -132,7 +132,7 @@ public class LookupRegionMutationIntegrationTest {
private Collection<String> toStrings(Object[] objects) { 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) { for (Object object : objects) {
cacheListenerNames.add(object.toString()); cacheListenerNames.add(object.toString());
@@ -141,17 +141,25 @@ public class LookupRegionMutationIntegrationTest {
return cacheListenerNames; return cacheListenerNames;
} }
/**
* @see <a href="https://issues.apache.org/jira/browse/GEODE-5039">EvictionAttributesMutator.setMaximum does not work</a>
*/
@Test @Test
public void testRegionConfiguration() { public void regionConfigurationIsCorrect() {
assertRegionAttributes(example, "Example", DataPolicy.REPLICATE); assertRegionAttributes(example, "Example", DataPolicy.NORMAL);
assertEquals(13, example.getAttributes().getInitialCapacity()); assertEquals(13, example.getAttributes().getInitialCapacity());
assertEquals(0.85f, example.getAttributes().getLoadFactor(), 0.0f); assertEquals(0.85f, example.getAttributes().getLoadFactor(), 0.0f);
assertCacheListeners(example.getAttributes().getCacheListeners(), Arrays.asList("A", "B")); assertCacheListeners(example.getAttributes().getCacheListeners(), Arrays.asList("A", "B"));
assertGemFireComponent(example.getAttributes().getCacheLoader(), "C"); assertGemFireComponent(example.getAttributes().getCacheLoader(), "C");
assertGemFireComponent(example.getAttributes().getCacheWriter(), "D"); 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, assertEvictionAttributes(example.getAttributes().getEvictionAttributes(), EvictionAction.OVERFLOW_TO_DISK,
EvictionAlgorithm.LRU_ENTRY, 1000); EvictionAlgorithm.LRU_ENTRY, 1000);
*/
assertEvictionAttributes(example.getAttributes().getEvictionAttributes(), EvictionAction.OVERFLOW_TO_DISK,
EvictionAlgorithm.LRU_ENTRY, 500);
assertExpirationAttributes(example.getAttributes().getRegionTimeToLive(), "Region TTL", assertExpirationAttributes(example.getAttributes().getRegionTimeToLive(), "Region TTL",
120, ExpirationAction.LOCAL_DESTROY); 120, ExpirationAction.LOCAL_DESTROY);
assertExpirationAttributes(example.getAttributes().getRegionIdleTimeout(), "Region TTI", assertExpirationAttributes(example.getAttributes().getRegionIdleTimeout(), "Region TTI",
@@ -167,12 +175,12 @@ public class LookupRegionMutationIntegrationTest {
assertEquals("AEQ", example.getAttributes().getAsyncEventQueueIds().iterator().next()); assertEquals("AEQ", example.getAttributes().getAsyncEventQueueIds().iterator().next());
} }
protected interface Nameable extends BeanNameAware { interface Nameable extends BeanNameAware {
String getName(); String getName();
void setName(String name); void setName(String name);
} }
protected static abstract class AbstractNameable implements Nameable { static abstract class AbstractNameable implements Nameable {
private String name; private String name;
@@ -214,12 +222,12 @@ public class LookupRegionMutationIntegrationTest {
return name; return name;
} }
public void setName(final String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
@Override @Override
public void setBeanName(final String name) { public void setBeanName(String name) {
if (!StringUtils.hasText(this.name)) { if (!StringUtils.hasText(this.name)) {
setName(name); setName(name);
} }

View File

@@ -370,6 +370,7 @@ public class PoolFactoryBeanTest {
poolFactoryBean.setSubscriptionEnabled(true); poolFactoryBean.setSubscriptionEnabled(true);
poolFactoryBean.setSubscriptionMessageTrackingTimeout(20000); poolFactoryBean.setSubscriptionMessageTrackingTimeout(20000);
poolFactoryBean.setSubscriptionRedundancy(2); poolFactoryBean.setSubscriptionRedundancy(2);
poolFactoryBean.setSubscriptionTimeoutMultiplier(4);
poolFactoryBean.setThreadLocalConnections(false); poolFactoryBean.setThreadLocalConnections(false);
Pool pool = poolFactoryBean.getPool(); Pool pool = poolFactoryBean.getPool();
@@ -397,6 +398,7 @@ public class PoolFactoryBeanTest {
assertThat(pool.getSubscriptionEnabled(), is(equalTo(true))); assertThat(pool.getSubscriptionEnabled(), is(equalTo(true)));
assertThat(pool.getSubscriptionMessageTrackingTimeout(), is(equalTo(20000))); assertThat(pool.getSubscriptionMessageTrackingTimeout(), is(equalTo(20000)));
assertThat(pool.getSubscriptionRedundancy(), is(equalTo(2))); assertThat(pool.getSubscriptionRedundancy(), is(equalTo(2)));
assertThat(pool.getSubscriptionTimeoutMultiplier(), is(equalTo(4)));
assertThat(pool.getThreadLocalConnections(), is(equalTo(false))); assertThat(pool.getThreadLocalConnections(), is(equalTo(false)));
} }

View File

@@ -54,7 +54,7 @@ import org.springframework.data.gemfire.GemfireUtils;
* @see org.junit.rules.ExpectedException * @see org.junit.rules.ExpectedException
* @see org.mockito.Mock * @see org.mockito.Mock
* @see org.mockito.Mockito * @see org.mockito.Mockito
* @see org.mockito.runners.MockitoJUnitRunner * @see org.mockito.junit.MockitoJUnitRunner
* @see org.springframework.data.gemfire.client.support.DefaultableDelegatingPoolAdapter * @see org.springframework.data.gemfire.client.support.DefaultableDelegatingPoolAdapter
* @since 1.8.0 * @since 1.8.0
*/ */
@@ -106,6 +106,7 @@ public class DefaultableDelegatingPoolAdapterTest {
when(this.mockPool.getSubscriptionEnabled()).thenReturn(true); when(this.mockPool.getSubscriptionEnabled()).thenReturn(true);
when(this.mockPool.getSubscriptionMessageTrackingTimeout()).thenReturn(20000); when(this.mockPool.getSubscriptionMessageTrackingTimeout()).thenReturn(20000);
when(this.mockPool.getSubscriptionRedundancy()).thenReturn(2); when(this.mockPool.getSubscriptionRedundancy()).thenReturn(2);
when(this.mockPool.getSubscriptionTimeoutMultiplier()).thenReturn(3);
when(this.mockPool.getThreadLocalConnections()).thenReturn(false); when(this.mockPool.getThreadLocalConnections()).thenReturn(false);
setupPoolAdapter(); setupPoolAdapter();
@@ -337,6 +338,7 @@ public class DefaultableDelegatingPoolAdapterTest {
assertThat(this.poolAdapter.getSubscriptionEnabled(false), is(equalTo(false))); assertThat(this.poolAdapter.getSubscriptionEnabled(false), is(equalTo(false)));
assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(15000), is(equalTo(15000))); assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(15000), is(equalTo(15000)));
assertThat(this.poolAdapter.getSubscriptionRedundancy(1), is(equalTo(1))); assertThat(this.poolAdapter.getSubscriptionRedundancy(1), is(equalTo(1)));
assertThat(this.poolAdapter.getSubscriptionTimeoutMultiplier(1), is(equalTo(1)));
assertThat(this.poolAdapter.getThreadLocalConnections(true), is(equalTo(true))); assertThat(this.poolAdapter.getThreadLocalConnections(true), is(equalTo(true)));
verify(this.mockPool, times(1)).getName(); verify(this.mockPool, times(1)).getName();
@@ -376,7 +378,8 @@ public class DefaultableDelegatingPoolAdapterTest {
assertThat(this.poolAdapter.getSubscriptionAckInterval(50), is(equalTo(50))); assertThat(this.poolAdapter.getSubscriptionAckInterval(50), is(equalTo(50)));
assertThat(this.poolAdapter.getSubscriptionEnabled(true), is(equalTo(true))); assertThat(this.poolAdapter.getSubscriptionEnabled(true), is(equalTo(true)));
assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(null), is(equalTo(20000))); 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))); assertThat(this.poolAdapter.getThreadLocalConnections(null), is(equalTo(false)));
verify(this.mockPool, times(1)).getFreeConnectionTimeout(); verify(this.mockPool, times(1)).getFreeConnectionTimeout();
@@ -392,7 +395,7 @@ public class DefaultableDelegatingPoolAdapterTest {
verify(this.mockPool, times(1)).getSocketConnectTimeout(); verify(this.mockPool, times(1)).getSocketConnectTimeout();
verify(this.mockPool, times(1)).getStatisticInterval(); verify(this.mockPool, times(1)).getStatisticInterval();
verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout(); verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout();
verify(this.mockPool, times(1)).getSubscriptionRedundancy(); verify(this.mockPool, times(1)).getSubscriptionTimeoutMultiplier();
verify(this.mockPool, times(1)).getThreadLocalConnections(); verify(this.mockPool, times(1)).getThreadLocalConnections();
verifyNoMoreInteractions(this.mockPool); verifyNoMoreInteractions(this.mockPool);
} }
@@ -429,6 +432,7 @@ public class DefaultableDelegatingPoolAdapterTest {
assertThat(this.poolAdapter.getSubscriptionEnabled(null), is(equalTo(true))); assertThat(this.poolAdapter.getSubscriptionEnabled(null), is(equalTo(true)));
assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(null), is(equalTo(20000))); assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(null), is(equalTo(20000)));
assertThat(this.poolAdapter.getSubscriptionRedundancy(null), is(equalTo(2))); assertThat(this.poolAdapter.getSubscriptionRedundancy(null), is(equalTo(2)));
assertThat(this.poolAdapter.getSubscriptionTimeoutMultiplier(null), is(equalTo(3)));
assertThat(this.poolAdapter.getThreadLocalConnections(null), is(equalTo(false))); assertThat(this.poolAdapter.getThreadLocalConnections(null), is(equalTo(false)));
verify(this.mockPool, times(1)).getFreeConnectionTimeout(); verify(this.mockPool, times(1)).getFreeConnectionTimeout();
@@ -454,6 +458,7 @@ public class DefaultableDelegatingPoolAdapterTest {
verify(this.mockPool, times(1)).getSubscriptionEnabled(); verify(this.mockPool, times(1)).getSubscriptionEnabled();
verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout(); verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout();
verify(this.mockPool, times(1)).getSubscriptionRedundancy(); verify(this.mockPool, times(1)).getSubscriptionRedundancy();
verify(this.mockPool, times(1)).getSubscriptionTimeoutMultiplier();
verify(this.mockPool, times(1)).getThreadLocalConnections(); verify(this.mockPool, times(1)).getThreadLocalConnections();
verifyNoMoreInteractions(this.mockPool); verifyNoMoreInteractions(this.mockPool);
} }
@@ -489,6 +494,7 @@ public class DefaultableDelegatingPoolAdapterTest {
assertThat(this.poolAdapter.getSubscriptionEnabled(false), is(equalTo(true))); assertThat(this.poolAdapter.getSubscriptionEnabled(false), is(equalTo(true)));
assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(30000), is(equalTo(20000))); assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(30000), is(equalTo(20000)));
assertThat(this.poolAdapter.getSubscriptionRedundancy(1), is(equalTo(2))); assertThat(this.poolAdapter.getSubscriptionRedundancy(1), is(equalTo(2)));
assertThat(this.poolAdapter.getSubscriptionTimeoutMultiplier(2), is(equalTo(3)));
assertThat(this.poolAdapter.getThreadLocalConnections(true), is(equalTo(false))); assertThat(this.poolAdapter.getThreadLocalConnections(true), is(equalTo(false)));
verify(this.mockPool, times(1)).getFreeConnectionTimeout(); verify(this.mockPool, times(1)).getFreeConnectionTimeout();
@@ -514,6 +520,7 @@ public class DefaultableDelegatingPoolAdapterTest {
verify(this.mockPool, times(1)).getSubscriptionEnabled(); verify(this.mockPool, times(1)).getSubscriptionEnabled();
verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout(); verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout();
verify(this.mockPool, times(1)).getSubscriptionRedundancy(); verify(this.mockPool, times(1)).getSubscriptionRedundancy();
verify(this.mockPool, times(1)).getSubscriptionTimeoutMultiplier();
verify(this.mockPool, times(1)).getThreadLocalConnections(); verify(this.mockPool, times(1)).getThreadLocalConnections();
verifyNoMoreInteractions(this.mockPool); verifyNoMoreInteractions(this.mockPool);
} }

View File

@@ -105,6 +105,7 @@ public class DelegatingPoolAdapterTest {
when(this.mockPool.getSubscriptionEnabled()).thenReturn(true); when(this.mockPool.getSubscriptionEnabled()).thenReturn(true);
when(this.mockPool.getSubscriptionMessageTrackingTimeout()).thenReturn(60000); when(this.mockPool.getSubscriptionMessageTrackingTimeout()).thenReturn(60000);
when(this.mockPool.getSubscriptionRedundancy()).thenReturn(2); when(this.mockPool.getSubscriptionRedundancy()).thenReturn(2);
when(this.mockPool.getSubscriptionTimeoutMultiplier()).thenReturn(3);
when(this.mockPool.getThreadLocalConnections()).thenReturn(false); when(this.mockPool.getThreadLocalConnections()).thenReturn(false);
} }
@@ -143,6 +144,7 @@ public class DelegatingPoolAdapterTest {
assertThat(pool.getSubscriptionEnabled(), is(equalTo(true))); assertThat(pool.getSubscriptionEnabled(), is(equalTo(true)));
assertThat(pool.getSubscriptionMessageTrackingTimeout(), is(equalTo(60000))); assertThat(pool.getSubscriptionMessageTrackingTimeout(), is(equalTo(60000)));
assertThat(pool.getSubscriptionRedundancy(), is(equalTo(2))); assertThat(pool.getSubscriptionRedundancy(), is(equalTo(2)));
assertThat(pool.getSubscriptionTimeoutMultiplier(), is(equalTo(3)));
assertThat(pool.getThreadLocalConnections(), is(equalTo(false))); assertThat(pool.getThreadLocalConnections(), is(equalTo(false)));
verify(this.mockPool, times(1)).isDestroyed(); verify(this.mockPool, times(1)).isDestroyed();
@@ -169,6 +171,7 @@ public class DelegatingPoolAdapterTest {
verify(this.mockPool, times(1)).getSubscriptionEnabled(); verify(this.mockPool, times(1)).getSubscriptionEnabled();
verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout(); verify(this.mockPool, times(1)).getSubscriptionMessageTrackingTimeout();
verify(this.mockPool, times(1)).getSubscriptionRedundancy(); verify(this.mockPool, times(1)).getSubscriptionRedundancy();
verify(this.mockPool, times(1)).getSubscriptionTimeoutMultiplier();
verify(this.mockPool, times(1)).getThreadLocalConnections(); verify(this.mockPool, times(1)).getThreadLocalConnections();
} }
@@ -214,6 +217,7 @@ public class DelegatingPoolAdapterTest {
assertThat(pool.getSubscriptionEnabled(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_ENABLED))); assertThat(pool.getSubscriptionEnabled(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_ENABLED)));
assertThat(pool.getSubscriptionMessageTrackingTimeout(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT))); assertThat(pool.getSubscriptionMessageTrackingTimeout(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT)));
assertThat(pool.getSubscriptionRedundancy(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY))); 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))); assertThat(pool.getThreadLocalConnections(), is(equalTo(PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS)));
verifyZeroInteractions(this.mockPool); verifyZeroInteractions(this.mockPool);

View File

@@ -78,6 +78,7 @@ public class FactoryDefaultsPoolAdapterTest {
assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(), assertThat(this.poolAdapter.getSubscriptionMessageTrackingTimeout(),
is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT))); is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT)));
assertThat(this.poolAdapter.getSubscriptionRedundancy(), is(equalTo(PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY))); 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))); assertThat(this.poolAdapter.getThreadLocalConnections(), is(equalTo(PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS)));
} }

View File

@@ -44,8 +44,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
/** /**
* The LocalRegionNamespaceTest class is a test suite of test cases testing the contract and functionality * Unit tests for the Local Region Namespace.
* of GemFire's Local Region support in SDG.
* *
* @author Costin Leau * @author Costin Leau
* @author David Turanski * @author David Turanski
@@ -56,6 +55,7 @@ import org.springframework.util.ObjectUtils;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@ContextConfiguration(locations="local-ns.xml", @ContextConfiguration(locations="local-ns.xml",
initializers = GemFireMockObjectsApplicationContextInitializer.class) initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings("unused")
public class LocalRegionNamespaceTest { public class LocalRegionNamespaceTest {
@Autowired @Autowired
@@ -66,6 +66,8 @@ public class LocalRegionNamespaceTest {
assertTrue(applicationContext.containsBean("simple")); assertTrue(applicationContext.containsBean("simple"));
assertTrue(applicationContext.containsBean("simple"));
Region<?, ?> simple = applicationContext.getBean("simple", Region.class); Region<?, ?> simple = applicationContext.getBean("simple", Region.class);
assertNotNull("The 'simple' Region was not properly configured or initialized!", simple); assertNotNull("The 'simple' Region was not properly configured or initialized!", simple);

View File

@@ -51,8 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
/** /**
* The PartitionRegionNamespaceTest class is a test suite of test cases testing the contract and functionality * Unit tests for the Partitioned Region Namespace.
* of the GemFire Partition Region support in SDG.
* *
* @author Costin Leau * @author Costin Leau
* @author David Turanski * @author David Turanski

View File

@@ -32,7 +32,7 @@ import org.springframework.data.gemfire.support.ConnectionEndpoint;
import org.springframework.data.gemfire.support.ConnectionEndpointList; import org.springframework.data.gemfire.support.ConnectionEndpointList;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer; import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration; 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}. * 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.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer
* @see org.apache.geode.cache.client.Pool * @see org.apache.geode.cache.client.Pool
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringRunner.class)
@ContextConfiguration(locations = "pool-ns.xml", initializers = GemfireTestApplicationContextInitializer.class) @ContextConfiguration(locations = "pool-ns.xml", initializers = GemfireTestApplicationContextInitializer.class)
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class PoolNamespaceTest { public class PoolNamespaceTest {
@@ -55,7 +55,7 @@ public class PoolNamespaceTest {
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
protected void assertConnectionEndpoint(ConnectionEndpointList connectionEndpoints, protected void assertConnectionEndpoint(ConnectionEndpointList connectionEndpoints,
String expectedHost, int expectedPort) { String expectedHost, int expectedPort) {
assertThat(connectionEndpoints).isNotNull(); assertThat(connectionEndpoints).isNotNull();
assertThat(connectionEndpoints.size()).isEqualTo(1); assertThat(connectionEndpoints.size()).isEqualTo(1);
@@ -77,6 +77,7 @@ public class PoolNamespaceTest {
@Test @Test
public void gemfirePoolIsConfiguredProperly() throws Exception { public void gemfirePoolIsConfiguredProperly() throws Exception {
assertThat(applicationContext.containsBean("gemfirePool")).isTrue(); assertThat(applicationContext.containsBean("gemfirePool")).isTrue();
assertThat(applicationContext.containsBean("gemfire-pool")).isTrue(); assertThat(applicationContext.containsBean("gemfire-pool")).isTrue();
@@ -89,6 +90,7 @@ public class PoolNamespaceTest {
@Test @Test
public void simplePoolIsConfiguredProperly() throws Exception { public void simplePoolIsConfiguredProperly() throws Exception {
assertThat(applicationContext.containsBean("simple")).isTrue(); assertThat(applicationContext.containsBean("simple")).isTrue();
PoolFactoryBean poolFactoryBean = applicationContext.getBean("&simple", PoolFactoryBean.class); PoolFactoryBean poolFactoryBean = applicationContext.getBean("&simple", PoolFactoryBean.class);
@@ -104,6 +106,7 @@ public class PoolNamespaceTest {
@Test @Test
public void locatorPoolIsConfiguredProperly() throws Exception { public void locatorPoolIsConfiguredProperly() throws Exception {
assertThat(applicationContext.containsBean("locator")).isTrue(); assertThat(applicationContext.containsBean("locator")).isTrue();
PoolFactoryBean poolFactoryBean = applicationContext.getBean("&locator", PoolFactoryBean.class); PoolFactoryBean poolFactoryBean = applicationContext.getBean("&locator", PoolFactoryBean.class);
@@ -125,6 +128,7 @@ public class PoolNamespaceTest {
@Test @Test
public void serverPoolIsConfiguredProperly() throws Exception { public void serverPoolIsConfiguredProperly() throws Exception {
assertThat(applicationContext.containsBean("server")).isTrue(); assertThat(applicationContext.containsBean("server")).isTrue();
PoolFactoryBean poolFactoryBean = applicationContext.getBean("&server", PoolFactoryBean.class); PoolFactoryBean poolFactoryBean = applicationContext.getBean("&server", PoolFactoryBean.class);
@@ -149,6 +153,7 @@ public class PoolNamespaceTest {
assertThat(pool.getSubscriptionEnabled()).isTrue(); assertThat(pool.getSubscriptionEnabled()).isTrue();
assertThat(pool.getSubscriptionMessageTrackingTimeout()).isEqualTo(30000); assertThat(pool.getSubscriptionMessageTrackingTimeout()).isEqualTo(30000);
assertThat(pool.getSubscriptionRedundancy()).isEqualTo(2); assertThat(pool.getSubscriptionRedundancy()).isEqualTo(2);
assertThat(pool.getSubscriptionTimeoutMultiplier()).isEqualTo(3);
assertThat(pool.getThreadLocalConnections()).isFalse(); assertThat(pool.getThreadLocalConnections()).isFalse();
ConnectionEndpointList servers = TestUtils.readField("servers", poolFactoryBean); ConnectionEndpointList servers = TestUtils.readField("servers", poolFactoryBean);
@@ -164,6 +169,7 @@ public class PoolNamespaceTest {
@Test @Test
public void locatorsPoolIsConfiguredProperly() throws Exception { public void locatorsPoolIsConfiguredProperly() throws Exception {
assertThat(applicationContext.containsBean("locators")).isTrue(); assertThat(applicationContext.containsBean("locators")).isTrue();
PoolFactoryBean poolFactoryBean = applicationContext.getBean("&locators", PoolFactoryBean.class); PoolFactoryBean poolFactoryBean = applicationContext.getBean("&locators", PoolFactoryBean.class);
@@ -183,6 +189,7 @@ public class PoolNamespaceTest {
@Test @Test
public void serversPoolIsConfiguredProperly() throws Exception { public void serversPoolIsConfiguredProperly() throws Exception {
assertThat(applicationContext.containsBean("servers")).isTrue(); assertThat(applicationContext.containsBean("servers")).isTrue();
PoolFactoryBean poolFactoryBean = applicationContext.getBean("&servers", PoolFactoryBean.class); PoolFactoryBean poolFactoryBean = applicationContext.getBean("&servers", PoolFactoryBean.class);

View File

@@ -158,6 +158,7 @@ public class PoolParserUnitTests {
} }
@Test @Test
@SuppressWarnings("all")
public void doParse() { public void doParse() {
Element mockPoolElement = mock(Element.class, "testDoParse.MockPoolElement"); 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-enabled"))).thenReturn("true");
when(mockPoolElement.getAttribute(eq("subscription-message-tracking-timeout"))).thenReturn("30000"); when(mockPoolElement.getAttribute(eq("subscription-message-tracking-timeout"))).thenReturn("30000");
when(mockPoolElement.getAttribute(eq("subscription-redundancy"))).thenReturn("2"); 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(eq("thread-local-connections"))).thenReturn("false");
when(mockPoolElement.getAttribute(PoolParser.LOCATORS_ATTRIBUTE_NAME)).thenReturn(null); when(mockPoolElement.getAttribute(PoolParser.LOCATORS_ATTRIBUTE_NAME)).thenReturn(null);
when(mockPoolElement.getAttribute(PoolParser.SERVERS_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, "subscriptionEnabled", "true");
assertPropertyValue(poolDefinition, "subscriptionMessageTrackingTimeout", "30000"); assertPropertyValue(poolDefinition, "subscriptionMessageTrackingTimeout", "30000");
assertPropertyValue(poolDefinition, "subscriptionRedundancy", "2"); assertPropertyValue(poolDefinition, "subscriptionRedundancy", "2");
assertPropertyValue(poolDefinition, "subscriptionTimeoutMultiplier", "3");
assertPropertyValue(poolDefinition, "threadLocalConnections", "false"); assertPropertyValue(poolDefinition, "threadLocalConnections", "false");
assertPropertyPresent(poolDefinition, "locators"); assertPropertyPresent(poolDefinition, "locators");
assertPropertyPresent(poolDefinition, "servers"); assertPropertyPresent(poolDefinition, "servers");

View File

@@ -30,7 +30,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer; import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration; 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 * 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 * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
* @since 1.3.4 * @since 1.3.4
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringRunner.class)
@ContextConfiguration(initializers = GemfireTestApplicationContextInitializer.class) @ContextConfiguration(initializers = GemfireTestApplicationContextInitializer.class)
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class RegionEvictionAttributesNamespaceTest { public class RegionEvictionAttributesNamespaceTest {
@@ -69,6 +69,7 @@ public class RegionEvictionAttributesNamespaceTest {
@Test @Test
public void testEntryCountRegionEvictionAttributes() { public void testEntryCountRegionEvictionAttributes() {
assertNotNull(one); assertNotNull(one);
assertNotNull(one.getAttributes()); assertNotNull(one.getAttributes());
assertEquals(DataPolicy.REPLICATE, one.getAttributes().getDataPolicy()); assertEquals(DataPolicy.REPLICATE, one.getAttributes().getDataPolicy());
@@ -88,8 +89,9 @@ public class RegionEvictionAttributesNamespaceTest {
two.getAttributes().getEvictionAttributes().getMaximum()); two.getAttributes().getEvictionAttributes().getMaximum());
} }
@Test(expected = UnsupportedOperationException.class) @Test
public void testHeapPercentageRegionEvictionAttributes() { public void testHeapPercentageRegionEvictionAttributes() {
assertNotNull(three); assertNotNull(three);
assertNotNull(three.getAttributes()); assertNotNull(three.getAttributes());
assertEquals(DataPolicy.REPLICATE, three.getAttributes().getDataPolicy()); assertEquals(DataPolicy.REPLICATE, three.getAttributes().getDataPolicy());
@@ -103,18 +105,12 @@ public class RegionEvictionAttributesNamespaceTest {
assertNotNull(four.getAttributes().getEvictionAttributes()); assertNotNull(four.getAttributes().getEvictionAttributes());
assertEquals(EvictionAction.OVERFLOW_TO_DISK, four.getAttributes().getEvictionAttributes().getAction()); assertEquals(EvictionAction.OVERFLOW_TO_DISK, four.getAttributes().getEvictionAttributes().getAction());
assertEquals(EvictionAlgorithm.LRU_HEAP, three.getAttributes().getEvictionAttributes().getAlgorithm()); assertEquals(EvictionAlgorithm.LRU_HEAP, three.getAttributes().getEvictionAttributes().getAlgorithm());
assertEquals(0, four.getAttributes().getEvictionAttributes().getMaximum());
try {
four.getAttributes().getEvictionAttributes().getMaximum();
}
catch (UnsupportedOperationException expected) {
assertEquals("LRUHeap does not support a maximum", expected.getMessage());
throw expected;
}
} }
@Test @Test
public void testMemorySizeRegionEvictionAttributes() { public void testMemorySizeRegionEvictionAttributes() {
assertNotNull(five); assertNotNull(five);
assertNotNull(five.getAttributes()); assertNotNull(five.getAttributes());
assertEquals(DataPolicy.REPLICATE, five.getAttributes().getDataPolicy()); assertEquals(DataPolicy.REPLICATE, five.getAttributes().getDataPolicy());
@@ -130,8 +126,8 @@ public class RegionEvictionAttributesNamespaceTest {
assertEquals(EvictionAction.OVERFLOW_TO_DISK, six.getAttributes().getEvictionAttributes().getAction()); assertEquals(EvictionAction.OVERFLOW_TO_DISK, six.getAttributes().getEvictionAttributes().getAction());
assertEquals(EvictionAlgorithm.LRU_MEMORY, six.getAttributes().getEvictionAttributes().getAlgorithm()); assertEquals(EvictionAlgorithm.LRU_MEMORY, six.getAttributes().getEvictionAttributes().getAlgorithm());
int expectedMaximum = (Boolean.getBoolean("org.springframework.data.gemfire.test.GemfireTestRunner.nomock") int expectedMaximum =
? 512 : 256); Boolean.getBoolean("org.springframework.data.gemfire.test.GemfireTestRunner.nomock") ? 512 : 256;
assertEquals(expectedMaximum, six.getAttributes().getEvictionAttributes().getMaximum()); assertEquals(expectedMaximum, six.getAttributes().getEvictionAttributes().getMaximum());
} }

View File

@@ -46,8 +46,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
/** /**
* The ReplicatedRegionNamespaceTest class is a test suite of test cases testing the contract and functionality * Unit tests for the Replicated Region Namespace.
* of GemFire Replicated Region support in SDG.
* *
* @author Costin Leau * @author Costin Leau
* @author David Turanski * @author David Turanski

View File

@@ -56,7 +56,7 @@ import org.mockito.junit.MockitoJUnitRunner;
* @see org.junit.Test * @see org.junit.Test
* @see org.junit.runner.RunWith * @see org.junit.runner.RunWith
* @see org.mockito.Mockito * @see org.mockito.Mockito
* @see org.mockito.runners.MockitoJUnitRunner * @see org.mockito.junit.MockitoJUnitRunner
* @see org.springframework.data.gemfire.function.execution.AbstractFunctionExecution * @see org.springframework.data.gemfire.function.execution.AbstractFunctionExecution
* @see org.apache.geode.cache.execute.Execution * @see org.apache.geode.cache.execute.Execution
* @since 1.7.0 * @since 1.7.0
@@ -65,13 +65,11 @@ import org.mockito.junit.MockitoJUnitRunner;
public class AbstractFunctionExecutionTest { public class AbstractFunctionExecutionTest {
@Rule @Rule
public ExpectedException expectedException = ExpectedException.none(); public ExpectedException exception = ExpectedException.none();
@Mock @Mock
private Execution mockExecution; private Execution mockExecution;
// TODO: add more tests!!!
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void executeWithResults() throws Exception { public void executeWithResults() throws Exception {
@@ -99,7 +97,7 @@ public class AbstractFunctionExecutionTest {
.setArgs(args).setTimeout(500).execute(); .setArgs(args).setTimeout(500).execute();
assertThat(actualResults, is(notNullValue())); 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, times(1)).setArguments(eq(args));
verify(mockExecution, never()).withCollector(any(ResultCollector.class)); verify(mockExecution, never()).withCollector(any(ResultCollector.class));
@@ -112,10 +110,13 @@ public class AbstractFunctionExecutionTest {
@Test @Test
public void executeAndExtractWithSingleResult() { public void executeAndExtractWithSingleResult() {
final List<String> results = Collections.singletonList("test");
List<String> results = Collections.singletonList("test");
AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() { AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() {
@Override protected Execution getExecution() {
@Override
protected Execution getExecution() {
return mockExecution; return mockExecution;
} }
@@ -130,10 +131,13 @@ public class AbstractFunctionExecutionTest {
@Test @Test
public void executeAndExtractWithMultipleResults() { public void executeAndExtractWithMultipleResults() {
final List<String> results = Arrays.asList("one", "two", "three");
List<String> results = Arrays.asList("one", "two", "three");
AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() { AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() {
@Override protected Execution getExecution() {
@Override
protected Execution getExecution() {
return mockExecution; return mockExecution;
} }
@@ -148,8 +152,11 @@ public class AbstractFunctionExecutionTest {
@Test @Test
public void executeAndExtractWithNullResults() { public void executeAndExtractWithNullResults() {
AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() { AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() {
@Override protected Execution getExecution() {
@Override
protected Execution getExecution() {
return mockExecution; return mockExecution;
} }
@@ -164,8 +171,11 @@ public class AbstractFunctionExecutionTest {
@Test @Test
public void executeAndExtractWithNoResults() { public void executeAndExtractWithNoResults() {
AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() { AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() {
@Override protected Execution getExecution() {
@Override
protected Execution getExecution() {
return mockExecution; return mockExecution;
} }
@@ -194,11 +204,10 @@ public class AbstractFunctionExecutionTest {
} }
}; };
expectedException.expect(FunctionException.class); exception.expect(FunctionException.class);
expectedException.expectCause(isA(IllegalArgumentException.class)); exception.expectCause(isA(IllegalArgumentException.class));
expectedException.expectMessage(containsString("Execution of Function with ID [TestFunction] failed")); exception.expectMessage(containsString("Execution of Function with ID [TestFunction] failed"));
functionExecution.setFunctionId("TestFunction").executeAndExtract(); functionExecution.setFunctionId("TestFunction").executeAndExtract();
} }
} }

View File

@@ -49,6 +49,7 @@ public class FunctionExecutionIntegrationTests extends ClientServerIntegrationTe
@BeforeClass @BeforeClass
public static void startGemFireServer() throws Exception { public static void startGemFireServer() throws Exception {
availablePort = findAvailablePort(); availablePort = findAvailablePort();
gemfireServer = run(FunctionCacheServerProcess.class, gemfireServer = run(FunctionCacheServerProcess.class,
@@ -67,24 +68,35 @@ public class FunctionExecutionIntegrationTests extends ClientServerIntegrationTe
@Before @Before
public void setupGemFireClient() { public void setupGemFireClient() {
gemfireCache = new ClientCacheFactory()
.set("name", "FunctionExecutionIntegrationTests") this.gemfireCache = new ClientCacheFactory()
.set("log-level", "warning") .set("name", FunctionExecutionIntegrationTests.class.getSimpleName())
.set("log-level", "error")
.setPoolSubscriptionEnabled(true) .setPoolSubscriptionEnabled(true)
.addPoolServer("localhost", availablePort) .addPoolServer("localhost", availablePort)
.create(); .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"); .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 @After
public void tearDownGemFireClient() { public void tearDownGemFireClient() {
if (gemfireCache != null) {
if (this.gemfireCache != null) {
try { try {
gemfireCache.close(); this.gemfireCache.close();
} }
catch (CacheClosedException ignore) { catch (CacheClosedException ignore) {
} }
@@ -93,6 +105,7 @@ public class FunctionExecutionIntegrationTests extends ClientServerIntegrationTe
@Test @Test
public void basicFunctionExecutionsAreCorrect() { public void basicFunctionExecutionsAreCorrect() {
verifyFunctionExecution(new PoolServerFunctionExecution(gemfirePool)); verifyFunctionExecution(new PoolServerFunctionExecution(gemfirePool));
verifyFunctionExecution(new RegionFunctionExecution(gemfireRegion)); verifyFunctionExecution(new RegionFunctionExecution(gemfireRegion));
verifyFunctionExecution(new ServerFunctionExecution(gemfireCache)); verifyFunctionExecution(new ServerFunctionExecution(gemfireCache));
@@ -100,7 +113,9 @@ public class FunctionExecutionIntegrationTests extends ClientServerIntegrationTe
} }
private void verifyFunctionExecution(AbstractFunctionExecution functionExecution) { private void verifyFunctionExecution(AbstractFunctionExecution functionExecution) {
Iterable<String> results = functionExecution.setArgs("1", "2", "3").setFunctionId("echoFunction").execute(); Iterable<String> results = functionExecution.setArgs("1", "2", "3").setFunctionId("echoFunction").execute();
int count = 1; int count = 1;
for (String result : results) { for (String result : results) {

View File

@@ -15,7 +15,6 @@ package org.springframework.data.gemfire.function.execution;
import static org.assertj.core.api.Java6Assertions.assertThat; 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.Region;
import org.apache.geode.cache.client.ClientCache; import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientCacheFactory; import org.apache.geode.cache.client.ClientCacheFactory;
@@ -27,6 +26,7 @@ import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.data.gemfire.GemfireUtils;
import org.springframework.data.gemfire.fork.FunctionCacheServerProcess; import org.springframework.data.gemfire.fork.FunctionCacheServerProcess;
import org.springframework.data.gemfire.process.ProcessWrapper; import org.springframework.data.gemfire.process.ProcessWrapper;
import org.springframework.data.gemfire.test.support.ClientServerIntegrationTestsSupport; import org.springframework.data.gemfire.test.support.ClientServerIntegrationTestsSupport;
@@ -48,6 +48,7 @@ public class GemfireFunctionTemplateIntegrationTests extends ClientServerIntegra
@BeforeClass @BeforeClass
public static void startGemFireServer() throws Exception { public static void startGemFireServer() throws Exception {
availablePort = findAvailablePort(); availablePort = findAvailablePort();
gemfireServer = run(FunctionCacheServerProcess.class, gemfireServer = run(FunctionCacheServerProcess.class,
@@ -66,32 +67,37 @@ public class GemfireFunctionTemplateIntegrationTests extends ClientServerIntegra
@Before @Before
public void setupGemFireClient() { public void setupGemFireClient() {
gemfireCache = new ClientCacheFactory()
.set("name", "GemfireFunctionTemplateIntegrationTests") this.gemfireCache = new ClientCacheFactory()
.set("log-level", "warning") .set("name", GemfireFunctionTemplateIntegrationTests.class.getSimpleName())
.set("log-level", "error")
.setPoolSubscriptionEnabled(true) .setPoolSubscriptionEnabled(true)
.addPoolServer("localhost", availablePort) .addPoolServer("localhost", availablePort)
.create(); .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"); .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 @After
public void tearDownGemFireClient() { public void tearDownGemFireClient() {
if (gemfireCache != null) { GemfireUtils.close(this.gemfireCache);
try {
gemfireCache.close();
}
catch (CacheClosedException ignore) {
}
}
} }
@Test @Test
public void testFunctionTemplates() { public void testFunctionTemplates() {
verifyFunctionTemplateExecution(new GemfireOnRegionFunctionTemplate(gemfireRegion)); verifyFunctionTemplateExecution(new GemfireOnRegionFunctionTemplate(gemfireRegion));
verifyFunctionTemplateExecution(new GemfireOnServerFunctionTemplate(gemfireCache)); verifyFunctionTemplateExecution(new GemfireOnServerFunctionTemplate(gemfireCache));
verifyFunctionTemplateExecution(new GemfireOnServerFunctionTemplate(gemfirePool)); verifyFunctionTemplateExecution(new GemfireOnServerFunctionTemplate(gemfirePool));
@@ -100,7 +106,9 @@ public class GemfireFunctionTemplateIntegrationTests extends ClientServerIntegra
} }
private void verifyFunctionTemplateExecution(GemfireFunctionOperations functionTemplate) { private void verifyFunctionTemplateExecution(GemfireFunctionOperations functionTemplate) {
Iterable<String> results = functionTemplate.execute("echoFunction", "1", "2", "3"); Iterable<String> results = functionTemplate.execute("echoFunction", "1", "2", "3");
int count = 1; int count = 1;
for (String result : results) { for (String result : results) {

View File

@@ -2056,9 +2056,9 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
return rememberMockedRegion(mockRegion); return rememberMockedRegion(mockRegion);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("all")
private static <K, V> RegionAttributes<K, V> mockRegionAttributes(Region<K, V> mockRegion, 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); AttributesMutator<K, V> mockAttributesMutator = mock(AttributesMutator.class);
@@ -2461,7 +2461,13 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
when(mockRegionFactory.setMulticastEnabled(anyBoolean())) when(mockRegionFactory.setMulticastEnabled(anyBoolean()))
.thenAnswer(newSetter(multicastEnabled, mockRegionFactory)); .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))) when(mockRegionFactory.setPartitionAttributes(any(PartitionAttributes.class)))
.thenAnswer(newSetter(partitionAttributes, mockRegionFactory)); .thenAnswer(newSetter(partitionAttributes, mockRegionFactory));

View File

@@ -1,13 +1,16 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cache PUBLIC "-//GemStone Systems, Inc.//GemFire Declarative Caching 8.0//EN" <cache xmlns="http://geode.apache.org/schema/cache"
"http://www.gemstone.com/dtd/cache8_0.dtd"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<cache> 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 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"> statistics-enabled="true">
<eviction-attributes> <eviction-attributes>
<lru-entry-count action="overflow-to-disk" maximum="500"/> <lru-entry-count action="overflow-to-disk" maximum="500"/>
</eviction-attributes> </eviction-attributes>
</region-attributes> </region-attributes>
</region> </region>
</cache> </cache>

View File

@@ -13,7 +13,8 @@
<util:properties id="gemfireProperties"> <util:properties id="gemfireProperties">
<prop key="name">LocalNamespaceConfig</prop> <prop key="name">LocalNamespaceConfig</prop>
<prop key="mcast-port">0</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> </util:properties>
<gfe:cache properties-ref="gemfireProperties"/> <gfe:cache properties-ref="gemfireProperties"/>

View File

@@ -32,7 +32,7 @@
ping-interval="5000" pr-single-hop-enabled="false" read-timeout="500" retry-attempts="5" ping-interval="5000" pr-single-hop-enabled="false" read-timeout="500" retry-attempts="5"
server-group="TestGroup" socket-buffer-size="65536" statistic-interval="250" server-group="TestGroup" socket-buffer-size="65536" statistic-interval="250"
subscription-ack-interval="250" subscription-enabled="true" subscription-message-tracking-timeout="30000" 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="${gfe.port.4}"/>
<gfe:server host="localhost" port="50505"/> <gfe:server host="localhost" port="50505"/>
</gfe:pool> </gfe:pool>