diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/InboundChannelAdapterExpressionTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/InboundChannelAdapterExpressionTests-context.xml index 7a20bf4f3b..ad94efa2c8 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/InboundChannelAdapterExpressionTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/InboundChannelAdapterExpressionTests-context.xml @@ -41,7 +41,7 @@ - + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/InboundChannelAdapterExpressionTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/InboundChannelAdapterExpressionTests.java index 0b21a52c4f..ca7c472f34 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/InboundChannelAdapterExpressionTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/InboundChannelAdapterExpressionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -20,8 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.annotation.Autowired; @@ -32,8 +31,8 @@ import org.springframework.integration.test.util.TestUtils; import org.springframework.scheduling.Trigger; import org.springframework.scheduling.support.CronTrigger; import org.springframework.scheduling.support.PeriodicTrigger; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * @author Mark Fisher @@ -41,8 +40,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * * @since 2.0 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig +@DirtiesContext public class InboundChannelAdapterExpressionTests { @Autowired diff --git a/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/channel/SubscribableKafkaChannel.java b/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/channel/SubscribableKafkaChannel.java index 55f6020d45..a0d1e28543 100644 --- a/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/channel/SubscribableKafkaChannel.java +++ b/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/channel/SubscribableKafkaChannel.java @@ -113,18 +113,7 @@ public class SubscribableKafkaChannel extends AbstractKafkaChannel implements Su String groupId = getGroupId(); ContainerProperties containerProperties = this.container.getContainerProperties(); containerProperties.setGroupId(groupId != null ? groupId : getBeanName()); - containerProperties.setMessageListener( - new RecordMessagingMessageListenerAdapter(null, null) { // NOSONAR - out of use - - @Override - public void onMessage(ConsumerRecord record, Acknowledgment acknowledgment, - Consumer consumer) { - - SubscribableKafkaChannel.this.dispatcher - .dispatch(toMessagingMessage(record, acknowledgment, consumer)); - } - - }); + containerProperties.setMessageListener(new IntegrationRecordMessageListener()); } protected MessageDispatcher createDispatcher() { @@ -163,4 +152,20 @@ public class SubscribableKafkaChannel extends AbstractKafkaChannel implements Su return this.dispatcher.removeHandler(handler); } + + private class IntegrationRecordMessageListener extends RecordMessagingMessageListenerAdapter { + + IntegrationRecordMessageListener() { + super(null, null); // NOSONAR - out of use + } + + @Override + public void onMessage(ConsumerRecord record, Acknowledgment acknowledgment, + Consumer consumer) { + + SubscribableKafkaChannel.this.dispatcher.dispatch(toMessagingMessage(record, acknowledgment, consumer)); + } + + } + }