From 57f96bb7597ad8e8fe75f29d493954bd184e8f52 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Tue, 5 Apr 2016 14:58:29 -0400 Subject: [PATCH] checkstyle Misc Rules checkstyle Nesting checkstyle GenericWhitespace checkstyle MethodParamPad checkstyle NoWhiteSpace checkstyle ParenPad Script checkstyle ParenPad --- build.gradle | 1 + .../integration/annotation/Payloads.java | 4 +- .../aop/AbstractMessageSourceAdvice.java | 2 +- .../config/xml/AnnotationConfigParser.java | 5 +- .../history/MessageHistoryConfigurer.java | 2 +- .../store/AbstractMessageGroupStore.java | 2 +- .../integration/store/SimpleMessageGroup.java | 7 +- .../store/SimpleMessageGroupFactory.java | 2 +- .../integration/support/IdGenerators.java | 38 +-- .../json/AbstractJacksonJsonObjectMapper.java | 2 +- .../support/locks/DefaultLockRegistry.java | 2 +- .../transformer/ObjectToMapTransformer.java | 2 +- .../util/MessagingMethodInvokerHelper.java | 2 +- .../aggregator/ConcurrentAggregatorTests.java | 7 +- .../aggregator/ResequencerTests.java | 4 +- .../integration/config/Adder.java | 2 +- .../config/AggregatorParserTests.java | 30 +-- .../config/ResequencerParserTests.java | 2 +- .../annotation/AggregatorAnnotationTests.java | 2 +- ...figuringBeanFactoryPostProcessorTests.java | 4 +- .../xml/IntervalTriggerParserTests.java | 5 +- ...hodInboundMessageMapperToMessageTests.java | 6 +- .../gateway/GatewayProxyFactoryBeanTests.java | 2 +- .../handler/BridgeHandlerTests.java | 2 +- .../router/MultiChannelRouterTests.java | 4 +- .../store/SimpleMessageGroupTests.java | 2 +- .../SmartLifecycleRoleControllerTests.java | 2 +- .../transformer/ContentEnricherTests.java | 6 +- ...PayloadTypeConvertingTransformerTests.java | 2 +- .../RemoteFileOutboundGatewayTests.java | 78 ++---- .../DelegatingSessionFactoryTests.java | 2 +- .../ftp/outbound/FtpOutboundTests.java | 9 +- .../gemfire/store/GemfireMessageStore.java | 17 +- ...pRequestHandlingMessagingGatewayTests.java | 2 +- ...tpRequestExecutingMessageHandlerTests.java | 238 +++++++++--------- .../ip/config/TcpOutboundGatewayParser.java | 8 +- .../connection/TcpSocketFactorySupport.java | 17 +- .../ip/tcp/connection/TcpSocketSupport.java | 22 +- .../integration/ip/util/TestingUtilities.java | 4 +- .../integration/ip/udp/MultiClientTests.java | 18 +- .../integration/ip/util/RegexUtilsTests.java | 4 +- .../integration/jdbc/StoredProcExecutor.java | 4 +- .../jdbc/StoredProcJmxManagedBeanTests.java | 30 ++- ...ocMessageHandlerDerbyIntegrationTests.java | 4 +- ...AdapterWithNamespace2IntegrationTests.java | 73 +++--- ...lAdapterWithNamespaceIntegrationTests.java | 71 +++--- ...pterWithSpringContextIntegrationTests.java | 71 +++--- .../JdbcPollingChannelAdapterParserTests.java | 4 +- .../StoredProcMessageHandlerParserTests.java | 13 +- .../StoredProcOutboundGatewayParserTests.java | 9 +- ...lJdbcMessageStoreMultipleChannelTests.java | 4 +- .../jdbc/storedproc/derby/DerbyFunctions.java | 2 +- .../derby/DerbyStoredProcedures.java | 2 +- .../jms/SubscribableJmsChannelTests.java | 16 +- .../jmx/OperationInvokingMessageHandler.java | 4 +- ...onPublishingChannelAdapterParserTests.java | 15 +- .../IdempotentReceiverIntegrationTests.java | 4 +- .../integration/jpa/core/JpaExecutor.java | 15 +- .../jpa/core/AbstractJpaOperationsTests.java | 8 +- .../integration/jpa/test/Consumer.java | 3 +- .../mail/ImapIdleChannelAdapter.java | 4 +- .../mail/ImapMailReceiverTests.java | 2 +- .../store/MongoDbMessageGroupStoreTests.java | 2 +- .../inbound/RedisQueueInboundGateway.java | 29 ++- ...RedisInboundChannelAdapterParserTests.java | 2 +- .../RedisInboundChannelAdapterTests.java | 2 +- .../outbound/RedisOutboundGatewayTests.java | 4 +- .../jsr223/PythonScriptExecutor.java | 13 +- .../scripting/jsr223/RubyScriptExecutor.java | 2 +- .../DeriveLanguageFromExtensionTests.java | 10 +- .../jsr223/PythonScriptExecutorTests.java | 8 +- .../stomp/outbound/StompMessageHandler.java | 2 +- .../integration/syslog/SyslogHeaders.java | 20 +- .../test/matcher/MapContentMatchers.java | 2 +- .../test/matcher/MockitoMessageMatchers.java | 2 +- .../AbstractRequestResponseScenarioTests.java | 90 +++---- .../support/AbstractResponseValidator.java | 2 +- .../StatusUpdatingMessageHandler.java | 6 +- ...MarshallingWebServiceIntegrationTests.java | 2 +- .../ws/config/StubMessageFactory.java | 2 +- .../WebServiceOutboundGatewayParserTests.java | 104 +++++--- .../xml/config/TestXmlApplicationContext.java | 4 +- .../xml/config/XPathRouterParserTests.java | 2 +- .../splitter/XPathMessageSplitterTests.java | 4 +- .../JaxbMarshallingIntegrationTests.java | 4 +- src/checkstyle/checkstyle.xml | 54 ++-- src/checkstyle/fixParenPad.gradle | 63 +++++ 87 files changed, 737 insertions(+), 628 deletions(-) create mode 100644 src/checkstyle/fixParenPad.gradle diff --git a/build.gradle b/build.gradle index 075acb528a..3b1ecda9ff 100644 --- a/build.gradle +++ b/build.gradle @@ -70,6 +70,7 @@ subprojects { subproject -> apply from: "${rootDir}/src/checkstyle/fixThis.gradle" apply from: "${rootDir}/src/checkstyle/fixRightCurly.gradle" apply from: "${rootDir}/src/checkstyle/fixWhiteAround.gradle" + apply from: "${rootDir}/src/checkstyle/fixParenPad.gradle" if (project.hasProperty('platformVersion')) { apply plugin: 'spring-io' diff --git a/spring-integration-core/src/main/java/org/springframework/integration/annotation/Payloads.java b/spring-integration-core/src/main/java/org/springframework/integration/annotation/Payloads.java index 7cf5103968..827b01c138 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/annotation/Payloads.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/annotation/Payloads.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 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. @@ -33,7 +33,7 @@ import java.lang.annotation.Target; * @author Dave Syer * @since 2.0 */ -@Target( { ElementType.PARAMETER, ElementType.METHOD }) +@Target({ ElementType.PARAMETER, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Payloads { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aop/AbstractMessageSourceAdvice.java b/spring-integration-core/src/main/java/org/springframework/integration/aop/AbstractMessageSourceAdvice.java index e1934345b4..cce00b80bc 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aop/AbstractMessageSourceAdvice.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aop/AbstractMessageSourceAdvice.java @@ -35,7 +35,7 @@ public abstract class AbstractMessageSourceAdvice implements MethodInterceptor { public final Object invoke(MethodInvocation invocation) throws Throwable { Object target = invocation.getThis(); if (!(target instanceof MessageSource) - || invocation.getMethod().getName() != "receive") { + || !invocation.getMethod().getName().equals("receive")) { return invocation.proceed(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AnnotationConfigParser.java b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AnnotationConfigParser.java index 3147f73f7e..709178f574 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AnnotationConfigParser.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AnnotationConfigParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 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. @@ -36,12 +36,13 @@ import org.springframework.integration.config.IntegrationRegistrar; */ public class AnnotationConfigParser implements BeanDefinitionParser { + @Override public BeanDefinition parse(final Element element, ParserContext parserContext) { new IntegrationRegistrar().registerBeanDefinitions(new StandardAnnotationMetadata(Object.class) { @Override public Map getAnnotationAttributes(String annotationType) { - return Collections. singletonMap("value", element.getAttribute("default-publisher-channel")); + return Collections.singletonMap("value", element.getAttribute("default-publisher-channel")); } }, parserContext.getRegistry()); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryConfigurer.java b/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryConfigurer.java index 40607dcd78..77ada59ea3 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryConfigurer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryConfigurer.java @@ -119,7 +119,7 @@ public class MessageHistoryConfigurer implements SmartLifecycle, BeanFactoryAwar Assert.notNull(componentNamePatternsSet, "'componentNamePatternsSet' must not be null"); Assert.state(!this.running, "'componentNamePatternsSet' cannot be changed without invoking stop() first"); for (String s : componentNamePatternsSet) { - String[] componentNamePatterns = StringUtils.delimitedListToStringArray(s, "," , " "); + String[] componentNamePatterns = StringUtils.delimitedListToStringArray(s, ",", " "); Arrays.sort(componentNamePatterns); if (this.componentNamePatternsExplicitlySet && !Arrays.equals(this.componentNamePatterns, componentNamePatterns)) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java b/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java index 2b07752177..23effc035c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java @@ -159,7 +159,7 @@ public abstract class AbstractMessageGroupStore extends AbstractBatchingMessageG public int getMessageGroupCount() { int count = 0; for (@SuppressWarnings("unused") MessageGroup group : this) { - count ++; + count++; } return count; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageGroup.java b/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageGroup.java index 1c0c7fd408..7d86ad941b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageGroup.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageGroup.java @@ -53,7 +53,7 @@ public class SimpleMessageGroup implements MessageGroup { private volatile boolean complete; public SimpleMessageGroup(Object groupId) { - this(Collections.> emptyList(), groupId); + this(Collections.>emptyList(), groupId); } public SimpleMessageGroup(Collection> messages, Object groupId) { @@ -90,6 +90,7 @@ public class SimpleMessageGroup implements MessageGroup { return this.timestamp; } + @Override public void setLastModified(long lastModified) { this.lastModified = lastModified; } @@ -104,10 +105,12 @@ public class SimpleMessageGroup implements MessageGroup { return true; } + @Override public void add(Message messageToAdd) { addMessage(messageToAdd); } + @Override public boolean remove(Message message) { return this.messages.remove(message); } @@ -126,6 +129,7 @@ public class SimpleMessageGroup implements MessageGroup { return Collections.unmodifiableCollection(this.messages); } + @Override public void setLastReleasedMessageSequenceNumber(int sequenceNumber) { this.lastReleasedMessageSequence = sequenceNumber; } @@ -166,6 +170,7 @@ public class SimpleMessageGroup implements MessageGroup { } } + @Override public void clear() { this.messages.clear(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageGroupFactory.java b/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageGroupFactory.java index b92c62e459..a14fd2ff0f 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageGroupFactory.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageGroupFactory.java @@ -45,7 +45,7 @@ public class SimpleMessageGroupFactory implements MessageGroupFactory { @Override public MessageGroup create(Object groupId) { - return create(Collections.> emptyList(), groupId); + return create(Collections.>emptyList(), groupId); } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/IdGenerators.java b/spring-integration-core/src/main/java/org/springframework/integration/support/IdGenerators.java index 8c5077cea9..2403f89e05 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/IdGenerators.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/IdGenerators.java @@ -37,12 +37,12 @@ public class IdGenerators { */ public static class JdkIdGenerator implements IdGenerator { - @Override - public UUID generateId() { - return UUID.randomUUID(); - } + @Override + public UUID generateId() { + return UUID.randomUUID(); + } - } + } /** * Based on the two {@link AtomicLong}s, for {@code topBits} and {@code bottomBits}, @@ -59,23 +59,23 @@ public class IdGenerators { * is initialized. Therefore, it is not suitable when persisting messages based on their ID; it should * only be used when the absolute best performance is required and messages are not persisted. */ - public static class SimpleIncrementingIdGenerator implements IdGenerator { + public static class SimpleIncrementingIdGenerator implements IdGenerator { - private final AtomicLong topBits = new AtomicLong(); + private final AtomicLong topBits = new AtomicLong(); - private final AtomicLong bottomBits = new AtomicLong(); + private final AtomicLong bottomBits = new AtomicLong(); - @Override - public UUID generateId() { - long bottomBits = this.bottomBits.incrementAndGet(); - if (bottomBits == 0) { - return new UUID(this.topBits.incrementAndGet(), bottomBits); - } - else { - return new UUID(this.topBits.get(), bottomBits); - } - } + @Override + public UUID generateId() { + long bottomBits = this.bottomBits.incrementAndGet(); + if (bottomBits == 0) { + return new UUID(this.topBits.incrementAndGet(), bottomBits); + } + else { + return new UUID(this.topBits.get(), bottomBits); + } + } - } + } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/json/AbstractJacksonJsonObjectMapper.java b/spring-integration-core/src/main/java/org/springframework/integration/support/json/AbstractJacksonJsonObjectMapper.java index 12d3347506..aa5b1a8888 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/json/AbstractJacksonJsonObjectMapper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/json/AbstractJacksonJsonObjectMapper.java @@ -42,7 +42,7 @@ public abstract class AbstractJacksonJsonObjectMapper extends JsonObjec implements BeanClassLoaderAware { protected static final Collection> supportedJsonTypes = - Arrays.> asList(String.class, byte[].class, File.class, URL.class, InputStream.class, Reader.class); + Arrays.>asList(String.class, byte[].class, File.class, URL.class, InputStream.class, Reader.class); private volatile ClassLoader classLoader = ClassUtils.getDefaultClassLoader(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/locks/DefaultLockRegistry.java b/spring-integration-core/src/main/java/org/springframework/integration/support/locks/DefaultLockRegistry.java index e1c1bd55c7..6ce5b0ca59 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/locks/DefaultLockRegistry.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/locks/DefaultLockRegistry.java @@ -60,7 +60,7 @@ public final class DefaultLockRegistry implements LockRegistry { */ public DefaultLockRegistry(int mask) { String bits = Integer.toBinaryString(mask); - Assert.isTrue(bits.length() < 32 && (mask == 0 || bits.lastIndexOf('0') < bits.indexOf('1') ), "Mask must be a power of 2 - 1"); + Assert.isTrue(bits.length() < 32 && (mask == 0 || bits.lastIndexOf('0') < bits.indexOf('1')), "Mask must be a power of 2 - 1"); this.mask = mask; int arraySize = this.mask + 1; this.lockTable = new ReentrantLock[arraySize]; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToMapTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToMapTransformer.java index a8b61344fc..634b2220e8 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToMapTransformer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToMapTransformer.java @@ -115,7 +115,7 @@ public class ObjectToMapTransformer extends AbstractPayloadTransformer extends AbstractExpressionEvaluator headerName = methodParameter.getParameterName(); } else if (valueAttribute.indexOf('.') != -1) { - String tokens[] = valueAttribute.split("\\.", 2); + String[] tokens = valueAttribute.split("\\.", 2); headerName = tokens[0]; if (StringUtils.hasText(tokens[1])) { relativeExpression = "." + tokens[1]; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ConcurrentAggregatorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ConcurrentAggregatorTests.java index e1dcda88b3..d314617213 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ConcurrentAggregatorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ConcurrentAggregatorTests.java @@ -32,7 +32,6 @@ import org.junit.Test; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.core.task.TaskExecutor; -import org.springframework.messaging.MessageHandlingException; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.store.MessageGroup; import org.springframework.integration.store.MessageGroupStore; @@ -41,6 +40,7 @@ import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageHandler; +import org.springframework.messaging.MessageHandlingException; import org.springframework.messaging.MessageHeaders; /** @@ -80,7 +80,7 @@ public class ConcurrentAggregatorTests { assertTrue(latch.await(10, TimeUnit.SECONDS)); - assertThat(latch.getCount(), is(0l)); + assertThat(latch.getCount(), is(0L)); Message reply = replyChannel.receive(2000); assertNotNull(reply); assertEquals(reply.getPayload(), 105); @@ -319,6 +319,7 @@ public class ConcurrentAggregatorTests { return this.exception; } + @Override public void run() { try { this.aggregator.handleMessage(message); @@ -335,6 +336,7 @@ public class ConcurrentAggregatorTests { private class MultiplyingProcessor implements MessageGroupProcessor { + @Override public Object processMessageGroup(MessageGroup group) { Integer product = 1; for (Message message : group.getMessages()) { @@ -346,6 +348,7 @@ public class ConcurrentAggregatorTests { private class NullReturningMessageProcessor implements MessageGroupProcessor { + @Override public Object processMessageGroup(MessageGroup group) { return null; } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ResequencerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ResequencerTests.java index 638c25b92b..646df9d75d 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ResequencerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ResequencerTests.java @@ -81,11 +81,11 @@ public class ResequencerTests { Message reply2 = replyChannel.receive(0); Message reply3 = replyChannel.receive(0); assertNotNull(reply1); - assertThat( new IntegrationMessageHeaderAccessor(reply1).getSequenceNumber(), is(1)); + assertThat(new IntegrationMessageHeaderAccessor(reply1).getSequenceNumber(), is(1)); assertNotNull(reply2); assertThat(new IntegrationMessageHeaderAccessor(reply2).getSequenceNumber(), is(2)); assertNotNull(reply3); - assertThat( new IntegrationMessageHeaderAccessor(reply3).getSequenceNumber(), is(3)); + assertThat(new IntegrationMessageHeaderAccessor(reply3).getSequenceNumber(), is(3)); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/Adder.java b/spring-integration-core/src/test/java/org/springframework/integration/config/Adder.java index 425774a1e9..039aa41e1a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/Adder.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/Adder.java @@ -24,7 +24,7 @@ import java.util.List; public class Adder { public Long add(List results) { - long total = 0l; + long total = 0L; for (long partialResult: results) { total += partialResult; } 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 fdacb955ff..cbddcb9719 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 @@ -190,7 +190,7 @@ public class AggregatorParserTests { outputChannel, accessor.getPropertyValue("outputChannel")); assertEquals("The AggregatorEndpoint is not injected with the appropriate discard channel", discardChannel, accessor.getPropertyValue("discardChannel")); - assertEquals("The AggregatorEndpoint is not set with the appropriate timeout value", 86420000l, + assertEquals("The AggregatorEndpoint is not set with the appropriate timeout value", 86420000L, TestUtils.getPropertyValue(consumer, "messagingTemplate.sendTimeout")); assertEquals( "The AggregatorEndpoint is not configured with the appropriate 'send partial results on timeout' flag", @@ -212,15 +212,15 @@ public class AggregatorParserTests { public void testSimpleJavaBeanAggregator() { List> outboundMessages = new ArrayList>(); MessageChannel input = (MessageChannel) context.getBean("aggregatorWithReferenceAndMethodInput"); - outboundMessages.add(createMessage(1l, "id1", 3, 1, null)); - outboundMessages.add(createMessage(2l, "id1", 3, 3, null)); - outboundMessages.add(createMessage(3l, "id1", 3, 2, null)); + 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); } PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel"); Message response = outputChannel.receive(10); - Assert.assertEquals(6l, response.getPayload()); + Assert.assertEquals(6L, response.getPayload()); Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); Object handler = context.getBean("aggregatorWithReferenceAndMethod.handler"); assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.messageBuilderFactory")); @@ -261,16 +261,16 @@ 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, "correllationId", 4, 0, null)); + input.send(createMessage(2L, "correllationId", 4, 1, null)); + input.send(createMessage(3L, "correllationId", 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, "correllationId", 4, 3, null)); reply = outputChannel.receive(0); Assert.assertNotNull(reply); - assertEquals(11l, reply.getPayload()); + assertEquals(11L, reply.getPayload()); } @Test // see INT-2011 @@ -286,16 +286,16 @@ 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, "correllationId", 4, 0, null)); + input.send(createMessage(2L, "correllationId", 4, 1, null)); + input.send(createMessage(3L, "correllationId", 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, "correllationId", 4, 3, null)); reply = outputChannel.receive(0); Assert.assertNotNull(reply); - assertEquals(11l, reply.getPayload()); + assertEquals(11L, reply.getPayload()); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/ResequencerParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/ResequencerParserTests.java index a78035365c..7e7d290883 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/ResequencerParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/ResequencerParserTests.java @@ -88,7 +88,7 @@ public class ResequencerParserTests { getPropertyValue(resequencer, "outputChannel")); assertEquals("The ResequencerEndpoint is not injected with the appropriate discard channel", discardChannel, getPropertyValue(resequencer, "discardChannel")); - assertEquals("The ResequencerEndpoint is not set with the appropriate timeout value", 86420000l, + assertEquals("The ResequencerEndpoint is not set with the appropriate timeout value", 86420000L, getPropertyValue(resequencer, "messagingTemplate.sendTimeout")); assertEquals( "The ResequencerEndpoint is not configured with the appropriate 'send partial results on timeout' flag", diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/AggregatorAnnotationTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/AggregatorAnnotationTests.java index 89d1b0b650..771ce25cd2 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/AggregatorAnnotationTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/annotation/AggregatorAnnotationTests.java @@ -68,7 +68,7 @@ public class AggregatorAnnotationTests { assertTrue(getPropertyValue(aggregator, "releaseStrategy") instanceof SequenceSizeReleaseStrategy); assertEquals("outputChannel", getPropertyValue(aggregator, "outputChannelName")); assertEquals("discardChannel", getPropertyValue(aggregator, "discardChannelName")); - assertEquals(98765432l, getPropertyValue(aggregator, "messagingTemplate.sendTimeout")); + assertEquals(98765432L, getPropertyValue(aggregator, "messagingTemplate.sendTimeout")); assertEquals(true, getPropertyValue(aggregator, "sendPartialResultOnExpiry")); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultConfiguringBeanFactoryPostProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultConfiguringBeanFactoryPostProcessorTests.java index faf8783012..4753dbf52a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultConfiguringBeanFactoryPostProcessorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultConfiguringBeanFactoryPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 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. @@ -90,7 +90,7 @@ public class DefaultConfiguringBeanFactoryPostProcessorTests { assertNotNull("Child task scheduler was null", childScheduler); assertNotNull("Parent task scheduler was null", parentScheduler); - assertEquals("Different schedulers in parent and child", parentScheduler, childScheduler ); + assertEquals("Different schedulers in parent and child", parentScheduler, childScheduler); } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/IntervalTriggerParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/IntervalTriggerParserTests.java index f6abb83bdf..706183df4b 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/IntervalTriggerParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/IntervalTriggerParserTests.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -50,7 +51,7 @@ public class IntervalTriggerParserTests { Boolean fixedRate = (Boolean) accessor.getPropertyValue("fixedRate"); Long period = (Long) accessor.getPropertyValue("period"); assertEquals(fixedRate, true); - assertEquals(36l, period.longValue()); + assertEquals(36L, period.longValue()); } @Test @@ -64,6 +65,6 @@ public class IntervalTriggerParserTests { Boolean fixedRate = (Boolean) accessor.getPropertyValue("fixedRate"); Long period = (Long) accessor.getPropertyValue("period"); assertEquals(fixedRate, false); - assertEquals(37l, period.longValue()); + assertEquals(37L, period.longValue()); } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapperToMessageTests.java b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapperToMessageTests.java index 4c0d380be6..1aa5953ba4 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapperToMessageTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapperToMessageTests.java @@ -30,12 +30,12 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.expression.Expression; import org.springframework.expression.common.LiteralExpression; import org.springframework.expression.spel.standard.SpelExpressionParser; +import org.springframework.integration.mapping.MessageMappingException; +import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.messaging.handler.annotation.Header; import org.springframework.messaging.handler.annotation.Headers; import org.springframework.messaging.handler.annotation.Payload; -import org.springframework.integration.mapping.MessageMappingException; -import org.springframework.integration.support.MessageBuilder; /** * @author Mark Fisher @@ -57,7 +57,7 @@ public class GatewayMethodInboundMessageMapperToMessageTests { Method method = TestService.class.getMethod("sendPayload", String.class); GatewayMethodInboundMessageMapper mapper = new GatewayMethodInboundMessageMapper(method); mapper.setBeanFactory(mock(BeanFactory.class)); - mapper.toMessage(new Object[] { "test" , "oops" }); + mapper.toMessage(new Object[] { "test", "oops" }); } @Test(expected = IllegalArgumentException.class) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java index 957aebe54d..19f90c1007 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java @@ -339,7 +339,7 @@ public class GatewayProxyFactoryBeanTests { gpfb.setDefaultRequestChannel(drc); gpfb.setDefaultReplyTimeout(0L); GatewayMethodMetadata meta = new GatewayMethodMetadata(); - meta.setHeaderExpressions(Collections. singletonMap("foo", new LiteralExpression("bar"))); + meta.setHeaderExpressions(Collections.singletonMap("foo", new LiteralExpression("bar"))); gpfb.setGlobalMethodMetadata(meta); gpfb.afterPropertiesSet(); ((TestEchoService) gpfb.getObject()).echo("foo"); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/BridgeHandlerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/BridgeHandlerTests.java index 7be44303b4..83c493e585 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/BridgeHandlerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/BridgeHandlerTests.java @@ -63,7 +63,7 @@ public class BridgeHandlerTests { @Test(timeout = 1000) public void missingOutputChannelAllowedForReplyChannelMessages() throws Exception { PollableChannel replyChannel = new QueueChannel(); - Message request = MessageBuilder.withPayload("tst").setReplyChannel(replyChannel ).build(); + Message request = MessageBuilder.withPayload("tst").setReplyChannel(replyChannel).build(); handler.handleMessage(request); assertThat(replyChannel.receive(), sameExceptImmutableHeaders(request)); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java index 61d9ef82c1..79f80295df 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 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. @@ -66,7 +66,7 @@ public class MultiChannelRouterTests { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @SuppressWarnings("unchecked") public List getChannelKeys(Message message) { - return CollectionUtils.arrayToList(new String[] {"noSuchChannel"} ); + return CollectionUtils.arrayToList(new String[] {"noSuchChannel"}); } }; TestChannelResolver channelResolver = new TestChannelResolver(); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/store/SimpleMessageGroupTests.java b/spring-integration-core/src/test/java/org/springframework/integration/store/SimpleMessageGroupTests.java index f7acf18d51..4aaace12b0 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/store/SimpleMessageGroupTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/store/SimpleMessageGroupTests.java @@ -45,7 +45,7 @@ public class SimpleMessageGroupTests { private final Object key = new Object(); - private SimpleMessageGroup group = new SimpleMessageGroup(Collections.> emptyList(), key); + private SimpleMessageGroup group = new SimpleMessageGroup(Collections.>emptyList(), key); @SuppressWarnings("unchecked") public void prepareForSequenceAwareMessageGroup() throws Exception { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/SmartLifecycleRoleControllerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/SmartLifecycleRoleControllerTests.java index 8f90578af1..bcf4c34861 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/SmartLifecycleRoleControllerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/support/SmartLifecycleRoleControllerTests.java @@ -40,7 +40,7 @@ public class SmartLifecycleRoleControllerTests { when(lc1.getPhase()).thenReturn(2); SmartLifecycle lc2 = mock(SmartLifecycle.class); when(lc1.getPhase()).thenReturn(1); - MultiValueMap map = new LinkedMultiValueMap(); + MultiValueMap map = new LinkedMultiValueMap(); map.add("foo", lc1); map.add("foo", lc2); SmartLifecycleRoleController controller = new SmartLifecycleRoleController(map); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/ContentEnricherTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/ContentEnricherTests.java index db38fe24fc..6a94dee7bb 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/ContentEnricherTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/ContentEnricherTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 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. @@ -523,7 +523,9 @@ public class ContentEnricherTests { @SuppressWarnings("unused") private static final class Source { - private final String firstName, lastName; + private final String firstName; + + private final String lastName; Source(String firstName, String lastName) { this.firstName = firstName; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTypeConvertingTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTypeConvertingTransformerTests.java index 5937234cf1..642ac8f7e3 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTypeConvertingTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTypeConvertingTransformerTests.java @@ -37,7 +37,7 @@ public class PayloadTypeConvertingTransformerTests { @Test public void testTransformPayloadObject() throws Exception { PayloadTypeConvertingTransformer tx = new PayloadTypeConvertingTransformer(); - tx.setConverter(new Converter () { + tx.setConverter(new Converter() { @Override public String convert(String source) { diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java index edde70663e..44273e1c84 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java @@ -95,16 +95,14 @@ public class RemoteFileOutboundGatewayTests { @Test(expected = IllegalArgumentException.class) public void testBad() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "bad", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "bad", "payload"); gw.afterPropertiesSet(); } @Test public void testBadFilterGet() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "get", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload"); gw.setFilter(new TestPatternFilter("")); try { gw.afterPropertiesSet(); @@ -118,8 +116,7 @@ public class RemoteFileOutboundGatewayTests { @Test public void testBadFilterRm() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "rm", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "rm", "payload"); gw.setFilter(new TestPatternFilter("")); try { gw.afterPropertiesSet(); @@ -134,8 +131,7 @@ public class RemoteFileOutboundGatewayTests { public void testLs() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "ls", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload"); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(session); TestLsEntry[] files = fileList(); @@ -167,8 +163,7 @@ public class RemoteFileOutboundGatewayTests { private void testMGetWildGuts(final String path1, final String path2) { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "mget", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mget", "payload"); gw.setLocalDirectory(new File(this.tmpDir)); gw.afterPropertiesSet(); new File(this.tmpDir + "/f1").delete(); @@ -209,8 +204,7 @@ public class RemoteFileOutboundGatewayTests { @Test public void testMGetSingle() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "mget", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mget", "payload"); gw.setLocalDirectory(new File(this.tmpDir)); gw.afterPropertiesSet(); new File(this.tmpDir + "/f1").delete(); @@ -240,8 +234,7 @@ public class RemoteFileOutboundGatewayTests { @Test(expected = MessagingException.class) public void testMGetEmpty() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "mget", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mget", "payload"); gw.setLocalDirectory(new File(this.tmpDir)); gw.setOptions(" -x "); gw.afterPropertiesSet(); @@ -262,8 +255,7 @@ public class RemoteFileOutboundGatewayTests { @Test public void testMove() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "mv", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mv", "payload"); gw.afterPropertiesSet(); Session session = mock(Session.class); final AtomicReference args = new AtomicReference(); @@ -288,8 +280,7 @@ public class RemoteFileOutboundGatewayTests { @Test public void testMoveWithExpression() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "mv", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mv", "payload"); gw.setRenameExpression(PARSER.parseExpression("payload.substring(1)")); gw.afterPropertiesSet(); Session session = mock(Session.class); @@ -313,8 +304,7 @@ public class RemoteFileOutboundGatewayTests { @Test public void testMoveWithMkDirs() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "mv", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mv", "payload"); gw.setRenameExpression(PARSER.parseExpression("'foo/bar/baz'")); gw.afterPropertiesSet(); Session session = mock(Session.class); @@ -363,8 +353,7 @@ public class RemoteFileOutboundGatewayTests { public void testLs_f() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "ls", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload"); gw.setOptions("-f"); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(session); @@ -405,8 +394,7 @@ public class RemoteFileOutboundGatewayTests { public void testLs_f_R() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "ls", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload"); gw.setOptions("-f -R"); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(session); @@ -432,8 +420,7 @@ public class RemoteFileOutboundGatewayTests { public void testLs_f_R_dirs() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "ls", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload"); gw.setOptions("-f -R -dirs"); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(session); @@ -461,8 +448,7 @@ public class RemoteFileOutboundGatewayTests { public void testLs_None() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "ls", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload"); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(session); TestLsEntry[] files = new TestLsEntry[0]; @@ -477,8 +463,7 @@ public class RemoteFileOutboundGatewayTests { public void testLs_1() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "ls", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload"); gw.setOptions("-1"); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(session); @@ -496,8 +481,7 @@ public class RemoteFileOutboundGatewayTests { public void testLs_1_f() throws Exception { //no sort SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "ls", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload"); gw.setOptions("-1 -f"); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(session); @@ -515,8 +499,7 @@ public class RemoteFileOutboundGatewayTests { public void testLs_1_dirs() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "ls", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload"); gw.setOptions("-1 -dirs"); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(session); @@ -535,8 +518,7 @@ public class RemoteFileOutboundGatewayTests { public void testLs_1_dirs_links() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "ls", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload"); gw.setOptions("-1 -dirs -links"); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(session); @@ -556,8 +538,7 @@ public class RemoteFileOutboundGatewayTests { public void testLs_1_a_f_dirs_links() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "ls", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload"); gw.setOptions("-1 -a -f -dirs -links"); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(session); @@ -579,8 +560,7 @@ public class RemoteFileOutboundGatewayTests { public void testLs_1_a_f_dirs_links_filtered() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "ls", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload"); gw.setOptions("-1 -a -f -dirs -links"); gw.setFilter(new TestPatternFilter("*4")); gw.afterPropertiesSet(); @@ -597,8 +577,7 @@ public class RemoteFileOutboundGatewayTests { @Test public void testGet() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "get", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload"); gw.setLocalDirectory(new File(this.tmpDir)); gw.afterPropertiesSet(); new File(this.tmpDir + "/f1").delete(); @@ -632,8 +611,7 @@ public class RemoteFileOutboundGatewayTests { @Test public void testGetExists() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "get", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload"); gw.setLocalDirectory(new File(this.tmpDir)); gw.afterPropertiesSet(); File outFile = new File(this.tmpDir + "/f1"); @@ -703,8 +681,7 @@ public class RemoteFileOutboundGatewayTests { @Test public void testGetTempFileDelete() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "get", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload"); gw.setLocalDirectory(new File(this.tmpDir)); gw.afterPropertiesSet(); new File(this.tmpDir + "/f1").delete(); @@ -741,8 +718,7 @@ public class RemoteFileOutboundGatewayTests { @Test public void testGet_P() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "get", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload"); gw.setLocalDirectory(new File(this.tmpDir)); gw.setOptions("-P"); gw.afterPropertiesSet(); @@ -784,8 +760,7 @@ public class RemoteFileOutboundGatewayTests { new File(this.tmpDir + "/x/f1").delete(); new File(this.tmpDir + "/x").delete(); SessionFactory sessionFactory = mock(SessionFactory.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "get", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload"); gw.setLocalDirectory(new File(this.tmpDir + "/x")); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(new TestSession() { @@ -814,8 +789,7 @@ public class RemoteFileOutboundGatewayTests { public void testRm() throws Exception { SessionFactory sessionFactory = mock(SessionFactory.class); Session session = mock(Session.class); - TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway - (sessionFactory, "rm", "payload"); + TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "rm", "payload"); gw.afterPropertiesSet(); when(sessionFactory.getSession()).thenReturn(session); when(session.remove("testremote/x/f1")).thenReturn(Boolean.TRUE); diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/session/DelegatingSessionFactoryTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/session/DelegatingSessionFactoryTests.java index 78079df1ed..185c7c24ae 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/session/DelegatingSessionFactoryTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/session/DelegatingSessionFactoryTests.java @@ -186,7 +186,7 @@ public class DelegatingSessionFactoryTests { @Override public Session getSession() { - return this.mockSession ; + return this.mockSession; } } diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpOutboundTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpOutboundTests.java index 415117e5ec..0381fbe33f 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpOutboundTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpOutboundTests.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -189,7 +190,8 @@ public class FtpOutboundTests { return null; } }).when(logger).warn(Mockito.anyString()); - RemoteFileTemplate template = TestUtils.getPropertyValue(handler, "remoteFileTemplate", RemoteFileTemplate.class); + RemoteFileTemplate template = TestUtils.getPropertyValue(handler, "remoteFileTemplate", + RemoteFileTemplate.class); new DirectFieldAccessor(template).setPropertyValue("logger", logger); handler.handleMessage(new GenericMessage(srcFile)); assertNotNull(logged.get()); @@ -251,7 +253,7 @@ public class FtpOutboundTests { when(ftpClient.login("kermit", "frog")).thenReturn(true); when(ftpClient.changeWorkingDirectory(Mockito.anyString())).thenReturn(true); when(ftpClient.printWorkingDirectory()).thenReturn("remote-target-dir"); - when(ftpClient.storeFile(Mockito.anyString(), Mockito.any(InputStream.class))).thenAnswer(new Answer() { + when(ftpClient.storeFile(Mockito.anyString(), any(InputStream.class))).thenAnswer(new Answer() { @Override public Boolean answer(InvocationOnMock invocation) throws Throwable { String fileName = (String) invocation.getArguments()[0]; @@ -278,7 +280,8 @@ public class FtpOutboundTests { file.setType(FTPFile.FILE_TYPE); file.setTimestamp(Calendar.getInstance()); ftpFiles.add(file); - when(ftpClient.retrieveFile(Mockito.eq("remote-test-dir/" + fileName) , Mockito.any(OutputStream.class))).thenReturn(true); + when(ftpClient.retrieveFile(Mockito.eq("remote-test-dir/" + fileName), + any(OutputStream.class))).thenReturn(true); } when(ftpClient.listFiles("remote-test-dir/")).thenReturn(ftpFiles.toArray(new FTPFile[]{})); return ftpClient; diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/store/GemfireMessageStore.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/store/GemfireMessageStore.java index 6778231e94..93432f45a7 100644 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/store/GemfireMessageStore.java +++ b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/store/GemfireMessageStore.java @@ -55,21 +55,20 @@ public class GemfireMessageStore extends AbstractKeyValueMessageStore implements * Provides the region to be used for the message store. This is useful when * using a configured region. This is also required if using a client region * on a remote cache server. - * * @param messageStoreRegion The region. */ public GemfireMessageStore(Region messageStoreRegion) { this.cache = null; this.messageStoreRegion = messageStoreRegion; } - /** - * Provides a cache reference used to create a message store region named - * 'messageStoreRegion' - * - * @param cache The cache. - * - * @deprecated - use the other constructor and provide a region directly. - */ + + /** + * Provides a cache reference used to create a message store region named + * 'messageStoreRegion' + * @param cache The cache. + * + * @deprecated - use the other constructor and provide a region directly. + */ @Deprecated public GemfireMessageStore(Cache cache) { Assert.notNull(cache, "'cache' must not be null"); diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayTests.java index 4e6be6e0bb..b6a9bee734 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayTests.java @@ -363,7 +363,7 @@ public class HttpRequestHandlingMessagingGatewayTests extends AbstractHttpInboun @Override protected Object handleRequestMessage(Message requestMessage) { return new GenericMessage("foo", - Collections. singletonMap(HttpHeaders.STATUS_CODE, HttpStatus.GATEWAY_TIMEOUT)); + Collections.singletonMap(HttpHeaders.STATUS_CODE, HttpStatus.GATEWAY_TIMEOUT)); } }); diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandlerTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandlerTests.java index 3dad1e8ae1..75fa99a62c 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandlerTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandlerTests.java @@ -43,7 +43,7 @@ import org.mockito.Mockito; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.BeanFactory; -import org.springframework.context.ApplicationContext; +import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.ParameterizedTypeReference; import org.springframework.expression.spel.standard.SpelExpressionParser; @@ -84,7 +84,8 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void simpleStringKeyStringValueFormData() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); @@ -109,7 +110,7 @@ public class HttpRequestExecutingMessageHandlerTests { Object body = request.getBody(); assertNotNull(request.getHeaders().getContentType()); assertTrue(body instanceof MultiValueMap); - MultiValueMap map = (MultiValueMap ) body; + MultiValueMap map = (MultiValueMap) body; assertEquals("1", map.get("a").iterator().next()); assertEquals("2", map.get("b").iterator().next()); assertEquals("3", map.get("c").iterator().next()); @@ -118,7 +119,8 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void simpleStringKeyObjectValueFormData() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); @@ -142,7 +144,7 @@ public class HttpRequestExecutingMessageHandlerTests { HttpEntity request = template.lastRequestEntity.get(); Object body = request.getBody(); assertTrue(body instanceof MultiValueMap); - MultiValueMap map = (MultiValueMap ) body; + MultiValueMap map = (MultiValueMap) body; assertEquals("Philadelphia", map.get("a").get(0).toString()); assertEquals("Ambler", map.get("b").get(0).toString()); assertEquals("Mohnton", map.get("c").get(0).toString()); @@ -151,7 +153,8 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void simpleObjectKeyObjectValueFormData() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); @@ -175,7 +178,7 @@ public class HttpRequestExecutingMessageHandlerTests { HttpEntity request = template.lastRequestEntity.get(); Object body = request.getBody(); assertTrue(body instanceof Map); - Map map = (Map ) body; + Map map = (Map) body; assertEquals("Philadelphia", map.get(1).toString()); assertEquals("Ambler", map.get(2).toString()); assertEquals("Mohnton", map.get(3).toString()); @@ -185,7 +188,8 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void stringKeyStringArrayValueFormData() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); @@ -208,7 +212,7 @@ public class HttpRequestExecutingMessageHandlerTests { HttpEntity request = template.lastRequestEntity.get(); Object body = request.getBody(); assertTrue(body instanceof MultiValueMap); - MultiValueMap map = (MultiValueMap ) body; + MultiValueMap map = (MultiValueMap) body; List aValue = map.get("a"); assertEquals(3, aValue.size()); @@ -232,14 +236,15 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void stringKeyPrimitiveArrayValueMixedFormData() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); setBeanFactory(handler); handler.afterPropertiesSet(); Map form = new LinkedHashMap(); - form.put("a", new int[]{1, 2, 3}); + form.put("a", new int[] { 1, 2, 3 }); form.put("b", "4"); form.put("c", new String[] { "5" }); form.put("d", "6"); @@ -255,7 +260,7 @@ public class HttpRequestExecutingMessageHandlerTests { HttpEntity request = template.lastRequestEntity.get(); Object body = request.getBody(); assertTrue(body instanceof MultiValueMap); - MultiValueMap map = (MultiValueMap ) body; + MultiValueMap map = (MultiValueMap) body; List aValue = map.get("a"); assertEquals(1, aValue.size()); @@ -279,16 +284,18 @@ public class HttpRequestExecutingMessageHandlerTests { assertEquals("6", dValue.get(0)); assertEquals(MediaType.MULTIPART_FORM_DATA, request.getHeaders().getContentType()); } + @Test public void stringKeyNullArrayValueMixedFormData() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); setBeanFactory(handler); handler.afterPropertiesSet(); Map form = new LinkedHashMap(); - form.put("a", new Object[]{null, 4, null}); + form.put("a", new Object[] { null, 4, null }); form.put("b", "4"); Message message = MessageBuilder.withPayload(form).build(); Exception exception = null; @@ -302,7 +309,7 @@ public class HttpRequestExecutingMessageHandlerTests { HttpEntity request = template.lastRequestEntity.get(); Object body = request.getBody(); assertTrue(body instanceof MultiValueMap); - MultiValueMap map = (MultiValueMap ) body; + MultiValueMap map = (MultiValueMap) body; List aValue = map.get("a"); assertEquals(3, aValue.size()); @@ -316,15 +323,17 @@ public class HttpRequestExecutingMessageHandlerTests { assertEquals(MediaType.MULTIPART_FORM_DATA, request.getHeaders().getContentType()); } + /** - * This test and the one below might look identical, but they are not. - * This test injected "5" into the list as String resulting in - * the Content-TYpe being application/x-www-form-urlencoded + * This test and the one below might look identical, but they are not. This test + * injected "5" into the list as String resulting in the Content-TYpe being + * application/x-www-form-urlencoded * @throws Exception */ @Test public void stringKeyNullCollectionValueMixedFormDataString() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); @@ -349,7 +358,7 @@ public class HttpRequestExecutingMessageHandlerTests { HttpEntity request = template.lastRequestEntity.get(); Object body = request.getBody(); assertTrue(body instanceof MultiValueMap); - MultiValueMap map = (MultiValueMap ) body; + MultiValueMap map = (MultiValueMap) body; List aValue = map.get("a"); assertEquals(3, aValue.size()); @@ -363,15 +372,16 @@ public class HttpRequestExecutingMessageHandlerTests { assertEquals(MediaType.APPLICATION_FORM_URLENCODED, request.getHeaders().getContentType()); } + /** - * This test and the one above might look identical, but they are not. - * This test injected 5 into the list as int resulting in - * Content-type being multipart/form-data + * This test and the one above might look identical, but they are not. This test + * injected 5 into the list as int resulting in Content-type being multipart/form-data * @throws Exception */ @Test public void stringKeyNullCollectionValueMixedFormDataObject() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); @@ -396,7 +406,7 @@ public class HttpRequestExecutingMessageHandlerTests { HttpEntity request = template.lastRequestEntity.get(); Object body = request.getBody(); assertTrue(body instanceof MultiValueMap); - MultiValueMap map = (MultiValueMap ) body; + MultiValueMap map = (MultiValueMap) body; List aValue = map.get("a"); assertEquals(3, aValue.size()); @@ -413,7 +423,8 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void stringKeyStringCollectionValueFormData() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); @@ -438,8 +449,7 @@ public class HttpRequestExecutingMessageHandlerTests { HttpEntity request = template.lastRequestEntity.get(); Object body = request.getBody(); assertTrue(body instanceof MultiValueMap); - MultiValueMap map = (MultiValueMap ) body; - + MultiValueMap map = (MultiValueMap) body; List aValue = map.get("a"); assertEquals(2, aValue.size()); @@ -458,7 +468,8 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void stringKeyObjectCollectionValueFormData() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); @@ -483,8 +494,7 @@ public class HttpRequestExecutingMessageHandlerTests { HttpEntity request = template.lastRequestEntity.get(); Object body = request.getBody(); assertTrue(body instanceof MultiValueMap); - MultiValueMap map = (MultiValueMap ) body; - + MultiValueMap map = (MultiValueMap) body; List aValue = map.get("a"); assertEquals(2, aValue.size()); @@ -503,7 +513,8 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void nameOnlyWithNullValues() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); @@ -540,7 +551,8 @@ public class HttpRequestExecutingMessageHandlerTests { @SuppressWarnings("cast") @Test public void contentAsByteArray() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); @@ -566,7 +578,8 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void contentAsXmlSource() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.POST); @@ -592,7 +605,8 @@ public class HttpRequestExecutingMessageHandlerTests { public void testWarnMessageForNonPostPutAndExtractPayload() throws Exception { // should see a warn message - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.GET); @@ -600,7 +614,7 @@ public class HttpRequestExecutingMessageHandlerTests { setBeanFactory(handler); handler.afterPropertiesSet(); - // should not see a warn message since 'setExtractPayload' is not set explicitly + // should not see a warn message since 'setExtractPayload' is not set explicitly handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); template = new MockRestTemplate(); @@ -609,7 +623,7 @@ public class HttpRequestExecutingMessageHandlerTests { setBeanFactory(handler); handler.afterPropertiesSet(); - // should not see a warn message since HTTP method is not GET + // should not see a warn message since HTTP method is not GET handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); template = new MockRestTemplate(); @@ -622,8 +636,9 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void contentTypeIsNotSetForGetRequest() throws Exception { - //GET - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + // GET + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); MockRestTemplate template = new MockRestTemplate(); new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); handler.setHttpMethod(HttpMethod.GET); @@ -642,80 +657,66 @@ public class HttpRequestExecutingMessageHandlerTests { HttpEntity request = template.lastRequestEntity.get(); assertNull(request.getHeaders().getContentType()); - /* TODO: reconsider the inclusion of content-type for various HttpMethods (only ignoring for GET as of 2.0.5) - * uncomment code below accordingly (see INT-1951) + /* + * TODO: reconsider the inclusion of content-type for various HttpMethods (only + * ignoring for GET as of 2.0.5) uncomment code below accordingly (see INT-1951) */ /* - //HEAD - handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); - template = new MockRestTemplate(); - new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); - handler.setHttpMethod(HttpMethod.HEAD); - - message = MessageBuilder.withPayload(mock(Source.class)).build(); - exception = null; - try { - handler.handleMessage(message); - } - catch (Exception e) { - exception = e; - } - assertEquals("intentional", exception.getCause().getMessage()); - request = template.lastRequestEntity.get(); - assertNull(request.getHeaders().getContentType()); - - //DELETE - handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); - template = new MockRestTemplate(); - new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); - handler.setHttpMethod(HttpMethod.DELETE); - - message = MessageBuilder.withPayload(mock(Source.class)).build(); - exception = null; - try { - handler.handleMessage(message); - } - catch (Exception e) { - exception = e; - } - assertEquals("intentional", exception.getCause().getMessage()); - request = template.lastRequestEntity.get(); - assertNull(request.getHeaders().getContentType()); - - //TRACE - handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); - template = new MockRestTemplate(); - new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); - handler.setHttpMethod(HttpMethod.TRACE); - - message = MessageBuilder.withPayload(mock(Source.class)).build(); - exception = null; - try { - handler.handleMessage(message); - } - catch (Exception e) { - exception = e; - } - assertEquals("intentional", exception.getCause().getMessage()); - request = template.lastRequestEntity.get(); - assertNull(request.getHeaders().getContentType()); - */ + * //HEAD handler = new HttpRequestExecutingMessageHandler( + * "http://www.springsource.org/spring-integration"); template = new + * MockRestTemplate(); new + * DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); + * handler.setHttpMethod(HttpMethod.HEAD); + * + * message = MessageBuilder.withPayload(mock(Source.class)).build(); exception = + * null; try { handler.handleMessage(message); } catch (Exception e) { exception = + * e; } assertEquals("intentional", exception.getCause().getMessage()); request = + * template.lastRequestEntity.get(); + * assertNull(request.getHeaders().getContentType()); + * + * //DELETE handler = new HttpRequestExecutingMessageHandler( + * "http://www.springsource.org/spring-integration"); template = new + * MockRestTemplate(); new + * DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); + * handler.setHttpMethod(HttpMethod.DELETE); + * + * message = MessageBuilder.withPayload(mock(Source.class)).build(); exception = + * null; try { handler.handleMessage(message); } catch (Exception e) { exception = + * e; } assertEquals("intentional", exception.getCause().getMessage()); request = + * template.lastRequestEntity.get(); + * assertNull(request.getHeaders().getContentType()); + * + * //TRACE handler = new HttpRequestExecutingMessageHandler( + * "http://www.springsource.org/spring-integration"); template = new + * MockRestTemplate(); new + * DirectFieldAccessor(handler).setPropertyValue("restTemplate", template); + * handler.setHttpMethod(HttpMethod.TRACE); + * + * message = MessageBuilder.withPayload(mock(Source.class)).build(); exception = + * null; try { handler.handleMessage(message); } catch (Exception e) { exception = + * e; } assertEquals("intentional", exception.getCause().getMessage()); request = + * template.lastRequestEntity.get(); + * assertNull(request.getHeaders().getContentType()); + */ } - @Test //INT-2275 + @Test // INT-2275 public void testOutboundChannelAdapterWithinChain() throws URISyntaxException { - ApplicationContext ctx = new ClassPathXmlApplicationContext("HttpOutboundWithinChainTests-context.xml", this.getClass()); + ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( + "HttpOutboundWithinChainTests-context.xml", this.getClass()); MessageChannel channel = ctx.getBean("httpOutboundChannelAdapterWithinChain", MessageChannel.class); RestTemplate restTemplate = ctx.getBean("restTemplate", RestTemplate.class); channel.send(MessageBuilder.withPayload("test").build()); - Mockito.verify(restTemplate).exchange(Mockito.eq(new URI("http://localhost/test1/%2f")), Mockito.eq(HttpMethod.POST), - Mockito.any(HttpEntity.class), Mockito.>eq(null)); + Mockito.verify(restTemplate).exchange(Mockito.eq(new URI("http://localhost/test1/%2f")), + Mockito.eq(HttpMethod.POST), Mockito.any(HttpEntity.class), Mockito.>eq(null)); + ctx.close(); } - @Test //INT-1029 + @Test // INT-1029 public void testHttpOutboundGatewayWithinChain() throws IOException, URISyntaxException { - ApplicationContext ctx = new ClassPathXmlApplicationContext("HttpOutboundWithinChainTests-context.xml", this.getClass()); + ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( + "HttpOutboundWithinChainTests-context.xml", this.getClass()); MessageChannel channel = ctx.getBean("httpOutboundGatewayWithinChain", MessageChannel.class); RestTemplate restTemplate = ctx.getBean("restTemplate", RestTemplate.class); channel.send(MessageBuilder.withPayload("test").build()); @@ -723,19 +724,20 @@ public class HttpRequestExecutingMessageHandlerTests { PollableChannel output = ctx.getBean("replyChannel", PollableChannel.class); Message receive = output.receive(); assertEquals(HttpStatus.OK, ((ResponseEntity) receive.getPayload()).getStatusCode()); - Mockito.verify(restTemplate) - .exchange(Mockito.eq(new URI("http://localhost:51235/%2f/testApps?param=http+Outbound+Gateway+Within+Chain")), - Mockito.eq(HttpMethod.POST), Mockito.any(HttpEntity.class), Mockito.eq(new ParameterizedTypeReference>() { + Mockito.verify(restTemplate).exchange( + Mockito.eq(new URI("http://localhost:51235/%2f/testApps?param=http+Outbound+Gateway+Within+Chain")), + Mockito.eq(HttpMethod.POST), Mockito.any(HttpEntity.class), + Mockito.eq(new ParameterizedTypeReference>() { - })); + })); + ctx.close(); } @Test public void testUriExpression() { MockRestTemplate restTemplate = new MockRestTemplate(); HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( - new SpelExpressionParser().parseExpression("headers['foo']"), - restTemplate); + new SpelExpressionParser().parseExpression("headers['foo']"), restTemplate); setBeanFactory(handler); handler.afterPropertiesSet(); String theURL = "http://bar/baz?foo#bar"; @@ -743,7 +745,8 @@ public class HttpRequestExecutingMessageHandlerTests { try { handler.handleRequestMessage(message); } - catch (Exception e) { } + catch (Exception e) { + } assertEquals(theURL, restTemplate.actualUrl.get()); } @@ -751,8 +754,7 @@ public class HttpRequestExecutingMessageHandlerTests { public void testInt2455UriNotEncoded() { MockRestTemplate restTemplate = new MockRestTemplate(); HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( - new SpelExpressionParser().parseExpression("'http://my.RabbitMQ.com/api/' + payload"), - restTemplate); + new SpelExpressionParser().parseExpression("'http://my.RabbitMQ.com/api/' + payload"), restTemplate); handler.setEncodeUri(false); setBeanFactory(handler); handler.afterPropertiesSet(); @@ -760,13 +762,15 @@ public class HttpRequestExecutingMessageHandlerTests { try { handler.handleRequestMessage(message); } - catch (Exception e) { } + catch (Exception e) { + } assertEquals("http://my.RabbitMQ.com/api/queues/%2f/si.test.queue?foo#bar", restTemplate.actualUrl.get()); } @Test public void acceptHeaderForSerializableResponse() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); handler.setHttpMethod(HttpMethod.GET); handler.setExpectedResponseType(Foo.class); @@ -799,7 +803,8 @@ public class HttpRequestExecutingMessageHandlerTests { @Test public void acceptHeaderForSerializableResponseMessageExchange() throws Exception { - HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration"); + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler( + "http://www.springsource.org/spring-integration"); handler.setHttpMethod(HttpMethod.GET); handler.setExtractPayload(false); @@ -844,8 +849,7 @@ public class HttpRequestExecutingMessageHandlerTests { ClientHttpRequest clientRequest = mock(ClientHttpRequest.class); when(clientRequest.getHeaders()).thenReturn(headers); - when(requestFactory.createRequest(any(URI.class), any(HttpMethod.class))) - .thenReturn(clientRequest); + when(requestFactory.createRequest(any(URI.class), any(HttpMethod.class))).thenReturn(clientRequest); ClientHttpResponse response = mock(ClientHttpResponse.class); when(response.getStatusCode()).thenReturn(HttpStatus.NOT_FOUND); @@ -898,13 +902,13 @@ public class HttpRequestExecutingMessageHandlerTests { @Override public ResponseEntity exchange(URI uri, HttpMethod method, HttpEntity requestEntity, - Class responseType) throws RestClientException { + Class responseType) throws RestClientException { return new ResponseEntity(HttpStatus.OK); } @Override public ResponseEntity exchange(URI url, HttpMethod method, HttpEntity requestEntity, - ParameterizedTypeReference responseType) throws RestClientException { + ParameterizedTypeReference responseType) throws RestClientException { return new ResponseEntity(HttpStatus.OK); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpOutboundGatewayParser.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpOutboundGatewayParser.java index a07f8a8d90..c298c23088 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpOutboundGatewayParser.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpOutboundGatewayParser.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. @@ -47,9 +47,9 @@ public class TcpOutboundGatewayParser extends AbstractConsumerEndpointParser { IpAdapterParserUtils.REPLY_CHANNEL); IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, IpAdapterParserUtils.REQUEST_TIMEOUT); - BeanDefinition remoteTimeoutExpression = IntegrationNamespaceUtils.createExpressionDefinitionFromValueOrExpression - (IpAdapterParserUtils.REMOTE_TIMEOUT, IpAdapterParserUtils.REMOTE_TIMEOUT_EXPRESSION, - parserContext, element, false); + BeanDefinition remoteTimeoutExpression = IntegrationNamespaceUtils + .createExpressionDefinitionFromValueOrExpression(IpAdapterParserUtils.REMOTE_TIMEOUT, + IpAdapterParserUtils.REMOTE_TIMEOUT_EXPRESSION, parserContext, element, false); if (remoteTimeoutExpression != null) { builder.addPropertyValue("remoteTimeoutExpression", remoteTimeoutExpression); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpSocketFactorySupport.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpSocketFactorySupport.java index 43d4c4dbe9..7e570f34ea 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpSocketFactorySupport.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpSocketFactorySupport.java @@ -31,17 +31,16 @@ import javax.net.SocketFactory; public interface TcpSocketFactorySupport { /** - * Supplies the {@link ServerSocketFactory} to be used to - * create new {@link ServerSocket}s. + * Supplies the {@link ServerSocketFactory} to be used to create new + * {@link ServerSocket}s. * @return the ServerSocketFacory */ - ServerSocketFactory getServerSocketFactory(); + ServerSocketFactory getServerSocketFactory(); - /** - * Supplies the {@link SocketFactory} to be used to - * create new {@link Socket}s. - * @return the SocketFactory - */ - SocketFactory getSocketFactory(); + /** + * Supplies the {@link SocketFactory} to be used to create new {@link Socket}s. + * @return the SocketFactory + */ + SocketFactory getSocketFactory(); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpSocketSupport.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpSocketSupport.java index 92d48efb5a..e8244a9936 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpSocketSupport.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpSocketSupport.java @@ -28,21 +28,19 @@ import java.net.Socket; public interface TcpSocketSupport { /** - * Performs any further modifications to the server socket - * after the connection factory has created the socket and - * set any configured attributes, before invoking + * Performs any further modifications to the server socket after the connection + * factory has created the socket and set any configured attributes, before invoking * {@link ServerSocket#accept()}. * @param serverSocket The ServerSocket */ - void postProcessServerSocket(ServerSocket serverSocket); + void postProcessServerSocket(ServerSocket serverSocket); - /** - * Performs any further modifications to the {@link Socket} after - * the socket has been created by a client, or accepted by - * a server, and after any configured atributes have been - * set. - * @param socket The Socket - */ - void postProcessSocket(Socket socket); + /** + * Performs any further modifications to the {@link Socket} after the socket has been + * created by a client, or accepted by a server, and after any configured atributes + * have been set. + * @param socket The Socket + */ + void postProcessSocket(Socket socket); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/util/TestingUtilities.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/util/TestingUtilities.java index 506c717889..a4a24a816f 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/util/TestingUtilities.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/util/TestingUtilities.java @@ -60,7 +60,7 @@ public final class TestingUtilities { } if (n++ > delay) { - throw new IllegalStateException ("Server didn't start listening."); + throw new IllegalStateException("Server didn't start listening."); } } } @@ -90,7 +90,7 @@ public final class TestingUtilities { throw new IllegalStateException(e); } if (n++ > 200) { - throw new IllegalStateException ("Server didn't stop listening."); + throw new IllegalStateException("Server didn't stop listening."); } } } diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MultiClientTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MultiClientTests.java index 839663bbcf..a84bb00e10 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MultiClientTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MultiClientTests.java @@ -66,7 +66,7 @@ public class MultiClientTests { final AtomicBoolean done = new AtomicBoolean(); for (int i = 0; i < drivers; i++) { - Thread t = new Thread( new Runnable() { + Thread t = new Thread(new Runnable() { @Override public void run() { UnicastSendingMessageHandler sender = new UnicastSendingMessageHandler( @@ -85,10 +85,10 @@ public class MultiClientTests { t.setDaemon(true); t.start(); } - for (int i = 0; i < drivers * 3 ; i++) { + for (int i = 0; i < drivers * 3; i++) { queueIn.send(MessageBuilder.withPayload(payload).build()); } - for (int i = 0; i < drivers * 3 ; i++) { + for (int i = 0; i < drivers * 3; i++) { Message messageOut = (Message) queue.receive(10000); assertNotNull(messageOut); Assert.assertEquals(payload, new String(messageOut.getPayload())); @@ -116,7 +116,7 @@ public class MultiClientTests { for (int i = 0; i < drivers; i++) { final int j = i; - Thread t = new Thread( new Runnable() { + Thread t = new Thread(new Runnable() { @Override public void run() { UnicastSendingMessageHandler sender = new UnicastSendingMessageHandler( @@ -138,10 +138,10 @@ public class MultiClientTests { t.setDaemon(true); t.start(); } - for (int i = 0; i < drivers * 3 ; i++) { + for (int i = 0; i < drivers * 3; i++) { queueIn.send(MessageBuilder.withPayload(payload).build()); } - for (int i = 0; i < drivers * 3 ; i++) { + for (int i = 0; i < drivers * 3; i++) { Message messageOut = (Message) queue.receive(20000); assertNotNull(messageOut); Assert.assertEquals(payload, new String(messageOut.getPayload())); @@ -169,7 +169,7 @@ public class MultiClientTests { for (int i = 0; i < drivers; i++) { final int j = i; - Thread t = new Thread( new Runnable() { + Thread t = new Thread(new Runnable() { @Override public void run() { UnicastSendingMessageHandler sender = new UnicastSendingMessageHandler( @@ -191,10 +191,10 @@ public class MultiClientTests { t.setDaemon(true); t.start(); } - for (int i = 0; i < drivers * 3 ; i++) { + for (int i = 0; i < drivers * 3; i++) { queueIn.send(MessageBuilder.withPayload(payload).build()); } - for (int i = 0; i < drivers * 3 ; i++) { + for (int i = 0; i < drivers * 3; i++) { Message messageOut = (Message) queue.receive(10000); assertNotNull(messageOut); Assert.assertEquals(payload, new String(messageOut.getPayload())); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/util/RegexUtilsTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/util/RegexUtilsTests.java index fdb632267b..2bc58195aa 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/util/RegexUtilsTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/util/RegexUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 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. @@ -29,7 +29,7 @@ public class RegexUtilsTests { * Verify that we properly escape all special characters for matching regex */ @Test - public void testRegex () { + public void testRegex() { String s = "xxx$^[]{()}+*\\?|.xxx"; assertEquals("xxx\\$\\^\\[\\]\\{\\(\\)\\}\\+\\*\\\\\\?\\|\\.xxx", RegexUtils.escapeRegexSpecials(s)); } diff --git a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/StoredProcExecutor.java b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/StoredProcExecutor.java index fa8425443d..25e23f10f5 100644 --- a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/StoredProcExecutor.java +++ b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/StoredProcExecutor.java @@ -142,7 +142,7 @@ public class StoredProcExecutor implements BeanFactoryAware, InitializingBean { * Custom Stored Procedure parameters that may contain static values * or Strings representing an {@link Expression}. */ - private volatile ListprocedureParameters; + private volatile List procedureParameters; private volatile boolean isFunction = false; @@ -181,7 +181,7 @@ public class StoredProcExecutor implements BeanFactoryAware, InitializingBean { + "Stored Procedure Name or a Stored Procedure Name Expression."); } - if (this.procedureParameters != null ) { + if (this.procedureParameters != null) { if (this.sqlParameterSourceFactory == null) { ExpressionEvaluatingSqlParameterSourceFactory expressionSourceFactory = diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcJmxManagedBeanTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcJmxManagedBeanTests.java index f5ed3d8a48..050a87b7db 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcJmxManagedBeanTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcJmxManagedBeanTests.java @@ -73,12 +73,13 @@ public class StoredProcJmxManagedBeanTests { // MessageHandler final Set messageHandlerObjectNames = server.queryNames( - ObjectName.getInstance("org.springframework.integration.jdbc.test:name=outboundChannelAdapter.adapter.storedProcExecutor,*"), + ObjectName.getInstance( + "org.springframework.integration.jdbc.test:name=outboundChannelAdapter.adapter.storedProcExecutor,*"), null); assertEquals(1, messageHandlerObjectNames.size()); ObjectName messageHandlerObjectName = messageHandlerObjectNames.iterator().next(); - Map messageHandlerCacheStatistics = - (Map) server.getAttribute(messageHandlerObjectName, "JdbcCallOperationsCacheStatisticsAsMap"); + Map messageHandlerCacheStatistics = (Map) server + .getAttribute(messageHandlerObjectName, "JdbcCallOperationsCacheStatisticsAsMap"); assertEquals(11, messageHandlerCacheStatistics.size()); @@ -89,13 +90,12 @@ public class StoredProcJmxManagedBeanTests { assertEquals(0L, messageHandlerCacheStatistics.get("missCount")); // StoredProcOutboundGateway - final Set storedProcOutboundGatewayObjectNames = server.queryNames( - ObjectName.getInstance("org.springframework.integration.jdbc.test:name=my gateway.storedProcExecutor,*"), - null); + final Set storedProcOutboundGatewayObjectNames = server.queryNames(ObjectName + .getInstance("org.springframework.integration.jdbc.test:name=my gateway.storedProcExecutor,*"), null); assertEquals(1, storedProcOutboundGatewayObjectNames.size()); ObjectName storedProcOutboundGatewayObjectName = storedProcOutboundGatewayObjectNames.iterator().next(); - Map storedProcOutboundGatewayCacheStatistics = - (Map) server.getAttribute(storedProcOutboundGatewayObjectName, "JdbcCallOperationsCacheStatisticsAsMap"); + Map storedProcOutboundGatewayCacheStatistics = (Map) server + .getAttribute(storedProcOutboundGatewayObjectName, "JdbcCallOperationsCacheStatisticsAsMap"); assertEquals(11, messageHandlerCacheStatistics.size()); @@ -107,10 +107,15 @@ public class StoredProcJmxManagedBeanTests { // StoredProcPollingChannelAdapter - final Set storedProcPollingChannelAdapterObjectNames = server.queryNames(ObjectName.getInstance("org.springframework.integration.jdbc.test:name=inbound-channel-adapter.storedProcExecutor,*"), null); + final Set storedProcPollingChannelAdapterObjectNames = server.queryNames( + ObjectName.getInstance( + "org.springframework.integration.jdbc.test:name=inbound-channel-adapter.storedProcExecutor,*"), + null); assertEquals(1, storedProcPollingChannelAdapterObjectNames.size()); - ObjectName storedProcPollingChannelAdapterObjectName = storedProcPollingChannelAdapterObjectNames.iterator().next(); - MapstoredProcPollingChannelAdapterCacheStatistics = (Map) server.getAttribute(storedProcPollingChannelAdapterObjectName, "JdbcCallOperationsCacheStatisticsAsMap"); + ObjectName storedProcPollingChannelAdapterObjectName = storedProcPollingChannelAdapterObjectNames.iterator() + .next(); + Map storedProcPollingChannelAdapterCacheStatistics = (Map) server + .getAttribute(storedProcPollingChannelAdapterObjectName, "JdbcCallOperationsCacheStatisticsAsMap"); assertEquals(11, storedProcPollingChannelAdapterCacheStatistics.size()); @@ -188,7 +193,8 @@ public class StoredProcJmxManagedBeanTests { static class Consumer { - private final BlockingQueue>> messages = new LinkedBlockingQueue>>(); + private final BlockingQueue>> messages = + new LinkedBlockingQueue>>(); @ServiceActivator public void receive(Message> message) { diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcMessageHandlerDerbyIntegrationTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcMessageHandlerDerbyIntegrationTests.java index c76bc897b3..56083bbfdd 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcMessageHandlerDerbyIntegrationTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcMessageHandlerDerbyIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 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. @@ -189,7 +189,7 @@ public class StoredProcMessageHandlerDerbyIntegrationTests { final List procedureParameters = new ArrayList(); procedureParameters.add(new ProcedureParameter("USERNAME", null, "headers[business_id] + '_' + payload.username")); procedureParameters.add(new ProcedureParameter("password", "static_password", null)); - procedureParameters.add(new ProcedureParameter("email", "static_email" , null)); + procedureParameters.add(new ProcedureParameter("email", "static_email", null)); storedProcExecutor.setProcedureParameters(procedureParameters); storedProcExecutor.setBeanFactory(mock(BeanFactory.class)); diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithNamespace2IntegrationTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithNamespace2IntegrationTests.java index 50f69fc624..53727c0698 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithNamespace2IntegrationTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithNamespace2IntegrationTests.java @@ -39,62 +39,61 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Gunnar Hillert + * @author Gary Russell */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @DirtiesContext // close at the end after class public class StoredProcPollingChannelAdapterWithNamespace2IntegrationTests { - @Autowired - private AbstractApplicationContext context; - - @Autowired - private Consumer consumer; + @Autowired + private AbstractApplicationContext context; + @Autowired + private Consumer consumer; @Test - public void pollH2DatabaseUsingStoredProcedureCall() throws Exception { - List>> received = new ArrayList>>(); + public void pollH2DatabaseUsingStoredProcedureCall() throws Exception { + List>> received = new ArrayList>>(); - received.add(consumer.poll(60000)); + received.add(consumer.poll(60000)); - Message> message = received.get(0); - context.stop(); - assertNotNull(message); - assertNotNull(message.getPayload()); - assertTrue(message.getPayload() instanceof List); + Message> message = received.get(0); + context.stop(); + assertNotNull(message); + assertNotNull(message.getPayload()); + assertTrue(message.getPayload() instanceof List); - List resultList = message.getPayload(); + List resultList = message.getPayload(); - assertTrue(resultList.size() == 1); + assertTrue(resultList.size() == 1); - } + } - static class Counter { + static class Counter { - private final AtomicInteger count = new AtomicInteger(); + private final AtomicInteger count = new AtomicInteger(); - public Integer next() throws InterruptedException { - if (count.get() > 2) { - //prevent message overload - return null; - } - return Integer.valueOf(count.incrementAndGet()); - } - } + public Integer next() throws InterruptedException { + if (count.get() > 2) { + // prevent message overload + return null; + } + return Integer.valueOf(count.incrementAndGet()); + } + } + static class Consumer { - static class Consumer { + private final BlockingQueue>> messages = new LinkedBlockingQueue>>(); - private final BlockingQueue>> messages = new LinkedBlockingQueue>>(); + @ServiceActivator + public void receive(Message> message) { + messages.add(message); + } - @ServiceActivator - public void receive(Message>message) { - messages.add(message); - } - - Message> poll(long timeoutInMillis) throws InterruptedException { - return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS); - } - } + Message> poll(long timeoutInMillis) throws InterruptedException { + return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS); + } + } } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithNamespaceIntegrationTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithNamespaceIntegrationTests.java index 1db60096ba..b4e935934a 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithNamespaceIntegrationTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithNamespaceIntegrationTests.java @@ -48,56 +48,55 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @DirtiesContext // close at the end after class public class StoredProcPollingChannelAdapterWithNamespaceIntegrationTests { - @Autowired - private AbstractApplicationContext context; + @Autowired + private AbstractApplicationContext context; - @Autowired - private Consumer consumer; + @Autowired + private Consumer consumer; - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") @Test - public void pollH2DatabaseUsingStoredProcedureCall() throws Exception { - List> received = new ArrayList>(); + public void pollH2DatabaseUsingStoredProcedureCall() throws Exception { + List> received = new ArrayList>(); - received.add(consumer.poll(60000)); + received.add(consumer.poll(60000)); - Message message = received.get(0); - context.stop(); - assertNotNull(message); - assertNotNull(message.getPayload()); - assertNotNull(message.getPayload() instanceof Collection); + Message message = received.get(0); + context.stop(); + assertNotNull(message); + assertNotNull(message.getPayload()); + assertNotNull(message.getPayload() instanceof Collection); - List primeNumbers = (List) message.getPayload(); + List primeNumbers = (List) message.getPayload(); assertThat(primeNumbers, contains(2, 3, 5, 7)); - } + } - static class Counter { + static class Counter { - private final AtomicInteger count = new AtomicInteger(); + private final AtomicInteger count = new AtomicInteger(); - public Integer next() throws InterruptedException { - if (count.get() > 2) { - //prevent message overload - return null; - } - return Integer.valueOf(count.incrementAndGet()); - } - } + public Integer next() throws InterruptedException { + if (count.get() > 2) { + // prevent message overload + return null; + } + return Integer.valueOf(count.incrementAndGet()); + } + } + static class Consumer { - static class Consumer { + private final BlockingQueue> messages = new LinkedBlockingQueue>(); - private final BlockingQueue> messages = new LinkedBlockingQueue>(); + @ServiceActivator + public void receive(Message message) { + messages.add(message); + } - @ServiceActivator - public void receive(Messagemessage) { - messages.add(message); - } - - Message poll(long timeoutInMillis) throws InterruptedException { - return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS); - } - } + Message poll(long timeoutInMillis) throws InterruptedException { + return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS); + } + } } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithSpringContextIntegrationTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithSpringContextIntegrationTests.java index 4976aa0ec2..00983586ab 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithSpringContextIntegrationTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcPollingChannelAdapterWithSpringContextIntegrationTests.java @@ -46,55 +46,54 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @DirtiesContext // close at the end after class public class StoredProcPollingChannelAdapterWithSpringContextIntegrationTests { - @Autowired - private AbstractApplicationContext context; + @Autowired + private AbstractApplicationContext context; - @Autowired - private Consumer consumer; + @Autowired + private Consumer consumer; @Test - public void test() throws Exception { - List>> received = new ArrayList>>(); + public void test() throws Exception { + List>> received = new ArrayList>>(); - received.add(consumer.poll(2000)); + received.add(consumer.poll(2000)); - Message> message = received.get(0); - context.stop(); - assertNotNull(message); - assertNotNull(message.getPayload()); - assertNotNull(message.getPayload() instanceof Collection); + Message> message = received.get(0); + context.stop(); + assertNotNull(message); + assertNotNull(message.getPayload()); + assertNotNull(message.getPayload() instanceof Collection); - Collection primeNumbers = message.getPayload(); + Collection primeNumbers = message.getPayload(); - assertTrue(primeNumbers.size() == 4); + assertTrue(primeNumbers.size() == 4); - } + } - static class Counter { + static class Counter { - private final AtomicInteger count = new AtomicInteger(); + private final AtomicInteger count = new AtomicInteger(); - public Integer next() throws InterruptedException { - if (count.get() > 2) { - //prevent message overload - return null; - } - return Integer.valueOf(count.incrementAndGet()); - } - } + public Integer next() throws InterruptedException { + if (count.get() > 2) { + // prevent message overload + return null; + } + return Integer.valueOf(count.incrementAndGet()); + } + } + static class Consumer { - static class Consumer { + private final BlockingQueue>> messages = new LinkedBlockingQueue>>(); - private final BlockingQueue>> messages = new LinkedBlockingQueue>>(); + @ServiceActivator + public void receive(Message> message) { + messages.add(message); + } - @ServiceActivator - public void receive(Message>message) { - messages.add(message); - } - - Message> poll(long timeoutInMillis) throws InterruptedException { - return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS); - } - } + Message> poll(long timeoutInMillis) throws InterruptedException { + return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS); + } + } } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/JdbcPollingChannelAdapterParserTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/JdbcPollingChannelAdapterParserTests.java index 3e3e2be4cc..63ee22c0e9 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/JdbcPollingChannelAdapterParserTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/JdbcPollingChannelAdapterParserTests.java @@ -133,12 +133,12 @@ public class JdbcPollingChannelAdapterParserTests { this.jdbcTemplate.update("insert into item values(1,'',42)"); Message message = messagingTemplate.receive(); assertNotNull(message); - assertEquals(42, ((Map) ((List ) message.getPayload()).get(0)).get("STATUS")); + assertEquals(42, ((Map) ((List) message.getPayload()).get(0)).get("STATUS")); this.jdbcTemplate.update("insert into item values(2,'',84)"); this.appCtx.getBean(Status.class).which = 84; message = messagingTemplate.receive(); assertNotNull(message); - assertEquals(84, ((Map) ((List ) message.getPayload()).get(0)).get("STATUS")); + assertEquals(84, ((Map) ((List) message.getPayload()).get(0)).get("STATUS")); } @Test diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcMessageHandlerParserTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcMessageHandlerParserTests.java index 9aa264fe55..13a89b98d3 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcMessageHandlerParserTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcMessageHandlerParserTests.java @@ -16,30 +16,31 @@ package org.springframework.integration.jdbc.config; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; import java.sql.Types; import java.util.List; import org.junit.After; import org.junit.Test; + import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.expression.Expression; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageHandler; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice; import org.springframework.integration.jdbc.storedproc.ProcedureParameter; -import org.springframework.messaging.support.GenericMessage; import org.springframework.integration.test.util.TestUtils; import org.springframework.jdbc.core.SqlInOutParameter; import org.springframework.jdbc.core.SqlOutParameter; import org.springframework.jdbc.core.SqlParameter; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageHandler; +import org.springframework.messaging.support.GenericMessage; /** * @author Gunnar Hillert @@ -86,7 +87,7 @@ public class StoredProcMessageHandlerParserTests { assertNotNull(procedureParameters); assertTrue(procedureParameters instanceof List); - ListprocedureParametersAsList = (List) procedureParameters; + List procedureParametersAsList = (List) procedureParameters; assertTrue(procedureParametersAsList.size() == 4); @@ -129,7 +130,7 @@ public class StoredProcMessageHandlerParserTests { assertNotNull(sqlParameters); assertTrue(sqlParameters instanceof List); - ListsqlParametersAsList = (List) sqlParameters; + List sqlParametersAsList = (List) sqlParameters; assertTrue(sqlParametersAsList.size() == 4); diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcOutboundGatewayParserTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcOutboundGatewayParserTests.java index 17f6aa4215..efa4c52022 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcOutboundGatewayParserTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/StoredProcOutboundGatewayParserTests.java @@ -29,15 +29,16 @@ import java.util.Map.Entry; import org.junit.After; import org.junit.Test; + import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.expression.Expression; +import org.springframework.integration.core.MessagingTemplate; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice; import org.springframework.integration.jdbc.storedproc.PrimeMapper; import org.springframework.integration.jdbc.storedproc.ProcedureParameter; -import org.springframework.messaging.support.GenericMessage; import org.springframework.integration.test.util.TestUtils; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.SqlInOutParameter; @@ -45,7 +46,7 @@ import org.springframework.jdbc.core.SqlOutParameter; import org.springframework.jdbc.core.SqlParameter; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; -import org.springframework.integration.core.MessagingTemplate; +import org.springframework.messaging.support.GenericMessage; /** * @author Gunnar Hillert @@ -182,7 +183,7 @@ public class StoredProcOutboundGatewayParserTests { assertNotNull(procedureParameters); assertTrue(procedureParameters instanceof List); - ListprocedureParametersAsList = (List) procedureParameters; + List procedureParametersAsList = (List) procedureParameters; assertTrue(procedureParametersAsList.size() == 4); @@ -248,7 +249,7 @@ public class StoredProcOutboundGatewayParserTests { assertNotNull(sqlParameters); assertTrue(sqlParameters instanceof List); - ListsqlParametersAsList = (List) sqlParameters; + List sqlParametersAsList = (List) sqlParameters; assertTrue(sqlParametersAsList.size() == 4); diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests.java index 46eeff62dc..4a153bdb74 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreMultipleChannelTests.java @@ -148,7 +148,7 @@ public class MySqlJdbcMessageStoreMultipleChannelTests { super(); } - public void first(Message message ) { + public void first(Message message) { int sequenceNumber = new IntegrationMessageHeaderAccessor(message).getSequenceNumber(); @@ -161,7 +161,7 @@ public class MySqlJdbcMessageStoreMultipleChannelTests { countDownLatch1.countDown(); } - public void second(Message message ) { + public void second(Message message) { int sequenceNumber = new IntegrationMessageHeaderAccessor(message).getSequenceNumber(); LOG.info("Second handling sequence number: " + sequenceNumber + "; Message ID: " + message.getHeaders().getId()); diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/storedproc/derby/DerbyFunctions.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/storedproc/derby/DerbyFunctions.java index bd008d558a..5eb4703f65 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/storedproc/derby/DerbyFunctions.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/storedproc/derby/DerbyFunctions.java @@ -30,7 +30,7 @@ public final class DerbyFunctions { super(); } - public static String convertStringToUpperCase( String invalue ) { + public static String convertStringToUpperCase(String invalue) { return invalue.toUpperCase(Locale.ENGLISH); } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/storedproc/derby/DerbyStoredProcedures.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/storedproc/derby/DerbyStoredProcedures.java index 2522041340..382c34d10c 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/storedproc/derby/DerbyStoredProcedures.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/storedproc/derby/DerbyStoredProcedures.java @@ -89,7 +89,7 @@ public final class DerbyStoredProcedures { Connection conn = DriverManager.getConnection("jdbc:default:connection"); PreparedStatement stmt = conn.prepareStatement("select MESSAGE_JSON from JSON_MESSAGE where MESSAGE_ID = ?"); - stmt.setString( 1, messageId); + stmt.setString(1, messageId); ResultSet results = stmt.executeQuery(); if (results.next()) { returnedData[0] = results.getClob(1); diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/SubscribableJmsChannelTests.java b/spring-integration-jms/src/test/java/org/springframework/integration/jms/SubscribableJmsChannelTests.java index 029c3af4a3..206a28384c 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/SubscribableJmsChannelTests.java +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/SubscribableJmsChannelTests.java @@ -99,7 +99,7 @@ public class SubscribableJmsChannelTests { @Test public void queueReference() throws Exception { final CountDownLatch latch = new CountDownLatch(2); - final List> receivedList1 = Collections.synchronizedList( new ArrayList>()); + final List> receivedList1 = Collections.synchronizedList(new ArrayList>()); MessageHandler handler1 = new MessageHandler() { @Override public void handleMessage(Message message) { @@ -107,7 +107,7 @@ public class SubscribableJmsChannelTests { latch.countDown(); } }; - final List> receivedList2 = Collections.synchronizedList( new ArrayList>()); + final List> receivedList2 = Collections.synchronizedList(new ArrayList>()); MessageHandler handler2 = new MessageHandler() { @Override public void handleMessage(Message message) { @@ -140,7 +140,7 @@ public class SubscribableJmsChannelTests { @Test public void topicReference() throws Exception { final CountDownLatch latch = new CountDownLatch(4); - final List> receivedList1 = Collections.synchronizedList( new ArrayList>()); + final List> receivedList1 = Collections.synchronizedList(new ArrayList>()); MessageHandler handler1 = new MessageHandler() { @Override public void handleMessage(Message message) { @@ -148,7 +148,7 @@ public class SubscribableJmsChannelTests { latch.countDown(); } }; - final List> receivedList2 = Collections.synchronizedList( new ArrayList>()); + final List> receivedList2 = Collections.synchronizedList(new ArrayList>()); MessageHandler handler2 = new MessageHandler() { @Override public void handleMessage(Message message) { @@ -184,7 +184,7 @@ public class SubscribableJmsChannelTests { @Test public void queueName() throws Exception { final CountDownLatch latch = new CountDownLatch(2); - final List> receivedList1 = Collections.synchronizedList( new ArrayList>()); + final List> receivedList1 = Collections.synchronizedList(new ArrayList>()); MessageHandler handler1 = new MessageHandler() { @Override @@ -193,7 +193,7 @@ public class SubscribableJmsChannelTests { latch.countDown(); } }; - final List> receivedList2 = Collections.synchronizedList( new ArrayList>()); + final List> receivedList2 = Collections.synchronizedList(new ArrayList>()); MessageHandler handler2 = new MessageHandler() { @Override @@ -232,7 +232,7 @@ public class SubscribableJmsChannelTests { @Test public void topicName() throws Exception { final CountDownLatch latch = new CountDownLatch(4); - final List> receivedList1 = Collections.synchronizedList( new ArrayList>()); + final List> receivedList1 = Collections.synchronizedList(new ArrayList>()); MessageHandler handler1 = new MessageHandler() { @Override public void handleMessage(Message message) { @@ -240,7 +240,7 @@ public class SubscribableJmsChannelTests { latch.countDown(); } }; - final List> receivedList2 = Collections.synchronizedList( new ArrayList>()); + final List> receivedList2 = Collections.synchronizedList(new ArrayList>()); MessageHandler handler2 = new MessageHandler() { @Override public void handleMessage(Message message) { diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/OperationInvokingMessageHandler.java b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/OperationInvokingMessageHandler.java index 822581d667..e506874197 100644 --- a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/OperationInvokingMessageHandler.java +++ b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/OperationInvokingMessageHandler.java @@ -133,8 +133,8 @@ public class OperationInvokingMessageHandler extends AbstractReplyProducingMessa } if (paramInfoArray.length == paramsFromMessage.size()) { int index = 0; - Object values[] = new Object[paramInfoArray.length]; - String signature[] = new String[paramInfoArray.length]; + Object[] values = new Object[paramInfoArray.length]; + String[] signature = new String[paramInfoArray.length]; for (MBeanParameterInfo paramInfo : paramInfoArray) { Object value = paramsFromMessage.get(paramInfo.getName()); if (value == null) { diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/NotificationPublishingChannelAdapterParserTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/NotificationPublishingChannelAdapterParserTests.java index fd914c10c9..bc9d2e9142 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/NotificationPublishingChannelAdapterParserTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/NotificationPublishingChannelAdapterParserTests.java @@ -26,6 +26,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.Set; + import javax.management.Attribute; import javax.management.MBeanException; import javax.management.MBeanServer; @@ -123,8 +124,11 @@ public class NotificationPublishingChannelAdapterParserTests { @Test //INT-2275 public void publishStringMessageWithinChain() throws Exception { - assertNotNull(this.beanFactory.getBean("chainWithJmxNotificationPublishing$child.jmx-notification-publishing-channel-adapter-within-chain.handler", - MessageHandler.class)); + assertNotNull( + this.beanFactory.getBean( + "chainWithJmxNotificationPublishing$child." + + "jmx-notification-publishing-channel-adapter-within-chain.handler", + MessageHandler.class)); assertNull(listener.lastNotification); Message message = MessageBuilder.withPayload("XYZ") .setHeader(JmxHeaders.NOTIFICATION_TYPE, "test.type").build(); @@ -134,10 +138,9 @@ public class NotificationPublishingChannelAdapterParserTests { assertEquals("XYZ", notification.getMessage()); assertEquals("test.type", notification.getType()); assertNull(notification.getUserData()); - Set names = server.queryNames( - new ObjectName("*:type=MessageHandler," + - "name=chainWithJmxNotificationPublishing$child.jmx-notification-publishing-channel-adapter-within-chain,*") - , null); + Set names = server + .queryNames(new ObjectName("*:type=MessageHandler," + "name=chainWithJmxNotificationPublishing$child." + + "jmx-notification-publishing-channel-adapter-within-chain,*"), null); assertEquals(1, names.size()); } diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/IdempotentReceiverIntegrationTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/IdempotentReceiverIntegrationTests.java index 2d2aeb7e7c..896c790205 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/IdempotentReceiverIntegrationTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/IdempotentReceiverIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2015 the original author or authors. + * Copyright 2014-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. @@ -192,7 +192,7 @@ public class IdempotentReceiverIntegrationTests { @Bean public HazelcastInstance hazelcastInstance() { - return Hazelcast.newHazelcastInstance(new Config().setProperty( "hazelcast.logging.type", "log4j" )); + return Hazelcast.newHazelcastInstance(new Config().setProperty("hazelcast.logging.type", "log4j")); } diff --git a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java index 90895539dd..8c08dad83d 100644 --- a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java +++ b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/core/JpaExecutor.java @@ -17,6 +17,7 @@ package org.springframework.integration.jpa.core; import java.util.List; + import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Query; @@ -616,13 +617,13 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware { } /** - * Set the max number of results to retrieve from the database. Defaults to - * 0, which means that all possible objects shall be retrieved. - * @param maxNumberOfResults Must not be negative. - * @see Query#setMaxResults(int) - */ - public void setMaxNumberOfResults(int maxNumberOfResults) { + * Set the max number of results to retrieve from the database. Defaults to + * 0, which means that all possible objects shall be retrieved. + * @param maxNumberOfResults Must not be negative. + * @see Query#setMaxResults(int) + */ + public void setMaxNumberOfResults(int maxNumberOfResults) { this.setMaxResultsExpression(new LiteralExpression("" + maxNumberOfResults)); - } + } } diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/core/AbstractJpaOperationsTests.java b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/core/AbstractJpaOperationsTests.java index 11b91ecb21..ba055e3518 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/core/AbstractJpaOperationsTests.java +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/core/AbstractJpaOperationsTests.java @@ -106,7 +106,7 @@ public class AbstractJpaOperationsTests { entityManager.flush(); - Assert.assertTrue( 1 == updatedRecords); + Assert.assertTrue(1 == updatedRecords); Assert.assertNull(student.getRollNumber()); } @@ -127,7 +127,7 @@ public class AbstractJpaOperationsTests { entityManager.flush(); - Assert.assertTrue( 1 == updatedRecords); + Assert.assertTrue(1 == updatedRecords); Assert.assertNull(student.getRollNumber()); } @@ -148,7 +148,7 @@ public class AbstractJpaOperationsTests { entityManager.flush(); - Assert.assertTrue( 1 == updatedRecords); + Assert.assertTrue(1 == updatedRecords); Assert.assertNull(student.getRollNumber()); } @@ -218,7 +218,7 @@ public class AbstractJpaOperationsTests { entityManager.flush(); - Assert.assertTrue( 1 == updatedRecords); + Assert.assertTrue(1 == updatedRecords); Assert.assertNull(student.getRollNumber()); } diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/test/Consumer.java b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/test/Consumer.java index 3961f7409f..0c5eee311b 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/test/Consumer.java +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/test/Consumer.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.messaging.Message; /** @@ -37,7 +38,7 @@ public final class Consumer { private static final BlockingQueue>> MESSAGES = new LinkedBlockingQueue>>(); - public synchronized void receive(Message>message) { + public synchronized void receive(Message> message) { logger.info("Service Activator received Message: " + message); MESSAGES.add(message); } diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java index f36a6bbef3..cfe9f8beaa 100755 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java @@ -155,7 +155,7 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be @Override // guarded by super#lifecycleLock protected void doStart() { final TaskScheduler scheduler = this.getTaskScheduler(); - Assert.notNull(scheduler, "'taskScheduler' must not be null" ); + Assert.notNull(scheduler, "'taskScheduler' must not be null"); if (this.sendingTaskExecutor == null) { this.sendingTaskExecutor = Executors.newFixedThreadPool(1); } @@ -254,7 +254,7 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be @Override public void run() { final TaskScheduler scheduler = getTaskScheduler(); - Assert.notNull(scheduler, "'taskScheduler' must not be null" ); + Assert.notNull(scheduler, "'taskScheduler' must not be null"); /* * The following shouldn't be necessary because doStart() will have ensured we have * one. But, just in case... diff --git a/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java b/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java index 6e246c0398..30686d86dc 100644 --- a/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java +++ b/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java @@ -852,7 +852,7 @@ public class ImapMailReceiverTests { receiver.setBeanFactory(mock(BeanFactory.class)); receiver.afterPropertiesSet(); - doAnswer(new Answer () { + doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { diff --git a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/MongoDbMessageGroupStoreTests.java b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/MongoDbMessageGroupStoreTests.java index ae4c75eb7b..be808bc39f 100644 --- a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/MongoDbMessageGroupStoreTests.java +++ b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/MongoDbMessageGroupStoreTests.java @@ -33,7 +33,7 @@ public class MongoDbMessageGroupStoreTests extends AbstractMongoDbMessageGroupSt @Override protected MongoDbMessageStore getMessageGroupStore() throws Exception { - MongoDbMessageStore mongoDbMessageStore = new MongoDbMessageStore( new SimpleMongoDbFactory(new MongoClient(), "test")); + MongoDbMessageStore mongoDbMessageStore = new MongoDbMessageStore(new SimpleMongoDbFactory(new MongoClient(), "test")); mongoDbMessageStore.afterPropertiesSet(); return mongoDbMessageStore; } diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueInboundGateway.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueInboundGateway.java index 217135f5ed..010ce50157 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueInboundGateway.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueInboundGateway.java @@ -234,17 +234,7 @@ public class RedisQueueInboundGateway extends MessagingGatewaySupport implements Message replyMessage = this.sendAndReceiveMessage(requestMessage); if (replyMessage != null) { if (this.extractPayload) { - if (!(replyMessage.getPayload() instanceof byte[])) { - if (replyMessage.getPayload() instanceof String && !this.serializerExplicitlySet) { - value = stringSerializer.serialize((String) replyMessage.getPayload()); - } - else { - value = ((RedisSerializer) this.serializer).serialize(replyMessage.getPayload()); - } - } - else { - value = (byte[]) replyMessage.getPayload(); - } + value = extractReplyPayload(replyMessage); } else { if (this.serializer != null) { @@ -257,6 +247,23 @@ public class RedisQueueInboundGateway extends MessagingGatewaySupport implements } } + @SuppressWarnings("unchecked") + private byte[] extractReplyPayload(Message replyMessage) { + byte[] value; + if (!(replyMessage.getPayload() instanceof byte[])) { + if (replyMessage.getPayload() instanceof String && !this.serializerExplicitlySet) { + value = stringSerializer.serialize((String) replyMessage.getPayload()); + } + else { + value = ((RedisSerializer) this.serializer).serialize(replyMessage.getPayload()); + } + } + else { + value = (byte[]) replyMessage.getPayload(); + } + return value; + } + @Override protected void doStart() { super.doStart(); diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java index 144c8445cc..0482ae1332 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java @@ -97,7 +97,7 @@ public class RedisInboundChannelAdapterParserTests extends RedisAvailableTests { for (int i = 0; i < 3; i++) { Message receive = receiveChannel.receive(2000); assertNotNull(receive); - assertThat(receive.getPayload(), Matchers. isOneOf("Hello Redis from foo", "Hello Redis from bar")); + assertThat(receive.getPayload(), Matchers.isOneOf("Hello Redis from foo", "Hello Redis from bar")); } } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisInboundChannelAdapterTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisInboundChannelAdapterTests.java index 25fbb9c60d..735eeed762 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisInboundChannelAdapterTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisInboundChannelAdapterTests.java @@ -47,7 +47,7 @@ public class RedisInboundChannelAdapterTests extends RedisAvailableTests { @Test @RedisAvailable public void testRedisInboundChannelAdapter() throws Exception { - for (int iteration = 0; iteration < 10; iteration ++) { + for (int iteration = 0; iteration < 10; iteration++) { testRedisInboundChannelAdapterGuts(iteration); } } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests.java index f6f67d1742..e451cde4fc 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/outbound/RedisOutboundGatewayTests.java @@ -127,7 +127,7 @@ public class RedisOutboundGatewayTests extends RedisAvailableTests { @Test @RedisAvailable public void testGetCommand() { - this.setDelCommandChannel.send(MessageBuilder.withPayload(new String[]{"foo", "bar"}) + this.setDelCommandChannel.send(MessageBuilder.withPayload(new String[] { "foo", "bar" }) .setHeader(RedisHeaders.COMMAND, "SET").build()); Message receive = this.replyChannel.receive(1000); assertNotNull(receive); @@ -161,7 +161,7 @@ public class RedisOutboundGatewayTests extends RedisAvailableTests { byte[] value2 = "bar2".getBytes(); connection.set("foo1".getBytes(), value1); connection.set("foo2".getBytes(), value2); - this.mgetCommandChannel.send(MessageBuilder.withPayload(new String [] {"foo1", "foo2"}).build()); + this.mgetCommandChannel.send(MessageBuilder.withPayload(new String[] { "foo1", "foo2" }).build()); Message receive = this.replyChannel.receive(1000); assertNotNull(receive); assertThat((List) receive.getPayload(), Matchers.contains(value1, value2)); diff --git a/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutor.java b/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutor.java index e6087b6692..f71dabbcce 100644 --- a/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutor.java +++ b/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutor.java @@ -22,18 +22,21 @@ import javax.script.ScriptEngine; import org.springframework.integration.scripting.ScriptExecutor; /** - * A {@link ScriptExecutor} that implements special handling required for Python to emulate behavior similar to other JSR223 scripting languages. + * A {@link ScriptExecutor} that implements special handling required for Python to + * emulate behavior similar to other JSR223 scripting languages. *

- * Script evaluation using the Jython implementation results in a null return value for normal variable expressions such as - * x=2. As a work around, it is necessary to get the value of 'x' explicitly following the script evaluation. This class performs - * simple parsing on the last line of the script to obtain the variable name, if any, and return its value. + * Script evaluation using the Jython implementation results in a null return + * value for normal variable expressions such as x=2. As a work around, it is + * necessary to get the value of 'x' explicitly following the script evaluation. This + * class performs simple parsing on the last line of the script to obtain the variable + * name, if any, and return its value. * * @author David Turanski * @author Gary Russell * @since 2.1 * */ - public class PythonScriptExecutor extends AbstractScriptExecutor { +public class PythonScriptExecutor extends AbstractScriptExecutor { public PythonScriptExecutor() { super("python"); diff --git a/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/RubyScriptExecutor.java b/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/RubyScriptExecutor.java index 60859e8cd6..fed41389cc 100644 --- a/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/RubyScriptExecutor.java +++ b/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/RubyScriptExecutor.java @@ -24,7 +24,7 @@ import org.springframework.util.ClassUtils; * @since 2.1 * */ - public class RubyScriptExecutor extends DefaultScriptExecutor { +public class RubyScriptExecutor extends DefaultScriptExecutor { static { if (ClassUtils.isPresent("org.jruby.embed.jsr223.JRubyEngine", System.class.getClassLoader())) { diff --git a/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/jsr223/DeriveLanguageFromExtensionTests.java b/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/jsr223/DeriveLanguageFromExtensionTests.java index 443f9a4744..4bb0cef4ef 100644 --- a/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/jsr223/DeriveLanguageFromExtensionTests.java +++ b/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/jsr223/DeriveLanguageFromExtensionTests.java @@ -43,8 +43,8 @@ public class DeriveLanguageFromExtensionTests { @Test public void testParseLanguage() { - String langs[] = { "ruby", "Groovy", "ECMAScript", "python" }; - Class executors[] = { + String[] langs = { "ruby", "Groovy", "ECMAScript", "python" }; + Class[] executors = { RubyScriptExecutor.class, DefaultScriptExecutor.class, DefaultScriptExecutor.class, @@ -71,7 +71,8 @@ public class DeriveLanguageFromExtensionTests { @Test public void testBadExtension() { try { - new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail1-context.xml", this.getClass()); + new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail1-context.xml", this.getClass()) + .close(); } catch (Exception e) { assertTrue(e.getMessage().contains("No suitable scripting engine found for extension 'xx'")); @@ -81,7 +82,8 @@ public class DeriveLanguageFromExtensionTests { @Test public void testNoExtension() { try { - new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail2-context.xml", this.getClass()); + new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail2-context.xml", this.getClass()) + .close(); } catch (Exception e) { assertTrue(e.getMessage().contains("Unable to determine language for script 'foo'")); diff --git a/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutorTests.java b/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutorTests.java index 8c6108ddfa..44e78bf917 100644 --- a/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutorTests.java +++ b/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/jsr223/PythonScriptExecutorTests.java @@ -46,23 +46,23 @@ public class PythonScriptExecutorTests { @Test public void testLiteral() { - Object obj = executor.executeScript(new StaticScriptSource("3+4") ); + Object obj = executor.executeScript(new StaticScriptSource("3+4")); assertEquals(7, obj); - obj = executor.executeScript(new StaticScriptSource("'hello,world'") ); + obj = executor.executeScript(new StaticScriptSource("'hello,world'")); assertEquals("hello,world", obj); } @Test public void test1() { - Object obj = executor.executeScript(new StaticScriptSource("x=2") ); + Object obj = executor.executeScript(new StaticScriptSource("x=2")); assertEquals(2, obj); } @Test public void test2() { - Object obj = executor.executeScript(new StaticScriptSource("def foo(y):\n\tx=y\n\treturn y\nz=foo(2)") ); + Object obj = executor.executeScript(new StaticScriptSource("def foo(y):\n\tx=y\n\treturn y\nz=foo(2)")); assertEquals(2, obj); } diff --git a/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/outbound/StompMessageHandler.java b/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/outbound/StompMessageHandler.java index 3181dd4b8c..ee0459be64 100644 --- a/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/outbound/StompMessageHandler.java +++ b/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/outbound/StompMessageHandler.java @@ -131,7 +131,7 @@ public class StompMessageHandler extends AbstractMessageHandler implements Appli connectIfNecessary(); } catch (Exception e) { - throw new MessageDeliveryException(message, "The [" + this + "] could not deliver message." , e); + throw new MessageDeliveryException(message, "The [" + this + "] could not deliver message.", e); } StompSession stompSession = this.stompSession; diff --git a/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/SyslogHeaders.java b/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/SyslogHeaders.java index cf7bc3a3e4..be53aef73b 100644 --- a/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/SyslogHeaders.java +++ b/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/SyslogHeaders.java @@ -47,28 +47,28 @@ public final class SyslogHeaders { public static final String MESSAGE = PREFIX + "MESSAGE"; - public static final String APP_NAME = PREFIX + "APP_NAME" ; + public static final String APP_NAME = PREFIX + "APP_NAME"; - public static final String PROCID = PREFIX + "PROCID" ; + public static final String PROCID = PREFIX + "PROCID"; - public static final String MSGID = PREFIX + "MSGID" ; + public static final String MSGID = PREFIX + "MSGID"; - public static final String VERSION = PREFIX + "VERSION" ; + public static final String VERSION = PREFIX + "VERSION"; - public static final String STRUCTURED_DATA = PREFIX + "STRUCTURED_DATA" ; + public static final String STRUCTURED_DATA = PREFIX + "STRUCTURED_DATA"; // Text versions of syslog numeric values - public static final String SEVERITY_TEXT = PREFIX + "SEVERITY_TEXT" ; + public static final String SEVERITY_TEXT = PREFIX + "SEVERITY_TEXT"; // Additional fields - public static final String SOURCE_TYPE = PREFIX + "SOURCE_TYPE" ; + public static final String SOURCE_TYPE = PREFIX + "SOURCE_TYPE"; - public static final String SOURCE = PREFIX + "SOURCE" ; + public static final String SOURCE = PREFIX + "SOURCE"; // full line when parse errors or retained original - public static final String UNDECODED = PREFIX + "UNDECODED" ; + public static final String UNDECODED = PREFIX + "UNDECODED"; - public static final String DECODE_ERRORS = PREFIX + "DECODE_ERRORS" ; + public static final String DECODE_ERRORS = PREFIX + "DECODE_ERRORS"; public static final String ERRORS = PREFIX + "ERRORS"; diff --git a/spring-integration-test/src/main/java/org/springframework/integration/test/matcher/MapContentMatchers.java b/spring-integration-test/src/main/java/org/springframework/integration/test/matcher/MapContentMatchers.java index 49d1c5457a..cfc6b1161b 100644 --- a/spring-integration-test/src/main/java/org/springframework/integration/test/matcher/MapContentMatchers.java +++ b/spring-integration-test/src/main/java/org/springframework/integration/test/matcher/MapContentMatchers.java @@ -100,7 +100,7 @@ public class MapContentMatchers extends /** * {@inheritDoc} */ -// @Override + @Override public void describeTo(Description description) { description.appendText("an entry with key ").appendValue(key) .appendText(" and value matching ").appendDescriptionOf( diff --git a/spring-integration-test/src/main/java/org/springframework/integration/test/matcher/MockitoMessageMatchers.java b/spring-integration-test/src/main/java/org/springframework/integration/test/matcher/MockitoMessageMatchers.java index 4ffc519692..8e4c48e033 100644 --- a/spring-integration-test/src/main/java/org/springframework/integration/test/matcher/MockitoMessageMatchers.java +++ b/spring-integration-test/src/main/java/org/springframework/integration/test/matcher/MockitoMessageMatchers.java @@ -92,7 +92,7 @@ public class MockitoMessageMatchers { public static Message messageWithHeaderEntry(String key, Matcher valueMatcher) { - return argThat(HeaderMatcher. hasHeader(key, valueMatcher)); + return argThat(HeaderMatcher.hasHeader(key, valueMatcher)); } public static Message messageWithHeaderEntries(Map entries) { diff --git a/spring-integration-test/src/main/java/org/springframework/integration/test/support/AbstractRequestResponseScenarioTests.java b/spring-integration-test/src/main/java/org/springframework/integration/test/support/AbstractRequestResponseScenarioTests.java index e405b14566..01eb7cec69 100644 --- a/spring-integration-test/src/main/java/org/springframework/integration/test/support/AbstractRequestResponseScenarioTests.java +++ b/spring-integration-test/src/main/java/org/springframework/integration/test/support/AbstractRequestResponseScenarioTests.java @@ -33,10 +33,10 @@ import org.springframework.messaging.PollableChannel; import org.springframework.messaging.SubscribableChannel; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - /** - * Convenience class for testing Spring Integration request-response message scenarios. Users - * create subclasses to execute on or more {@link RequestResponseScenario} tests. each scenario defines: + * Convenience class for testing Spring Integration request-response message scenarios. + * Users create subclasses to execute on or more {@link RequestResponseScenario} tests. + * each scenario defines: *

    *
  • An inputChannelName
  • *
  • An outputChannelName
  • @@ -49,55 +49,57 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) public abstract class AbstractRequestResponseScenarioTests { - private List scenarios = null; + private List scenarios = null; - @Autowired - private ApplicationContext applicationContext; + @Autowired + private ApplicationContext applicationContext; - @Before - public void setUp() { - scenarios = defineRequestResponseScenarios(); - } + @Before + public void setUp() { + scenarios = defineRequestResponseScenarios(); + } - /** - * Execute each scenario. Instantiate the message channels, send the request message on the - * input channel and invoke the validator on the response received on the output channel. - * This can handle subscribable or pollable output channels. - */ - @Test - public void testRequestResponseScenarios() { - int i = 1; - for (RequestResponseScenario scenario: scenarios) { - String name = scenario.getName() == null ? "scenario-" + (i++) : scenario.getName(); - scenario.init(); - MessageChannel inputChannel = applicationContext.getBean(scenario.getInputChannelName(), MessageChannel.class); - MessageChannel outputChannel = applicationContext.getBean(scenario.getOutputChannelName(), MessageChannel.class); - if (outputChannel instanceof SubscribableChannel) { - ((SubscribableChannel) outputChannel).subscribe(scenario.getResponseValidator()); - } + /** + * Execute each scenario. Instantiate the message channels, send the request message + * on the input channel and invoke the validator on the response received on the + * output channel. This can handle subscribable or pollable output channels. + */ + @Test + public void testRequestResponseScenarios() { + int i = 1; + for (RequestResponseScenario scenario : scenarios) { + String name = scenario.getName() == null ? "scenario-" + (i++) : scenario.getName(); + scenario.init(); + MessageChannel inputChannel = applicationContext.getBean(scenario.getInputChannelName(), + MessageChannel.class); + MessageChannel outputChannel = applicationContext.getBean(scenario.getOutputChannelName(), + MessageChannel.class); + if (outputChannel instanceof SubscribableChannel) { + ((SubscribableChannel) outputChannel).subscribe(scenario.getResponseValidator()); + } - assertTrue(name + ": message not sent on " + scenario.getInputChannelName() - , inputChannel.send(scenario.getMessage())); + assertTrue(name + ": message not sent on " + scenario.getInputChannelName(), + inputChannel.send(scenario.getMessage())); - if (outputChannel instanceof PollableChannel) { - Message response = ((PollableChannel) outputChannel).receive(10000); - assertNotNull(name + ": receive timeout on " + scenario.getOutputChannelName(), response); - scenario.getResponseValidator().handleMessage(response); - } + if (outputChannel instanceof PollableChannel) { + Message response = ((PollableChannel) outputChannel).receive(10000); + assertNotNull(name + ": receive timeout on " + scenario.getOutputChannelName(), response); + scenario.getResponseValidator().handleMessage(response); + } - assertNotNull("message was not handled on " + outputChannel + " for scenario '" + name + "'.", + assertNotNull("message was not handled on " + outputChannel + " for scenario '" + name + "'.", scenario.getResponseValidator().getLastMessage()); - if (outputChannel instanceof SubscribableChannel) { - ((SubscribableChannel) outputChannel).unsubscribe(scenario.getResponseValidator()); - } - } - } - /** - * Implement this method to define RequestResponse scenarios - * @return - A List of {@link RequestResponseScenario} - */ - protected abstract List defineRequestResponseScenarios(); + if (outputChannel instanceof SubscribableChannel) { + ((SubscribableChannel) outputChannel).unsubscribe(scenario.getResponseValidator()); + } + } + } + /** + * Implement this method to define RequestResponse scenarios + * @return - A List of {@link RequestResponseScenario} + */ + protected abstract List defineRequestResponseScenarios(); } diff --git a/spring-integration-test/src/main/java/org/springframework/integration/test/support/AbstractResponseValidator.java b/spring-integration-test/src/main/java/org/springframework/integration/test/support/AbstractResponseValidator.java index 17b3593547..6acde53096 100644 --- a/spring-integration-test/src/main/java/org/springframework/integration/test/support/AbstractResponseValidator.java +++ b/spring-integration-test/src/main/java/org/springframework/integration/test/support/AbstractResponseValidator.java @@ -35,7 +35,7 @@ public abstract class AbstractResponseValidator implements MessageHandler { @SuppressWarnings("unchecked") public void handleMessage(Message message) throws MessagingException { this.lastMessage = message; - validateResponse((T) (extractPayload() ? message.getPayload() : message )); + validateResponse((T) (extractPayload() ? message.getPayload() : message)); } /** diff --git a/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/outbound/StatusUpdatingMessageHandler.java b/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/outbound/StatusUpdatingMessageHandler.java index c4b6dc444d..024d7c8683 100644 --- a/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/outbound/StatusUpdatingMessageHandler.java +++ b/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/outbound/StatusUpdatingMessageHandler.java @@ -81,9 +81,9 @@ public class StatusUpdatingMessageHandler extends AbstractMessageHandler { TypeLocator typeLocator = this.evaluationContext.getTypeLocator(); if (typeLocator instanceof StandardTypeLocator) { - /* - * Register the twitter api package so they don't need a FQCN for TweetData. - */ + /* + * Register the twitter api package so they don't need a FQCN for TweetData. + */ ((StandardTypeLocator) typeLocator).registerImport("org.springframework.social.twitter.api"); } } diff --git a/spring-integration-ws/src/test/java/org/springframework/integration/ws/MarshallingWebServiceIntegrationTests.java b/spring-integration-ws/src/test/java/org/springframework/integration/ws/MarshallingWebServiceIntegrationTests.java index e1e5a8ea9e..ebb571eb7c 100644 --- a/spring-integration-ws/src/test/java/org/springframework/integration/ws/MarshallingWebServiceIntegrationTests.java +++ b/spring-integration-ws/src/test/java/org/springframework/integration/ws/MarshallingWebServiceIntegrationTests.java @@ -89,7 +89,7 @@ public class MarshallingWebServiceIntegrationTests { public void sendString() throws Exception { when(context.getResponse()).thenReturn(response); when(context.getRequest()).thenReturn(request); - when(request.getPayloadSource()).thenReturn(stringSource ); + when(request.getPayloadSource()).thenReturn(stringSource); when(response.getPayloadResult()).thenReturn(stringResult); gateway.invoke(context); assertTrue(output.toString().endsWith(input)); diff --git a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/StubMessageFactory.java b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/StubMessageFactory.java index 96d5b8525d..c9b3e556a1 100644 --- a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/StubMessageFactory.java +++ b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/StubMessageFactory.java @@ -53,7 +53,7 @@ public class StubMessageFactory implements WebServiceMessageFactory { Transformer transformer = TransformerFactory.newInstance().newTransformer(); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - InputSource is = new InputSource( new InputStreamReader(inputStream)); + InputSource is = new InputSource(new InputStreamReader(inputStream)); Document document = builder.parse(is); return new DomPoxMessage(document, transformer, "text/xml"); } diff --git a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java index 0c487d9943..70afa570f0 100644 --- a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java +++ b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java @@ -33,7 +33,7 @@ import org.mockito.Matchers; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; -import org.springframework.context.ApplicationContext; +import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.endpoint.AbstractEndpoint; import org.springframework.integration.endpoint.EventDrivenConsumer; @@ -72,7 +72,7 @@ public class WebServiceOutboundGatewayParserTests { @Test public void simpleGatewayWithReplyChannel() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithReplyChannel"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -95,11 +95,12 @@ public class WebServiceOutboundGatewayParserTests { Long sendTimeout = TestUtils.getPropertyValue(gateway, "messagingTemplate.sendTimeout", Long.class); assertEquals(Long.valueOf(777), sendTimeout); + context.close(); } @Test public void simpleGatewayWithIgnoreEmptyResponseTrueByDefault() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithReplyChannel"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -108,11 +109,12 @@ public class WebServiceOutboundGatewayParserTests { DirectFieldAccessor accessor = new DirectFieldAccessor(gateway); assertEquals(Boolean.TRUE, accessor.getPropertyValue("ignoreEmptyResponses")); Assert.assertEquals(Boolean.FALSE, accessor.getPropertyValue("requiresReply")); + context.close(); } @Test public void simpleGatewayWithIgnoreEmptyResponses() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithIgnoreEmptyResponsesFalseAndRequiresReplyTrue"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -121,11 +123,12 @@ public class WebServiceOutboundGatewayParserTests { DirectFieldAccessor accessor = new DirectFieldAccessor(gateway); assertEquals(Boolean.FALSE, accessor.getPropertyValue("ignoreEmptyResponses")); Assert.assertEquals(Boolean.TRUE, accessor.getPropertyValue("requiresReply")); + context.close(); } @Test public void simpleGatewayWithDefaultSourceExtractor() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithDefaultSourceExtractor"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -133,11 +136,12 @@ public class WebServiceOutboundGatewayParserTests { assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass()); DirectFieldAccessor accessor = new DirectFieldAccessor(gateway); assertEquals("DefaultSourceExtractor", accessor.getPropertyValue("sourceExtractor").getClass().getSimpleName()); + context.close(); } @Test public void simpleGatewayWithCustomSourceExtractor() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomSourceExtractor"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -146,11 +150,12 @@ public class WebServiceOutboundGatewayParserTests { DirectFieldAccessor accessor = new DirectFieldAccessor(gateway); SourceExtractor sourceExtractor = (SourceExtractor) context.getBean("sourceExtractor"); assertEquals(sourceExtractor, accessor.getPropertyValue("sourceExtractor")); + context.close(); } @Test public void simpleGatewayWithCustomRequestCallback() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomRequestCallback"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -159,11 +164,12 @@ public class WebServiceOutboundGatewayParserTests { DirectFieldAccessor accessor = new DirectFieldAccessor(gateway); WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback"); assertEquals(callback, accessor.getPropertyValue("requestCallback")); + context.close(); } @Test public void simpleGatewayWithCustomMessageFactory() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomMessageFactory"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -173,11 +179,12 @@ public class WebServiceOutboundGatewayParserTests { accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate")); WebServiceMessageFactory factory = (WebServiceMessageFactory) context.getBean("messageFactory"); assertEquals(factory, accessor.getPropertyValue("messageFactory")); + context.close(); } @Test public void simpleGatewayWithCustomSourceExtractorAndMessageFactory() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomSourceExtractorAndMessageFactory"); SourceExtractor sourceExtractor = (SourceExtractor) context.getBean("sourceExtractor"); @@ -189,11 +196,12 @@ public class WebServiceOutboundGatewayParserTests { accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate")); WebServiceMessageFactory factory = (WebServiceMessageFactory) context.getBean("messageFactory"); assertEquals(factory, accessor.getPropertyValue("messageFactory")); + context.close(); } @Test public void simpleGatewayWithCustomFaultMessageResolver() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomFaultMessageResolver"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -203,12 +211,13 @@ public class WebServiceOutboundGatewayParserTests { accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate")); FaultMessageResolver resolver = (FaultMessageResolver) context.getBean("faultMessageResolver"); assertEquals(resolver, accessor.getPropertyValue("faultMessageResolver")); + context.close(); } @Test public void simpleGatewayWithCustomMessageSender() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomMessageSender"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -218,10 +227,11 @@ public class WebServiceOutboundGatewayParserTests { accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate")); WebServiceMessageSender messageSender = (WebServiceMessageSender) context.getBean("messageSender"); assertEquals(messageSender, ((WebServiceMessageSender[]) accessor.getPropertyValue("messageSenders"))[0]); + context.close(); } @Test public void simpleGatewayWithCustomMessageSenderList() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomMessageSenderList"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -232,12 +242,13 @@ public class WebServiceOutboundGatewayParserTests { WebServiceMessageSender messageSender = (WebServiceMessageSender) context.getBean("messageSender"); assertEquals(messageSender, ((WebServiceMessageSender[]) accessor.getPropertyValue("messageSenders"))[0]); assertEquals("Wrong number of message senders ", - 2 , ((WebServiceMessageSender[]) accessor.getPropertyValue("messageSenders")).length); + 2, ((WebServiceMessageSender[]) accessor.getPropertyValue("messageSenders")).length); + context.close(); } @Test public void simpleGatewayWithCustomInterceptor() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomInterceptor"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -247,10 +258,12 @@ public class WebServiceOutboundGatewayParserTests { accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate")); ClientInterceptor interceptor = context.getBean("interceptor", ClientInterceptor.class); assertEquals(interceptor, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors"))[0]); + context.close(); } + @Test public void simpleGatewayWithCustomInterceptorList() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomInterceptorList"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -261,12 +274,13 @@ public class WebServiceOutboundGatewayParserTests { ClientInterceptor interceptor = context.getBean("interceptor", ClientInterceptor.class); assertEquals(interceptor, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors"))[0]); assertEquals("Wrong number of interceptors ", - 2 , ((ClientInterceptor[]) accessor.getPropertyValue("interceptors")).length); + 2, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors")).length); + context.close(); } @Test public void simpleGatewayWithPoller() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithPoller"); assertEquals(PollingConsumer.class, endpoint.getClass()); @@ -276,20 +290,22 @@ public class WebServiceOutboundGatewayParserTests { DirectFieldAccessor accessor = new DirectFieldAccessor(trigger); assertEquals("PeriodicTrigger had wrong period", 5000, ((Long) accessor.getPropertyValue("period")).longValue()); + context.close(); } @Test public void simpleGatewayWithOrder() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithOrderAndAutoStartupFalse"); Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler"); assertEquals(99, new DirectFieldAccessor(gateway).getPropertyValue("order")); + context.close(); } @Test public void simpleGatewayWithStartupFalse() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithOrderAndAutoStartupFalse"); assertEquals(Boolean.FALSE, new DirectFieldAccessor(endpoint).getPropertyValue("autoStartup")); @@ -297,7 +313,7 @@ public class WebServiceOutboundGatewayParserTests { @Test public void marshallingGatewayWithAllInOneMarshaller() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithAllInOneMarshaller"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -305,11 +321,12 @@ public class WebServiceOutboundGatewayParserTests { Marshaller marshaller = (Marshaller) context.getBean("marshallerAndUnmarshaller"); assertEquals(marshaller, TestUtils.getPropertyValue(gateway, "marshaller", Marshaller.class)); assertEquals(marshaller, TestUtils.getPropertyValue(gateway, "unmarshaller", Unmarshaller.class)); + context.close(); } @Test public void marshallingGatewayWithSeparateMarshallerAndUnmarshaller() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithSeparateMarshallerAndUnmarshaller"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -318,11 +335,12 @@ public class WebServiceOutboundGatewayParserTests { Unmarshaller unmarshaller = (Unmarshaller) context.getBean("unmarshaller"); assertEquals(marshaller, TestUtils.getPropertyValue(gateway, "marshaller", Marshaller.class)); assertEquals(unmarshaller, TestUtils.getPropertyValue(gateway, "unmarshaller", Unmarshaller.class)); + context.close(); } @Test public void marshallingGatewayWithCustomRequestCallback() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomRequestCallback"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -331,11 +349,12 @@ public class WebServiceOutboundGatewayParserTests { DirectFieldAccessor accessor = new DirectFieldAccessor(gateway); WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback"); assertEquals(callback, accessor.getPropertyValue("requestCallback")); + context.close(); } @Test public void marshallingGatewayWithAllInOneMarshallerAndMessageFactory() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithAllInOneMarshallerAndMessageFactory"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -346,11 +365,12 @@ public class WebServiceOutboundGatewayParserTests { WebServiceMessageFactory messageFactory = (WebServiceMessageFactory) context.getBean("messageFactory"); assertEquals(messageFactory, TestUtils.getPropertyValue(gateway, "webServiceTemplate.messageFactory")); + context.close(); } @Test public void marshallingGatewayWithSeparateMarshallerAndUnmarshallerAndMessageFactory() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithSeparateMarshallerAndUnmarshallerAndMessageFactory"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -362,11 +382,12 @@ public class WebServiceOutboundGatewayParserTests { assertEquals(unmarshaller, TestUtils.getPropertyValue(gateway, "unmarshaller", Unmarshaller.class)); WebServiceMessageFactory messageFactory = (WebServiceMessageFactory) context.getBean("messageFactory"); assertEquals(messageFactory, TestUtils.getPropertyValue(gateway, "webServiceTemplate.messageFactory")); + context.close(); } @Test public void simpleGatewayWithDestinationProvider() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithDestinationProvider"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -379,34 +400,37 @@ public class WebServiceOutboundGatewayParserTests { Object destinationProviderObject = new DirectFieldAccessor( accessor.getPropertyValue("webServiceTemplate")).getPropertyValue("destinationProvider"); assertEquals("Wrong DestinationProvider", stubProvider, destinationProviderObject); + context.close(); } @Test public void advised() { adviceCalled = 0; - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithAdvice"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class); handler.handleMessage(new GenericMessage("foo")); assertEquals(1, adviceCalled); + context.close(); } @Test public void testInt2718AdvisedInsideAChain() { adviceCalled = 0; - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); MessageChannel channel = context.getBean("gatewayWithAdviceInsideAChain", MessageChannel.class); channel.send(new GenericMessage("foo")); assertEquals(1, adviceCalled); + context.close(); } @Test @SuppressWarnings("unchecked") public void jmsUri() { - ApplicationContext context = new ClassPathXmlApplicationContext( + ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "simpleWebServiceOutboundGatewayParserTests.xml", this.getClass()); AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithJmsUri"); assertEquals(EventDrivenConsumer.class, endpoint.getClass()); @@ -429,19 +453,22 @@ public class WebServiceOutboundGatewayParserTests { verify(webServiceTemplate).sendAndReceive(eq("jms:wsQueue"), any(WebServiceMessageCallback.class), Matchers.>any()); + context.close(); } - @Test(expected = BeanDefinitionParsingException.class) - public void invalidGatewayWithBothUriAndDestinationProvider() { - new ClassPathXmlApplicationContext("invalidGatewayWithBothUriAndDestinationProvider.xml", this.getClass()); - } + @Test(expected = BeanDefinitionParsingException.class) + public void invalidGatewayWithBothUriAndDestinationProvider() { + new ClassPathXmlApplicationContext("invalidGatewayWithBothUriAndDestinationProvider.xml", this.getClass()) + .close(); + } - @Test(expected = BeanDefinitionParsingException.class) - public void invalidGatewayWithNeitherUriNorDestinationProvider() { - new ClassPathXmlApplicationContext("invalidGatewayWithNeitherUriNorDestinationProvider.xml", this.getClass()); - } + @Test(expected = BeanDefinitionParsingException.class) + public void invalidGatewayWithNeitherUriNorDestinationProvider() { + new ClassPathXmlApplicationContext("invalidGatewayWithNeitherUriNorDestinationProvider.xml", this.getClass()) + .close(); + } - public static class FooAdvice extends AbstractRequestHandlerAdvice { + public static class FooAdvice extends AbstractRequestHandlerAdvice { @Override protected Object doInvoke(ExecutionCallback callback, Object target, Message message) throws Exception { @@ -449,5 +476,6 @@ public class WebServiceOutboundGatewayParserTests { return null; } - } + } + } diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/TestXmlApplicationContext.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/TestXmlApplicationContext.java index 0f75818ea9..6d8a0d86dd 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/TestXmlApplicationContext.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/TestXmlApplicationContext.java @@ -30,7 +30,7 @@ public class TestXmlApplicationContext extends AbstractXmlApplicationContext { public TestXmlApplicationContext(String ... xmlStrings) { resources = new Resource[xmlStrings.length]; - for (int i = 0 ; i < xmlStrings.length; i++) { + for (int i = 0; i < xmlStrings.length; i++) { resources[i] = new TestResource(xmlStrings[i]); } refresh(); @@ -50,10 +50,12 @@ public class TestXmlApplicationContext extends AbstractXmlApplicationContext { } + @Override public String getDescription() { return "test"; } + @Override public InputStream getInputStream() throws IOException { return new ByteArrayInputStream(xmlString.getBytes("UTF-8")); } diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests.java index bcd3075ebd..2477ec7597 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests.java @@ -77,7 +77,7 @@ public class XPathRouterParserTests { ConfigurableApplicationContext appContext; public EventDrivenConsumer buildContext(String routerDef) { - appContext = TestXmlApplicationContextHelper.getTestAppContext( channelConfig + routerDef); + appContext = TestXmlApplicationContextHelper.getTestAppContext(channelConfig + routerDef); appContext.getAutowireCapableBeanFactory().autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false); EventDrivenConsumer consumer = (EventDrivenConsumer) appContext.getBean("router"); consumer.start(); diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/splitter/XPathMessageSplitterTests.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/splitter/XPathMessageSplitterTests.java index 2d23b2830a..d0c235a7ea 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/splitter/XPathMessageSplitterTests.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/splitter/XPathMessageSplitterTests.java @@ -41,7 +41,7 @@ public class XPathMessageSplitterTests { private XPathMessageSplitter splitter; - private QueueChannel replyChannel = new QueueChannel(); + private final QueueChannel replyChannel = new QueueChannel(); @Before @@ -81,7 +81,7 @@ public class XPathMessageSplitterTests { for (Message message : docMessages) { assertTrue("unexpected payload type" + message.getPayload().getClass().getName(), message.getPayload() instanceof Document); Document docPayload = (Document) message.getPayload(); - assertEquals("Wrong root element name" , "order", docPayload.getDocumentElement().getLocalName()); + assertEquals("Wrong root element name", "order", docPayload.getDocumentElement().getLocalName()); } } diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests.java index 6df03ef64e..5f686c49c7 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests.java @@ -62,8 +62,8 @@ public class JaxbMarshallingIntegrationTests extends AbstractJUnit4SpringContext person.setFirstName("john"); marshallIn.send(new GenericMessage(person)); GenericMessage res = (GenericMessage) marshalledOut.receive(2000); - assertNotNull("No response recevied" , res); - assertTrue("payload was not a DOMResult" , res.getPayload() instanceof DOMResult); + assertNotNull("No response recevied", res); + assertTrue("payload was not a DOMResult", res.getPayload() instanceof DOMResult); Document doc = (Document) ((DOMResult) res.getPayload()).getNode(); assertEquals("Wrong name for root element ", "person", doc.getDocumentElement().getLocalName()); } diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index 17bac679ca..da15001050 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -52,21 +52,21 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -119,10 +119,12 @@ - - - - + + + + + + @@ -155,14 +157,14 @@ - - - - - - - - + + + + + + + + diff --git a/src/checkstyle/fixParenPad.gradle b/src/checkstyle/fixParenPad.gradle new file mode 100644 index 0000000000..8324c58836 --- /dev/null +++ b/src/checkstyle/fixParenPad.gradle @@ -0,0 +1,63 @@ +task fixParenPad << { + fileTree("${buildDir}/reports/checkstyle").include('*.xml').each { report -> + def xml = new XmlParser(false, false).parse(report) + xml.file.each { f -> + def errors = f.error + def thisErrors = [] + errors.each { error -> + if (error.@source == 'com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck' || + error.@source == 'com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheck') { + thisErrors.add(error) + } + } + if (thisErrors) { + def errorInx = 0 + def error = thisErrors[errorInx++] + def file = new File(f.@name) + println "Fixing file $file ..." + boolean headerFixed + def outSource = '' + file.eachLine { line, ln -> + if (!headerFixed) { + def matcher = line =~ /Copyright (20\d\d)(?:-(20\d\d))?/ + if (matcher.count) { + def year1 = matcher[0][1] + if (now != year1) { + if (now != matcher[0][2]) { + line = line.replaceFirst(/(20\d\d)(?:-20\d\d)?/, year1 + "-$now") + } + } + headerFixed = true + } + } + + if (error && ln == (error.@line as int)) { + def message = error.@message + def index = (error.@column as int) - 1 + def chars = line.toCharArray() + for (int i = 0; i < index; i++) { + if (chars[i] == '\t') { // tabs before code == 8 + index -= 7; + } + else if (chars[i] != ' ') { // tabs after code start are only counted as 1 + break; + } + } + + line = line.substring(0, index) + line.substring(index + 1) + + println "Fixed line $line" + + while (error && ln == (error.@line as int)) { + error = thisErrors[errorInx++] + } + } + + outSource += line + System.lineSeparator() + } + file.write(outSource) + println() + } + } + } +}