1146 Fixed early initialization in StreamListenerAnnotationBeanPostProcessor
Removed autowiring from StreamListenerAnnotationBeanPostProcessor in favor of late-binding callbacks Fixed tests Resolves #1146
This commit is contained in:
@@ -23,7 +23,6 @@ import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
@@ -82,8 +81,8 @@ public class StreamListenerAnnotatedMethodArgumentsTests {
|
||||
SpringApplication.run(TestPojoWithInvalidInputAnnotatedArgument.class, "--server.port=0");
|
||||
fail("Exception expected: " + INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause().getMessage()).contains(INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -75,8 +74,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected: " + INPUT_AT_STREAM_LISTENER);
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause().getMessage()).contains(INPUT_AT_STREAM_LISTENER);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(INPUT_AT_STREAM_LISTENER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,8 +173,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected: " + RETURN_TYPE_MULTIPLE_OUTBOUND_SPECIFIED);
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause().getMessage()).contains(RETURN_TYPE_MULTIPLE_OUTBOUND_SPECIFIED);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(RETURN_TYPE_MULTIPLE_OUTBOUND_SPECIFIED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,8 +185,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected: " + RETURN_TYPE_NO_OUTBOUND_SPECIFIED);
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause().getMessage()).contains(RETURN_TYPE_NO_OUTBOUND_SPECIFIED);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(RETURN_TYPE_NO_OUTBOUND_SPECIFIED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,8 +197,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected: " + INVALID_INBOUND_NAME);
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause().getMessage()).contains(INVALID_INBOUND_NAME);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(INVALID_INBOUND_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,8 +209,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected: " + INVALID_OUTBOUND_NAME);
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause().getMessage()).contains(INVALID_OUTBOUND_NAME);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(INVALID_OUTBOUND_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,10 +221,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected on using invalid inbound name");
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause()).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThat(e.getCause())
|
||||
.hasMessageContaining(StreamListenerErrorMessages.INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(StreamListenerErrorMessages.INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,9 +233,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected on using invalid outbound name");
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause()).isInstanceOf(NoSuchBeanDefinitionException.class);
|
||||
assertThat(e.getCause()).hasMessageContaining("'invalid'");
|
||||
catch (NoSuchBeanDefinitionException e) {
|
||||
assertThat(e.getMessage()).contains("invalid");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,8 +245,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected: " + AMBIGUOUS_MESSAGE_HANDLER_METHOD_ARGUMENTS);
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause().getMessage()).contains(AMBIGUOUS_MESSAGE_HANDLER_METHOD_ARGUMENTS);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(AMBIGUOUS_MESSAGE_HANDLER_METHOD_ARGUMENTS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,8 +257,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected:" + AMBIGUOUS_MESSAGE_HANDLER_METHOD_ARGUMENTS);
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause().getMessage()).contains(AMBIGUOUS_MESSAGE_HANDLER_METHOD_ARGUMENTS);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(AMBIGUOUS_MESSAGE_HANDLER_METHOD_ARGUMENTS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,8 +269,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected: " + INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause().getMessage()).contains(INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,8 +281,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected:" + INVALID_OUTPUT_VALUES);
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause().getMessage()).startsWith(INVALID_OUTPUT_VALUES);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).startsWith(INVALID_OUTPUT_VALUES);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,8 +293,8 @@ public class StreamListenerHandlerMethodTests {
|
||||
"--spring.jmx.enabled=false");
|
||||
fail("Exception expected when inbound target is not set");
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause().getMessage()).contains(NO_INPUT_DESTINATION);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(NO_INPUT_DESTINATION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
@@ -62,7 +61,7 @@ public class StreamListenerWithAnnotatedInputOutputArgsTests {
|
||||
SpringApplication.run(TestInputOutputArgsWithMoreParameters.class, "--server.port=0");
|
||||
fail("Expected exception: " + INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
}
|
||||
}
|
||||
@@ -73,10 +72,8 @@ public class StreamListenerWithAnnotatedInputOutputArgsTests {
|
||||
SpringApplication.run(TestInputOutputArgsWithInvalidBindableTarget.class, "--server.port=0","--spring.jmx.enabled=false");
|
||||
fail("Exception expected on using invalid bindable target as method parameter");
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e.getCause()).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThat(e.getCause())
|
||||
.hasMessageContaining(StreamListenerErrorMessages.INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(StreamListenerErrorMessages.INVALID_DECLARATIVE_METHOD_PARAMETERS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
@@ -79,10 +78,8 @@ public class StreamListenerWithConditionsTest {
|
||||
context.close();
|
||||
fail("Context creation failure expected");
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e).hasRootCauseInstanceOf(IllegalArgumentException.class);
|
||||
assertThat(e.getCause())
|
||||
.hasMessageContaining(StreamListenerErrorMessages.CONDITION_ON_METHOD_RETURNING_VALUE);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(StreamListenerErrorMessages.CONDITION_ON_METHOD_RETURNING_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +92,8 @@ public class StreamListenerWithConditionsTest {
|
||||
context.close();
|
||||
fail("Context creation failure expected");
|
||||
}
|
||||
catch (BeanCreationException e) {
|
||||
assertThat(e).hasRootCauseInstanceOf(IllegalArgumentException.class);
|
||||
assertThat(e.getCause()).hasMessageContaining(StreamListenerErrorMessages.CONDITION_ON_DECLARATIVE_METHOD);
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).contains(StreamListenerErrorMessages.CONDITION_ON_DECLARATIVE_METHOD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user