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:
@@ -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"/>
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.hazelcast;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.MessageRejectedException;
|
||||
import org.springframework.integration.annotation.BridgeFrom;
|
||||
import org.springframework.integration.annotation.BridgeTo;
|
||||
import org.springframework.integration.annotation.IdempotentReceiver;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.config.GlobalChannelInterceptor;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.handler.ServiceActivatingHandler;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.handler.advice.IdempotentReceiverInterceptor;
|
||||
import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport;
|
||||
import org.springframework.integration.metadata.ConcurrentMetadataStore;
|
||||
import org.springframework.integration.metadata.MetadataStore;
|
||||
import org.springframework.integration.metadata.SimpleMetadataStore;
|
||||
import org.springframework.integration.selector.MetadataStoreSelector;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.transaction.PseudoTransactionManager;
|
||||
import org.springframework.integration.transaction.TransactionInterceptorBuilder;
|
||||
import org.springframework.integration.transformer.Transformer;
|
||||
import org.springframework.jmx.support.MBeanServerFactoryBean;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
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.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.interceptor.TransactionInterceptor;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import com.hazelcast.core.Hazelcast;
|
||||
import com.hazelcast.core.HazelcastInstance;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class IdempotentReceiverIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private MessageChannel input;
|
||||
|
||||
@Autowired
|
||||
private PollableChannel output;
|
||||
|
||||
@Autowired
|
||||
private MetadataStore store;
|
||||
|
||||
@Autowired
|
||||
private IdempotentReceiverInterceptor idempotentReceiverInterceptor;
|
||||
|
||||
@Autowired
|
||||
private AtomicInteger adviceCalled;
|
||||
|
||||
@Autowired
|
||||
private MessageChannel annotatedMethodChannel;
|
||||
|
||||
@Autowired
|
||||
private FooService fooService;
|
||||
|
||||
@Autowired
|
||||
private MessageChannel annotatedBeanMessageHandlerChannel;
|
||||
|
||||
@Autowired
|
||||
private MessageChannel annotatedBeanMessageHandlerChannel2;
|
||||
|
||||
@Autowired
|
||||
private MessageChannel bridgeChannel;
|
||||
|
||||
@Autowired
|
||||
private MessageChannel toBridgeChannel;
|
||||
|
||||
@Autowired
|
||||
private PollableChannel bridgePollableChannel;
|
||||
|
||||
@Autowired
|
||||
private AtomicBoolean txSupplied;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testIdempotentReceiver() {
|
||||
this.idempotentReceiverInterceptor.setThrowExceptionOnRejection(true);
|
||||
TestUtils.getPropertyValue(this.store, "metadata", Map.class).clear();
|
||||
Message<String> message = new GenericMessage<>("foo");
|
||||
this.input.send(message);
|
||||
Message<?> receive = this.output.receive(10000);
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(this.adviceCalled.get()).isEqualTo(1);
|
||||
assertThat(TestUtils.getPropertyValue(this.store, "metadata", Map.class)).hasSize(1);
|
||||
String foo = this.store.get("foo");
|
||||
assertThat(foo).isEqualTo("FOO");
|
||||
|
||||
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()).containsEntry(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, true);
|
||||
assertThat(TestUtils.getPropertyValue(store, "metadata", Map.class)).hasSize(1);
|
||||
|
||||
assertThat(this.txSupplied.get()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdempotentReceiverOnMethod() {
|
||||
TestUtils.getPropertyValue(this.store, "metadata", Map.class).clear();
|
||||
Message<String> message = new GenericMessage<>("foo");
|
||||
this.annotatedMethodChannel.send(message);
|
||||
this.annotatedMethodChannel.send(message);
|
||||
|
||||
assertThat(this.fooService.messages.size()).isEqualTo(2);
|
||||
assertThat(this.fooService.messages.get(1)
|
||||
.getHeaders()).containsEntry(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdempotentReceiverOnBeanMessageHandler() {
|
||||
PollableChannel replyChannel = new QueueChannel();
|
||||
Message<String> message = MessageBuilder.withPayload("bar").setReplyChannel(replyChannel).build();
|
||||
this.annotatedBeanMessageHandlerChannel.send(message);
|
||||
|
||||
Message<?> receive = replyChannel.receive(10000);
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders()).doesNotContainKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE);
|
||||
|
||||
this.annotatedBeanMessageHandlerChannel.send(message);
|
||||
receive = replyChannel.receive(10000);
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders()).containsEntry(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, true);
|
||||
|
||||
this.annotatedBeanMessageHandlerChannel2.send(new GenericMessage<>("baz"));
|
||||
|
||||
assertThatExceptionOfType(MessageHandlingException.class)
|
||||
.isThrownBy(() -> this.annotatedBeanMessageHandlerChannel2.send(new GenericMessage<>("baz")))
|
||||
.withMessageContaining("duplicate message has been received");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIdempotentReceiverOnBridgeTo() {
|
||||
PollableChannel replyChannel = new QueueChannel();
|
||||
Message<String> message = MessageBuilder.withPayload("bridgeTo").setReplyChannel(replyChannel).build();
|
||||
this.bridgeChannel.send(message);
|
||||
|
||||
Message<?> receive = replyChannel.receive(10000);
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders()).doesNotContainKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE);
|
||||
|
||||
this.bridgeChannel.send(message);
|
||||
receive = replyChannel.receive(10000);
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders()).containsEntry(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdempotentReceiverOnBridgeFrom() {
|
||||
Message<String> message = MessageBuilder.withPayload("bridgeFrom").build();
|
||||
this.toBridgeChannel.send(message);
|
||||
|
||||
Message<?> receive = this.bridgePollableChannel.receive(10000);
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders()).doesNotContainKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE);
|
||||
|
||||
this.toBridgeChannel.send(message);
|
||||
receive = this.bridgePollableChannel.receive(10000);
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders()).containsEntry(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, true);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableIntegration
|
||||
@EnableIntegrationMBeanExport(server = "mBeanServer")
|
||||
public static class ContextConfiguration {
|
||||
|
||||
@Bean
|
||||
public static MBeanServerFactoryBean mBeanServer() {
|
||||
return new MBeanServerFactoryBean();
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
public HazelcastInstance hazelcastInstance() {
|
||||
return Hazelcast.newHazelcastInstance();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public ConcurrentMetadataStore store() {
|
||||
return new SimpleMetadataStore(
|
||||
hazelcastInstance()
|
||||
.getMap("idempotentReceiverMetadataStore"));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IdempotentReceiverInterceptor idempotentReceiverInterceptor() {
|
||||
return new IdempotentReceiverInterceptor(
|
||||
new MetadataStoreSelector(
|
||||
message -> message.getPayload().toString(),
|
||||
message -> message.getPayload().toString().toUpperCase(), store()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PlatformTransactionManager transactionManager() {
|
||||
return spy(new PseudoTransactionManager());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TransactionInterceptor transactionInterceptor() {
|
||||
return new TransactionInterceptorBuilder(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageChannel input() {
|
||||
return new DirectChannel();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PollableChannel output() {
|
||||
return new QueueChannel();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AtomicBoolean txSupplied() {
|
||||
return new AtomicBoolean();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@GlobalChannelInterceptor(patterns = "output")
|
||||
public ChannelInterceptor txSuppliedChannelInterceptor(final AtomicBoolean txSupplied) {
|
||||
return new ChannelInterceptor() {
|
||||
|
||||
@Override
|
||||
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
|
||||
txSupplied.set(TransactionSynchronizationManager.isActualTransactionActive());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
@org.springframework.integration.annotation.Transformer(inputChannel = "input",
|
||||
outputChannel = "output",
|
||||
adviceChain = { "fooAdvice",
|
||||
"idempotentReceiverInterceptor",
|
||||
"transactionInterceptor" })
|
||||
public Transformer transformer() {
|
||||
return message -> message;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AtomicInteger adviceCalled() {
|
||||
return new AtomicInteger();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Advice fooAdvice(@SuppressWarnings("unused") final AtomicInteger adviceCalled) {
|
||||
return new AbstractRequestHandlerAdvice() {
|
||||
|
||||
@Override
|
||||
protected Object doInvoke(ExecutionCallback callback, Object target, Message<?> message) {
|
||||
adviceCalled.incrementAndGet();
|
||||
return callback.execute();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageChannel annotatedMethodChannel() {
|
||||
return new DirectChannel();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FooService fooService() {
|
||||
return new FooService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@BridgeTo
|
||||
@IdempotentReceiver("idempotentReceiverInterceptor")
|
||||
public MessageChannel bridgeChannel() {
|
||||
return new DirectChannel();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@BridgeFrom("toBridgeChannel")
|
||||
@IdempotentReceiver("idempotentReceiverInterceptor")
|
||||
public PollableChannel bridgePollableChannel() {
|
||||
return new QueueChannel();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ServiceActivator(inputChannel = "annotatedBeanMessageHandlerChannel")
|
||||
@IdempotentReceiver("idempotentReceiverInterceptor")
|
||||
public MessageHandler messageHandler() {
|
||||
return new ServiceActivatingHandler((MessageProcessor<Object>) message -> message);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ServiceActivator(inputChannel = "annotatedBeanMessageHandlerChannel2")
|
||||
@IdempotentReceiver("idempotentReceiverInterceptor")
|
||||
public MessageHandler messageHandler2() {
|
||||
return message -> {
|
||||
if (message.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)) {
|
||||
throw new MessageHandlingException(message, "duplicate message has been received");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component
|
||||
private static class FooService {
|
||||
|
||||
private final List<Message<?>> messages = new ArrayList<Message<?>>();
|
||||
|
||||
@ServiceActivator(inputChannel = "annotatedMethodChannel")
|
||||
@IdempotentReceiver("idempotentReceiverInterceptor")
|
||||
public void handle(Message<?> message) {
|
||||
this.messages.add(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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