Fix BeanFactory propagation for MMInvokerHelper (#2694)
* Fix BeanFactory propagation for MMInvokerHelper * Remove check for `null` in the `MessagingMethodInvokerHelper.isProvidedMessageHandlerFactoryBean()` * Fix `RecipientListRouter` for `BeanFactory` propagation to the `Recipient.selector` * Fix tests for `BeanFactory` population and propagation * Add `errorChannel` into the `TestUtils.createTestApplicationContext()` * Fix some Sonar smell, including new reported * * Restore NPE check for the `BeanFactory` in the `MessagingMethodInvokerHelper` to avoid breaking changes in the current point release * Some other polishing and optimizations in the `MessagingMethodInvokerHelper`
This commit is contained in:
committed by
Gary Russell
parent
63684e2012
commit
eed16f02ca
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -170,6 +170,8 @@ public class ApplicationEventListeningMessageProducerTests {
|
||||
Message<?> message3 = channel.receive(20);
|
||||
assertNotNull(message3);
|
||||
assertEquals("received: event2", message3.getPayload());
|
||||
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -180,7 +182,7 @@ public class ApplicationEventListeningMessageProducerTests {
|
||||
adapter.start();
|
||||
Message<?> message1 = channel.receive(0);
|
||||
assertNull(message1);
|
||||
adapter.onApplicationEvent(new MessagingEvent(new GenericMessage<String>("test")));
|
||||
adapter.onApplicationEvent(new MessagingEvent(new GenericMessage<>("test")));
|
||||
Message<?> message2 = channel.receive(20);
|
||||
assertNotNull(message2);
|
||||
assertEquals("test", message2.getPayload());
|
||||
@@ -194,7 +196,7 @@ public class ApplicationEventListeningMessageProducerTests {
|
||||
adapter.start();
|
||||
Message<?> message1 = channel.receive(0);
|
||||
assertNull(message1);
|
||||
adapter.onApplicationEvent(new TestMessagingEvent(new GenericMessage<String>("test")));
|
||||
adapter.onApplicationEvent(new TestMessagingEvent(new GenericMessage<>("test")));
|
||||
Message<?> message2 = channel.receive(20);
|
||||
assertNotNull(message2);
|
||||
assertEquals("test", message2.getPayload());
|
||||
@@ -204,6 +206,7 @@ public class ApplicationEventListeningMessageProducerTests {
|
||||
public void anyApplicationEventCausesExceptionWithErrorHandling() {
|
||||
DirectChannel channel = new DirectChannel();
|
||||
channel.subscribe(new AbstractReplyProducingMessageHandler() {
|
||||
|
||||
@Override
|
||||
protected Object handleRequestMessage(Message<?> requestMessage) {
|
||||
throw new RuntimeException("Failed");
|
||||
@@ -223,7 +226,7 @@ public class ApplicationEventListeningMessageProducerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"unchecked", "serial"})
|
||||
@SuppressWarnings({ "unchecked", "serial" })
|
||||
public void testInt2935CheckRetrieverCache() {
|
||||
GenericApplicationContext ctx = TestUtils.createTestApplicationContext();
|
||||
ConfigurableListableBeanFactory beanFactory = ctx.getBeanFactory();
|
||||
@@ -278,6 +281,7 @@ public class ApplicationEventListeningMessageProducerTests {
|
||||
}
|
||||
|
||||
ctx.publishEvent(new ApplicationEvent("Some event") {
|
||||
|
||||
});
|
||||
|
||||
assertEquals(4, listenerCounter.get());
|
||||
|
||||
Reference in New Issue
Block a user