|
47 | 47 | * by autowiring the test harness into test cases.
|
48 | 48 | *
|
49 | 49 | * @author Gary Russell
|
| 50 | + * @author Artem Bilan |
| 51 | + * |
50 | 52 | * @since 1.6
|
51 | 53 | *
|
52 | 54 | */
|
53 | 55 | public class RabbitListenerTestHarness extends RabbitListenerAnnotationBeanPostProcessor {
|
54 | 56 |
|
55 | 57 | private final Log logger = LogFactory.getLog(this.getClass());
|
56 | 58 |
|
57 |
| - private final Map<String, CaptureAdvice> listenerCapture = new HashMap<String, CaptureAdvice>(); |
| 59 | + private final Map<String, CaptureAdvice> listenerCapture = new HashMap<>(); |
58 | 60 |
|
59 |
| - private final AnnotationAttributes attributes; |
| 61 | + private final Map<String, Object> listeners = new HashMap<>(); |
60 | 62 |
|
61 |
| - private final Map<String, Object> listeners = new HashMap<String, Object>(); |
| 63 | + private final AnnotationAttributes attributes; |
62 | 64 |
|
63 | 65 | public RabbitListenerTestHarness(AnnotationMetadata importMetadata) {
|
64 | 66 | Map<String, Object> map = importMetadata.getAnnotationAttributes(RabbitListenerTest.class.getName());
|
@@ -112,33 +114,37 @@ public <T> T getSpy(String id) {
|
112 | 114 | return (T) this.listeners.get(id);
|
113 | 115 | }
|
114 | 116 |
|
| 117 | + @Override |
| 118 | + public int getOrder() { |
| 119 | + return super.getOrder() - 100; |
| 120 | + } |
| 121 | + |
115 | 122 | private static final class CaptureAdvice implements MethodInterceptor {
|
116 | 123 |
|
117 |
| - private final BlockingQueue<InvocationData> invocationData = new LinkedBlockingQueue<InvocationData>(); |
| 124 | + private final BlockingQueue<InvocationData> invocationData = new LinkedBlockingQueue<>(); |
118 | 125 |
|
119 | 126 | CaptureAdvice() {
|
120 | 127 | super();
|
121 | 128 | }
|
122 | 129 |
|
123 | 130 | @Override
|
124 | 131 | public Object invoke(MethodInvocation invocation) throws Throwable {
|
125 |
| - Object result = null; |
126 | 132 | boolean isListenerMethod =
|
127 | 133 | AnnotationUtils.findAnnotation(invocation.getMethod(), RabbitListener.class) != null
|
128 | 134 | || AnnotationUtils.findAnnotation(invocation.getMethod(), RabbitHandler.class) != null;
|
129 | 135 | try {
|
130 |
| - result = invocation.proceed(); |
| 136 | + Object result = invocation.proceed(); |
131 | 137 | if (isListenerMethod) {
|
132 | 138 | this.invocationData.put(new InvocationData(invocation, result));
|
133 | 139 | }
|
| 140 | + return result; |
134 | 141 | }
|
135 | 142 | catch (Throwable t) { // NOSONAR - rethrown below
|
136 | 143 | if (isListenerMethod) {
|
137 | 144 | this.invocationData.put(new InvocationData(invocation, t));
|
138 | 145 | }
|
139 | 146 | throw t;
|
140 | 147 | }
|
141 |
| - return result; |
142 | 148 | }
|
143 | 149 |
|
144 | 150 | }
|
|
0 commit comments