Skip to content

Commit 7d16ab5

Browse files
committed
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
1 parent 5781493 commit 7d16ab5

File tree

10 files changed

+103
-44
lines changed

10 files changed

+103
-44
lines changed

spring-integration-file/src/test/java/org/springframework/integration/file/filters/PersistentAcceptOnceFileListFilterExternalStoreTests.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 the original author or authors.
2+
* Copyright 2014-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,12 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.integration.file.filters;
1718

1819
import static org.junit.Assert.assertEquals;
1920
import static org.junit.Assert.assertTrue;
2021

2122
import java.io.File;
23+
import java.util.Properties;
2224
import java.util.concurrent.Callable;
2325
import java.util.concurrent.CountDownLatch;
2426
import java.util.concurrent.Executors;
@@ -31,6 +33,7 @@
3133
import org.mockito.invocation.InvocationOnMock;
3234
import org.mockito.stubbing.Answer;
3335

36+
import org.springframework.data.gemfire.CacheFactoryBean;
3437
import org.springframework.data.redis.core.RedisTemplate;
3538
import org.springframework.data.redis.serializer.StringRedisSerializer;
3639
import org.springframework.integration.gemfire.metadata.GemfireMetadataStore;
@@ -39,7 +42,7 @@
3942
import org.springframework.integration.redis.rules.RedisAvailable;
4043
import org.springframework.integration.redis.rules.RedisAvailableTests;
4144

42-
import com.gemstone.gemfire.cache.CacheFactory;
45+
import com.gemstone.gemfire.cache.Cache;
4346

4447
/**
4548
* @author Gary Russell
@@ -69,7 +72,14 @@ public void testFileSystemWithRedisMetadataStore() throws Exception {
6972

7073
@Test
7174
public void testFileSystemWithGemfireMetadataStore() throws Exception {
72-
this.testFileSystem(new GemfireMetadataStore(new CacheFactory().create()));
75+
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
76+
Properties gemfireProperties = new Properties();
77+
gemfireProperties.setProperty("mcast-port", "0");
78+
cacheFactoryBean.setProperties(gemfireProperties);
79+
cacheFactoryBean.afterPropertiesSet();
80+
Cache cache = cacheFactoryBean.getObject();
81+
testFileSystem(new GemfireMetadataStore(cache));
82+
cacheFactoryBean.destroy();
7383
}
7484

7585
private void testFileSystem(ConcurrentMetadataStore store) throws Exception {

spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
2121
import static org.junit.Assert.assertNull;
2222
import static org.mockito.Mockito.mock;
2323

24+
import java.util.Properties;
25+
2426
import org.junit.AfterClass;
2527
import org.junit.BeforeClass;
2628
import org.junit.Test;
@@ -38,6 +40,7 @@
3840
* @author Mark Fisher
3941
* @author Gary Russell
4042
* @author Artem Bilan
43+
*
4144
* @since 2.1
4245
*/
4346
@SuppressWarnings("deprecation")
@@ -53,6 +56,11 @@ public class CacheListeningMessageProducerTests {
5356
public static void setup() throws Exception {
5457
cacheFactoryBean = new CacheFactoryBean();
5558

59+
Properties gemfireProperties = new Properties();
60+
gemfireProperties.setProperty("mcast-port", "0");
61+
cacheFactoryBean.setProperties(gemfireProperties);
62+
cacheFactoryBean.afterPropertiesSet();
63+
5664
regionFactoryBean = new RegionFactoryBean<String, String>() { };
5765
regionFactoryBean.setName("test.receiveNewValuePayloadForCreateEvent");
5866
regionFactoryBean.setCache(cacheFactoryBean.getObject());
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,56 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<beans xmlns="http://www.springframework.org/schema/beans"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xmlns:gfe="http://www.springframework.org/schema/gemfire"
5-
xmlns:int="http://www.springframework.org/schema/integration"
6-
xmlns:util="http://www.springframework.org/schema/util"
7-
xmlns:int-gfe="http://www.springframework.org/schema/integration/gemfire"
8-
xmlns:context="http://www.springframework.org/schema/context"
9-
xsi:schemaLocation="http://www.springframework.org/schema/integration/gemfire http://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire.xsd
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:gfe="http://www.springframework.org/schema/gemfire"
5+
xmlns:int="http://www.springframework.org/schema/integration"
6+
xmlns:util="http://www.springframework.org/schema/util"
7+
xmlns:int-gfe="http://www.springframework.org/schema/integration/gemfire"
8+
xmlns:context="http://www.springframework.org/schema/context"
9+
xsi:schemaLocation="http://www.springframework.org/schema/integration/gemfire http://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire.xsd
1010
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
1111
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
1212
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
1313
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
1414
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
1515

16-
<context:property-placeholder properties-ref="props" />
16+
<context:property-placeholder properties-ref="props"/>
1717

1818
<util:properties id="props">
1919
<prop key="durable">true</prop>
2020
</util:properties>
2121

22+
<util:properties id="gemfireProperties">
23+
<prop key="mcast-port">0</prop>
24+
</util:properties>
25+
2226
<gfe:client-cache use-bean-factory-locator="false"
23-
id="client-cache" pool-name="client-pool" />
27+
id="client-cache" pool-name="client-pool"
28+
properties-ref="gemfireProperties"/>
2429

2530
<gfe:pool id="client-pool" subscription-enabled="true">
26-
<gfe:server host="localhost" port="40404" />
31+
<gfe:server host="localhost" port="40404"/>
2732
</gfe:pool>
2833

2934
<gfe:client-region id="test" cache-ref="client-cache"
30-
pool-name="client-pool" data-policy="EMPTY" />
35+
pool-name="client-pool" data-policy="EMPTY"/>
3136

3237
<gfe:cq-listener-container id="queryListenerContainer"
33-
cache="client-cache" />
38+
cache="client-cache"/>
3439

3540
<int-gfe:cq-inbound-channel-adapter id="withDurable"
36-
cq-listener-container="queryListenerContainer" query="select * from /test"
37-
channel="outputChannel1" durable="${durable}" />
41+
cq-listener-container="queryListenerContainer" query="select * from /test"
42+
channel="outputChannel1" durable="${durable}"/>
3843

3944
<int:channel id="outputChannel1">
40-
<int:queue />
45+
<int:queue/>
4146
</int:channel>
4247

4348
<int-gfe:cq-inbound-channel-adapter
44-
cq-listener-container="queryListenerContainer" query="select * from /test"
45-
channel="outputChannel2" expression="newValue" query-events="CREATED" />
49+
cq-listener-container="queryListenerContainer" query="select * from /test"
50+
channel="outputChannel2" expression="newValue" query-events="CREATED"/>
4651

4752
<int:channel id="outputChannel2">
48-
<int:queue />
53+
<int:queue/>
4954
</int:channel>
5055

5156
</beans>

spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests-context.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns:gfe="http://www.springframework.org/schema/gemfire"
55
xmlns:int-gfe="http://www.springframework.org/schema/integration/gemfire"
6+
xmlns:util="http://www.springframework.org/schema/util"
67
xsi:schemaLocation="http://www.springframework.org/schema/integration/gemfire
78
http://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire.xsd
89
http://www.springframework.org/schema/gemfire
910
http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
1011
http://www.springframework.org/schema/beans
11-
http://www.springframework.org/schema/beans/spring-beans.xsd">
12+
http://www.springframework.org/schema/beans/spring-beans.xsd
13+
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
1214

13-
<gfe:cache id="gemfire-cache-2" use-bean-factory-locator="false"/>
15+
<util:properties id="gemfireProperties">
16+
<prop key="mcast-port">0</prop>
17+
</util:properties>
18+
19+
<gfe:cache id="gemfire-cache-2" use-bean-factory-locator="false" properties-ref="gemfireProperties"/>
1420

1521
<gfe:local-region id="region1" cache-ref="gemfire-cache-2"/>
1622

spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStoreTests.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,48 +19,54 @@
1919
import static org.junit.Assert.assertNull;
2020
import static org.junit.Assert.fail;
2121

22+
import java.util.Properties;
23+
2224
import org.junit.After;
2325
import org.junit.AfterClass;
2426
import org.junit.Before;
2527
import org.junit.BeforeClass;
2628
import org.junit.Test;
2729

30+
import org.springframework.data.gemfire.CacheFactoryBean;
2831
import org.springframework.data.gemfire.GemfireTemplate;
2932
import org.springframework.integration.metadata.ConcurrentMetadataStore;
30-
import org.springframework.util.Assert;
3133

3234
import com.gemstone.gemfire.cache.Cache;
33-
import com.gemstone.gemfire.cache.CacheFactory;
3435
import com.gemstone.gemfire.cache.Region;
3536

3637
/**
3738
* @author Artem Bilan
39+
*
3840
* @since 4.0
3941
*
4042
*/
4143
public class GemfireMetadataStoreTests {
4244

43-
private static Cache cache;
45+
private static CacheFactoryBean cacheFactoryBean;
4446

4547
private static ConcurrentMetadataStore metadataStore;
4648

4749
private static Region<Object, Object> region;
4850

4951
@BeforeClass
5052
public static void startUp() throws Exception {
51-
cache = new CacheFactory().create();
53+
cacheFactoryBean = new CacheFactoryBean();
54+
Properties gemfireProperties = new Properties();
55+
gemfireProperties.setProperty("mcast-port", "0");
56+
cacheFactoryBean.setProperties(gemfireProperties);
57+
cacheFactoryBean.afterPropertiesSet();
58+
Cache cache = cacheFactoryBean.getObject();
5259
metadataStore = new GemfireMetadataStore(cache);
5360
region = cache.getRegion(GemfireMetadataStore.KEY);
5461
}
5562

5663
@AfterClass
57-
public static void cleanUp() {
64+
public static void cleanUp() throws Exception {
5865
if (region != null) {
5966
region.close();
6067
}
61-
if (cache != null) {
62-
cache.close();
63-
Assert.isTrue(cache.isClosed(), "Cache did not close after close() call");
68+
if (cacheFactoryBean != null) {
69+
cacheFactoryBean.destroy();
6470
}
6571
}
6672

spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/CacheWritingMessageHandlerTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
2222
import java.util.Collections;
2323
import java.util.HashMap;
2424
import java.util.Map;
25+
import java.util.Properties;
2526

2627
import org.junit.AfterClass;
2728
import org.junit.Before;
@@ -46,6 +47,7 @@
4647
* @author Gunnar Hillert
4748
* @author Gary Russell
4849
* @author Artem Bilan
50+
*
4951
* @since 2.1
5052
*/
5153
public class CacheWritingMessageHandlerTests {
@@ -57,6 +59,9 @@ public class CacheWritingMessageHandlerTests {
5759
@BeforeClass
5860
public static void startUp() throws Exception {
5961
cacheFactoryBean = new CacheFactoryBean();
62+
Properties gemfireProperties = new Properties();
63+
gemfireProperties.setProperty("mcast-port", "0");
64+
cacheFactoryBean.setProperties(gemfireProperties);
6065
cacheFactoryBean.afterPropertiesSet();
6166
Cache cache = cacheFactoryBean.getObject();
6267
region = cache.createRegionFactory().setScope(Scope.LOCAL).create("sig-tests");

spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests-context.xml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<beans xmlns="http://www.springframework.org/schema/beans"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xmlns:int-gfe="http://www.springframework.org/schema/integration/gemfire"
5-
xmlns:int="http://www.springframework.org/schema/integration"
6-
xmlns:gfe="http://www.springframework.org/schema/gemfire"
7-
xsi:schemaLocation="http://www.springframework.org/schema/integration/gemfire http://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire.xsd
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:int-gfe="http://www.springframework.org/schema/integration/gemfire"
5+
xmlns:int="http://www.springframework.org/schema/integration"
6+
xmlns:gfe="http://www.springframework.org/schema/gemfire"
7+
xmlns:util="http://www.springframework.org/schema/util"
8+
xsi:schemaLocation="http://www.springframework.org/schema/integration/gemfire http://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire.xsd
89
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
910
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
10-
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
11+
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
12+
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
1113

12-
<gfe:cache use-bean-factory-locator="false"/>
14+
<util:properties id="gemfireProperties">
15+
<prop key="mcast-port">0</prop>
16+
</util:properties>
17+
18+
<gfe:cache use-bean-factory-locator="false" properties-ref="gemfireProperties"/>
1319

1420
<gfe:replicated-region id="region1"/>
1521

spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/DelayerHandlerRescheduleIntegrationTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2016 the original author or authors.
2+
* Copyright 2013-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -19,6 +19,7 @@
1919
import static org.junit.Assert.assertTrue;
2020
import static org.junit.Assert.fail;
2121

22+
import java.util.Properties;
2223
import java.util.concurrent.TimeUnit;
2324

2425
import org.junit.AfterClass;
@@ -48,6 +49,7 @@
4849
/**
4950
* @author Artem Bilan
5051
* @author Gary Russell
52+
*
5153
* @since 3.0
5254
*/
5355
public class DelayerHandlerRescheduleIntegrationTests {
@@ -64,6 +66,9 @@ public class DelayerHandlerRescheduleIntegrationTests {
6466
@BeforeClass
6567
public static void startUp() throws Exception {
6668
cacheFactoryBean = new CacheFactoryBean();
69+
Properties gemfireProperties = new Properties();
70+
gemfireProperties.setProperty("mcast-port", "0");
71+
cacheFactoryBean.setProperties(gemfireProperties);
6772
cacheFactoryBean.afterPropertiesSet();
6873
Cache cache = cacheFactoryBean.getObject();
6974
region = cache.createRegionFactory().setScope(Scope.LOCAL).create("sig-tests");

spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireGroupStoreTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2007-2015 the original author or authors
2+
* Copyright 2007-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -377,6 +377,9 @@ public void prepare() {
377377
@BeforeClass
378378
public static void init() throws Exception {
379379
cacheFactoryBean = new CacheFactoryBean();
380+
Properties gemfireProperties = new Properties();
381+
gemfireProperties.setProperty("mcast-port", "0");
382+
cacheFactoryBean.setProperties(gemfireProperties);
380383
cacheFactoryBean.afterPropertiesSet();
381384
Cache cache = cacheFactoryBean.getObject();
382385
region = cache.createRegionFactory().setScope(Scope.LOCAL).create("sig-tests");

spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireMessageStoreTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,6 +48,7 @@
4848
* @author David Turanski
4949
* @author Gary Russell
5050
* @author Artem Bilan
51+
*
5152
* @since 2.1
5253
*/
5354
public class GemfireMessageStoreTests {
@@ -133,6 +134,10 @@ public void prepare() {
133134
@BeforeClass
134135
public static void init() throws Exception {
135136
cacheFactoryBean = new CacheFactoryBean();
137+
Properties gemfireProperties = new Properties();
138+
gemfireProperties.setProperty("mcast-port", "0");
139+
cacheFactoryBean.setProperties(gemfireProperties);
140+
cacheFactoryBean.afterPropertiesSet();
136141
Cache cache = cacheFactoryBean.getObject();
137142
region = cache.createRegionFactory().setScope(Scope.LOCAL).create("sig-tests");
138143
}

0 commit comments

Comments
 (0)