From 7d16ab5f063ac99ef77470b8e180a5bc745b0d5c Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Sun, 4 Jun 2017 19:07:20 -0400 Subject: [PATCH] INT-4266: Disable multicast for Gemfire tests JIRA: https://jira.spring.io/browse/INT-4266 https://build.spring.io/browse/INT-B41-634 Conflicts: spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireGroupStoreTests.java spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireMessageStoreTests.java --- ...tOnceFileListFilterExternalStoreTests.java | 16 ++++++-- .../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 +++- 10 files changed, 103 insertions(+), 44 deletions(-) diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/filters/PersistentAcceptOnceFileListFilterExternalStoreTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/filters/PersistentAcceptOnceFileListFilterExternalStoreTests.java index 7668b7372e..89d802e692 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/filters/PersistentAcceptOnceFileListFilterExternalStoreTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/filters/PersistentAcceptOnceFileListFilterExternalStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 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. @@ -13,12 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.file.filters; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; +import java.util.Properties; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; @@ -31,6 +33,7 @@ import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import org.springframework.data.gemfire.CacheFactoryBean; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.integration.gemfire.metadata.GemfireMetadataStore; @@ -39,7 +42,7 @@ import org.springframework.integration.redis.metadata.RedisMetadataStore; import org.springframework.integration.redis.rules.RedisAvailable; import org.springframework.integration.redis.rules.RedisAvailableTests; -import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.cache.Cache; /** * @author Gary Russell @@ -69,7 +72,14 @@ public class PersistentAcceptOnceFileListFilterExternalStoreTests extends RedisA @Test public void testFileSystemWithGemfireMetadataStore() throws Exception { - this.testFileSystem(new GemfireMetadataStore(new CacheFactory().create())); + CacheFactoryBean cacheFactoryBean = new CacheFactoryBean(); + Properties gemfireProperties = new Properties(); + gemfireProperties.setProperty("mcast-port", "0"); + cacheFactoryBean.setProperties(gemfireProperties); + cacheFactoryBean.afterPropertiesSet(); + Cache cache = cacheFactoryBean.getObject(); + testFileSystem(new GemfireMetadataStore(cache)); + cacheFactoryBean.destroy(); } private void testFileSystem(ConcurrentMetadataStore store) throws Exception { 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 7dbc6938ad..0fb6223b31 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; @@ -38,6 +40,7 @@ import com.gemstone.gemfire.cache.Region; * @author Mark Fisher * @author Gary Russell * @author Artem Bilan + * * @since 2.1 */ @SuppressWarnings("deprecation") @@ -53,6 +56,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 3ac1d8bc6d..938e2283d8 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. @@ -19,28 +19,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; @@ -48,19 +50,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 cdd6503c63..00f99692d8 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. You may obtain a copy of the License at @@ -19,6 +19,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; @@ -48,6 +49,7 @@ import com.gemstone.gemfire.cache.Scope; /** * @author Artem Bilan * @author Gary Russell + * * @since 3.0 */ public class DelayerHandlerRescheduleIntegrationTests { @@ -64,6 +66,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(); 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/GemfireGroupStoreTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireGroupStoreTests.java index bd230209ba..ba153ab4ef 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-2015 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. @@ -377,6 +377,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 75e19cf42e..d27a055e0e 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-2015 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"); }