diff --git a/build.gradle b/build.gradle index c8d0932ef5..02272f9ed6 100644 --- a/build.gradle +++ b/build.gradle @@ -641,6 +641,26 @@ project('spring-integration-groovy') { } } +project('spring-integration-hazelcast') { + description = 'Spring Integration Hazelcast Support' + dependencies { + api project(':spring-integration-core') + api "com.hazelcast:hazelcast:$hazelcastVersion" + + testImplementation project(':spring-integration-jmx') + } + + tasks.withType(JavaForkOptions) { + jvmArgs '--add-modules', 'java.se', + '--add-exports', 'java.base/jdk.internal.ref=ALL-UNNAMED', + '--add-opens', 'java.base/java.lang=ALL-UNNAMED', + '--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED', + '--add-opens', 'java.management/sun.management=ALL-UNNAMED', + '--add-opens', 'jdk.management/com.sun.management.internal=ALL-UNNAMED', + '-Dhazelcast.logging.type=log4j2' + } +} + project('spring-integration-http') { description = 'Spring Integration HTTP Support' dependencies { @@ -722,7 +742,6 @@ project('spring-integration-jmx') { api project(':spring-integration-core') testImplementation "org.aspectj:aspectjweaver:$aspectjVersion" - testImplementation "com.hazelcast:hazelcast:$hazelcastVersion" } } @@ -1080,15 +1099,6 @@ project('spring-integration-bom') { } } - -project('spring-integration-hazelcast') { - description = 'Spring Integration Hazelcast Support' - dependencies { - api "com.hazelcast:hazelcast:$hazelcastVersion" - api project(':spring-integration-core') - } -} - sonarqube { properties { property 'sonar.links.homepage', linkHomepage diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java index d68930047c..f674ce2bad 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -204,7 +204,12 @@ public abstract class AbstractEndpoint extends IntegrationObjectSupport * @param callback the Runnable to invoke. */ protected void doStop(Runnable callback) { - doStop(); + try { + doStop(); + } + catch (Exception ex) { + logger.error(ex, "Error during stopping: " + this); + } callback.run(); } diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/HazelcastIntegrationDefinitionValidatorTests-context.xml b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/HazelcastIntegrationDefinitionValidatorTests-context.xml index b731b11b51..4b284dfbc7 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/HazelcastIntegrationDefinitionValidatorTests-context.xml +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/HazelcastIntegrationDefinitionValidatorTests-context.xml @@ -8,7 +8,7 @@ - + diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/IdempotentReceiverIntegrationTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/IdempotentReceiverIntegrationTests.java similarity index 83% rename from spring-integration-jmx/src/test/java/org/springframework/integration/monitor/IdempotentReceiverIntegrationTests.java rename to spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/IdempotentReceiverIntegrationTests.java index 74e6f3ab7d..4411f754f7 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/IdempotentReceiverIntegrationTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/IdempotentReceiverIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 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. @@ -14,10 +14,10 @@ * limitations under the License. */ -package org.springframework.integration.monitor; +package org.springframework.integration.hazelcast; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.Mockito.spy; import java.util.ArrayList; @@ -27,8 +27,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import org.aopalliance.aop.Advice; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -67,21 +66,21 @@ import org.springframework.messaging.support.ChannelInterceptor; import org.springframework.messaging.support.GenericMessage; import org.springframework.stereotype.Component; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.interceptor.TransactionInterceptor; import org.springframework.transaction.support.TransactionSynchronizationManager; -import com.hazelcast.config.Config; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; /** * @author Artem Bilan * @author Gary Russell + * * @since 4.1 */ -@RunWith(SpringRunner.class) +@SpringJUnitConfig @DirtiesContext public class IdempotentReceiverIntegrationTests { @@ -125,6 +124,7 @@ public class IdempotentReceiverIntegrationTests { private AtomicBoolean txSupplied; @Test + @SuppressWarnings("unchecked") public void testIdempotentReceiver() { this.idempotentReceiverInterceptor.setThrowExceptionOnRejection(true); TestUtils.getPropertyValue(this.store, "metadata", Map.class).clear(); @@ -133,25 +133,20 @@ public class IdempotentReceiverIntegrationTests { Message receive = this.output.receive(10000); assertThat(receive).isNotNull(); assertThat(this.adviceCalled.get()).isEqualTo(1); - assertThat(TestUtils.getPropertyValue(this.store, "metadata", Map.class).size()).isEqualTo(1); + assertThat(TestUtils.getPropertyValue(this.store, "metadata", Map.class)).hasSize(1); String foo = this.store.get("foo"); assertThat(foo).isEqualTo("FOO"); - try { - this.input.send(message); - fail("MessageRejectedException expected"); - } - catch (Exception e) { - assertThat(e).isInstanceOf(MessageRejectedException.class); - } + assertThatExceptionOfType(MessageRejectedException.class) + .isThrownBy(() -> this.input.send(message)); + this.idempotentReceiverInterceptor.setThrowExceptionOnRejection(false); this.input.send(message); receive = this.output.receive(10000); assertThat(receive).isNotNull(); assertThat(this.adviceCalled.get()).isEqualTo(2); - assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class)) - .isTrue(); - assertThat(TestUtils.getPropertyValue(store, "metadata", Map.class).size()).isEqualTo(1); + assertThat(receive.getHeaders()).containsEntry(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, true); + assertThat(TestUtils.getPropertyValue(store, "metadata", Map.class)).hasSize(1); assertThat(this.txSupplied.get()).isTrue(); } @@ -165,8 +160,7 @@ public class IdempotentReceiverIntegrationTests { assertThat(this.fooService.messages.size()).isEqualTo(2); assertThat(this.fooService.messages.get(1) - .getHeaders() - .get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class)).isTrue(); + .getHeaders()).containsEntry(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, true); } @Test @@ -177,23 +171,18 @@ public class IdempotentReceiverIntegrationTests { Message receive = replyChannel.receive(10000); assertThat(receive).isNotNull(); - assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isFalse(); + assertThat(receive.getHeaders()).doesNotContainKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE); this.annotatedBeanMessageHandlerChannel.send(message); receive = replyChannel.receive(10000); assertThat(receive).isNotNull(); - assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isTrue(); - assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class)) - .isTrue(); + assertThat(receive.getHeaders()).containsEntry(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, true); - this.annotatedBeanMessageHandlerChannel2.send(new GenericMessage("baz")); - try { - this.annotatedBeanMessageHandlerChannel2.send(new GenericMessage("baz")); - fail("MessageHandlingException expected"); - } - catch (Exception e) { - assertThat(e.getMessage()).contains("duplicate message has been received"); - } + this.annotatedBeanMessageHandlerChannel2.send(new GenericMessage<>("baz")); + + assertThatExceptionOfType(MessageHandlingException.class) + .isThrownBy(() -> this.annotatedBeanMessageHandlerChannel2.send(new GenericMessage<>("baz"))) + .withMessageContaining("duplicate message has been received"); } @@ -205,14 +194,12 @@ public class IdempotentReceiverIntegrationTests { Message receive = replyChannel.receive(10000); assertThat(receive).isNotNull(); - assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isFalse(); + assertThat(receive.getHeaders()).doesNotContainKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE); this.bridgeChannel.send(message); receive = replyChannel.receive(10000); assertThat(receive).isNotNull(); - assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isTrue(); - assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class)) - .isTrue(); + assertThat(receive.getHeaders()).containsEntry(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, true); } @Test @@ -222,14 +209,12 @@ public class IdempotentReceiverIntegrationTests { Message receive = this.bridgePollableChannel.receive(10000); assertThat(receive).isNotNull(); - assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isFalse(); + assertThat(receive.getHeaders()).doesNotContainKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE); this.toBridgeChannel.send(message); receive = this.bridgePollableChannel.receive(10000); assertThat(receive).isNotNull(); - assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isTrue(); - assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class)) - .isTrue(); + assertThat(receive.getHeaders()).containsEntry(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, true); } @Configuration @@ -242,9 +227,9 @@ public class IdempotentReceiverIntegrationTests { return new MBeanServerFactoryBean(); } - @Bean + @Bean(destroyMethod = "shutdown") public HazelcastInstance hazelcastInstance() { - return Hazelcast.newHazelcastInstance(new Config().setProperty("hazelcast.logging.type", "slf4j")); + return Hazelcast.newHazelcastInstance(); } diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/common-config.xml b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/common-config.xml index fe00317838..ff7256d52e 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/common-config.xml +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/common-config.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastCQDistributedMapInboundChannelAdapterTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastCQDistributedMapInboundChannelAdapterTests.java index 19cb8d98e9..36a226e5ab 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastCQDistributedMapInboundChannelAdapterTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastCQDistributedMapInboundChannelAdapterTests.java @@ -18,7 +18,6 @@ package org.springframework.integration.hazelcast.inbound; import static org.assertj.core.api.Assertions.assertThat; -import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -34,7 +33,6 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import com.hazelcast.core.EntryEventType; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; import com.hazelcast.map.IMap; /** @@ -79,11 +77,6 @@ public class HazelcastCQDistributedMapInboundChannelAdapterTests { @Autowired private IMap cqDistributedMap5; - @AfterClass - public static void shutdown() { - HazelcastInstanceFactory.terminateAll(); - } - @Test public void testContinuousQueryForOnlyADDEDEntryEvent() { HazelcastInboundChannelAdapterTestUtils diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedListEventDrivenInboundChannelAdapterTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedListEventDrivenInboundChannelAdapterTests.java index da756c846f..162b84a86a 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedListEventDrivenInboundChannelAdapterTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedListEventDrivenInboundChannelAdapterTests.java @@ -18,7 +18,6 @@ package org.springframework.integration.hazelcast.inbound; import static org.assertj.core.api.Assertions.assertThat; -import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -34,7 +33,6 @@ import org.springframework.test.context.junit4.SpringRunner; import com.hazelcast.collection.IList; import com.hazelcast.core.EntryEventType; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; /** * Hazelcast Distributed List Event Driven Inbound Channel Adapter Test Class @@ -66,11 +64,6 @@ public class HazelcastDistributedListEventDrivenInboundChannelAdapterTests { @Autowired private IList edDistributedList3; - @AfterClass - public static void shutdown() { - HazelcastInstanceFactory.terminateAll(); - } - @Test public void testEventDrivenForOnlyADDEDEntryEvent() { edDistributedList1.add(new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1")); diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedMapEventDrivenInboundChannelAdapterTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedMapEventDrivenInboundChannelAdapterTests.java index d4dcd0bb2f..00f8dbb6c8 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedMapEventDrivenInboundChannelAdapterTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedMapEventDrivenInboundChannelAdapterTests.java @@ -18,7 +18,6 @@ package org.springframework.integration.hazelcast.inbound; import static org.assertj.core.api.Assertions.assertThat; -import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -34,7 +33,6 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import com.hazelcast.core.EntryEventType; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; import com.hazelcast.map.IMap; /** @@ -73,11 +71,6 @@ public class HazelcastDistributedMapEventDrivenInboundChannelAdapterTests { @Autowired private IMap edDistributedMap4; - @AfterClass - public static void shutdown() { - HazelcastInstanceFactory.terminateAll(); - } - @Test public void testEventDrivenForOnlyADDEDEntryEvent() { HazelcastInboundChannelAdapterTestUtils diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedQueueEventDrivenInboundChannelAdapterTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedQueueEventDrivenInboundChannelAdapterTests.java index 42b00679a9..fe16d1c70c 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedQueueEventDrivenInboundChannelAdapterTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedQueueEventDrivenInboundChannelAdapterTests.java @@ -18,7 +18,6 @@ package org.springframework.integration.hazelcast.inbound; import static org.assertj.core.api.Assertions.assertThat; -import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -34,7 +33,6 @@ import org.springframework.test.context.junit4.SpringRunner; import com.hazelcast.collection.IQueue; import com.hazelcast.core.EntryEventType; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; /** * Hazelcast Distributed Queue Event Driven Inbound Channel Adapter Test @@ -66,11 +64,6 @@ public class HazelcastDistributedQueueEventDrivenInboundChannelAdapterTests { @Autowired private IQueue edDistributedQueue3; - @AfterClass - public static void shutdown() { - HazelcastInstanceFactory.terminateAll(); - } - @Test public void testEventDrivenForOnlyADDEDEntryEvent() { edDistributedQueue1 diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedSQLInboundChannelAdapterTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedSQLInboundChannelAdapterTests.java index f6193c677e..64dae02d1a 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedSQLInboundChannelAdapterTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedSQLInboundChannelAdapterTests.java @@ -16,7 +16,6 @@ package org.springframework.integration.hazelcast.inbound; -import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -27,7 +26,6 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; import com.hazelcast.map.IMap; /** @@ -66,11 +64,6 @@ public class HazelcastDistributedSQLInboundChannelAdapterTests { @Autowired private IMap dsDistributedMap4; - @AfterClass - public static void shutdown() { - HazelcastInstanceFactory.terminateAll(); - } - @Test public void testDistributedSQLForOnlyENTRYIterationType() { HazelcastInboundChannelAdapterTestUtils diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedSetEventDrivenInboundChannelAdapterTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedSetEventDrivenInboundChannelAdapterTests.java index c01e159f2a..d46da4a404 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedSetEventDrivenInboundChannelAdapterTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedSetEventDrivenInboundChannelAdapterTests.java @@ -18,7 +18,6 @@ package org.springframework.integration.hazelcast.inbound; import static org.assertj.core.api.Assertions.assertThat; -import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -34,7 +33,6 @@ import org.springframework.test.context.junit4.SpringRunner; import com.hazelcast.collection.ISet; import com.hazelcast.core.EntryEventType; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; /** * Hazelcast Distributed Set Event Driven Inbound Channel Adapter Test @@ -66,11 +64,6 @@ public class HazelcastDistributedSetEventDrivenInboundChannelAdapterTests { @Autowired private ISet edDistributedSet3; - @AfterClass - public static void shutdown() { - HazelcastInstanceFactory.terminateAll(); - } - @Test public void testEventDrivenForOnlyADDEDEntryEvent() { edDistributedSet1 diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedTopicEventDrivenInboundChannelAdapterTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedTopicEventDrivenInboundChannelAdapterTests.java index d8801f7832..0859956a1d 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedTopicEventDrivenInboundChannelAdapterTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastDistributedTopicEventDrivenInboundChannelAdapterTests.java @@ -16,7 +16,6 @@ package org.springframework.integration.hazelcast.inbound; -import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -27,7 +26,6 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; import com.hazelcast.topic.ITopic; /** @@ -48,11 +46,6 @@ public class HazelcastDistributedTopicEventDrivenInboundChannelAdapterTests { @Autowired private ITopic edDistributedTopic1; - @AfterClass - public static void shutdown() { - HazelcastInstanceFactory.terminateAll(); - } - @Test public void testEventDrivenForOnlyADDEDEntryEvent() { HazelcastInboundChannelAdapterTestUtils diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastMultiMapEventDrivenInboundChannelAdapterTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastMultiMapEventDrivenInboundChannelAdapterTests.java index 61e23b6623..a73674512d 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastMultiMapEventDrivenInboundChannelAdapterTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastMultiMapEventDrivenInboundChannelAdapterTests.java @@ -18,7 +18,6 @@ package org.springframework.integration.hazelcast.inbound; import static org.assertj.core.api.Assertions.assertThat; -import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -34,7 +33,6 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import com.hazelcast.core.EntryEventType; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; import com.hazelcast.multimap.MultiMap; /** @@ -68,11 +66,6 @@ public class HazelcastMultiMapEventDrivenInboundChannelAdapterTests { @Autowired private MultiMap edMultiMap3; - @AfterClass - public static void shutdown() { - HazelcastInstanceFactory.terminateAll(); - } - @Test public void testEventDrivenForOnlyADDEDEntryEvent() { edMultiMap1 diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastReplicatedMapEventDrivenInboundChannelAdapterTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastReplicatedMapEventDrivenInboundChannelAdapterTests.java index b2f2c44ebc..e523ea035f 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastReplicatedMapEventDrivenInboundChannelAdapterTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastReplicatedMapEventDrivenInboundChannelAdapterTests.java @@ -18,7 +18,6 @@ package org.springframework.integration.hazelcast.inbound; import static org.assertj.core.api.Assertions.assertThat; -import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -34,7 +33,6 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import com.hazelcast.core.EntryEventType; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; import com.hazelcast.replicatedmap.ReplicatedMap; /** @@ -73,11 +71,6 @@ public class HazelcastReplicatedMapEventDrivenInboundChannelAdapterTests { @Autowired private ReplicatedMap edReplicatedMap4; - @AfterClass - public static void shutdown() { - HazelcastInstanceFactory.terminateAll(); - } - @Test public void testEventDrivenForOnlyADDEDEntryEvent() { edReplicatedMap1 diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/config/HazelcastIntegrationInboundTestConfiguration.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/config/HazelcastIntegrationInboundTestConfiguration.java index 180dfbb013..980c955d11 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/config/HazelcastIntegrationInboundTestConfiguration.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/config/HazelcastIntegrationInboundTestConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.integration.hazelcast.inbound.config; -import org.junit.AfterClass; - import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.integration.annotation.InboundChannelAdapter; @@ -39,7 +37,6 @@ import com.hazelcast.collection.ISet; import com.hazelcast.config.Config; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; import com.hazelcast.map.IMap; import com.hazelcast.multimap.MultiMap; import com.hazelcast.replicatedmap.ReplicatedMap; @@ -55,11 +52,6 @@ import com.hazelcast.topic.ITopic; @EnableIntegration public class HazelcastIntegrationInboundTestConfiguration { - @AfterClass - public void shutdown() { - HazelcastInstanceFactory.terminateAll(); - } - @Bean public PollableChannel distributedMapChannel() { return new QueueChannel(); @@ -228,7 +220,7 @@ public class HazelcastIntegrationInboundTestConfiguration { return config; } - @Bean(destroyMethod = "") + @Bean(destroyMethod = "shutdown") public HazelcastInstance testHazelcastInstance() { return Hazelcast.newHazelcastInstance(hazelcastConfig()); } diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/leader/LeaderInitiatorTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/leader/LeaderInitiatorTests.java index 455e27501c..1e9a384548 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/leader/LeaderInitiatorTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/leader/LeaderInitiatorTests.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -46,7 +45,6 @@ import org.springframework.test.context.junit4.SpringRunner; import com.hazelcast.config.Config; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; /** * Tests for hazelcast leader election. @@ -74,11 +72,6 @@ public class LeaderInitiatorTests { @Autowired private LeaderInitiator initiator; - @AfterClass - public static void shutdown() { - HazelcastInstanceFactory.terminateAll(); - } - @Test public void testLeaderElections() throws Exception { assertThat(this.candidate.onGrantedLatch.await(5, TimeUnit.SECONDS)).isTrue(); @@ -230,7 +223,7 @@ public class LeaderInitiatorTests { return config; } - @Bean(destroyMethod = "") + @Bean(destroyMethod = "shutdown") public HazelcastInstance hazelcastInstance() { return Hazelcast.newHazelcastInstance(hazelcastConfig()); } diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/metadata/HazelcastMetadataStoreTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/metadata/HazelcastMetadataStoreTests.java index 58046227c2..be15a7607a 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/metadata/HazelcastMetadataStoreTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/metadata/HazelcastMetadataStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 the original author or authors. + * Copyright 2017-2022 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. @@ -52,7 +52,7 @@ public class HazelcastMetadataStoreTests { @AfterClass public static void destroy() { - instance.getLifecycleService().terminate(); + instance.shutdown(); } @Before diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/outbound/config/HazelcastIntegrationOutboundTestConfiguration.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/outbound/config/HazelcastIntegrationOutboundTestConfiguration.java index 5e979e388d..1a018a941f 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/outbound/config/HazelcastIntegrationOutboundTestConfiguration.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/outbound/config/HazelcastIntegrationOutboundTestConfiguration.java @@ -20,13 +20,9 @@ import java.util.List; import java.util.Queue; import java.util.Set; -import org.junit.AfterClass; - import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.expression.spel.standard.SpelExpressionParser; -import org.springframework.integration.annotation.IntegrationComponentScan; import org.springframework.integration.annotation.ServiceActivator; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.config.EnableIntegration; @@ -39,7 +35,6 @@ import org.springframework.messaging.MessageChannel; import com.hazelcast.core.DistributedObject; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.instance.impl.HazelcastInstanceFactory; import com.hazelcast.map.IMap; import com.hazelcast.multimap.MultiMap; import com.hazelcast.replicatedmap.ReplicatedMap; @@ -54,16 +49,9 @@ import com.hazelcast.topic.ITopic; * @since 6.0 */ @Configuration -@ComponentScan(basePackages = { "org.springframework.integration.hazelcast.*" }) @EnableIntegration -@IntegrationComponentScan("org.springframework.integration.hazelcast.outbound") public class HazelcastIntegrationOutboundTestConfiguration { - @AfterClass - public void terminate() { - HazelcastInstanceFactory.terminateAll(); - } - @Bean public MessageChannel distMapChannel() { return new DirectChannel(); @@ -144,7 +132,7 @@ public class HazelcastIntegrationOutboundTestConfiguration { return testHzInstance().getReplicatedMap("Replicated_Map1"); } - @Bean(destroyMethod = "") + @Bean(destroyMethod = "shutdown") public HazelcastInstance testHzInstance() { return Hazelcast.newHazelcastInstance(); } diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/store/HazelcastMessageStoreTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/store/HazelcastMessageStoreTests.java index 7cc308d40e..7b0fa42212 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/store/HazelcastMessageStoreTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/store/HazelcastMessageStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2021 the original author or authors. + * Copyright 2017-2022 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. @@ -60,7 +60,7 @@ public class HazelcastMessageStoreTests { @AfterClass public static void destroy() { - instance.getLifecycleService().terminate(); + instance.shutdown(); } @Before