From 0488b1e2ec99c35654d1e4bdfe413e6245967897 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 31 Oct 2016 15:30:09 -0400 Subject: [PATCH] Fix `AggregatorParserTests` according latest SF Fix JavaDocs for the `IntegrationComponentScan` --- .../annotation/IntegrationComponentScan.java | 3 + .../config/AggregatorParserTests.java | 56 +++++++++---------- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/annotation/IntegrationComponentScan.java b/spring-integration-core/src/main/java/org/springframework/integration/annotation/IntegrationComponentScan.java index 0f18cb4b63..7d5c3bfc53 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/annotation/IntegrationComponentScan.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/annotation/IntegrationComponentScan.java @@ -77,6 +77,7 @@ public @interface IntegrationComponentScan { /** * Indicates whether automatic detection of classes annotated with * {@code @MessagingGateway} should be enabled. + * @return the {@code useDefaultFilters} flag * @since 5.0 */ boolean useDefaultFilters() default true; @@ -90,6 +91,7 @@ public @interface IntegrationComponentScan { * specified. Any type under the specified base packages which matches a given filter * will be included, even if it does not match the default filters (i.e. is not * annotated with {@code @MessagingGateway}). + * @return the {@code includeFilters} array * @since 5.0 * @see #excludeFilters() */ @@ -97,6 +99,7 @@ public @interface IntegrationComponentScan { /** * Specifies which types are not eligible for component scanning. + * @return the {@code excludeFilters} array * @since 5.0 * @see #includeFilters() */ diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorParserTests.java index 3e3d9fb247..a7e95c6697 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -58,6 +58,7 @@ import org.springframework.integration.support.MessageBuilder; import org.springframework.integration.support.locks.LockRegistry; import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.integration.test.util.TestUtils; +import org.springframework.integration.util.MessagingMethodInvokerHelper; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.PollableChannel; @@ -126,9 +127,7 @@ public class AggregatorParserTests { outboundMessages.add(createMessage("123", "id1", 3, 1, null)); outboundMessages.add(createMessage("789", "id1", 3, 3, null)); outboundMessages.add(createMessage("456", "id1", 3, 2, null)); - for (Message message : outboundMessages) { - input.send(message); - } + outboundMessages.forEach(input::send); assertEquals(3, output.getQueueSize()); output.purge(null); } @@ -138,14 +137,12 @@ public class AggregatorParserTests { MessageChannel input = (MessageChannel) context.getBean("aggregatorWithExpressionsInput"); SubscribableChannel outputChannel = (SubscribableChannel) context.getBean("aggregatorWithExpressionsOutput"); final AtomicReference> aggregatedMessage = new AtomicReference>(); - outputChannel.subscribe(message -> aggregatedMessage.set(message)); + outputChannel.subscribe(aggregatedMessage::set); List> outboundMessages = new ArrayList>(); outboundMessages.add(MessageBuilder.withPayload("123").setHeader("foo", "1").build()); outboundMessages.add(MessageBuilder.withPayload("456").setHeader("foo", "1").build()); outboundMessages.add(MessageBuilder.withPayload("789").setHeader("foo", "1").build()); - for (Message message : outboundMessages) { - input.send(message); - } + outboundMessages.forEach(input::send); assertEquals("The aggregated message payload is not correct", "[123]", aggregatedMessage.get().getPayload() .toString()); Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); @@ -164,11 +161,11 @@ public class AggregatorParserTests { Object consumer = new DirectFieldAccessor(endpoint).getPropertyValue("handler"); assertThat(consumer, is(instanceOf(AggregatingMessageHandler.class))); DirectFieldAccessor accessor = new DirectFieldAccessor(consumer); - Object handlerMethods = new DirectFieldAccessor(new DirectFieldAccessor(new DirectFieldAccessor(accessor + Object handlerMethods = new DirectFieldAccessor(new DirectFieldAccessor(new DirectFieldAccessor(accessor .getPropertyValue("outputProcessor")).getPropertyValue("processor")).getPropertyValue("delegate")) .getPropertyValue("handlerMethods"); assertNull(handlerMethods); - Object handlerMethod = new DirectFieldAccessor(new DirectFieldAccessor(new DirectFieldAccessor(accessor + Object handlerMethod = new DirectFieldAccessor(new DirectFieldAccessor(new DirectFieldAccessor(accessor .getPropertyValue("outputProcessor")).getPropertyValue("processor")).getPropertyValue("delegate")) .getPropertyValue("handlerMethod"); assertTrue(handlerMethod.toString().contains("createSingleMessageFromGroup")); @@ -205,9 +202,7 @@ public class AggregatorParserTests { outboundMessages.add(createMessage(1L, "id1", 3, 1, null)); outboundMessages.add(createMessage(2L, "id1", 3, 3, null)); outboundMessages.add(createMessage(3L, "id1", 3, 2, null)); - for (Message message : outboundMessages) { - input.send(message); - } + outboundMessages.forEach(input::send); PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel"); Message response = outputChannel.receive(10); Assert.assertEquals(6L, response.getPayload()); @@ -234,30 +229,31 @@ public class AggregatorParserTests { fail("Expected exception"); } catch (BeanCreationException e) { - assertThat(e.getMessage(), containsString("No bean named 'testReleaseStrategy' is defined")); + assertThat(e.getMessage(), containsString("No bean named 'testReleaseStrategy' available")); } } @Test + @SuppressWarnings("unchecked") public void testAggregatorWithPojoReleaseStrategy() { - MessageChannel input = (MessageChannel) context.getBean("aggregatorWithPojoReleaseStrategyInput"); - EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("aggregatorWithPojoReleaseStrategy"); - ReleaseStrategy releaseStrategy = (ReleaseStrategy) new DirectFieldAccessor(new DirectFieldAccessor(endpoint) - .getPropertyValue("handler")).getPropertyValue("releaseStrategy"); + MessageChannel input = this.context.getBean("aggregatorWithPojoReleaseStrategyInput", MessageChannel.class); + EventDrivenConsumer endpoint = this.context.getBean("aggregatorWithPojoReleaseStrategy", EventDrivenConsumer.class); + ReleaseStrategy releaseStrategy = + TestUtils.getPropertyValue(endpoint, "handler.releaseStrategy", ReleaseStrategy.class); Assert.assertTrue(releaseStrategy instanceof MethodInvokingReleaseStrategy); - DirectFieldAccessor releaseStrategyAccessor = new DirectFieldAccessor(new DirectFieldAccessor(new DirectFieldAccessor(releaseStrategy) - .getPropertyValue("adapter")).getPropertyValue("delegate")); - Object handlerMethods = releaseStrategyAccessor.getPropertyValue("handlerMethods"); + MessagingMethodInvokerHelper methodInvokerHelper = + TestUtils.getPropertyValue(releaseStrategy, "adapter.delegate", MessagingMethodInvokerHelper.class); + Object handlerMethods = TestUtils.getPropertyValue(methodInvokerHelper, "handlerMethods"); assertNull(handlerMethods); - Object handlerMethod = releaseStrategyAccessor.getPropertyValue("handlerMethod"); + Object handlerMethod = TestUtils.getPropertyValue(methodInvokerHelper, "handlerMethod"); assertTrue(handlerMethod.toString().contains("checkCompleteness")); - input.send(createMessage(1L, "correllationId", 4, 0, null)); - input.send(createMessage(2L, "correllationId", 4, 1, null)); - input.send(createMessage(3L, "correllationId", 4, 2, null)); + input.send(createMessage(1L, "correlationId", 4, 0, null)); + input.send(createMessage(2L, "correlationId", 4, 1, null)); + input.send(createMessage(3L, "correlationId", 4, 2, null)); PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel"); Message reply = outputChannel.receive(0); Assert.assertNull(reply); - input.send(createMessage(5L, "correllationId", 4, 3, null)); + input.send(createMessage(5L, "correlationId", 4, 3, null)); reply = outputChannel.receive(0); Assert.assertNotNull(reply); assertEquals(11L, reply.getPayload()); @@ -276,13 +272,13 @@ public class AggregatorParserTests { assertNull(handlerMethods); Object handlerMethod = releaseStrategyAccessor.getPropertyValue("handlerMethod"); assertTrue(handlerMethod.toString().contains("checkCompleteness")); - input.send(createMessage(1L, "correllationId", 4, 0, null)); - input.send(createMessage(2L, "correllationId", 4, 1, null)); - input.send(createMessage(3L, "correllationId", 4, 2, null)); + input.send(createMessage(1L, "correlationId", 4, 0, null)); + input.send(createMessage(2L, "correlationId", 4, 1, null)); + input.send(createMessage(3L, "correlationId", 4, 2, null)); PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel"); Message reply = outputChannel.receive(0); Assert.assertNull(reply); - input.send(createMessage(5L, "correllationId", 4, 3, null)); + input.send(createMessage(5L, "correlationId", 4, 3, null)); reply = outputChannel.receive(0); Assert.assertNotNull(reply); assertEquals(11L, reply.getPayload());