Some test improvement; fix new Sonar smell
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
<poller trigger="customTrigger"/>
|
||||
</inbound-channel-adapter>
|
||||
|
||||
<inbound-channel-adapter id="expressionElement" channel="triggerRefChannel">
|
||||
<inbound-channel-adapter id="expressionElement" channel="triggerRefChannel" auto-startup="false">
|
||||
<poller fixed-delay="1000"/>
|
||||
<expression key="test.greeting"/>
|
||||
</inbound-channel-adapter>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Object, Object>(null, null) { // NOSONAR - out of use
|
||||
|
||||
@Override
|
||||
public void onMessage(ConsumerRecord<Object, Object> 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<Object, Object> {
|
||||
|
||||
IntegrationRecordMessageListener() {
|
||||
super(null, null); // NOSONAR - out of use
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(ConsumerRecord<Object, Object> record, Acknowledgment acknowledgment,
|
||||
Consumer<?, ?> consumer) {
|
||||
|
||||
SubscribableKafkaChannel.this.dispatcher.dispatch(toMessagingMessage(record, acknowledgment, consumer));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user