checkstyle FinalClassCheck

fixes

fixModifiers after fixFinal

Revert CachingSessionFactory

Class is spied in tests.

checkstyle - Import Rules

checkstyle InterfaceIsType

checkstyle InnerTypeLast

checkstyle OneStatementPerLine

CovariantEquals
OneTopLevelClass

* Revert `'\n'` -> `System.lineSeparator()` in the Gradle scripts to meet Git `autocrlf = true` on Windows
* Fix timing issue with the `LastModifiedFileListFilterTests`, when the `age = 1` might not be enough for the file object when we have some delay before checking
This commit is contained in:
Gary Russell
2016-04-02 10:52:19 -04:00
committed by Artem Bilan
parent 43af472c3a
commit 4ac3a79df7
105 changed files with 752 additions and 539 deletions

View File

@@ -64,6 +64,7 @@ subprojects { subproject ->
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply from: "${rootDir}/src/checkstyle/fixFinal.gradle"
apply from: "${rootDir}/src/checkstyle/fixHeaders.gradle"
apply from: "${rootDir}/src/checkstyle/fixModifiers.gradle"
apply from: "${rootDir}/src/checkstyle/fixThis.gradle"

View File

@@ -201,12 +201,59 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
}
}
/*
* SmartLifecycle implementation (delegates to the MessageListener container)
*/
@Override
public boolean isAutoStartup() {
return (this.container != null) && this.container.isAutoStartup();
}
@Override
public int getPhase() {
return (this.container != null) ? this.container.getPhase() : 0;
}
@Override
public boolean isRunning() {
return (this.container != null) && this.container.isRunning();
}
@Override
public void start() {
if (this.container != null) {
this.container.start();
}
}
@Override
public void stop() {
if (this.container != null) {
this.container.stop();
}
}
@Override
public void stop(Runnable callback) {
if (this.container != null) {
this.container.stop(callback);
}
}
@Override
public void destroy() throws Exception {
if (this.container != null) {
this.container.destroy();
}
}
protected abstract AbstractDispatcher createDispatcher();
protected abstract String obtainQueueName(AmqpAdmin admin, String channelName);
private static class DispatchingMessageListener implements MessageListener {
private static final class DispatchingMessageListener implements MessageListener {
private final Log logger = LogFactory.getLog(this.getClass());
@@ -283,52 +330,4 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
}
/*
* SmartLifecycle implementation (delegates to the MessageListener container)
*/
@Override
public boolean isAutoStartup() {
return (this.container != null) && this.container.isAutoStartup();
}
@Override
public int getPhase() {
return (this.container != null) ? this.container.getPhase() : 0;
}
@Override
public boolean isRunning() {
return (this.container != null) && this.container.isRunning();
}
@Override
public void start() {
if (this.container != null) {
this.container.start();
}
}
@Override
public void stop() {
if (this.container != null) {
this.container.stop();
}
}
@Override
public void stop(Runnable callback) {
if (this.container != null) {
this.container.stop(callback);
}
}
@Override
public void destroy() throws Exception {
if (this.container != null) {
this.container.destroy();
}
}
}

View File

@@ -431,7 +431,7 @@ public abstract class AbstractAmqpOutboundEndpoint extends AbstractReplyProducin
}
}
protected static class CorrelationDataWrapper extends CorrelationData {
protected static final class CorrelationDataWrapper extends CorrelationData {
private final Object userData;

View File

@@ -30,7 +30,7 @@ import org.springframework.messaging.Message;
* @since 4.3
*
*/
public class MappingUtils {
public final class MappingUtils {
private MappingUtils() {
super();

View File

@@ -16,9 +16,8 @@
package org.springframework.integration.annotation;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
@@ -28,7 +27,7 @@ import java.lang.annotation.Target;
* @since 4.0
*/
@Target({ })
@Retention(RUNTIME)
@Retention(RetentionPolicy.RUNTIME)
public @interface GatewayHeader {
/**

View File

@@ -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.
@@ -16,9 +16,8 @@
package org.springframework.integration.annotation;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.integration.scheduling.PollerMetadata;
@@ -43,7 +42,7 @@ import org.springframework.scheduling.support.PeriodicTrigger;
* @since 4.0
*/
@Target({})
@Retention(RUNTIME)
@Retention(RetentionPolicy.RUNTIME)
public @interface Poller {
/**

View File

@@ -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.
@@ -108,7 +108,7 @@ public class PublisherAnnotationAdvisor extends AbstractPointcutAdvisor implemen
}
private static class MetaAnnotationMatchingPointcut implements Pointcut {
private static final class MetaAnnotationMatchingPointcut implements Pointcut {
private final ClassFilter classFilter;
@@ -168,7 +168,7 @@ public class PublisherAnnotationAdvisor extends AbstractPointcutAdvisor implemen
}
private static class MetaAnnotationMethodMatcher extends AnnotationMethodMatcher {
private static final class MetaAnnotationMethodMatcher extends AnnotationMethodMatcher {
private final Class<? extends Annotation> annotationType;

View File

@@ -226,7 +226,7 @@ public class DefaultHeaderChannelRegistry extends IntegrationObjectSupport
}
private class MessageChannelWrapper {
private final class MessageChannelWrapper {
private final MessageChannel channel;
@@ -237,11 +237,11 @@ public class DefaultHeaderChannelRegistry extends IntegrationObjectSupport
this.expireAt = expireAt;
}
public final long getExpireAt() {
public long getExpireAt() {
return this.expireAt;
}
public final MessageChannel getChannel() {
public MessageChannel getChannel() {
return this.channel;
}

View File

@@ -103,7 +103,7 @@ public class PriorityChannel extends QueueChannel {
return message;
}
private static class SequenceFallbackComparator implements Comparator<Message<?>> {
private static final class SequenceFallbackComparator implements Comparator<Message<?>> {
private final Comparator<Message<?>> targetComparator;
@@ -136,7 +136,7 @@ public class PriorityChannel extends QueueChannel {
}
//we need this because of INT-2508
private class MessageWrapper implements Message<Object> {
private final class MessageWrapper implements Message<Object> {
private final Message<?> rootMessage;
private final long sequence;

View File

@@ -91,7 +91,7 @@ public abstract class ThreadStatePropagationChannelInterceptor<S>
protected abstract void populatePropagatedContext(S state, Message<?> message, MessageChannel channel);
private static class MessageWithThreadState<S> implements Message<Object> {
private static final class MessageWithThreadState<S> implements Message<Object> {
private final Message<?> message;

View File

@@ -35,7 +35,7 @@ import org.springframework.util.Assert;
* @since 4.0
*
*/
public class FixedSubscriberChannelBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
public final class FixedSubscriberChannelBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
private final Map<String, String> candidateFixedChannelHandlerMap;

View File

@@ -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.
@@ -84,7 +84,7 @@ public class ServiceActivatorAnnotationPostProcessor extends AbstractMethodAnnot
return serviceActivator;
}
private class ReplyProducingMessageHandlerWrapper extends AbstractReplyProducingMessageHandler
private final class ReplyProducingMessageHandlerWrapper extends AbstractReplyProducingMessageHandler
implements Lifecycle {
private final MessageHandler target;

View File

@@ -16,8 +16,6 @@
package org.springframework.integration.config.xml;
import static org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.ID_ATTRIBUTE;
import java.util.List;
import java.util.Map;
@@ -39,6 +37,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.core.Conventions;
@@ -407,7 +406,7 @@ public abstract class IntegrationNamespaceUtils {
public static String[] generateAlias(Element element) {
String[] handlerAlias = null;
String id = element.getAttribute(ID_ATTRIBUTE);
String id = element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE);
if (StringUtils.hasText(id)) {
handlerAlias = new String[] {id + IntegrationConfigUtils.HANDLER_ALIAS_SUFFIX};
}
@@ -517,7 +516,7 @@ public abstract class IntegrationNamespaceUtils {
}
public static String createDirectChannel(Element element, ParserContext parserContext) {
String channelId = element.getAttribute(ID_ATTRIBUTE);
String channelId = element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE);
if (!StringUtils.hasText(channelId)) {
parserContext.getReaderContext().error("The channel-adapter's 'id' attribute is required when no 'channel' "
+ "reference has been provided, because that 'id' would be used for the created channel.", element);

View File

@@ -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.
@@ -26,12 +26,12 @@ import org.springframework.core.task.support.TaskExecutorAdapter;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.messaging.core.MessagePostProcessor;
import org.springframework.util.Assert;
/**
* @author Mark Fisher
* @author Gary Russell
* @since 2.0
*/
public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMessagingOperations {
@@ -45,177 +45,219 @@ public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMe
(AsyncTaskExecutor) executor : new TaskExecutorAdapter(executor);
}
@Override
public Future<?> asyncSend(final Message<?> message) {
return this.executor.submit(new Runnable() {
@Override
public void run() {
send(message);
}
});
}
@Override
public Future<?> asyncSend(final MessageChannel channel, final Message<?> message) {
return this.executor.submit(new Runnable() {
@Override
public void run() {
send(channel, message);
}
});
}
@Override
public Future<?> asyncSend(final String channelName, final Message<?> message) {
return this.executor.submit(new Runnable() {
@Override
public void run() {
send(channelName, message);
}
});
}
@Override
public Future<?> asyncConvertAndSend(final Object object) {
return this.executor.submit(new Runnable() {
@Override
public void run() {
convertAndSend(object);
}
});
}
@Override
public Future<?> asyncConvertAndSend(final MessageChannel channel, final Object object) {
return this.executor.submit(new Runnable() {
@Override
public void run() {
convertAndSend(channel, object);
}
});
}
@Override
public Future<?> asyncConvertAndSend(final String channelName, final Object object) {
return this.executor.submit(new Runnable() {
@Override
public void run() {
convertAndSend(channelName, object);
}
});
}
@Override
public Future<Message<?>> asyncReceive() {
return this.executor.submit(new Callable<Message<?>>() {
@Override
public Message<?> call() throws Exception {
return receive();
}
});
}
@Override
public Future<Message<?>> asyncReceive(final PollableChannel channel) {
return this.executor.submit(new Callable<Message<?>>() {
@Override
public Message<?> call() throws Exception {
return receive(channel);
}
});
}
@Override
public Future<Message<?>> asyncReceive(final String channelName) {
return this.executor.submit(new Callable<Message<?>>() {
@Override
public Message<?> call() throws Exception {
return receive(channelName);
}
});
}
@Override
@SuppressWarnings("unchecked")
public <R> Future<R> asyncReceiveAndConvert() {
return this.executor.submit(new Callable<R>() {
@Override
public R call() throws Exception {
return (R) receiveAndConvert(null);
}
});
}
@Override
@SuppressWarnings("unchecked")
public <R> Future<R> asyncReceiveAndConvert(final PollableChannel channel) {
return this.executor.submit(new Callable<R>() {
@Override
public R call() throws Exception {
return (R) receiveAndConvert(channel, null);
}
});
}
@Override
@SuppressWarnings("unchecked")
public <R> Future<R> asyncReceiveAndConvert(final String channelName) {
return this.executor.submit(new Callable<R>() {
@Override
public R call() throws Exception {
return (R) receiveAndConvert(channelName, null);
}
});
}
@Override
public Future<Message<?>> asyncSendAndReceive(final Message<?> requestMessage) {
return this.executor.submit(new Callable<Message<?>>() {
@Override
public Message<?> call() throws Exception {
return sendAndReceive(requestMessage);
}
});
}
@Override
public Future<Message<?>> asyncSendAndReceive(final MessageChannel channel, final Message<?> requestMessage) {
return this.executor.submit(new Callable<Message<?>>() {
@Override
public Message<?> call() throws Exception {
return sendAndReceive(channel, requestMessage);
}
});
}
@Override
public Future<Message<?>> asyncSendAndReceive(final String channelName, final Message<?> requestMessage) {
return this.executor.submit(new Callable<Message<?>>() {
@Override
public Message<?> call() throws Exception {
return sendAndReceive(channelName, requestMessage);
}
});
}
@Override
@SuppressWarnings("unchecked")
public <R> Future<R> asyncConvertSendAndReceive(final Object request) {
return this.executor.submit(new Callable<R>() {
@Override
public R call() throws Exception {
return (R) convertSendAndReceive(request, null);
}
});
}
@Override
@SuppressWarnings("unchecked")
public <R> Future<R> asyncConvertSendAndReceive(final MessageChannel channel, final Object request) {
return this.executor.submit(new Callable<R>() {
@Override
public R call() throws Exception {
return (R) convertSendAndReceive(channel, request, null);
}
});
}
@Override
@SuppressWarnings("unchecked")
public <R> Future<R> asyncConvertSendAndReceive(final String channelName, final Object request) {
return this.executor.submit(new Callable<R>() {
@Override
public R call() throws Exception {
return (R) convertSendAndReceive(channelName, request, null);
}
});
}
@Override
@SuppressWarnings("unchecked")
public <R> Future<R> asyncConvertSendAndReceive(final Object request, final MessagePostProcessor requestPostProcessor) {
return this.executor.submit(new Callable<R>() {
@Override
public R call() throws Exception {
return (R) convertSendAndReceive(request, null, requestPostProcessor);
}
});
}
@Override
@SuppressWarnings("unchecked")
public <R> Future<R> asyncConvertSendAndReceive(final MessageChannel channel, final Object request, final MessagePostProcessor requestPostProcessor) {
return this.executor.submit(new Callable<R>() {
@Override
public R call() throws Exception {
return (R) convertSendAndReceive(channel, request, null, requestPostProcessor);
}
});
}
@Override
@SuppressWarnings("unchecked")
public <R> Future<R> asyncConvertSendAndReceive(final String channelName, final Object request, final MessagePostProcessor requestPostProcessor) {
return this.executor.submit(new Callable<R>() {
@Override
public R call() throws Exception {
return (R) convertSendAndReceive(channelName, request, null, requestPostProcessor);
}

View File

@@ -312,7 +312,7 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
/**
* Default Poller implementation
*/
private class Poller implements Runnable {
private final class Poller implements Runnable {
private final Callable<Boolean> pollingTask;

View File

@@ -537,7 +537,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* change detection, and the timestamp of the last refresh attempt
* (updated every time the cache entry gets re-validated).
*/
private class PropertiesHolder {
private final class PropertiesHolder {
private Properties properties;

View File

@@ -65,7 +65,7 @@ public class GatewayCompletableFutureProxyFactoryBean extends GatewayProxyFactor
return super.invoke(invocation);
}
private class Invoker implements Supplier<Object> {
private final class Invoker implements Supplier<Object> {
private final MethodInvocation invocation;

View File

@@ -613,7 +613,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
}
private static class MethodInvocationGateway extends MessagingGatewaySupport {
private static final class MethodInvocationGateway extends MessagingGatewaySupport {
private MethodInvocationGateway(GatewayMethodInboundMessageMapper messageMapper) {
this.setRequestMapper(messageMapper);
@@ -622,7 +622,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
}
private class AsyncInvocationTask implements Callable<Object> {
private final class AsyncInvocationTask implements Callable<Object> {
private final MethodInvocation invocation;

View File

@@ -79,7 +79,7 @@ public class ExpressionCommandMessageProcessor extends AbstractMessageProcessor<
}
private static class ExpressionCommandMethodResolver extends ReflectiveMethodResolver {
private static final class ExpressionCommandMethodResolver extends ReflectiveMethodResolver {
private final MethodFilter methodFilter;

View File

@@ -182,7 +182,7 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
}
@SuppressWarnings("serial")
private class ThrowableHolderException extends RuntimeException {
private final class ThrowableHolderException extends RuntimeException {
private ThrowableHolderException(Throwable cause) {
super(cause);

View File

@@ -95,7 +95,7 @@ public class RequestHandlerCircuitBreakerAdvice extends AbstractRequestHandlerAd
/**
* An exception thrown when the circuit breaker is in an open state.
*/
public static class CircuitBreakerOpenException extends RuntimeException {
public static final class CircuitBreakerOpenException extends RuntimeException {
private static final long serialVersionUID = 1L;

View File

@@ -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.
@@ -37,7 +37,7 @@ import org.springframework.util.StringUtils;
* @since 2.0
*/
@SuppressWarnings("serial")
public class MessageHistory implements List<Properties>, Serializable {
public final class MessageHistory implements List<Properties>, Serializable {
public static final String HEADER_NAME = "history";

View File

@@ -28,7 +28,7 @@ import java.util.Collections;
* @author Gary Russell
* @since 3.0
*/
public class JsonHeaders {
public final class JsonHeaders {
private JsonHeaders() {
super();

View File

@@ -58,6 +58,7 @@ import org.springframework.messaging.Message;
* </pre>
*
* @author Artem Bilan
* @author Gary Russell
* @since 4.1
*/
public class ExpressionEvaluatingRoutingSlipRouteStrategy
@@ -101,6 +102,11 @@ public class ExpressionEvaluatingRoutingSlipRouteStrategy
String.class);
}
@Override
public String toString() {
return "ExpressionEvaluatingRoutingSlipRouteStrategy for: [" + this.expression.getExpressionString() + "]";
}
public static class RequestAndReply {
private final Message<?> request;
@@ -122,10 +128,4 @@ public class ExpressionEvaluatingRoutingSlipRouteStrategy
}
}
@Override
public String toString() {
return "ExpressionEvaluatingRoutingSlipRouteStrategy for: [" + this.expression.getExpressionString() + "]";
}
}

View File

@@ -356,7 +356,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
return (Message<?>) message;
}
private class MessageGroupIterator implements Iterator<MessageGroup> {
private final class MessageGroupIterator implements Iterator<MessageGroup> {
private final Iterator<?> idIterator;

View File

@@ -34,7 +34,7 @@ import org.springframework.util.StringUtils;
* @since 4.0
*
*/
public class MutableMessageBuilder<T> extends AbstractIntegrationMessageBuilder<T> {
public final class MutableMessageBuilder<T> extends AbstractIntegrationMessageBuilder<T> {
private final MutableMessage<T> mutableMessage;

View File

@@ -35,7 +35,7 @@ import org.springframework.util.Assert;
* @since 4.0
*
*/
public class IntegrationUtils {
public final class IntegrationUtils {
private static final Log logger = LogFactory.getLog(IntegrationUtils.class);

View File

@@ -53,7 +53,7 @@ public class DefaultTransactionSynchronizationFactory implements TransactionSync
/**
*/
private class DefaultTransactionalResourceSynchronization extends IntegrationResourceHolderSynchronization {
private final class DefaultTransactionalResourceSynchronization extends IntegrationResourceHolderSynchronization {
private DefaultTransactionalResourceSynchronization(Object resourceKey) {
super(new IntegrationResourceHolder(), resourceKey);

View File

@@ -922,7 +922,7 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
}
@SuppressWarnings("serial")
private static class IneligibleMethodException extends RuntimeException {
private static final class IneligibleMethodException extends RuntimeException {
private IneligibleMethodException(String message) {
super(message);

View File

@@ -23,7 +23,7 @@ package org.springframework.integration.util;
* @since 3.0
*
*/
public class StackTraceUtils {
public final class StackTraceUtils {
private StackTraceUtils() {}

View File

@@ -16,8 +16,14 @@
package org.springframework.integration.aggregator;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import java.lang.reflect.Method;
import java.util.ArrayList;

View File

@@ -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.
@@ -16,23 +16,26 @@
package org.springframework.integration.aggregator;
import org.junit.Test;
import org.springframework.messaging.Message;
import org.springframework.integration.store.SimpleMessageGroup;
import org.springframework.integration.support.MessageBuilder;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.springframework.integration.store.SimpleMessageGroup;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
/**
* @author Iwein Fuld
* @author Gary Russell
*/
public class ResequencingMessageGroupProcessorTests {
private ResequencingMessageGroupProcessor processor = new ResequencingMessageGroupProcessor();
private final ResequencingMessageGroupProcessor processor = new ResequencingMessageGroupProcessor();
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
@@ -49,7 +52,7 @@ public class ResequencingMessageGroupProcessorTests {
List<Message> processedMessages = (List<Message>) processor.processMessageGroup(group);
assertThat(processedMessages, hasItems(message1, message2, message3));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void shouldPartiallProcessIncompleteSequence() {
@@ -66,4 +69,5 @@ public class ResequencingMessageGroupProcessorTests {
assertThat(processedMessages, hasItems(message1));
assertThat(processedMessages.size(), is(1));
}
}

View File

@@ -16,27 +16,31 @@
package org.springframework.integration.aggregator.scenarios;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
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.MessagingException;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Iwein Fuld
* @author Gary Russell
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@@ -54,6 +58,7 @@ public class PartialSequencesWithGapsTests {
@Before
public void collectOutput() {
out.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
received.add(message);
}
@@ -81,4 +86,5 @@ public class PartialSequencesWithGapsTests {
.setSequenceSize(sequenceSize)
.setCorrelationId("foo").build();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 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.
@@ -23,12 +23,12 @@ import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
/**
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Gary Russell
*/
public class DirectChannelParserTests {
@@ -40,6 +40,7 @@ public class DirectChannelParserTests {
assertEquals(DirectChannel.class, channel.getClass());
DirectFieldAccessor dcAccessor = new DirectFieldAccessor(((DirectChannel)channel).getDispatcher());
assertTrue(dcAccessor.getPropertyValue("loadBalancingStrategy") instanceof RoundRobinLoadBalancingStrategy);
context.close();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -16,15 +16,17 @@
package org.springframework.integration.channel.config;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.CoreMatchers.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -38,6 +40,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*
* @author Iwein Fuld
* @author Gunnar Hillert
* @author Gary Russell
*
* @see ChannelWithCustomQueueParserTests
*/

View File

@@ -16,8 +16,10 @@
package org.springframework.integration.channel.interceptor;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.util.List;

View File

@@ -16,7 +16,9 @@
package org.springframework.integration.config.annotation;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -81,7 +83,7 @@ public class MessagingAnnotationPostProcessorTests {
inputChannel.send(new GenericMessage<String>("world"));
Message<?> reply = outputChannel.receive(0);
assertEquals("hello world", reply.getPayload());
context.stop();
context.close();
}
@Test
@@ -100,7 +102,7 @@ public class MessagingAnnotationPostProcessorTests {
inputChannel.send(messageToSend);
message = outputChannel.receive(1000);
assertEquals("hello world advised", message.getPayload());
context.stop();
context.close();
}
@Test
@@ -113,7 +115,7 @@ public class MessagingAnnotationPostProcessorTests {
inputChannel.send(new GenericMessage<String>("world"));
Message<?> message = outputChannel.receive(1000);
assertEquals("hello world", message.getPayload());
context.stop();
context.close();
}
@Test
@@ -126,7 +128,7 @@ public class MessagingAnnotationPostProcessorTests {
inputChannel.send(new GenericMessage<String>("123"));
Message<?> message = outputChannel.receive(1000);
assertEquals(246, message.getPayload());
context.stop();
context.close();
}
@Test
@@ -353,6 +355,7 @@ public class MessagingAnnotationPostProcessorTests {
private static class SimpleAnnotatedEndpointImplementation implements SimpleAnnotatedEndpointInterface {
@Override
@ServiceActivator(inputChannel="inputChannel", outputChannel="outputChannel")
public String test(String input) {
return "test-" + input;

View File

@@ -142,7 +142,8 @@ public class ControlBusRecipientListRouterTests {
MessagingTemplate messagingTemplate = new MessagingTemplate();
messagingTemplate.setReceiveTimeout(1000);
Map<String,String> map = new HashMap<String,String>();map.put("channel6","true");
Map<String,String> map = new HashMap<String,String>();
map.put("channel6","true");
Message<?> message = MessageBuilder.withPayload("@'simpleRouter.handler'.setRecipientMappings(headers.recipientMap)").setHeader("recipientMap", map).build();
this.input.send(message);
message = new GenericMessage<Integer>(1);

View File

@@ -16,24 +16,26 @@
package org.springframework.integration.dispatcher;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doThrow;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.support.MessageBuilder;
import java.util.concurrent.atomic.AtomicInteger;
import static org.mockito.Mockito.*;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
/**
* @author Iwein Fuld
@@ -43,7 +45,7 @@ import static org.mockito.Mockito.*;
@RunWith(MockitoJUnitRunner.class)
public class RoundRobinDispatcherTests {
private UnicastingDispatcher dispatcher = new UnicastingDispatcher();
private final UnicastingDispatcher dispatcher = new UnicastingDispatcher();
@Mock
private MessageHandler handler;
@@ -84,7 +86,7 @@ public class RoundRobinDispatcherTests {
dispatcher.dispatch(message);
}
verify(handler, times(4)).handleMessage(message);
verify(differentHandler, times(3)).handleMessage(message);
verify(differentHandler, times(3)).handleMessage(message);
}
@Test

View File

@@ -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.
@@ -16,8 +16,11 @@
package org.springframework.integration.endpoint;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicInteger;
@@ -29,7 +32,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.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -86,6 +89,7 @@ public class PseudoTransactionalMessageSourceTests {
adapter.setOutputChannel(outputChannel);
adapter.setSource(new MessageSource<String>() {
@Override
public Message<String> receive() {
GenericMessage<String> message = new GenericMessage<String>("foo");
IntegrationResourceHolder holder =
@@ -127,7 +131,7 @@ public class PseudoTransactionalMessageSourceTests {
@Test
public void testTransactionSynchronizationFactoryBean() {
ApplicationContext ctx = new AnnotationConfigApplicationContext(TestTxSyncConfiguration.class);
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(TestTxSyncConfiguration.class);
TransactionSynchronizationFactory syncFactory = ctx.getBean(TransactionSynchronizationFactory.class);
@@ -141,6 +145,7 @@ public class PseudoTransactionalMessageSourceTests {
adapter.setOutputChannel(outputChannel);
adapter.setSource(new MessageSource<String>() {
@Override
public Message<String> receive() {
GenericMessage<String> message = new GenericMessage<String>("foo");
IntegrationResourceHolder holder =
@@ -165,6 +170,7 @@ public class PseudoTransactionalMessageSourceTests {
TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED);
TransactionSynchronizationManager.clearSynchronization();
TransactionSynchronizationManager.setActualTransactionActive(false);
ctx.close();
}
@@ -187,6 +193,7 @@ public class PseudoTransactionalMessageSourceTests {
adapter.setOutputChannel(outputChannel);
adapter.setSource(new MessageSource<String>() {
@Override
public Message<String> receive() {
GenericMessage<String> message = new GenericMessage<String>("foo");
((IntegrationResourceHolder) TransactionSynchronizationManager.getResource(this))
@@ -212,6 +219,7 @@ public class PseudoTransactionalMessageSourceTests {
TransactionTemplate transactionTemplate = new TransactionTemplate(new PseudoTransactionManager());
transactionTemplate.execute(new TransactionCallback<Object>() {
@Override
public Object doInTransaction(TransactionStatus status) {
SourcePollingChannelAdapter adapter = new SourcePollingChannelAdapter();
ExpressionEvaluatingTransactionSynchronizationProcessor syncProcessor =
@@ -231,6 +239,7 @@ public class PseudoTransactionalMessageSourceTests {
adapter.setOutputChannel(outputChannel);
adapter.setSource(new MessageSource<String>() {
@Override
public Message<String> receive() {
GenericMessage<String> message = new GenericMessage<String>("foo");
IntegrationResourceHolder holder =
@@ -260,6 +269,7 @@ public class PseudoTransactionalMessageSourceTests {
try {
transactionTemplate.execute(new TransactionCallback<Object>() {
@Override
public Object doInTransaction(TransactionStatus status) {
SourcePollingChannelAdapter adapter = new SourcePollingChannelAdapter();
@@ -278,6 +288,7 @@ public class PseudoTransactionalMessageSourceTests {
adapter.setOutputChannel(outputChannel);
adapter.setSource(new MessageSource<String>() {
@Override
public Message<String> receive() {
GenericMessage<String> message = new GenericMessage<String>("foo");
((IntegrationResourceHolder) TransactionSynchronizationManager.getResource(this))
@@ -305,6 +316,7 @@ public class PseudoTransactionalMessageSourceTests {
TransactionTemplate transactionTemplate = new TransactionTemplate(new PseudoTransactionManager());
transactionTemplate.execute(new TransactionCallback<Object>() {
@Override
public Object doInTransaction(TransactionStatus status) {
SourcePollingChannelAdapter adapter = new SourcePollingChannelAdapter();
@@ -323,6 +335,7 @@ public class PseudoTransactionalMessageSourceTests {
adapter.setOutputChannel(outputChannel);
adapter.setSource(new MessageSource<String>() {
@Override
public Message<String> receive() {
GenericMessage<String> message = new GenericMessage<String>("foo");
((IntegrationResourceHolder) TransactionSynchronizationManager.getResource(this))
@@ -347,6 +360,7 @@ public class PseudoTransactionalMessageSourceTests {
adapter.setSource(new MessageSource<String>() {
@Override
public Message<String> receive() {
return null;
}
@@ -370,6 +384,7 @@ public class PseudoTransactionalMessageSourceTests {
TransactionSynchronizationFactory syncFactory = new TransactionSynchronizationFactory() {
@Override
public TransactionSynchronization create(Object key) {
return new TransactionSynchronizationAdapter() {
@Override
@@ -383,6 +398,7 @@ public class PseudoTransactionalMessageSourceTests {
adapter.setTransactionSynchronizationFactory(syncFactory);
adapter.setSource(new MessageSource<String>() {
@Override
public Message<String> receive() {
return null;
}

View File

@@ -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.
@@ -16,14 +16,11 @@
package org.springframework.integration.json;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.springframework.integration.history.MessageHistory;
@@ -32,8 +29,14 @@ import org.springframework.integration.support.context.NamedComponent;
import org.springframework.integration.support.json.JsonOutboundMessageMapper;
import org.springframework.messaging.Message;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* @author Jeremy Grelle
* @author Gary Russell
* @since 2.0
*/
public class JsonOutboundMessageMapperTests {
@@ -128,10 +131,12 @@ public class JsonOutboundMessageMapperTests {
this.id = id;
}
@Override
public String getComponentName() {
return "testName-" + this.id;
}
@Override
public String getComponentType() {
return "testType-" + this.id;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -16,10 +16,8 @@
package org.springframework.integration.json;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.springframework.integration.support.json.BoonJsonObjectMapper;
@@ -27,9 +25,13 @@ import org.springframework.integration.support.json.Jackson2JsonObjectMapper;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.GenericMessage;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* @author Mark Fisher
* @author Artem Bilan
* @author Gary Russell
* @since 2.0
*/
public class JsonToObjectTransformerTests {

View File

@@ -16,13 +16,16 @@
package org.springframework.integration.json;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.fasterxml.jackson.databind.JsonNode;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -44,6 +47,8 @@ import org.springframework.messaging.MessageHeaders;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.fasterxml.jackson.databind.JsonNode;
/**
* @author Mark Fisher
* @author Oleg Zhurakousky

View File

@@ -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.
@@ -16,26 +16,29 @@
package org.springframework.integration.router.config;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.integration.handler.ReplyRequiredException;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import java.util.Collections;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.handler.ReplyRequiredException;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
/**
* @author Mark Fisher
* @author Iwein Fuld
* @author Gary Russell
*/
public class SplitterParserTests {
@@ -56,6 +59,7 @@ public class SplitterParserTests {
Message<?> result4 = output.receive(1000);
assertEquals("test", result4.getPayload());
assertNull(output.receive(0));
context.close();
}
@Test
@@ -75,6 +79,7 @@ public class SplitterParserTests {
Message<?> result4 = output.receive(1000);
assertEquals("test", result4.getPayload());
assertNull(output.receive(0));
context.close();
}
@Test
@@ -94,6 +99,7 @@ public class SplitterParserTests {
Message<?> result4 = output.receive(1000);
assertEquals("test", result4.getPayload());
assertNull(output.receive(0));
context.close();
}
@Test(expected = ReplyRequiredException.class)
@@ -103,6 +109,7 @@ public class SplitterParserTests {
context.start();
DirectChannel inputChannel = context.getBean("requiresReplyInput", DirectChannel.class);
inputChannel.send(MessageBuilder.withPayload(Collections.emptyList()).build());
context.close();
}
@Test
@@ -116,7 +123,7 @@ public class SplitterParserTests {
Message<?> message = output.receive(1000);
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceNumber(), is(0));
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceSize(), is(0));
context.close();
}
}

View File

@@ -26,10 +26,10 @@
ref="splitterImpl"
input-channel="splitterImplementationInput"
output-channel="output"/>
<splitter id="splitterImplementationRequiresReply"
input-channel="requiresReplyInput"
output-channel="output"
output-channel="output"
requires-reply="true"/>
<splitter id="splitterBeanNoSequence"

View File

@@ -16,7 +16,9 @@
package org.springframework.integration.splitter;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.ArrayList;
import java.util.Arrays;
@@ -39,6 +41,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
* @author Artem Bilan
* @author Gary Russell
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)

View File

@@ -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.
@@ -32,13 +32,13 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.annotation.Splitter;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
@@ -48,6 +48,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @author Iwein Fuld
* @author Alexander Peters
* @author Mark Fisher
* @author Gary Russell
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@@ -70,9 +71,9 @@ public class SplitterIntegrationTests {
@Qualifier("splitter.handler")
MethodInvokingSplitter splitter;
private String sentence = "The quick brown fox jumped over the lazy dog";
private final String sentence = "The quick brown fox jumped over the lazy dog";
private List<String> words = Arrays.asList(sentence.split("\\s"));
private final List<String> words = Arrays.asList(sentence.split("\\s"));
@Autowired
Receiver receiver;
@@ -84,7 +85,7 @@ public class SplitterIntegrationTests {
@MessageEndpoint
public static class Receiver {
private List<String> receivedWords = new ArrayList<String>();
private final List<String> receivedWords = new ArrayList<String>();
@ServiceActivator(inputChannel = "out")
public void deliveredWords(String string) {
@@ -137,7 +138,8 @@ public class SplitterIntegrationTests {
@Test(expected = IllegalArgumentException.class)
public void delimitersNotAllowedWithRef() throws Throwable {
try {
new ClassPathXmlApplicationContext("SplitterIntegrationTests-invalidRef.xml", SplitterIntegrationTests.class);
new ClassPathXmlApplicationContext("SplitterIntegrationTests-invalidRef.xml",
SplitterIntegrationTests.class).close();
}
catch (BeanCreationException e) {
Throwable cause = e.getMostSpecificCause();
@@ -151,7 +153,8 @@ public class SplitterIntegrationTests {
@Test(expected = IllegalArgumentException.class)
public void delimitersNotAllowedWithInnerBean() throws Throwable {
try {
new ClassPathXmlApplicationContext("SplitterIntegrationTests-invalidInnerBean.xml", SplitterIntegrationTests.class);
new ClassPathXmlApplicationContext("SplitterIntegrationTests-invalidInnerBean.xml",
SplitterIntegrationTests.class).close();
}
catch (BeanCreationException e) {
Throwable cause = e.getMostSpecificCause();
@@ -165,7 +168,8 @@ public class SplitterIntegrationTests {
@Test(expected = IllegalArgumentException.class)
public void delimitersNotAllowedWithExpression() throws Throwable {
try {
new ClassPathXmlApplicationContext("SplitterIntegrationTests-invalidExpression.xml", SplitterIntegrationTests.class);
new ClassPathXmlApplicationContext("SplitterIntegrationTests-invalidExpression.xml",
SplitterIntegrationTests.class).close();
}
catch (BeanCreationException e) {
Throwable cause = e.getMostSpecificCause();

View File

@@ -16,8 +16,10 @@
package org.springframework.integration.splitter;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Collections;
import java.util.Comparator;
@@ -47,6 +49,7 @@ import org.springframework.messaging.support.GenericMessage;
/**
* @author Alex Peters
* @author Artem Bilan
* @author Gary Russell
* @since 4.1
*/
public class StreamingSplitterTests {
@@ -72,6 +75,7 @@ public class StreamingSplitterTests {
List<Message<?>> receivedMessages = replyChannel.clear();
Collections.sort(receivedMessages, new Comparator<Message<?>>() {
@Override
public int compare(Message<?> o1, Message<?> o2) {
return o1.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, Integer.class)
.compareTo(o2.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, Integer.class));
@@ -146,6 +150,7 @@ public class StreamingSplitterTests {
new EventDrivenConsumer(replyChannel, new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
assertThat("Failure with msg: " + message,
message.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, Integer.class),
@@ -167,6 +172,7 @@ public class StreamingSplitterTests {
final AtomicInteger receivedMessageCounter = new AtomicInteger(0);
new EventDrivenConsumer(replyChannel, new MessageHandler() {
@Override
public void handleMessage(Message<?> message)
throws MessageRejectedException, MessageHandlingException,
MessageDeliveryException {
@@ -196,10 +202,12 @@ public class StreamingSplitterTests {
public Iterator<String> annotatedMethod(String input) {
return new Iterator<String>() {
@Override
public boolean hasNext() {
return counter.get() < max;
}
@Override
public String next() {
if (!hasNext()) {
throw new IllegalStateException("Last element reached!");
@@ -207,6 +215,7 @@ public class StreamingSplitterTests {
return String.valueOf(counter.incrementAndGet());
}
@Override
public void remove() {
throw new AssertionError("not implemented!");
@@ -230,14 +239,17 @@ public class StreamingSplitterTests {
public Iterable<String> annotatedMethod(String input) {
return new Iterable<String>() {
@Override
public Iterator<String> iterator() {
return new Iterator<String>() {
@Override
public boolean hasNext() {
return counter.get() < max;
}
@Override
public String next() {
if (!hasNext()) {
throw new IllegalStateException(
@@ -246,6 +258,7 @@ public class StreamingSplitterTests {
return String.valueOf(counter.incrementAndGet());
}
@Override
public void remove() {
throw new AssertionError("not implemented!");

View File

@@ -16,7 +16,9 @@
package org.springframework.integration.transformer;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.io.IOException;
import java.math.BigDecimal;

View File

@@ -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.
@@ -16,9 +16,10 @@
package org.springframework.integration.transformer;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.core.convert.converter.Converter;
/**
@@ -29,16 +30,21 @@ import org.springframework.core.convert.converter.Converter;
public class PayloadTypeConvertingTransformerTests {
/**
* Test method for {@link org.springframework.integration.transformer.PayloadTypeConvertingTransformer#transformPayload(java.lang.Object)}.
* Test method for
* {@link org.springframework.integration.transformer.PayloadTypeConvertingTransformer#transformPayload(java.lang.Object)}
* .
*/
@Test
public void testTransformPayloadObject() throws Exception {
PayloadTypeConvertingTransformer<String, String> tx = new PayloadTypeConvertingTransformer<String, String>();
tx.setConverter(new Converter<String, String> () {
@Override
public String convert(String source) {
return source.toUpperCase();
}}
);
}
});
String in = "abcd";
String out = tx.transformPayload(in);
assertEquals("ABCD", out);

View File

@@ -16,7 +16,9 @@
package org.springframework.integration.transformer;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import java.util.Map;
@@ -32,7 +34,7 @@ import org.junit.Test;
*/
public class SysLogTransformerTests {
private SyslogToMapTransformer sut = new SyslogToMapTransformer();
private final SyslogToMapTransformer sut = new SyslogToMapTransformer();
@Test
public void testMap() throws Exception {

View File

@@ -57,7 +57,7 @@ public class HeadDirectoryScanner extends DefaultDirectoryScanner {
}
private static class HeadFilter implements FileListFilter<File> {
private static final class HeadFilter implements FileListFilter<File> {
private final int maxNumberOfFiles;

View File

@@ -548,7 +548,7 @@ public class RemoteFileTemplate<F> implements RemoteFileOperations<F>, Initializ
return directoryPath;
}
private class StreamHolder {
private final class StreamHolder {
private final InputStream stream;

View File

@@ -30,7 +30,7 @@ import org.springframework.integration.file.remote.session.Session;
* @since 3.0
*
*/
public class RemoteFileUtils {
public final class RemoteFileUtils {
private RemoteFileUtils() {}

View File

@@ -157,7 +157,7 @@ public class CachingSessionFactory<F> implements SessionFactory<F>, DisposableBe
this.pool.removeAllIdleItems();
}
public class CachedSession implements Session<F> {
public class CachedSession implements Session<F> { //NOSONAR (final)
private final Session<F> targetSession;

View File

@@ -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.
@@ -35,50 +35,52 @@ import org.springframework.integration.file.filters.FileListFilter;
/**
* @author Iwein Fuld
* @author Gary Russell
*/
public class CompositeFileListFilterTests {
@SuppressWarnings("unchecked")
private FileListFilter<File> fileFilterMock1 = mock(FileListFilter.class);
@SuppressWarnings("unchecked")
private final FileListFilter<File> fileFilterMock1 = mock(FileListFilter.class);
@SuppressWarnings("unchecked")
private FileListFilter<File> fileFilterMock2 = mock(FileListFilter.class);
@SuppressWarnings("unchecked")
private final FileListFilter<File> fileFilterMock2 = mock(FileListFilter.class);
private File fileMock = mock(File.class);
private final File fileMock = mock(File.class);
@Test
public void forwardedToFilters() throws Exception {
CompositeFileListFilter<File> compositeFileFilter = new CompositeFileListFilter<File>();
compositeFileFilter .addFilter(fileFilterMock1);compositeFileFilter.addFilter(fileFilterMock2);
List<File> returnedFiles = Arrays.asList( fileMock);
when(fileFilterMock1.filterFiles(isA(File[].class))).thenReturn(returnedFiles);
when(fileFilterMock2.filterFiles(isA(File[].class))).thenReturn(returnedFiles);
assertEquals(returnedFiles, compositeFileFilter.filterFiles(new File[]{fileMock}));
verify(fileFilterMock1).filterFiles(isA(File[].class));
verify(fileFilterMock2).filterFiles(isA(File[].class));
}
@Test
public void forwardedToFilters() throws Exception {
CompositeFileListFilter<File> compositeFileFilter = new CompositeFileListFilter<File>();
compositeFileFilter.addFilter(fileFilterMock1);
compositeFileFilter.addFilter(fileFilterMock2);
List<File> returnedFiles = Arrays.asList(fileMock);
when(fileFilterMock1.filterFiles(isA(File[].class))).thenReturn(returnedFiles);
when(fileFilterMock2.filterFiles(isA(File[].class))).thenReturn(returnedFiles);
assertEquals(returnedFiles, compositeFileFilter.filterFiles(new File[] { fileMock }));
verify(fileFilterMock1).filterFiles(isA(File[].class));
verify(fileFilterMock2).filterFiles(isA(File[].class));
}
@Test
public void forwardedToAddedFilters() throws Exception {
CompositeFileListFilter<File> compositeFileFilter = new CompositeFileListFilter<File>();
compositeFileFilter.addFilter(fileFilterMock1);
compositeFileFilter.addFilter( fileFilterMock2);
List<File> returnedFiles = Arrays.asList(fileMock);
when(fileFilterMock1.filterFiles(isA(File[].class))).thenReturn(returnedFiles);
when(fileFilterMock2.filterFiles(isA(File[].class))).thenReturn(returnedFiles);
assertEquals(returnedFiles, compositeFileFilter.filterFiles(new File[]{fileMock}));
verify(fileFilterMock1).filterFiles(isA(File[].class));
verify(fileFilterMock2).filterFiles(isA(File[].class));
}
@Test
public void forwardedToAddedFilters() throws Exception {
CompositeFileListFilter<File> compositeFileFilter = new CompositeFileListFilter<File>();
compositeFileFilter.addFilter(fileFilterMock1);
compositeFileFilter.addFilter(fileFilterMock2);
List<File> returnedFiles = Arrays.asList(fileMock);
when(fileFilterMock1.filterFiles(isA(File[].class))).thenReturn(returnedFiles);
when(fileFilterMock2.filterFiles(isA(File[].class))).thenReturn(returnedFiles);
assertEquals(returnedFiles, compositeFileFilter.filterFiles(new File[] { fileMock }));
verify(fileFilterMock1).filterFiles(isA(File[].class));
verify(fileFilterMock2).filterFiles(isA(File[].class));
}
@Test
public void negative() throws Exception {
CompositeFileListFilter<File> compositeFileFilter = new CompositeFileListFilter<File>();
compositeFileFilter.addFilter(fileFilterMock1);
compositeFileFilter.addFilter(fileFilterMock2);
@Test
public void negative() throws Exception {
CompositeFileListFilter<File> compositeFileFilter = new CompositeFileListFilter<File>();
compositeFileFilter.addFilter(fileFilterMock1);
compositeFileFilter.addFilter(fileFilterMock2);
when(fileFilterMock2.filterFiles(isA(File[].class))).thenReturn(new ArrayList<File>());
when(fileFilterMock1.filterFiles(isA(File[].class))).thenReturn(new ArrayList<File>());
assertTrue(compositeFileFilter.filterFiles(new File[]{fileMock}).isEmpty());
}
when(fileFilterMock2.filterFiles(isA(File[].class))).thenReturn(new ArrayList<File>());
when(fileFilterMock1.filterFiles(isA(File[].class))).thenReturn(new ArrayList<File>());
assertTrue(compositeFileFilter.filterFiles(new File[] { fileMock }).isEmpty());
}
}

View File

@@ -28,6 +28,7 @@ import org.junit.rules.TemporaryFolder;
/**
* @author Gary Russell
* @author Artem Bilan
* @since 4.2
*
*/
@@ -39,13 +40,14 @@ public class LastModifiedFileListFilterTests {
@Test
public void testAge() throws Exception {
LastModifiedFileListFilter filter = new LastModifiedFileListFilter();
filter.setAge(1, TimeUnit.SECONDS);
filter.setAge(60, TimeUnit.SECONDS);
File foo = this.folder.newFile();
FileOutputStream fileOutputStream = new FileOutputStream(foo);
fileOutputStream.write("x".getBytes());
fileOutputStream.close();
assertEquals(0, filter.filterFiles(new File[] { foo }).size());
foo.setLastModified(System.currentTimeMillis() - 10000);
// Make a file as of yesterday's
foo.setLastModified(System.currentTimeMillis() - 1000 * 60 * 60 * 24);
assertEquals(1, filter.filterFiles(new File[] { foo }).size());
}

View File

@@ -210,7 +210,7 @@ public class GroovyScriptExecutingMessageProcessor extends AbstractScriptExecuti
}
}
private class BeanFactoryFallbackBinding extends Binding {
private final class BeanFactoryFallbackBinding extends Binding {
private BeanFactoryFallbackBinding(Map<?, ?> variables) {
super(variables);

View File

@@ -111,7 +111,7 @@ public class GroovyControlBusFactoryBean extends AbstractSimpleMessageHandlerFac
* In additionally beans should be 'managed' with specific properties which
* are allowed in the Control Bus operations.
*/
private static class ManagedBeansBinding extends Binding {
private static final class ManagedBeansBinding extends Binding {
private final ConfigurableListableBeanFactory beanFactory;

View File

@@ -274,7 +274,7 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler
* @author Gary Russell
* @since 2.0
*/
private class AsyncReply {
private final class AsyncReply {
private final CountDownLatch latch;

View File

@@ -897,7 +897,7 @@ public abstract class AbstractConnectionFactory extends IntegrationObjectSupport
+ ", port=" + getPort();
}
private class PendingIO {
private final class PendingIO {
private final long failedAt;

View File

@@ -136,94 +136,6 @@ public class CachingClientConnectionFactory extends AbstractClientConnectionFact
return new CachedConnection(this.pool.getItem(), getListener());
}
private class CachedConnection extends TcpConnectionInterceptorSupport {
private final AtomicBoolean released = new AtomicBoolean();
private CachedConnection(TcpConnectionSupport connection, TcpListener tcpListener) {
super.setTheConnection(connection);
registerListener(tcpListener);
}
@Override
public void close() {
if (!this.released.compareAndSet(false, true)) {
if (logger.isDebugEnabled()) {
logger.debug("Connection " + getConnectionId() + " has already been released");
}
}
else {
/**
* If the delegate is stopped, actually close the connection, but still release
* it to the pool, it will be discarded/renewed the next time it is retrieved.
*/
if (!isRunning()) {
if (logger.isDebugEnabled()) {
logger.debug("Factory not running - closing " + getConnectionId());
}
super.close();
}
CachingClientConnectionFactory.this.pool.releaseItem(getTheConnection());
}
}
@Override
public String getConnectionId() {
return "Cached:" + super.getConnectionId();
}
@Override
public String toString() {
return getConnectionId();
}
/**
* We have to intercept the message to replace the connectionId header with
* ours so the listener can correlate a response with a request. We supply
* the actual connectionId in another header for convenience and tracing
* purposes.
*/
@Override
public boolean onMessage(Message<?> message) {
Message<?> modifiedMessage;
if (message instanceof ErrorMessage) {
Map<String, Object> headers = new HashMap<String, Object>(message.getHeaders());
headers.put(IpHeaders.CONNECTION_ID, getConnectionId());
if (headers.get(IpHeaders.ACTUAL_CONNECTION_ID) == null) {
headers.put(IpHeaders.ACTUAL_CONNECTION_ID,
message.getHeaders().get(IpHeaders.CONNECTION_ID));
}
modifiedMessage = new ErrorMessage((Throwable) message.getPayload(), headers);
}
else {
AbstractIntegrationMessageBuilder<?> messageBuilder =
CachingClientConnectionFactory.this.getMessageBuilderFactory()
.fromMessage(message)
.setHeader(IpHeaders.CONNECTION_ID, getConnectionId());
if (message.getHeaders().get(IpHeaders.ACTUAL_CONNECTION_ID) == null) {
messageBuilder.setHeader(IpHeaders.ACTUAL_CONNECTION_ID,
message.getHeaders().get(IpHeaders.CONNECTION_ID));
}
modifiedMessage = messageBuilder.build();
}
TcpListener listener = getListener();
if (listener != null) {
listener.onMessage(modifiedMessage);
}
else {
if (logger.isDebugEnabled()) {
logger.debug("Message discarded; no listener: " + message);
}
}
return true;
}
private void physicallyClose() {
getTheConnection().close();
}
}
///////////////// DELEGATE METHODS ///////////////////////
@Override
@@ -491,4 +403,92 @@ public class CachingClientConnectionFactory extends AbstractClientConnectionFact
this.targetConnectionFactory.stop(callback);
}
private final class CachedConnection extends TcpConnectionInterceptorSupport {
private final AtomicBoolean released = new AtomicBoolean();
private CachedConnection(TcpConnectionSupport connection, TcpListener tcpListener) {
super.setTheConnection(connection);
registerListener(tcpListener);
}
@Override
public void close() {
if (!this.released.compareAndSet(false, true)) {
if (logger.isDebugEnabled()) {
logger.debug("Connection " + getConnectionId() + " has already been released");
}
}
else {
/**
* If the delegate is stopped, actually close the connection, but still release
* it to the pool, it will be discarded/renewed the next time it is retrieved.
*/
if (!isRunning()) {
if (logger.isDebugEnabled()) {
logger.debug("Factory not running - closing " + getConnectionId());
}
super.close();
}
CachingClientConnectionFactory.this.pool.releaseItem(getTheConnection());
}
}
@Override
public String getConnectionId() {
return "Cached:" + super.getConnectionId();
}
@Override
public String toString() {
return getConnectionId();
}
/**
* We have to intercept the message to replace the connectionId header with
* ours so the listener can correlate a response with a request. We supply
* the actual connectionId in another header for convenience and tracing
* purposes.
*/
@Override
public boolean onMessage(Message<?> message) {
Message<?> modifiedMessage;
if (message instanceof ErrorMessage) {
Map<String, Object> headers = new HashMap<String, Object>(message.getHeaders());
headers.put(IpHeaders.CONNECTION_ID, getConnectionId());
if (headers.get(IpHeaders.ACTUAL_CONNECTION_ID) == null) {
headers.put(IpHeaders.ACTUAL_CONNECTION_ID,
message.getHeaders().get(IpHeaders.CONNECTION_ID));
}
modifiedMessage = new ErrorMessage((Throwable) message.getPayload(), headers);
}
else {
AbstractIntegrationMessageBuilder<?> messageBuilder =
CachingClientConnectionFactory.this.getMessageBuilderFactory()
.fromMessage(message)
.setHeader(IpHeaders.CONNECTION_ID, getConnectionId());
if (message.getHeaders().get(IpHeaders.ACTUAL_CONNECTION_ID) == null) {
messageBuilder.setHeader(IpHeaders.ACTUAL_CONNECTION_ID,
message.getHeaders().get(IpHeaders.CONNECTION_ID));
}
modifiedMessage = messageBuilder.build();
}
TcpListener listener = getListener();
if (listener != null) {
listener.onMessage(modifiedMessage);
}
else {
if (logger.isDebugEnabled()) {
logger.debug("Message discarded; no listener: " + message);
}
}
return true;
}
private void physicallyClose() {
getTheConnection().close();
}
}
}

View File

@@ -144,7 +144,7 @@ public class FailoverClientConnectionFactory extends AbstractClientConnectionFac
* @since 2.2
*
*/
private class FailoverTcpConnection extends TcpConnectionSupport implements TcpListener {
private final class FailoverTcpConnection extends TcpConnectionSupport implements TcpListener {
private final List<AbstractClientConnectionFactory> factories;

View File

@@ -278,7 +278,7 @@ public class TcpNioSSLConnection extends TcpNioConnection {
* send to encrypted data to the SocketChannel.
*
*/
class SSLChannelOutputStream extends ChannelOutputStream {
final class SSLChannelOutputStream extends ChannelOutputStream {
private final ChannelOutputStream channelOutputStream;

View File

@@ -28,7 +28,7 @@ import org.springframework.integration.ip.tcp.connection.AbstractServerConnectio
* @since 2.2
*
*/
public class TestingUtilities {
public final class TestingUtilities {
private TestingUtilities() {
super();

View File

@@ -55,7 +55,7 @@ public class BeanPropertySqlParameterSourceFactory implements SqlParameterSource
return toReturn;
}
private static class StaticBeanPropertySqlParameterSource extends AbstractSqlParameterSource implements
private static final class StaticBeanPropertySqlParameterSource extends AbstractSqlParameterSource implements
SqlParameterSource {
private final BeanPropertySqlParameterSource input;

View File

@@ -663,7 +663,7 @@ public class StoredProcExecutor implements BeanFactoryAware, InitializingBean {
*
* @since 4.2
*/
private static class GuavaCacheWrapper {
private static final class GuavaCacheWrapper {
private final LoadingCache<String, SimpleJdbcCallOperations> jdbcCallOperationsCache;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 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.
@@ -16,7 +16,9 @@
package org.springframework.integration.jdbc.store.channel;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import javax.sql.DataSource;
@@ -39,6 +41,7 @@ import org.springframework.transaction.support.TransactionTemplate;
/**
* @author Gunnar Hillert
* @author Gary Russell
*/
@RunWith(SpringJUnit4ClassRunner.class)

View File

@@ -479,7 +479,7 @@ public class ChannelPublishingJmsMessageListener
* Internal class combining a destination name
* and its target destination type (queue or topic).
*/
private static class DestinationNameHolder {
private static final class DestinationNameHolder {
private final String name;

View File

@@ -54,7 +54,7 @@ import org.springframework.util.StringUtils;
* @author Gary Russell
* @author Artem Bilan
*/
public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
public class DefaultJmsHeaderMapper extends JmsHeaderMapper {
private static List<Class<?>> SUPPORTED_PROPERTY_TYPES = Arrays.asList(new Class<?>[] {
Boolean.class, Byte.class, Double.class, Float.class, Integer.class, Long.class, Short.class, String.class });

View File

@@ -29,7 +29,7 @@ import org.springframework.integration.mapping.HeaderMapper;
* @author Oleg Zhurakousky
* @author Gary Russell
*/
public interface JmsHeaderMapper extends HeaderMapper<Message> {
public abstract class JmsHeaderMapper implements HeaderMapper<Message> {
String CONTENT_TYPE_PROPERTY = "content_type";

View File

@@ -1422,7 +1422,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
}
private class TimedReply {
private final class TimedReply {
private final long timeStamp = System.currentTimeMillis();

View File

@@ -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.
@@ -150,7 +150,7 @@ public class JmsSendingMessageHandler extends AbstractMessageHandler {
}
private static class HeaderMappingMessagePostProcessor implements MessagePostProcessor {
private static final class HeaderMappingMessagePostProcessor implements MessagePostProcessor {
private final Message<?> integrationMessage;

View File

@@ -120,8 +120,55 @@ public class SubscribableJmsChannel extends AbstractJmsChannel implements Subscr
this.dispatcher.setMaxSubscribers(this.maxSubscribers);
}
/*
* SmartLifecycle implementation (delegates to the MessageListener container)
*/
private static class DispatchingMessageListener implements MessageListener {
@Override
public boolean isAutoStartup() {
return (this.container != null) ? this.container.isAutoStartup() : false;
}
@Override
public int getPhase() {
return (this.container != null) ? this.container.getPhase() : 0;
}
@Override
public boolean isRunning() {
return (this.container != null) ? this.container.isRunning() : false;
}
@Override
public void start() {
if (this.container != null) {
this.container.start();
}
}
@Override
public void stop() {
if (this.container != null) {
this.container.stop();
}
}
@Override
public void stop(Runnable callback) {
if (this.container != null) {
this.container.stop(callback);
}
}
@Override
public void destroy() throws Exception {
if (this.container != null) {
this.container.destroy();
}
}
private static final class DispatchingMessageListener implements MessageListener {
private final Log logger = LogFactory.getLog(this.getClass());
@@ -181,52 +228,4 @@ public class SubscribableJmsChannel extends AbstractJmsChannel implements Subscr
}
}
/*
* SmartLifecycle implementation (delegates to the MessageListener container)
*/
@Override
public boolean isAutoStartup() {
return (this.container != null) ? this.container.isAutoStartup() : false;
}
@Override
public int getPhase() {
return (this.container != null) ? this.container.getPhase() : 0;
}
@Override
public boolean isRunning() {
return (this.container != null) ? this.container.isRunning() : false;
}
@Override
public void start() {
if (this.container != null) {
this.container.start();
}
}
@Override
public void stop() {
if (this.container != null) {
this.container.stop();
}
}
@Override
public void stop(Runnable callback) {
if (this.container != null) {
this.container.stop(callback);
}
}
@Override
public void destroy() throws Exception {
if (this.container != null) {
this.container.destroy();
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 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.
@@ -21,17 +21,20 @@ import java.util.Map;
import javax.jms.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.integration.jms.JmsHeaderMapper;
import org.springframework.messaging.MessageHeaders;
/**
* @author Mark Fisher
* @author Gary Russell
*/
public class TestJmsHeaderMapper implements JmsHeaderMapper {
public class TestJmsHeaderMapper extends JmsHeaderMapper {
@Override
public void fromHeaders(MessageHeaders headers, Message target) {
}
@Override
public Map<String, Object> toHeaders(Message source) {
Map<String, Object> headerMap = new HashMap<String, Object>();
headerMap.put("testProperty", "foo");

View File

@@ -16,9 +16,6 @@
package org.springframework.integration.jpa.support;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static java.util.regex.Pattern.compile;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -37,6 +34,7 @@ import org.springframework.util.Assert;
*
* @author Oliver Gierke
* @author Gunnar Hillert
* @author Gary Russell
*
* @since 2.2
*
@@ -60,7 +58,7 @@ public final class JpaUtils {
builder.append("(?: )+"); // at least one space separating
builder.append("(\\w*)"); // the actual alias
ALIAS_MATCH = compile(builder.toString(), CASE_INSENSITIVE);
ALIAS_MATCH = Pattern.compile(builder.toString(), Pattern.CASE_INSENSITIVE);
builder = new StringBuilder();
builder.append("(select\\s+((distinct )?.+?)\\s+)?(from\\s+");

View File

@@ -51,7 +51,7 @@ public class BeanPropertyParameterSourceFactory implements ParameterSourceFactor
return toReturn;
}
private static class StaticBeanPropertyParameterSource implements
private static final class StaticBeanPropertyParameterSource implements
ParameterSource {
private final BeanPropertyParameterSource input;

View File

@@ -33,7 +33,7 @@ import org.springframework.util.Assert;
* @since 2.2
*
*/
class ExpressionEvaluatingParameterSourceUtils {
final class ExpressionEvaluatingParameterSourceUtils {
private ExpressionEvaluatingParameterSourceUtils() {
throw new AssertionError();

View File

@@ -16,7 +16,10 @@
package org.springframework.integration.jpa.outbound;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.util.List;
@@ -49,6 +52,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*
* @author Amol Nayak
* @author Artem Bilan
* @author Gary Russell
* @since 3.0
*
*/

View File

@@ -454,7 +454,7 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl
* @since 2.2
*
*/
private class IntegrationMimeMessage extends MimeMessage {
private final class IntegrationMimeMessage extends MimeMessage {
private final MimeMessage source;

View File

@@ -182,6 +182,54 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
}
}
private Runnable createMessageSendingTask(final Message mailMessage){
Runnable sendingTask = new Runnable() {
@Override
public void run() {
org.springframework.messaging.Message<?> message =
ImapIdleChannelAdapter.this.getMessageBuilderFactory().withPayload(mailMessage).build();
if (TransactionSynchronizationManager.isActualTransactionActive()) {
if (ImapIdleChannelAdapter.this.transactionSynchronizationFactory != null){
TransactionSynchronization synchronization =
ImapIdleChannelAdapter.this.transactionSynchronizationFactory
.create(ImapIdleChannelAdapter.this);
TransactionSynchronizationManager.registerSynchronization(synchronization);
if (synchronization instanceof IntegrationResourceHolderSynchronization) {
IntegrationResourceHolder holder =
((IntegrationResourceHolderSynchronization) synchronization).getResourceHolder();
holder.setMessage(message);
}
}
}
sendMessage(message);
}
};
// wrap in the TX proxy if necessary
if (!CollectionUtils.isEmpty(this.adviceChain)) {
ProxyFactory proxyFactory = new ProxyFactory(sendingTask);
if (!CollectionUtils.isEmpty(this.adviceChain)) {
for (Advice advice : this.adviceChain) {
proxyFactory.addAdvice(advice);
}
}
sendingTask = (Runnable) proxyFactory.getProxy(this.classLoader);
}
return sendingTask;
}
private void publishException(Exception e) {
if (this.applicationEventPublisher != null) {
this.applicationEventPublisher.publishEvent(new ImapIdleExceptionEvent(e));
}
else {
if (logger.isDebugEnabled()) {
logger.debug("No application event publisher for exception: " + e.getMessage());
}
}
}
private class ReceivingTask implements Runnable {
@Override
@@ -247,54 +295,6 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
}
}
private Runnable createMessageSendingTask(final Message mailMessage){
Runnable sendingTask = new Runnable() {
@Override
public void run() {
org.springframework.messaging.Message<?> message =
ImapIdleChannelAdapter.this.getMessageBuilderFactory().withPayload(mailMessage).build();
if (TransactionSynchronizationManager.isActualTransactionActive()) {
if (ImapIdleChannelAdapter.this.transactionSynchronizationFactory != null){
TransactionSynchronization synchronization =
ImapIdleChannelAdapter.this.transactionSynchronizationFactory
.create(ImapIdleChannelAdapter.this);
TransactionSynchronizationManager.registerSynchronization(synchronization);
if (synchronization instanceof IntegrationResourceHolderSynchronization) {
IntegrationResourceHolder holder =
((IntegrationResourceHolderSynchronization) synchronization).getResourceHolder();
holder.setMessage(message);
}
}
}
sendMessage(message);
}
};
// wrap in the TX proxy if necessary
if (!CollectionUtils.isEmpty(this.adviceChain)) {
ProxyFactory proxyFactory = new ProxyFactory(sendingTask);
if (!CollectionUtils.isEmpty(this.adviceChain)) {
for (Advice advice : this.adviceChain) {
proxyFactory.addAdvice(advice);
}
}
sendingTask = (Runnable) proxyFactory.getProxy(this.classLoader);
}
return sendingTask;
}
private void publishException(Exception e) {
if (this.applicationEventPublisher != null) {
this.applicationEventPublisher.publishEvent(new ImapIdleExceptionEvent(e));
}
else {
if (logger.isDebugEnabled()) {
logger.debug("No application event publisher for exception: " + e.getMessage());
}
}
}
private class ExceptionAwarePeriodicTrigger implements Trigger {
private volatile boolean delayNextExecution;

View File

@@ -30,7 +30,7 @@ import org.springframework.util.StringUtils;
* @author Gary Russell
* @since 2.2
*/
class MongoParserUtils {
final class MongoParserUtils {
private MongoParserUtils() {
super();

View File

@@ -454,10 +454,20 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore
this.collectionName).get(SEQUENCE);
}
@SuppressWarnings("unchecked")
private static void enhanceHeaders(MessageHeaders messageHeaders, Map<String, Object> headers) {
Map<String, Object> innerMap =
(Map<String, Object>) new DirectFieldAccessor(messageHeaders).getPropertyValue("headers");
// using reflection to set ID and TIMESTAMP since they are immutable through MessageHeaders
innerMap.put(MessageHeaders.ID, headers.get(MessageHeaders.ID));
innerMap.put(MessageHeaders.TIMESTAMP, headers.get(MessageHeaders.TIMESTAMP));
}
/**
* Custom implementation of the {@link MappingMongoConverter} strategy.
*/
private class MessageReadingMongoConverter extends MappingMongoConverter {
private final class MessageReadingMongoConverter extends MappingMongoConverter {
private MessageReadingMongoConverter(MongoDbFactory mongoDbFactory,
MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) {
@@ -586,16 +596,6 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore
}
@SuppressWarnings("unchecked")
private static void enhanceHeaders(MessageHeaders messageHeaders, Map<String, Object> headers) {
Map<String, Object> innerMap =
(Map<String, Object>) new DirectFieldAccessor(messageHeaders).getPropertyValue("headers");
// using reflection to set ID and TIMESTAMP since they are immutable through MessageHeaders
innerMap.put(MessageHeaders.ID, headers.get(MessageHeaders.ID));
innerMap.put(MessageHeaders.TIMESTAMP, headers.get(MessageHeaders.TIMESTAMP));
}
private static class UuidToDBObjectConverter implements Converter<UUID, DBObject> {
@Override
public DBObject convert(UUID source) {
@@ -650,7 +650,7 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore
}
private class DBObjectToMutableMessageConverter implements GenericConverter {
private final class DBObjectToMutableMessageConverter implements GenericConverter {
private final Class<?> mutableMessageClass;

View File

@@ -23,7 +23,7 @@ package org.springframework.integration.mongodb.support;
* @author Gary Russell
* @since 2.2
*/
public class MongoHeaders {
public final class MongoHeaders {
private MongoHeaders() {
super();

View File

@@ -252,7 +252,7 @@ public abstract class AbstractMqttMessageDrivenChannelAdapter extends MessagePro
/**
* @since 4.1
*/
private static class Topic {
private static final class Topic {
private final String topic;

View File

@@ -23,7 +23,7 @@ package org.springframework.integration.mqtt.support;
* @since 4.0
*
*/
public class MqttHeaders {
public final class MqttHeaders {
private static final String prefix = "mqtt_";

View File

@@ -25,7 +25,7 @@ package org.springframework.integration.redis.support;
* @author Artem Bilan
* @since 2.2
*/
public class RedisHeaders {
public final class RedisHeaders {
private RedisHeaders() {
super();

View File

@@ -296,7 +296,7 @@ public final class RedisLockRegistry implements LockRegistry {
});
}
private class RedisLock implements Lock {
private final class RedisLock implements Lock {
private final String lockKey;

View File

@@ -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.
@@ -16,7 +16,9 @@
package org.springframework.integration.redis.config;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 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.
@@ -16,7 +16,11 @@
package org.springframework.integration.redis.outbound;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Arrays;
import java.util.List;

View File

@@ -25,7 +25,7 @@ import org.springframework.integration.transformer.SyslogToMapTransformer;
* @since 3.0
*
*/
public class SyslogHeaders {
public final class SyslogHeaders {
private SyslogHeaders() {
super();

View File

@@ -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.
@@ -172,7 +172,7 @@ public final class ClientWebSocketContainer extends IntegrationWebSocketContaine
* <p>
* The {@link #webSocketHandler} is used to handle {@link WebSocketSession} events.
*/
private class IntegrationWebSocketConnectionManager extends ConnectionManagerSupport {
private final class IntegrationWebSocketConnectionManager extends ConnectionManagerSupport {
private final WebSocketClient client;

View File

@@ -117,7 +117,7 @@ public class MarshallingWebServiceOutboundGateway extends AbstractWebServiceOutb
this.unmarshaller = unmarshaller;
}
private class MarshallingRequestMessageCallback extends RequestMessageCallback {
private final class MarshallingRequestMessageCallback extends RequestMessageCallback {
private MarshallingRequestMessageCallback(WebServiceMessageCallback requestCallback,
Message<?> requestMessage) {

View File

@@ -100,7 +100,7 @@ public class SimpleWebServiceOutboundGateway extends AbstractWebServiceOutboundG
new SimpleResponseMessageExtractor(responseResultInstance));
}
private class SimpleRequestMessageCallback extends RequestMessageCallback {
private final class SimpleRequestMessageCallback extends RequestMessageCallback {
private SimpleRequestMessageCallback(WebServiceMessageCallback requestCallback, Message<?> requestMessage) {
super(requestCallback, requestMessage);
@@ -141,7 +141,7 @@ public class SimpleWebServiceOutboundGateway extends AbstractWebServiceOutboundG
}
private class SimpleResponseMessageExtractor extends ResponseMessageExtractor {
private final class SimpleResponseMessageExtractor extends ResponseMessageExtractor {
private final Result result;

View File

@@ -269,7 +269,7 @@ public class XPathMessageSplitter extends AbstractMessageSplitter {
}
}
private class NodeListIterator implements Iterator<Node> {
private final class NodeListIterator implements Iterator<Node> {
private final DocumentBuilder documentBuilder;

View File

@@ -16,27 +16,27 @@
package org.springframework.integration.xml.source;
import static org.custommonkey.xmlunit.XMLAssert.*;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import java.io.BufferedReader;
import org.junit.Before;
import org.junit.Test;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.xml.util.XmlTestUtil;
import org.springframework.xml.transform.StringSource;
import org.w3c.dom.Document;
import org.springframework.integration.xml.util.XmlTestUtil;
import org.springframework.messaging.MessagingException;
import org.springframework.xml.transform.StringSource;
public class StringSourceTests {
StringSourceFactory sourceFactory;
@Before
public void setUp() throws Exception{
sourceFactory = new StringSourceFactory();
}
@Test
public void testWithDocument() throws Exception{
String docString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>";
@@ -46,8 +46,8 @@ public class StringSourceTests {
String docAsString =reader.readLine();
assertXMLEqual("Wrong content in StringSource","<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>", docAsString);
}
@Test
public void testWithString() throws Exception{
String docString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>";
@@ -56,8 +56,8 @@ public class StringSourceTests {
String docAsString =reader.readLine();
assertXMLEqual("Wrong content in StringSource","<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>", docAsString);
}
@Test(expected=MessagingException.class)
public void testWithUnsupportedPayload() throws Exception{
String docString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>";

View File

@@ -25,11 +25,10 @@ package org.springframework.integration.xmpp;
* @author Oleg Zhurakousky
* @since 2.0
*/
public class XmppHeaders {
public final class XmppHeaders {
private XmppHeaders() {
super();
// TODO Auto-generated constructor stub
}
public static final String PREFIX = "xmpp_";

View File

@@ -18,10 +18,16 @@ package org.springframework.integration.xmpp.core;
/**
* @author Oleg ZHurakousky
* @author Gary Russell
* @since 2.0
*/
public interface XmppContextUtils {
public final class XmppContextUtils {
String XMPP_CONNECTION_BEAN_NAME = "xmppConnection";
private XmppContextUtils() {
super();
}
public static String XMPP_CONNECTION_BEAN_NAME = "xmppConnection";
}

View File

@@ -47,7 +47,7 @@ import org.springframework.util.StringUtils;
*/
public class ChatMessageSendingMessageHandler extends AbstractXmppConnectionAwareMessageHandler {
private static final Pattern xmlPattern = Pattern.compile("<(\\S[^>\\s]*)[^>]*>[^<]*</\\1>");
private static final Pattern XML_PATTERN = Pattern.compile("<(\\S[^>\\s]*)[^>]*>[^<]*</\\1>");
private volatile XmppHeaderMapper headerMapper = new DefaultXmppHeaderMapper();
@@ -101,7 +101,7 @@ public class ChatMessageSendingMessageHandler extends AbstractXmppConnectionAwar
else if (payload instanceof String) {
if (this.extensionProvider != null) {
String data = (String) payload;
if (!xmlPattern.matcher(data.trim()).matches()) {
if (!XML_PATTERN.matcher(data.trim()).matches()) {
// Since XMPP Extension parsers deal only with XML content,
// add an arbitrary tag that is removed by the extension parser,
// if the target content isn't XML.

View File

@@ -151,7 +151,7 @@ public class ZookeeperLockRegistry implements ExpirableLockRegistry {
}
private static class DefaultKeyToPathStrategy implements KeyToPathStrategy {
private static final class DefaultKeyToPathStrategy implements KeyToPathStrategy {
private final String root;
@@ -177,7 +177,7 @@ public class ZookeeperLockRegistry implements ExpirableLockRegistry {
}
private static class ZkLock implements Lock {
private static final class ZkLock implements Lock {
private final InterProcessMutex mutex;

Some files were not shown because too many files have changed in this diff Show More