Repository: camel Updated Branches: refs/heads/master 6fce772f2 -> 2684ad7ed
CAMEL-10326: Hazelcast aggregation repository tests may fail if multiple network interfaces are configured on th host Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2684ad7e Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2684ad7e Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2684ad7e Branch: refs/heads/master Commit: 2684ad7ed9682b3094de9d80c01e3640eadc6f15 Parents: 6fce772 Author: lburgazzoli <lburgazz...@gmail.com> Authored: Fri Sep 16 12:04:02 2016 +0200 Committer: lburgazzoli <lburgazz...@gmail.com> Committed: Fri Sep 16 12:04:19 2016 +0200 ---------------------------------------------------------------------- ...stAggregationRepositoryCamelTestSupport.java | 24 ++++++++++---------- ...castAggregationRepositoryOperationsTest.java | 15 ++++++++---- 2 files changed, 23 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/2684ad7e/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryCamelTestSupport.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryCamelTestSupport.java b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryCamelTestSupport.java index 5efb98b..0f55471 100644 --- a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryCamelTestSupport.java +++ b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryCamelTestSupport.java @@ -28,16 +28,6 @@ public class HazelcastAggregationRepositoryCamelTestSupport extends CamelTestSup private static HazelcastInstance hzOne; private static HazelcastInstance hzTwo; - protected static void doInitializeHazelcastInstances() { - hzOne = Hazelcast.newHazelcastInstance(new Config("hzOne")); - hzTwo = Hazelcast.newHazelcastInstance(new Config("hzTwo")); - } - - protected static void doDestroyHazelcastInstances() { - hzOne.getLifecycleService().shutdown(); - hzTwo.getLifecycleService().shutdown(); - } - protected static HazelcastInstance getFirstInstance() { return hzOne; } @@ -48,11 +38,21 @@ public class HazelcastAggregationRepositoryCamelTestSupport extends CamelTestSup @BeforeClass public static void setUpHazelcastCluster() { - doInitializeHazelcastInstances(); + hzOne = Hazelcast.newHazelcastInstance(createConfig("hzOne")); + hzTwo = Hazelcast.newHazelcastInstance(createConfig("hzTwo")); } @AfterClass public static void shutDownHazelcastCluster() { - doDestroyHazelcastInstances(); + Hazelcast.shutdownAll(); + } + + private static Config createConfig(String name) { + Config config = new Config(); + config.setInstanceName(name); + config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false); + config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true).addMember("127.0.0.1"); + + return config; } } http://git-wip-us.apache.org/repos/asf/camel/blob/2684ad7e/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryOperationsTest.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryOperationsTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryOperationsTest.java index 59d38bf..651cd75 100644 --- a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryOperationsTest.java +++ b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryOperationsTest.java @@ -49,6 +49,7 @@ public class HazelcastAggregationRepositoryOperationsTest extends HazelcastAggre Exchange theNewestEx = createExchangeWithBody(theNewestBody); oldEx = repoTwo.add(context(), key, newEx, theNewestEx); + assertNotNull("oldEx is null", oldEx); assertEquals(newEx.getIn().getBody(), oldEx.getIn().getBody()); } finally { @@ -77,6 +78,7 @@ public class HazelcastAggregationRepositoryOperationsTest extends HazelcastAggre Exchange theNewestEx = createExchangeWithBody(theNewestBody); oldEx = repoTwo.add(context(), key, theNewestEx); + assertNotNull("oldEx is null", oldEx); assertEquals(newEx.getIn().getBody(), oldEx.getIn().getBody()); } finally { @@ -90,8 +92,8 @@ public class HazelcastAggregationRepositoryOperationsTest extends HazelcastAggre HazelcastAggregationRepository repoOne = new HazelcastAggregationRepository(THREAD_SAFE_REPO, true, getFirstInstance()); HazelcastAggregationRepository repoTwo = new HazelcastAggregationRepository(THREAD_SAFE_REPO, true, getSecondInstance()); try { - repoOne.doStart(); - repoTwo.doStart(); + repoOne.start(); + repoTwo.start(); final String testBody = "This is an optimistic test body. Sincerely yours, Captain Obvious."; final String key = "optimisticKey"; @@ -99,7 +101,11 @@ public class HazelcastAggregationRepositoryOperationsTest extends HazelcastAggre Exchange ex = createExchangeWithBody(testBody); repoOne.add(context(), key, null, ex); + assertEquals(1, getFirstInstance().getMap(THREAD_SAFE_REPO).size()); + assertEquals(1, getSecondInstance().getMap(THREAD_SAFE_REPO).size()); + Exchange gotEx = repoTwo.get(context(), key); + assertNotNull("gotEx is null", gotEx); assertEquals("ex and gotEx should be equal", gotEx.getIn().getBody(), ex.getIn().getBody()); } finally { repoOne.doStop(); @@ -113,8 +119,8 @@ public class HazelcastAggregationRepositoryOperationsTest extends HazelcastAggre HazelcastAggregationRepository repoTwo = new HazelcastAggregationRepository(OPTIMISTIC_REPO, false, getSecondInstance()); try { - repoOne.doStart(); - repoTwo.doStart(); + repoOne.start(); + repoTwo.start(); final String testBody = "This is a thread-safe test body. Sincerely yours, Captain Obvious."; @@ -124,6 +130,7 @@ public class HazelcastAggregationRepositoryOperationsTest extends HazelcastAggre repoOne.add(context(), key, ex); Exchange gotEx = repoTwo.get(context(), key); + assertNotNull("gotEx is null", gotEx); assertEquals("ex and gotEx should be equal", gotEx.getIn().getBody(), ex.getIn().getBody()); } finally { repoOne.doStop();