Class RabbitListenerTestHarness
java.lang.Object
org.springframework.amqp.listener.AbstractListenerAnnotationBeanPostProcessor<RabbitListener>
org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor
org.springframework.amqp.rabbit.test.RabbitListenerTestHarness
- All Implemented Interfaces:
Aware, BeanClassLoaderAware, BeanFactoryAware, BeanPostProcessor, SmartInitializingSingleton, EnvironmentAware, Ordered
BeanPostProcessor extending
RabbitListenerAnnotationBeanPostProcessor.
Wraps the listener bean in a CGLIB proxy with an advice to capture the arguments
and result (if any) in a blocking queue. Test cases can access the results
by autowiring the test harness into test cases.- Since:
- 1.6
- Author:
- Gary Russell, Artem Bilan, Miguel Gross Valle
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class AbstractListenerAnnotationBeanPostProcessor
AbstractListenerAnnotationBeanPostProcessor.ListenerMethod<A>, AbstractListenerAnnotationBeanPostProcessor.TypeMetadata<A> -
Field Summary
Fields inherited from class RabbitListenerAnnotationBeanPostProcessor
DEFAULT_RABBIT_LISTENER_CONTAINER_FACTORY_BEAN_NAME, RABBIT_EMPTY_STRING_ARGUMENTS_PROPERTYFields inherited from class AbstractListenerAnnotationBeanPostProcessor
CONVERSION_SERVICE, typeCacheFields inherited from interface Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> @Nullable TgetDelegate(String id) Get the actual listener object (not the spy).<T> LambdaAnswer<T> getLambdaAnswerFor(String id, boolean callRealMethod, LambdaAnswer.ValueToReturn<T> callback) Return aLambdaAnswerthat is properly configured to invoke the listener.getLatchAnswerFor(String id, int count) Return aLatchCountDownAndCallRealMethodAnswerthat is properly configured to invoke the listener.@Nullable RabbitListenerTestHarness.InvocationDatagetNextInvocationDataFor(String id, long wait, TimeUnit unit) <T> @Nullable Tprotected Collection<Declarable> processListener(MethodRabbitListenerEndpoint endpoint, RabbitListener rabbitListener, Object bean, Object target, String beanName) Methods inherited from class RabbitListenerAnnotationBeanPostProcessor
afterSingletonsInstantiated, buildMetadata, doProcessAmqpListener, processAmqpListener, processMultiMethodListeners, setCharset, setContainerFactoryBeanName, setEndpointRegistry, setEnvironment, setMessageHandlerMethodFactoryMethods inherited from class AbstractListenerAnnotationBeanPostProcessor
buildMetadata, checkProxy, getBeanClassLoader, getBeanFactory, getOrder, noBeanFoundMessage, postProcessAfterInitialization, resolveExpression, resolveExpressionAsBoolean, resolveExpressionAsBoolean, resolveExpressionAsString, resolveExpressionAsStringOrInteger, resolveExpressionToBean, resolveExpressionToInteger, setBeanClassLoader, setBeanFactory, toDuration, toDurationMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BeanPostProcessor
postProcessBeforeInitialization
-
Constructor Details
-
RabbitListenerTestHarness
-
-
Method Details
-
processListener
protected Collection<Declarable> processListener(MethodRabbitListenerEndpoint endpoint, RabbitListener rabbitListener, Object bean, Object target, String beanName) - Overrides:
processListenerin classRabbitListenerAnnotationBeanPostProcessor
-
getLatchAnswerFor
Return aLatchCountDownAndCallRealMethodAnswerthat is properly configured to invoke the listener.- Parameters:
id- the listener id.count- the count.- Returns:
- the answer.
- Since:
- 2.1.16
-
getLambdaAnswerFor
public <T> LambdaAnswer<T> getLambdaAnswerFor(String id, boolean callRealMethod, LambdaAnswer.ValueToReturn<T> callback) Return aLambdaAnswerthat is properly configured to invoke the listener.- Type Parameters:
T- the return type.- Parameters:
id- the listener id.callRealMethod- true to call the real method.callback- the callback.- Returns:
- the answer.
- Since:
- 2.1.16
-
getNextInvocationDataFor
public @Nullable RabbitListenerTestHarness.InvocationData getNextInvocationDataFor(String id, long wait, TimeUnit unit) throws InterruptedException - Throws:
InterruptedException
-
getSpy
-
getDelegate
Get the actual listener object (not the spy).- Type Parameters:
T- the type.- Parameters:
id- the id.- Returns:
- the listener.
- Since:
- 2.1.16
-