From 883281f58fff46629d1d8a54daf915a6b15e818d Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 1 May 2017 09:53:20 -0400 Subject: [PATCH] INT-4266: Disable multicast for Gemfire tests JIRA: https://jira.spring.io/browse/INT-4266 --- .../CacheListeningMessageProducerTests.java | 10 ++++- .../CqInboundChannelAdapterTests-context.xml | 41 +++++++++++-------- ...fireInboundChannelAdapterTests-context.xml | 10 ++++- .../metadata/GemfireMetadataStoreTests.java | 24 +++++++---- .../CacheWritingMessageHandlerTests.java | 7 +++- ...ireOutboundChannelAdapterTests-context.xml | 20 +++++---- ...ayerHandlerRescheduleIntegrationTests.java | 7 +++- .../gemfire/store/GemfireGroupStoreTests.java | 5 ++- .../store/GemfireMessageStoreTests.java | 7 +++- 9 files changed, 90 insertions(+), 41 deletions(-) diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java index 5062165e85..d540ec3d47 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.mockito.Mockito.mock; +import java.util.Properties; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -39,6 +41,7 @@ import com.gemstone.gemfire.cache.Region; * @author Mark Fisher * @author Gary Russell * @author Artem Bilan + * * @since 2.1 */ public class CacheListeningMessageProducerTests { @@ -55,6 +58,11 @@ public class CacheListeningMessageProducerTests { public static void setup() throws Exception { cacheFactoryBean = new CacheFactoryBean(); + Properties gemfireProperties = new Properties(); + gemfireProperties.setProperty("mcast-port", "0"); + cacheFactoryBean.setProperties(gemfireProperties); + cacheFactoryBean.afterPropertiesSet(); + regionFactoryBean = new RegionFactoryBean() { }; regionFactoryBean.setName("test.receiveNewValuePayloadForCreateEvent"); regionFactoryBean.setCache(cacheFactoryBean.getObject()); diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests-context.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests-context.xml index 6fd36bcd98..5d725993ab 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests-context.xml +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests-context.xml @@ -1,51 +1,56 @@ - + true + + 0 + + + id="client-cache" pool-name="client-pool" + properties-ref="gemfireProperties"/> - + + pool-name="client-pool" data-policy="EMPTY"/> + cache="client-cache"/> + cq-listener-container="queryListenerContainer" query="select * from /test" + channel="outputChannel1" durable="${durable}"/> - + + cq-listener-container="queryListenerContainer" query="select * from /test" + channel="outputChannel2" expression="newValue" query-events="CREATED"/> - + diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests-context.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests-context.xml index 78018b11ef..098388a0b5 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests-context.xml +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests-context.xml @@ -3,14 +3,20 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gfe="http://www.springframework.org/schema/gemfire" xmlns:int-gfe="http://www.springframework.org/schema/integration/gemfire" + xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/integration/gemfire http://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire.xsd http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd"> + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> - + + 0 + + + diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStoreTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStoreTests.java index 5f325ba9d8..a273ac40ed 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStoreTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,28 +20,30 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; +import java.util.Properties; + import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.springframework.data.gemfire.CacheFactoryBean; import org.springframework.data.gemfire.GemfireTemplate; import org.springframework.integration.metadata.ConcurrentMetadataStore; -import org.springframework.util.Assert; import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheFactory; import com.gemstone.gemfire.cache.Region; /** * @author Artem Bilan + * * @since 4.0 * */ public class GemfireMetadataStoreTests { - private static Cache cache; + private static CacheFactoryBean cacheFactoryBean; private static ConcurrentMetadataStore metadataStore; @@ -49,19 +51,23 @@ public class GemfireMetadataStoreTests { @BeforeClass public static void startUp() throws Exception { - cache = new CacheFactory().create(); + cacheFactoryBean = new CacheFactoryBean(); + Properties gemfireProperties = new Properties(); + gemfireProperties.setProperty("mcast-port", "0"); + cacheFactoryBean.setProperties(gemfireProperties); + cacheFactoryBean.afterPropertiesSet(); + Cache cache = cacheFactoryBean.getObject(); metadataStore = new GemfireMetadataStore(cache); region = cache.getRegion(GemfireMetadataStore.KEY); } @AfterClass - public static void cleanUp() { + public static void cleanUp() throws Exception { if (region != null) { region.close(); } - if (cache != null) { - cache.close(); - Assert.isTrue(cache.isClosed(), "Cache did not close after close() call"); + if (cacheFactoryBean != null) { + cacheFactoryBean.destroy(); } } diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/CacheWritingMessageHandlerTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/CacheWritingMessageHandlerTests.java index a372e5a56c..962f093800 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/CacheWritingMessageHandlerTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/CacheWritingMessageHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import static org.mockito.Mockito.mock; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Properties; import org.junit.AfterClass; import org.junit.Before; @@ -46,6 +47,7 @@ import com.gemstone.gemfire.cache.Scope; * @author Gunnar Hillert * @author Gary Russell * @author Artem Bilan + * * @since 2.1 */ public class CacheWritingMessageHandlerTests { @@ -57,6 +59,9 @@ public class CacheWritingMessageHandlerTests { @BeforeClass public static void startUp() throws Exception { cacheFactoryBean = new CacheFactoryBean(); + Properties gemfireProperties = new Properties(); + gemfireProperties.setProperty("mcast-port", "0"); + cacheFactoryBean.setProperties(gemfireProperties); cacheFactoryBean.afterPropertiesSet(); Cache cache = cacheFactoryBean.getObject(); region = cache.createRegionFactory().setScope(Scope.LOCAL).create("sig-tests"); diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests-context.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests-context.xml index fa3deacc8a..dbaf38e0f5 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests-context.xml +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests-context.xml @@ -1,15 +1,21 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> - + + 0 + + + diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/DelayerHandlerRescheduleIntegrationTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/DelayerHandlerRescheduleIntegrationTests.java index 0da1b133e8..12cf1585e5 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/DelayerHandlerRescheduleIntegrationTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/DelayerHandlerRescheduleIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2016 the original author or authors. + * Copyright 2013-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.util.Properties; import java.util.concurrent.TimeUnit; import org.junit.AfterClass; @@ -47,6 +48,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; /** * @author Artem Bilan * @author Gary Russell + * * @since 3.0 */ public class DelayerHandlerRescheduleIntegrationTests { @@ -61,6 +63,9 @@ public class DelayerHandlerRescheduleIntegrationTests { @BeforeClass public static void startUp() throws Exception { cacheFactoryBean = new CacheFactoryBean(); + Properties gemfireProperties = new Properties(); + gemfireProperties.setProperty("mcast-port", "0"); + cacheFactoryBean.setProperties(gemfireProperties); cacheFactoryBean.afterPropertiesSet(); } diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireGroupStoreTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireGroupStoreTests.java index 45a4564c7e..10c68cbd41 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireGroupStoreTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireGroupStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2007-2016 the original author or authors. + * Copyright 2007-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -379,6 +379,9 @@ public class GemfireGroupStoreTests { @BeforeClass public static void init() throws Exception { cacheFactoryBean = new CacheFactoryBean(); + Properties gemfireProperties = new Properties(); + gemfireProperties.setProperty("mcast-port", "0"); + cacheFactoryBean.setProperties(gemfireProperties); cacheFactoryBean.afterPropertiesSet(); Cache cache = cacheFactoryBean.getObject(); region = cache.createRegionFactory().setScope(Scope.LOCAL).create("sig-tests"); diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireMessageStoreTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireMessageStoreTests.java index f3460d8f0a..bb187984dd 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireMessageStoreTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireMessageStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ import com.gemstone.gemfire.cache.Scope; * @author David Turanski * @author Gary Russell * @author Artem Bilan + * * @since 2.1 */ public class GemfireMessageStoreTests { @@ -133,6 +134,10 @@ public class GemfireMessageStoreTests { @BeforeClass public static void init() throws Exception { cacheFactoryBean = new CacheFactoryBean(); + Properties gemfireProperties = new Properties(); + gemfireProperties.setProperty("mcast-port", "0"); + cacheFactoryBean.setProperties(gemfireProperties); + cacheFactoryBean.afterPropertiesSet(); Cache cache = cacheFactoryBean.getObject(); region = cache.createRegionFactory().setScope(Scope.LOCAL).create("sig-tests"); }