Improve Hazelcast test suite performance
* Add recommended JVM args to the Gradle module for HZ performance * Move `IdempotentReceiverIntegrationTests` from JMX module to HZ for consistency * Remove component scan from the `HazelcastIntegrationOutboundTestConfiguration` - redundant * Use `HazelcastInstance.shutdown()` during normal context lifecycle. The `@AfterClass` may happen early, so the `stop()` of the channel adapters may fail with an exception that HZ is not available causing the `LifecycleProcessor` to wait for 30 seconds on the lifecycle barrier * Wrap `AbstractEndpoint.doStop()` call into `try..catch` to log error instead of re-throwing to avoid the mentioned above 30 secs delay of the application context stop
This commit is contained in:
30
build.gradle
30
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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<constructor-arg value="distList"/>
|
||||
</bean>
|
||||
|
||||
<bean id="hzInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance">
|
||||
<bean id="hzInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance" destroy-method="shutdown">
|
||||
<constructor-arg>
|
||||
<bean class="com.hazelcast.config.Config">
|
||||
<property name="instanceName" value="Test_Hazelcast_Instance"/>
|
||||
|
||||
@@ -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<String>("baz"));
|
||||
try {
|
||||
this.annotatedBeanMessageHandlerChannel2.send(new GenericMessage<String>("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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
<bean id="instance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance">
|
||||
<bean id="instance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance" destroy-method="shutdown">
|
||||
<constructor-arg>
|
||||
<bean class="com.hazelcast.config.Config">
|
||||
<property name="CPSubsystemConfig">
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user