checkstyle Misc Rules
checkstyle Nesting checkstyle GenericWhitespace checkstyle MethodParamPad checkstyle NoWhiteSpace checkstyle ParenPad Script checkstyle ParenPad
This commit is contained in:
committed by
Artem Bilan
parent
05cc7be644
commit
57f96bb759
@@ -70,6 +70,7 @@ subprojects { subproject ->
|
||||
apply from: "${rootDir}/src/checkstyle/fixThis.gradle"
|
||||
apply from: "${rootDir}/src/checkstyle/fixRightCurly.gradle"
|
||||
apply from: "${rootDir}/src/checkstyle/fixWhiteAround.gradle"
|
||||
apply from: "${rootDir}/src/checkstyle/fixParenPad.gradle"
|
||||
|
||||
if (project.hasProperty('platformVersion')) {
|
||||
apply plugin: 'spring-io'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,7 +33,7 @@ import java.lang.annotation.Target;
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
@Target( { ElementType.PARAMETER, ElementType.METHOD })
|
||||
@Target({ ElementType.PARAMETER, ElementType.METHOD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Payloads {
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class AbstractMessageSourceAdvice implements MethodInterceptor {
|
||||
public final Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
Object target = invocation.getThis();
|
||||
if (!(target instanceof MessageSource)
|
||||
|| invocation.getMethod().getName() != "receive") {
|
||||
|| !invocation.getMethod().getName().equals("receive")) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,12 +36,13 @@ import org.springframework.integration.config.IntegrationRegistrar;
|
||||
*/
|
||||
public class AnnotationConfigParser implements BeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
public BeanDefinition parse(final Element element, ParserContext parserContext) {
|
||||
new IntegrationRegistrar().registerBeanDefinitions(new StandardAnnotationMetadata(Object.class) {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAnnotationAttributes(String annotationType) {
|
||||
return Collections.<String, Object> singletonMap("value", element.getAttribute("default-publisher-channel"));
|
||||
return Collections.<String, Object>singletonMap("value", element.getAttribute("default-publisher-channel"));
|
||||
}
|
||||
}, parserContext.getRegistry());
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public class MessageHistoryConfigurer implements SmartLifecycle, BeanFactoryAwar
|
||||
Assert.notNull(componentNamePatternsSet, "'componentNamePatternsSet' must not be null");
|
||||
Assert.state(!this.running, "'componentNamePatternsSet' cannot be changed without invoking stop() first");
|
||||
for (String s : componentNamePatternsSet) {
|
||||
String[] componentNamePatterns = StringUtils.delimitedListToStringArray(s, "," , " ");
|
||||
String[] componentNamePatterns = StringUtils.delimitedListToStringArray(s, ",", " ");
|
||||
Arrays.sort(componentNamePatterns);
|
||||
if (this.componentNamePatternsExplicitlySet
|
||||
&& !Arrays.equals(this.componentNamePatterns, componentNamePatterns)) {
|
||||
|
||||
@@ -159,7 +159,7 @@ public abstract class AbstractMessageGroupStore extends AbstractBatchingMessageG
|
||||
public int getMessageGroupCount() {
|
||||
int count = 0;
|
||||
for (@SuppressWarnings("unused") MessageGroup group : this) {
|
||||
count ++;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class SimpleMessageGroup implements MessageGroup {
|
||||
private volatile boolean complete;
|
||||
|
||||
public SimpleMessageGroup(Object groupId) {
|
||||
this(Collections.<Message<?>> emptyList(), groupId);
|
||||
this(Collections.<Message<?>>emptyList(), groupId);
|
||||
}
|
||||
|
||||
public SimpleMessageGroup(Collection<? extends Message<?>> messages, Object groupId) {
|
||||
@@ -90,6 +90,7 @@ public class SimpleMessageGroup implements MessageGroup {
|
||||
return this.timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastModified(long lastModified) {
|
||||
this.lastModified = lastModified;
|
||||
}
|
||||
@@ -104,10 +105,12 @@ public class SimpleMessageGroup implements MessageGroup {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Message<?> messageToAdd) {
|
||||
addMessage(messageToAdd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Message<?> message) {
|
||||
return this.messages.remove(message);
|
||||
}
|
||||
@@ -126,6 +129,7 @@ public class SimpleMessageGroup implements MessageGroup {
|
||||
return Collections.unmodifiableCollection(this.messages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastReleasedMessageSequenceNumber(int sequenceNumber) {
|
||||
this.lastReleasedMessageSequence = sequenceNumber;
|
||||
}
|
||||
@@ -166,6 +170,7 @@ public class SimpleMessageGroup implements MessageGroup {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.messages.clear();
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SimpleMessageGroupFactory implements MessageGroupFactory {
|
||||
|
||||
@Override
|
||||
public MessageGroup create(Object groupId) {
|
||||
return create(Collections.<Message<?>> emptyList(), groupId);
|
||||
return create(Collections.<Message<?>>emptyList(), groupId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,12 +37,12 @@ public class IdGenerators {
|
||||
*/
|
||||
public static class JdkIdGenerator implements IdGenerator {
|
||||
|
||||
@Override
|
||||
public UUID generateId() {
|
||||
return UUID.randomUUID();
|
||||
}
|
||||
@Override
|
||||
public UUID generateId() {
|
||||
return UUID.randomUUID();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the two {@link AtomicLong}s, for {@code topBits} and {@code bottomBits},
|
||||
@@ -59,23 +59,23 @@ public class IdGenerators {
|
||||
* is initialized. Therefore, it is not suitable when persisting messages based on their ID; it should
|
||||
* only be used when the absolute best performance is required and messages are not persisted.
|
||||
*/
|
||||
public static class SimpleIncrementingIdGenerator implements IdGenerator {
|
||||
public static class SimpleIncrementingIdGenerator implements IdGenerator {
|
||||
|
||||
private final AtomicLong topBits = new AtomicLong();
|
||||
private final AtomicLong topBits = new AtomicLong();
|
||||
|
||||
private final AtomicLong bottomBits = new AtomicLong();
|
||||
private final AtomicLong bottomBits = new AtomicLong();
|
||||
|
||||
@Override
|
||||
public UUID generateId() {
|
||||
long bottomBits = this.bottomBits.incrementAndGet();
|
||||
if (bottomBits == 0) {
|
||||
return new UUID(this.topBits.incrementAndGet(), bottomBits);
|
||||
}
|
||||
else {
|
||||
return new UUID(this.topBits.get(), bottomBits);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public UUID generateId() {
|
||||
long bottomBits = this.bottomBits.incrementAndGet();
|
||||
if (bottomBits == 0) {
|
||||
return new UUID(this.topBits.incrementAndGet(), bottomBits);
|
||||
}
|
||||
else {
|
||||
return new UUID(this.topBits.get(), bottomBits);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class AbstractJacksonJsonObjectMapper<N, P, J> extends JsonObjec
|
||||
implements BeanClassLoaderAware {
|
||||
|
||||
protected static final Collection<Class<?>> supportedJsonTypes =
|
||||
Arrays.<Class<?>> asList(String.class, byte[].class, File.class, URL.class, InputStream.class, Reader.class);
|
||||
Arrays.<Class<?>>asList(String.class, byte[].class, File.class, URL.class, InputStream.class, Reader.class);
|
||||
|
||||
private volatile ClassLoader classLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class DefaultLockRegistry implements LockRegistry {
|
||||
*/
|
||||
public DefaultLockRegistry(int mask) {
|
||||
String bits = Integer.toBinaryString(mask);
|
||||
Assert.isTrue(bits.length() < 32 && (mask == 0 || bits.lastIndexOf('0') < bits.indexOf('1') ), "Mask must be a power of 2 - 1");
|
||||
Assert.isTrue(bits.length() < 32 && (mask == 0 || bits.lastIndexOf('0') < bits.indexOf('1')), "Mask must be a power of 2 - 1");
|
||||
this.mask = mask;
|
||||
int arraySize = this.mask + 1;
|
||||
this.lockTable = new ReentrantLock[arraySize];
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ObjectToMapTransformer extends AbstractPayloadTransformer<Object, M
|
||||
int counter = 0;
|
||||
for (Object element : list) {
|
||||
this.doProcessElement(propertyPrefix + "[" + counter + "]", element, resultMap);
|
||||
counter ++;
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -831,7 +831,7 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
headerName = methodParameter.getParameterName();
|
||||
}
|
||||
else if (valueAttribute.indexOf('.') != -1) {
|
||||
String tokens[] = valueAttribute.split("\\.", 2);
|
||||
String[] tokens = valueAttribute.split("\\.", 2);
|
||||
headerName = tokens[0];
|
||||
if (StringUtils.hasText(tokens[1])) {
|
||||
relativeExpression = "." + tokens[1];
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
@@ -41,6 +40,7 @@ import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ public class ConcurrentAggregatorTests {
|
||||
|
||||
assertTrue(latch.await(10, TimeUnit.SECONDS));
|
||||
|
||||
assertThat(latch.getCount(), is(0l));
|
||||
assertThat(latch.getCount(), is(0L));
|
||||
Message<?> reply = replyChannel.receive(2000);
|
||||
assertNotNull(reply);
|
||||
assertEquals(reply.getPayload(), 105);
|
||||
@@ -319,6 +319,7 @@ public class ConcurrentAggregatorTests {
|
||||
return this.exception;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
this.aggregator.handleMessage(message);
|
||||
@@ -335,6 +336,7 @@ public class ConcurrentAggregatorTests {
|
||||
|
||||
|
||||
private class MultiplyingProcessor implements MessageGroupProcessor {
|
||||
@Override
|
||||
public Object processMessageGroup(MessageGroup group) {
|
||||
Integer product = 1;
|
||||
for (Message<?> message : group.getMessages()) {
|
||||
@@ -346,6 +348,7 @@ public class ConcurrentAggregatorTests {
|
||||
|
||||
|
||||
private class NullReturningMessageProcessor implements MessageGroupProcessor {
|
||||
@Override
|
||||
public Object processMessageGroup(MessageGroup group) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -81,11 +81,11 @@ public class ResequencerTests {
|
||||
Message<?> reply2 = replyChannel.receive(0);
|
||||
Message<?> reply3 = replyChannel.receive(0);
|
||||
assertNotNull(reply1);
|
||||
assertThat( new IntegrationMessageHeaderAccessor(reply1).getSequenceNumber(), is(1));
|
||||
assertThat(new IntegrationMessageHeaderAccessor(reply1).getSequenceNumber(), is(1));
|
||||
assertNotNull(reply2);
|
||||
assertThat(new IntegrationMessageHeaderAccessor(reply2).getSequenceNumber(), is(2));
|
||||
assertNotNull(reply3);
|
||||
assertThat( new IntegrationMessageHeaderAccessor(reply3).getSequenceNumber(), is(3));
|
||||
assertThat(new IntegrationMessageHeaderAccessor(reply3).getSequenceNumber(), is(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
public class Adder {
|
||||
|
||||
public Long add(List<Long> results) {
|
||||
long total = 0l;
|
||||
long total = 0L;
|
||||
for (long partialResult: results) {
|
||||
total += partialResult;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public class AggregatorParserTests {
|
||||
outputChannel, accessor.getPropertyValue("outputChannel"));
|
||||
assertEquals("The AggregatorEndpoint is not injected with the appropriate discard channel",
|
||||
discardChannel, accessor.getPropertyValue("discardChannel"));
|
||||
assertEquals("The AggregatorEndpoint is not set with the appropriate timeout value", 86420000l,
|
||||
assertEquals("The AggregatorEndpoint is not set with the appropriate timeout value", 86420000L,
|
||||
TestUtils.getPropertyValue(consumer, "messagingTemplate.sendTimeout"));
|
||||
assertEquals(
|
||||
"The AggregatorEndpoint is not configured with the appropriate 'send partial results on timeout' flag",
|
||||
@@ -212,15 +212,15 @@ public class AggregatorParserTests {
|
||||
public void testSimpleJavaBeanAggregator() {
|
||||
List<Message<?>> outboundMessages = new ArrayList<Message<?>>();
|
||||
MessageChannel input = (MessageChannel) context.getBean("aggregatorWithReferenceAndMethodInput");
|
||||
outboundMessages.add(createMessage(1l, "id1", 3, 1, null));
|
||||
outboundMessages.add(createMessage(2l, "id1", 3, 3, null));
|
||||
outboundMessages.add(createMessage(3l, "id1", 3, 2, null));
|
||||
outboundMessages.add(createMessage(1L, "id1", 3, 1, null));
|
||||
outboundMessages.add(createMessage(2L, "id1", 3, 3, null));
|
||||
outboundMessages.add(createMessage(3L, "id1", 3, 2, null));
|
||||
for (Message<?> message : outboundMessages) {
|
||||
input.send(message);
|
||||
}
|
||||
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
|
||||
Message<?> response = outputChannel.receive(10);
|
||||
Assert.assertEquals(6l, response.getPayload());
|
||||
Assert.assertEquals(6L, response.getPayload());
|
||||
Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME);
|
||||
Object handler = context.getBean("aggregatorWithReferenceAndMethod.handler");
|
||||
assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.messageBuilderFactory"));
|
||||
@@ -261,16 +261,16 @@ public class AggregatorParserTests {
|
||||
assertNull(handlerMethods);
|
||||
Object handlerMethod = releaseStrategyAccessor.getPropertyValue("handlerMethod");
|
||||
assertTrue(handlerMethod.toString().contains("checkCompleteness"));
|
||||
input.send(createMessage(1l, "correllationId", 4, 0, null));
|
||||
input.send(createMessage(2l, "correllationId", 4, 1, null));
|
||||
input.send(createMessage(3l, "correllationId", 4, 2, null));
|
||||
input.send(createMessage(1L, "correllationId", 4, 0, null));
|
||||
input.send(createMessage(2L, "correllationId", 4, 1, null));
|
||||
input.send(createMessage(3L, "correllationId", 4, 2, null));
|
||||
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
|
||||
Message<?> reply = outputChannel.receive(0);
|
||||
Assert.assertNull(reply);
|
||||
input.send(createMessage(5l, "correllationId", 4, 3, null));
|
||||
input.send(createMessage(5L, "correllationId", 4, 3, null));
|
||||
reply = outputChannel.receive(0);
|
||||
Assert.assertNotNull(reply);
|
||||
assertEquals(11l, reply.getPayload());
|
||||
assertEquals(11L, reply.getPayload());
|
||||
}
|
||||
|
||||
@Test // see INT-2011
|
||||
@@ -286,16 +286,16 @@ public class AggregatorParserTests {
|
||||
assertNull(handlerMethods);
|
||||
Object handlerMethod = releaseStrategyAccessor.getPropertyValue("handlerMethod");
|
||||
assertTrue(handlerMethod.toString().contains("checkCompleteness"));
|
||||
input.send(createMessage(1l, "correllationId", 4, 0, null));
|
||||
input.send(createMessage(2l, "correllationId", 4, 1, null));
|
||||
input.send(createMessage(3l, "correllationId", 4, 2, null));
|
||||
input.send(createMessage(1L, "correllationId", 4, 0, null));
|
||||
input.send(createMessage(2L, "correllationId", 4, 1, null));
|
||||
input.send(createMessage(3L, "correllationId", 4, 2, null));
|
||||
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
|
||||
Message<?> reply = outputChannel.receive(0);
|
||||
Assert.assertNull(reply);
|
||||
input.send(createMessage(5l, "correllationId", 4, 3, null));
|
||||
input.send(createMessage(5L, "correllationId", 4, 3, null));
|
||||
reply = outputChannel.receive(0);
|
||||
Assert.assertNotNull(reply);
|
||||
assertEquals(11l, reply.getPayload());
|
||||
assertEquals(11L, reply.getPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -88,7 +88,7 @@ public class ResequencerParserTests {
|
||||
getPropertyValue(resequencer, "outputChannel"));
|
||||
assertEquals("The ResequencerEndpoint is not injected with the appropriate discard channel", discardChannel,
|
||||
getPropertyValue(resequencer, "discardChannel"));
|
||||
assertEquals("The ResequencerEndpoint is not set with the appropriate timeout value", 86420000l,
|
||||
assertEquals("The ResequencerEndpoint is not set with the appropriate timeout value", 86420000L,
|
||||
getPropertyValue(resequencer, "messagingTemplate.sendTimeout"));
|
||||
assertEquals(
|
||||
"The ResequencerEndpoint is not configured with the appropriate 'send partial results on timeout' flag",
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AggregatorAnnotationTests {
|
||||
assertTrue(getPropertyValue(aggregator, "releaseStrategy") instanceof SequenceSizeReleaseStrategy);
|
||||
assertEquals("outputChannel", getPropertyValue(aggregator, "outputChannelName"));
|
||||
assertEquals("discardChannel", getPropertyValue(aggregator, "discardChannelName"));
|
||||
assertEquals(98765432l, getPropertyValue(aggregator, "messagingTemplate.sendTimeout"));
|
||||
assertEquals(98765432L, getPropertyValue(aggregator, "messagingTemplate.sendTimeout"));
|
||||
assertEquals(true, getPropertyValue(aggregator, "sendPartialResultOnExpiry"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -90,7 +90,7 @@ public class DefaultConfiguringBeanFactoryPostProcessorTests {
|
||||
|
||||
assertNotNull("Child task scheduler was null", childScheduler);
|
||||
assertNotNull("Parent task scheduler was null", parentScheduler);
|
||||
assertEquals("Different schedulers in parent and child", parentScheduler, childScheduler );
|
||||
assertEquals("Different schedulers in parent and child", parentScheduler, childScheduler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -50,7 +51,7 @@ public class IntervalTriggerParserTests {
|
||||
Boolean fixedRate = (Boolean) accessor.getPropertyValue("fixedRate");
|
||||
Long period = (Long) accessor.getPropertyValue("period");
|
||||
assertEquals(fixedRate, true);
|
||||
assertEquals(36l, period.longValue());
|
||||
assertEquals(36L, period.longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,6 +65,6 @@ public class IntervalTriggerParserTests {
|
||||
Boolean fixedRate = (Boolean) accessor.getPropertyValue("fixedRate");
|
||||
Long period = (Long) accessor.getPropertyValue("period");
|
||||
assertEquals(fixedRate, false);
|
||||
assertEquals(37l, period.longValue());
|
||||
assertEquals(37L, period.longValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,12 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.mapping.MessageMappingException;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.messaging.handler.annotation.Headers;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.integration.mapping.MessageMappingException;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -57,7 +57,7 @@ public class GatewayMethodInboundMessageMapperToMessageTests {
|
||||
Method method = TestService.class.getMethod("sendPayload", String.class);
|
||||
GatewayMethodInboundMessageMapper mapper = new GatewayMethodInboundMessageMapper(method);
|
||||
mapper.setBeanFactory(mock(BeanFactory.class));
|
||||
mapper.toMessage(new Object[] { "test" , "oops" });
|
||||
mapper.toMessage(new Object[] { "test", "oops" });
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
||||
@@ -339,7 +339,7 @@ public class GatewayProxyFactoryBeanTests {
|
||||
gpfb.setDefaultRequestChannel(drc);
|
||||
gpfb.setDefaultReplyTimeout(0L);
|
||||
GatewayMethodMetadata meta = new GatewayMethodMetadata();
|
||||
meta.setHeaderExpressions(Collections. <String, Expression> singletonMap("foo", new LiteralExpression("bar")));
|
||||
meta.setHeaderExpressions(Collections.<String, Expression>singletonMap("foo", new LiteralExpression("bar")));
|
||||
gpfb.setGlobalMethodMetadata(meta);
|
||||
gpfb.afterPropertiesSet();
|
||||
((TestEchoService) gpfb.getObject()).echo("foo");
|
||||
|
||||
@@ -63,7 +63,7 @@ public class BridgeHandlerTests {
|
||||
@Test(timeout = 1000)
|
||||
public void missingOutputChannelAllowedForReplyChannelMessages() throws Exception {
|
||||
PollableChannel replyChannel = new QueueChannel();
|
||||
Message<String> request = MessageBuilder.withPayload("tst").setReplyChannel(replyChannel ).build();
|
||||
Message<String> request = MessageBuilder.withPayload("tst").setReplyChannel(replyChannel).build();
|
||||
handler.handleMessage(request);
|
||||
assertThat(replyChannel.receive(), sameExceptImmutableHeaders(request));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -66,7 +66,7 @@ public class MultiChannelRouterTests {
|
||||
AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> getChannelKeys(Message<?> message) {
|
||||
return CollectionUtils.arrayToList(new String[] {"noSuchChannel"} );
|
||||
return CollectionUtils.arrayToList(new String[] {"noSuchChannel"});
|
||||
}
|
||||
};
|
||||
TestChannelResolver channelResolver = new TestChannelResolver();
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SimpleMessageGroupTests {
|
||||
|
||||
private final Object key = new Object();
|
||||
|
||||
private SimpleMessageGroup group = new SimpleMessageGroup(Collections.<Message<?>> emptyList(), key);
|
||||
private SimpleMessageGroup group = new SimpleMessageGroup(Collections.<Message<?>>emptyList(), key);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void prepareForSequenceAwareMessageGroup() throws Exception {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SmartLifecycleRoleControllerTests {
|
||||
when(lc1.getPhase()).thenReturn(2);
|
||||
SmartLifecycle lc2 = mock(SmartLifecycle.class);
|
||||
when(lc1.getPhase()).thenReturn(1);
|
||||
MultiValueMap<String , SmartLifecycle> map = new LinkedMultiValueMap<String, SmartLifecycle>();
|
||||
MultiValueMap<String, SmartLifecycle> map = new LinkedMultiValueMap<String, SmartLifecycle>();
|
||||
map.add("foo", lc1);
|
||||
map.add("foo", lc2);
|
||||
SmartLifecycleRoleController controller = new SmartLifecycleRoleController(map);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -523,7 +523,9 @@ public class ContentEnricherTests {
|
||||
@SuppressWarnings("unused")
|
||||
private static final class Source {
|
||||
|
||||
private final String firstName, lastName;
|
||||
private final String firstName;
|
||||
|
||||
private final String lastName;
|
||||
|
||||
Source(String firstName, String lastName) {
|
||||
this.firstName = firstName;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class PayloadTypeConvertingTransformerTests {
|
||||
@Test
|
||||
public void testTransformPayloadObject() throws Exception {
|
||||
PayloadTypeConvertingTransformer<String, String> tx = new PayloadTypeConvertingTransformer<String, String>();
|
||||
tx.setConverter(new Converter<String, String> () {
|
||||
tx.setConverter(new Converter<String, String>() {
|
||||
|
||||
@Override
|
||||
public String convert(String source) {
|
||||
|
||||
@@ -95,16 +95,14 @@ public class RemoteFileOutboundGatewayTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testBad() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "bad", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "bad", "payload");
|
||||
gw.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadFilterGet() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "get", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload");
|
||||
gw.setFilter(new TestPatternFilter(""));
|
||||
try {
|
||||
gw.afterPropertiesSet();
|
||||
@@ -118,8 +116,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
@Test
|
||||
public void testBadFilterRm() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "rm", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "rm", "payload");
|
||||
gw.setFilter(new TestPatternFilter(""));
|
||||
try {
|
||||
gw.afterPropertiesSet();
|
||||
@@ -134,8 +131,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testLs() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "ls", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload");
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
TestLsEntry[] files = fileList();
|
||||
@@ -167,8 +163,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
|
||||
private void testMGetWildGuts(final String path1, final String path2) {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "mget", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mget", "payload");
|
||||
gw.setLocalDirectory(new File(this.tmpDir));
|
||||
gw.afterPropertiesSet();
|
||||
new File(this.tmpDir + "/f1").delete();
|
||||
@@ -209,8 +204,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
@Test
|
||||
public void testMGetSingle() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "mget", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mget", "payload");
|
||||
gw.setLocalDirectory(new File(this.tmpDir));
|
||||
gw.afterPropertiesSet();
|
||||
new File(this.tmpDir + "/f1").delete();
|
||||
@@ -240,8 +234,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
@Test(expected = MessagingException.class)
|
||||
public void testMGetEmpty() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "mget", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mget", "payload");
|
||||
gw.setLocalDirectory(new File(this.tmpDir));
|
||||
gw.setOptions(" -x ");
|
||||
gw.afterPropertiesSet();
|
||||
@@ -262,8 +255,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
@Test
|
||||
public void testMove() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "mv", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mv", "payload");
|
||||
gw.afterPropertiesSet();
|
||||
Session<?> session = mock(Session.class);
|
||||
final AtomicReference<String> args = new AtomicReference<String>();
|
||||
@@ -288,8 +280,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
@Test
|
||||
public void testMoveWithExpression() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "mv", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mv", "payload");
|
||||
gw.setRenameExpression(PARSER.parseExpression("payload.substring(1)"));
|
||||
gw.afterPropertiesSet();
|
||||
Session<?> session = mock(Session.class);
|
||||
@@ -313,8 +304,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
@Test
|
||||
public void testMoveWithMkDirs() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "mv", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "mv", "payload");
|
||||
gw.setRenameExpression(PARSER.parseExpression("'foo/bar/baz'"));
|
||||
gw.afterPropertiesSet();
|
||||
Session<?> session = mock(Session.class);
|
||||
@@ -363,8 +353,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testLs_f() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "ls", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload");
|
||||
gw.setOptions("-f");
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
@@ -405,8 +394,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testLs_f_R() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "ls", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload");
|
||||
gw.setOptions("-f -R");
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
@@ -432,8 +420,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testLs_f_R_dirs() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "ls", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload");
|
||||
gw.setOptions("-f -R -dirs");
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
@@ -461,8 +448,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testLs_None() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "ls", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload");
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
TestLsEntry[] files = new TestLsEntry[0];
|
||||
@@ -477,8 +463,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testLs_1() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "ls", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload");
|
||||
gw.setOptions("-1");
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
@@ -496,8 +481,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testLs_1_f() throws Exception { //no sort
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "ls", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload");
|
||||
gw.setOptions("-1 -f");
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
@@ -515,8 +499,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testLs_1_dirs() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "ls", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload");
|
||||
gw.setOptions("-1 -dirs");
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
@@ -535,8 +518,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testLs_1_dirs_links() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "ls", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload");
|
||||
gw.setOptions("-1 -dirs -links");
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
@@ -556,8 +538,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testLs_1_a_f_dirs_links() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "ls", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload");
|
||||
gw.setOptions("-1 -a -f -dirs -links");
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
@@ -579,8 +560,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testLs_1_a_f_dirs_links_filtered() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "ls", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "ls", "payload");
|
||||
gw.setOptions("-1 -a -f -dirs -links");
|
||||
gw.setFilter(new TestPatternFilter("*4"));
|
||||
gw.afterPropertiesSet();
|
||||
@@ -597,8 +577,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
@Test
|
||||
public void testGet() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "get", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload");
|
||||
gw.setLocalDirectory(new File(this.tmpDir));
|
||||
gw.afterPropertiesSet();
|
||||
new File(this.tmpDir + "/f1").delete();
|
||||
@@ -632,8 +611,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
@Test
|
||||
public void testGetExists() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "get", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload");
|
||||
gw.setLocalDirectory(new File(this.tmpDir));
|
||||
gw.afterPropertiesSet();
|
||||
File outFile = new File(this.tmpDir + "/f1");
|
||||
@@ -703,8 +681,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
@Test
|
||||
public void testGetTempFileDelete() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "get", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload");
|
||||
gw.setLocalDirectory(new File(this.tmpDir));
|
||||
gw.afterPropertiesSet();
|
||||
new File(this.tmpDir + "/f1").delete();
|
||||
@@ -741,8 +718,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
@Test
|
||||
public void testGet_P() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "get", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload");
|
||||
gw.setLocalDirectory(new File(this.tmpDir));
|
||||
gw.setOptions("-P");
|
||||
gw.afterPropertiesSet();
|
||||
@@ -784,8 +760,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
new File(this.tmpDir + "/x/f1").delete();
|
||||
new File(this.tmpDir + "/x").delete();
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "get", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "get", "payload");
|
||||
gw.setLocalDirectory(new File(this.tmpDir + "/x"));
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(new TestSession() {
|
||||
@@ -814,8 +789,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
public void testRm() throws Exception {
|
||||
SessionFactory sessionFactory = mock(SessionFactory.class);
|
||||
Session session = mock(Session.class);
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
|
||||
(sessionFactory, "rm", "payload");
|
||||
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway(sessionFactory, "rm", "payload");
|
||||
gw.afterPropertiesSet();
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
when(session.remove("testremote/x/f1")).thenReturn(Boolean.TRUE);
|
||||
|
||||
@@ -186,7 +186,7 @@ public class DelegatingSessionFactoryTests {
|
||||
|
||||
@Override
|
||||
public Session<String> getSession() {
|
||||
return this.mockSession ;
|
||||
return this.mockSession;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -189,7 +190,8 @@ public class FtpOutboundTests {
|
||||
return null;
|
||||
}
|
||||
}).when(logger).warn(Mockito.anyString());
|
||||
RemoteFileTemplate<?> template = TestUtils.getPropertyValue(handler, "remoteFileTemplate", RemoteFileTemplate.class);
|
||||
RemoteFileTemplate<?> template = TestUtils.getPropertyValue(handler, "remoteFileTemplate",
|
||||
RemoteFileTemplate.class);
|
||||
new DirectFieldAccessor(template).setPropertyValue("logger", logger);
|
||||
handler.handleMessage(new GenericMessage<File>(srcFile));
|
||||
assertNotNull(logged.get());
|
||||
@@ -251,7 +253,7 @@ public class FtpOutboundTests {
|
||||
when(ftpClient.login("kermit", "frog")).thenReturn(true);
|
||||
when(ftpClient.changeWorkingDirectory(Mockito.anyString())).thenReturn(true);
|
||||
when(ftpClient.printWorkingDirectory()).thenReturn("remote-target-dir");
|
||||
when(ftpClient.storeFile(Mockito.anyString(), Mockito.any(InputStream.class))).thenAnswer(new Answer<Boolean>() {
|
||||
when(ftpClient.storeFile(Mockito.anyString(), any(InputStream.class))).thenAnswer(new Answer<Boolean>() {
|
||||
@Override
|
||||
public Boolean answer(InvocationOnMock invocation) throws Throwable {
|
||||
String fileName = (String) invocation.getArguments()[0];
|
||||
@@ -278,7 +280,8 @@ public class FtpOutboundTests {
|
||||
file.setType(FTPFile.FILE_TYPE);
|
||||
file.setTimestamp(Calendar.getInstance());
|
||||
ftpFiles.add(file);
|
||||
when(ftpClient.retrieveFile(Mockito.eq("remote-test-dir/" + fileName) , Mockito.any(OutputStream.class))).thenReturn(true);
|
||||
when(ftpClient.retrieveFile(Mockito.eq("remote-test-dir/" + fileName),
|
||||
any(OutputStream.class))).thenReturn(true);
|
||||
}
|
||||
when(ftpClient.listFiles("remote-test-dir/")).thenReturn(ftpFiles.toArray(new FTPFile[]{}));
|
||||
return ftpClient;
|
||||
|
||||
@@ -55,21 +55,20 @@ public class GemfireMessageStore extends AbstractKeyValueMessageStore implements
|
||||
* Provides the region to be used for the message store. This is useful when
|
||||
* using a configured region. This is also required if using a client region
|
||||
* on a remote cache server.
|
||||
*
|
||||
* @param messageStoreRegion The region.
|
||||
*/
|
||||
public GemfireMessageStore(Region<Object, Object> messageStoreRegion) {
|
||||
this.cache = null;
|
||||
this.messageStoreRegion = messageStoreRegion;
|
||||
}
|
||||
/**
|
||||
* Provides a cache reference used to create a message store region named
|
||||
* 'messageStoreRegion'
|
||||
*
|
||||
* @param cache The cache.
|
||||
*
|
||||
* @deprecated - use the other constructor and provide a region directly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides a cache reference used to create a message store region named
|
||||
* 'messageStoreRegion'
|
||||
* @param cache The cache.
|
||||
*
|
||||
* @deprecated - use the other constructor and provide a region directly.
|
||||
*/
|
||||
@Deprecated
|
||||
public GemfireMessageStore(Cache cache) {
|
||||
Assert.notNull(cache, "'cache' must not be null");
|
||||
|
||||
@@ -363,7 +363,7 @@ public class HttpRequestHandlingMessagingGatewayTests extends AbstractHttpInboun
|
||||
@Override
|
||||
protected Object handleRequestMessage(Message<?> requestMessage) {
|
||||
return new GenericMessage<String>("foo",
|
||||
Collections.<String, Object> singletonMap(HttpHeaders.STATUS_CODE, HttpStatus.GATEWAY_TIMEOUT));
|
||||
Collections.<String, Object>singletonMap(HttpHeaders.STATUS_CODE, HttpStatus.GATEWAY_TIMEOUT));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
@@ -84,7 +84,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void simpleStringKeyStringValueFormData() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
@@ -109,7 +110,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
Object body = request.getBody();
|
||||
assertNotNull(request.getHeaders().getContentType());
|
||||
assertTrue(body instanceof MultiValueMap<?, ?>);
|
||||
MultiValueMap<?, ?> map = (MultiValueMap <?, ?>) body;
|
||||
MultiValueMap<?, ?> map = (MultiValueMap<?, ?>) body;
|
||||
assertEquals("1", map.get("a").iterator().next());
|
||||
assertEquals("2", map.get("b").iterator().next());
|
||||
assertEquals("3", map.get("c").iterator().next());
|
||||
@@ -118,7 +119,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void simpleStringKeyObjectValueFormData() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
@@ -142,7 +144,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
HttpEntity<?> request = template.lastRequestEntity.get();
|
||||
Object body = request.getBody();
|
||||
assertTrue(body instanceof MultiValueMap<?, ?>);
|
||||
MultiValueMap<?, ?> map = (MultiValueMap <?, ?>) body;
|
||||
MultiValueMap<?, ?> map = (MultiValueMap<?, ?>) body;
|
||||
assertEquals("Philadelphia", map.get("a").get(0).toString());
|
||||
assertEquals("Ambler", map.get("b").get(0).toString());
|
||||
assertEquals("Mohnton", map.get("c").get(0).toString());
|
||||
@@ -151,7 +153,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void simpleObjectKeyObjectValueFormData() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
@@ -175,7 +178,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
HttpEntity<?> request = template.lastRequestEntity.get();
|
||||
Object body = request.getBody();
|
||||
assertTrue(body instanceof Map<?, ?>);
|
||||
Map<?, ?> map = (Map <?, ?>) body;
|
||||
Map<?, ?> map = (Map<?, ?>) body;
|
||||
assertEquals("Philadelphia", map.get(1).toString());
|
||||
assertEquals("Ambler", map.get(2).toString());
|
||||
assertEquals("Mohnton", map.get(3).toString());
|
||||
@@ -185,7 +188,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void stringKeyStringArrayValueFormData() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
@@ -208,7 +212,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
HttpEntity<?> request = template.lastRequestEntity.get();
|
||||
Object body = request.getBody();
|
||||
assertTrue(body instanceof MultiValueMap<?, ?>);
|
||||
MultiValueMap<?, ?> map = (MultiValueMap <?, ?>) body;
|
||||
MultiValueMap<?, ?> map = (MultiValueMap<?, ?>) body;
|
||||
|
||||
List<?> aValue = map.get("a");
|
||||
assertEquals(3, aValue.size());
|
||||
@@ -232,14 +236,15 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void stringKeyPrimitiveArrayValueMixedFormData() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
setBeanFactory(handler);
|
||||
handler.afterPropertiesSet();
|
||||
Map<String, Object> form = new LinkedHashMap<String, Object>();
|
||||
form.put("a", new int[]{1, 2, 3});
|
||||
form.put("a", new int[] { 1, 2, 3 });
|
||||
form.put("b", "4");
|
||||
form.put("c", new String[] { "5" });
|
||||
form.put("d", "6");
|
||||
@@ -255,7 +260,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
HttpEntity<?> request = template.lastRequestEntity.get();
|
||||
Object body = request.getBody();
|
||||
assertTrue(body instanceof MultiValueMap<?, ?>);
|
||||
MultiValueMap<?, ?> map = (MultiValueMap <?, ?>) body;
|
||||
MultiValueMap<?, ?> map = (MultiValueMap<?, ?>) body;
|
||||
|
||||
List<?> aValue = map.get("a");
|
||||
assertEquals(1, aValue.size());
|
||||
@@ -279,16 +284,18 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
assertEquals("6", dValue.get(0));
|
||||
assertEquals(MediaType.MULTIPART_FORM_DATA, request.getHeaders().getContentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stringKeyNullArrayValueMixedFormData() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
setBeanFactory(handler);
|
||||
handler.afterPropertiesSet();
|
||||
Map<String, Object> form = new LinkedHashMap<String, Object>();
|
||||
form.put("a", new Object[]{null, 4, null});
|
||||
form.put("a", new Object[] { null, 4, null });
|
||||
form.put("b", "4");
|
||||
Message<?> message = MessageBuilder.withPayload(form).build();
|
||||
Exception exception = null;
|
||||
@@ -302,7 +309,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
HttpEntity<?> request = template.lastRequestEntity.get();
|
||||
Object body = request.getBody();
|
||||
assertTrue(body instanceof MultiValueMap<?, ?>);
|
||||
MultiValueMap<?, ?> map = (MultiValueMap <?, ?>) body;
|
||||
MultiValueMap<?, ?> map = (MultiValueMap<?, ?>) body;
|
||||
|
||||
List<?> aValue = map.get("a");
|
||||
assertEquals(3, aValue.size());
|
||||
@@ -316,15 +323,17 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
assertEquals(MediaType.MULTIPART_FORM_DATA, request.getHeaders().getContentType());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test and the one below might look identical, but they are not.
|
||||
* This test injected "5" into the list as String resulting in
|
||||
* the Content-TYpe being application/x-www-form-urlencoded
|
||||
* This test and the one below might look identical, but they are not. This test
|
||||
* injected "5" into the list as String resulting in the Content-TYpe being
|
||||
* application/x-www-form-urlencoded
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void stringKeyNullCollectionValueMixedFormDataString() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
@@ -349,7 +358,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
HttpEntity<?> request = template.lastRequestEntity.get();
|
||||
Object body = request.getBody();
|
||||
assertTrue(body instanceof MultiValueMap<?, ?>);
|
||||
MultiValueMap<?, ?> map = (MultiValueMap <?, ?>) body;
|
||||
MultiValueMap<?, ?> map = (MultiValueMap<?, ?>) body;
|
||||
|
||||
List<?> aValue = map.get("a");
|
||||
assertEquals(3, aValue.size());
|
||||
@@ -363,15 +372,16 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
assertEquals(MediaType.APPLICATION_FORM_URLENCODED, request.getHeaders().getContentType());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test and the one above might look identical, but they are not.
|
||||
* This test injected 5 into the list as int resulting in
|
||||
* Content-type being multipart/form-data
|
||||
* This test and the one above might look identical, but they are not. This test
|
||||
* injected 5 into the list as int resulting in Content-type being multipart/form-data
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void stringKeyNullCollectionValueMixedFormDataObject() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
@@ -396,7 +406,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
HttpEntity<?> request = template.lastRequestEntity.get();
|
||||
Object body = request.getBody();
|
||||
assertTrue(body instanceof MultiValueMap<?, ?>);
|
||||
MultiValueMap<?, ?> map = (MultiValueMap <?, ?>) body;
|
||||
MultiValueMap<?, ?> map = (MultiValueMap<?, ?>) body;
|
||||
|
||||
List<?> aValue = map.get("a");
|
||||
assertEquals(3, aValue.size());
|
||||
@@ -413,7 +423,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void stringKeyStringCollectionValueFormData() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
@@ -438,8 +449,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
HttpEntity<?> request = template.lastRequestEntity.get();
|
||||
Object body = request.getBody();
|
||||
assertTrue(body instanceof MultiValueMap<?, ?>);
|
||||
MultiValueMap<?, ?> map = (MultiValueMap <?, ?>) body;
|
||||
|
||||
MultiValueMap<?, ?> map = (MultiValueMap<?, ?>) body;
|
||||
|
||||
List<?> aValue = map.get("a");
|
||||
assertEquals(2, aValue.size());
|
||||
@@ -458,7 +468,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void stringKeyObjectCollectionValueFormData() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
@@ -483,8 +494,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
HttpEntity<?> request = template.lastRequestEntity.get();
|
||||
Object body = request.getBody();
|
||||
assertTrue(body instanceof MultiValueMap<?, ?>);
|
||||
MultiValueMap<?, ?> map = (MultiValueMap <?, ?>) body;
|
||||
|
||||
MultiValueMap<?, ?> map = (MultiValueMap<?, ?>) body;
|
||||
|
||||
List<?> aValue = map.get("a");
|
||||
assertEquals(2, aValue.size());
|
||||
@@ -503,7 +513,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void nameOnlyWithNullValues() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
@@ -540,7 +551,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
@SuppressWarnings("cast")
|
||||
@Test
|
||||
public void contentAsByteArray() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
@@ -566,7 +578,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void contentAsXmlSource() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
@@ -592,7 +605,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
public void testWarnMessageForNonPostPutAndExtractPayload() throws Exception {
|
||||
// should see a warn message
|
||||
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.GET);
|
||||
@@ -600,7 +614,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
setBeanFactory(handler);
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
// should not see a warn message since 'setExtractPayload' is not set explicitly
|
||||
// should not see a warn message since 'setExtractPayload' is not set explicitly
|
||||
|
||||
handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
template = new MockRestTemplate();
|
||||
@@ -609,7 +623,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
setBeanFactory(handler);
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
// should not see a warn message since HTTP method is not GET
|
||||
// should not see a warn message since HTTP method is not GET
|
||||
|
||||
handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
template = new MockRestTemplate();
|
||||
@@ -622,8 +636,9 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void contentTypeIsNotSetForGetRequest() throws Exception {
|
||||
//GET
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
// GET
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.GET);
|
||||
@@ -642,80 +657,66 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
HttpEntity<?> request = template.lastRequestEntity.get();
|
||||
assertNull(request.getHeaders().getContentType());
|
||||
|
||||
/* TODO: reconsider the inclusion of content-type for various HttpMethods (only ignoring for GET as of 2.0.5)
|
||||
* uncomment code below accordingly (see INT-1951)
|
||||
/*
|
||||
* TODO: reconsider the inclusion of content-type for various HttpMethods (only
|
||||
* ignoring for GET as of 2.0.5) uncomment code below accordingly (see INT-1951)
|
||||
*/
|
||||
|
||||
/*
|
||||
//HEAD
|
||||
handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.HEAD);
|
||||
|
||||
message = MessageBuilder.withPayload(mock(Source.class)).build();
|
||||
exception = null;
|
||||
try {
|
||||
handler.handleMessage(message);
|
||||
}
|
||||
catch (Exception e) {
|
||||
exception = e;
|
||||
}
|
||||
assertEquals("intentional", exception.getCause().getMessage());
|
||||
request = template.lastRequestEntity.get();
|
||||
assertNull(request.getHeaders().getContentType());
|
||||
|
||||
//DELETE
|
||||
handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.DELETE);
|
||||
|
||||
message = MessageBuilder.withPayload(mock(Source.class)).build();
|
||||
exception = null;
|
||||
try {
|
||||
handler.handleMessage(message);
|
||||
}
|
||||
catch (Exception e) {
|
||||
exception = e;
|
||||
}
|
||||
assertEquals("intentional", exception.getCause().getMessage());
|
||||
request = template.lastRequestEntity.get();
|
||||
assertNull(request.getHeaders().getContentType());
|
||||
|
||||
//TRACE
|
||||
handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.TRACE);
|
||||
|
||||
message = MessageBuilder.withPayload(mock(Source.class)).build();
|
||||
exception = null;
|
||||
try {
|
||||
handler.handleMessage(message);
|
||||
}
|
||||
catch (Exception e) {
|
||||
exception = e;
|
||||
}
|
||||
assertEquals("intentional", exception.getCause().getMessage());
|
||||
request = template.lastRequestEntity.get();
|
||||
assertNull(request.getHeaders().getContentType());
|
||||
*/
|
||||
* //HEAD handler = new HttpRequestExecutingMessageHandler(
|
||||
* "http://www.springsource.org/spring-integration"); template = new
|
||||
* MockRestTemplate(); new
|
||||
* DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
* handler.setHttpMethod(HttpMethod.HEAD);
|
||||
*
|
||||
* message = MessageBuilder.withPayload(mock(Source.class)).build(); exception =
|
||||
* null; try { handler.handleMessage(message); } catch (Exception e) { exception =
|
||||
* e; } assertEquals("intentional", exception.getCause().getMessage()); request =
|
||||
* template.lastRequestEntity.get();
|
||||
* assertNull(request.getHeaders().getContentType());
|
||||
*
|
||||
* //DELETE handler = new HttpRequestExecutingMessageHandler(
|
||||
* "http://www.springsource.org/spring-integration"); template = new
|
||||
* MockRestTemplate(); new
|
||||
* DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
* handler.setHttpMethod(HttpMethod.DELETE);
|
||||
*
|
||||
* message = MessageBuilder.withPayload(mock(Source.class)).build(); exception =
|
||||
* null; try { handler.handleMessage(message); } catch (Exception e) { exception =
|
||||
* e; } assertEquals("intentional", exception.getCause().getMessage()); request =
|
||||
* template.lastRequestEntity.get();
|
||||
* assertNull(request.getHeaders().getContentType());
|
||||
*
|
||||
* //TRACE handler = new HttpRequestExecutingMessageHandler(
|
||||
* "http://www.springsource.org/spring-integration"); template = new
|
||||
* MockRestTemplate(); new
|
||||
* DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
* handler.setHttpMethod(HttpMethod.TRACE);
|
||||
*
|
||||
* message = MessageBuilder.withPayload(mock(Source.class)).build(); exception =
|
||||
* null; try { handler.handleMessage(message); } catch (Exception e) { exception =
|
||||
* e; } assertEquals("intentional", exception.getCause().getMessage()); request =
|
||||
* template.lastRequestEntity.get();
|
||||
* assertNull(request.getHeaders().getContentType());
|
||||
*/
|
||||
}
|
||||
|
||||
@Test //INT-2275
|
||||
@Test // INT-2275
|
||||
public void testOutboundChannelAdapterWithinChain() throws URISyntaxException {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("HttpOutboundWithinChainTests-context.xml", this.getClass());
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"HttpOutboundWithinChainTests-context.xml", this.getClass());
|
||||
MessageChannel channel = ctx.getBean("httpOutboundChannelAdapterWithinChain", MessageChannel.class);
|
||||
RestTemplate restTemplate = ctx.getBean("restTemplate", RestTemplate.class);
|
||||
channel.send(MessageBuilder.withPayload("test").build());
|
||||
Mockito.verify(restTemplate).exchange(Mockito.eq(new URI("http://localhost/test1/%2f")), Mockito.eq(HttpMethod.POST),
|
||||
Mockito.any(HttpEntity.class), Mockito.<Class<Object>>eq(null));
|
||||
Mockito.verify(restTemplate).exchange(Mockito.eq(new URI("http://localhost/test1/%2f")),
|
||||
Mockito.eq(HttpMethod.POST), Mockito.any(HttpEntity.class), Mockito.<Class<Object>>eq(null));
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test //INT-1029
|
||||
@Test // INT-1029
|
||||
public void testHttpOutboundGatewayWithinChain() throws IOException, URISyntaxException {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("HttpOutboundWithinChainTests-context.xml", this.getClass());
|
||||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"HttpOutboundWithinChainTests-context.xml", this.getClass());
|
||||
MessageChannel channel = ctx.getBean("httpOutboundGatewayWithinChain", MessageChannel.class);
|
||||
RestTemplate restTemplate = ctx.getBean("restTemplate", RestTemplate.class);
|
||||
channel.send(MessageBuilder.withPayload("test").build());
|
||||
@@ -723,19 +724,20 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
PollableChannel output = ctx.getBean("replyChannel", PollableChannel.class);
|
||||
Message<?> receive = output.receive();
|
||||
assertEquals(HttpStatus.OK, ((ResponseEntity<?>) receive.getPayload()).getStatusCode());
|
||||
Mockito.verify(restTemplate)
|
||||
.exchange(Mockito.eq(new URI("http://localhost:51235/%2f/testApps?param=http+Outbound+Gateway+Within+Chain")),
|
||||
Mockito.eq(HttpMethod.POST), Mockito.any(HttpEntity.class), Mockito.eq(new ParameterizedTypeReference<List<String>>() {
|
||||
Mockito.verify(restTemplate).exchange(
|
||||
Mockito.eq(new URI("http://localhost:51235/%2f/testApps?param=http+Outbound+Gateway+Within+Chain")),
|
||||
Mockito.eq(HttpMethod.POST), Mockito.any(HttpEntity.class),
|
||||
Mockito.eq(new ParameterizedTypeReference<List<String>>() {
|
||||
|
||||
}));
|
||||
}));
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUriExpression() {
|
||||
MockRestTemplate restTemplate = new MockRestTemplate();
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
new SpelExpressionParser().parseExpression("headers['foo']"),
|
||||
restTemplate);
|
||||
new SpelExpressionParser().parseExpression("headers['foo']"), restTemplate);
|
||||
setBeanFactory(handler);
|
||||
handler.afterPropertiesSet();
|
||||
String theURL = "http://bar/baz?foo#bar";
|
||||
@@ -743,7 +745,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
try {
|
||||
handler.handleRequestMessage(message);
|
||||
}
|
||||
catch (Exception e) { }
|
||||
catch (Exception e) {
|
||||
}
|
||||
assertEquals(theURL, restTemplate.actualUrl.get());
|
||||
}
|
||||
|
||||
@@ -751,8 +754,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
public void testInt2455UriNotEncoded() {
|
||||
MockRestTemplate restTemplate = new MockRestTemplate();
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
new SpelExpressionParser().parseExpression("'http://my.RabbitMQ.com/api/' + payload"),
|
||||
restTemplate);
|
||||
new SpelExpressionParser().parseExpression("'http://my.RabbitMQ.com/api/' + payload"), restTemplate);
|
||||
handler.setEncodeUri(false);
|
||||
setBeanFactory(handler);
|
||||
handler.afterPropertiesSet();
|
||||
@@ -760,13 +762,15 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
try {
|
||||
handler.handleRequestMessage(message);
|
||||
}
|
||||
catch (Exception e) { }
|
||||
catch (Exception e) {
|
||||
}
|
||||
assertEquals("http://my.RabbitMQ.com/api/queues/%2f/si.test.queue?foo#bar", restTemplate.actualUrl.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptHeaderForSerializableResponse() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
handler.setHttpMethod(HttpMethod.GET);
|
||||
handler.setExpectedResponseType(Foo.class);
|
||||
|
||||
@@ -799,7 +803,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void acceptHeaderForSerializableResponseMessageExchange() throws Exception {
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
|
||||
handler.setHttpMethod(HttpMethod.GET);
|
||||
handler.setExtractPayload(false);
|
||||
@@ -844,8 +849,7 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
ClientHttpRequest clientRequest = mock(ClientHttpRequest.class);
|
||||
when(clientRequest.getHeaders()).thenReturn(headers);
|
||||
|
||||
when(requestFactory.createRequest(any(URI.class), any(HttpMethod.class)))
|
||||
.thenReturn(clientRequest);
|
||||
when(requestFactory.createRequest(any(URI.class), any(HttpMethod.class))).thenReturn(clientRequest);
|
||||
|
||||
ClientHttpResponse response = mock(ClientHttpResponse.class);
|
||||
when(response.getStatusCode()).thenReturn(HttpStatus.NOT_FOUND);
|
||||
@@ -898,13 +902,13 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
@Override
|
||||
public <T> ResponseEntity<T> exchange(URI uri, HttpMethod method, HttpEntity<?> requestEntity,
|
||||
Class<T> responseType) throws RestClientException {
|
||||
Class<T> responseType) throws RestClientException {
|
||||
return new ResponseEntity<T>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity,
|
||||
ParameterizedTypeReference<T> responseType) throws RestClientException {
|
||||
ParameterizedTypeReference<T> responseType) throws RestClientException {
|
||||
return new ResponseEntity<T>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,9 +47,9 @@ public class TcpOutboundGatewayParser extends AbstractConsumerEndpointParser {
|
||||
IpAdapterParserUtils.REPLY_CHANNEL);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element,
|
||||
IpAdapterParserUtils.REQUEST_TIMEOUT);
|
||||
BeanDefinition remoteTimeoutExpression = IntegrationNamespaceUtils.createExpressionDefinitionFromValueOrExpression
|
||||
(IpAdapterParserUtils.REMOTE_TIMEOUT, IpAdapterParserUtils.REMOTE_TIMEOUT_EXPRESSION,
|
||||
parserContext, element, false);
|
||||
BeanDefinition remoteTimeoutExpression = IntegrationNamespaceUtils
|
||||
.createExpressionDefinitionFromValueOrExpression(IpAdapterParserUtils.REMOTE_TIMEOUT,
|
||||
IpAdapterParserUtils.REMOTE_TIMEOUT_EXPRESSION, parserContext, element, false);
|
||||
if (remoteTimeoutExpression != null) {
|
||||
builder.addPropertyValue("remoteTimeoutExpression", remoteTimeoutExpression);
|
||||
}
|
||||
|
||||
@@ -31,17 +31,16 @@ import javax.net.SocketFactory;
|
||||
public interface TcpSocketFactorySupport {
|
||||
|
||||
/**
|
||||
* Supplies the {@link ServerSocketFactory} to be used to
|
||||
* create new {@link ServerSocket}s.
|
||||
* Supplies the {@link ServerSocketFactory} to be used to create new
|
||||
* {@link ServerSocket}s.
|
||||
* @return the ServerSocketFacory
|
||||
*/
|
||||
ServerSocketFactory getServerSocketFactory();
|
||||
ServerSocketFactory getServerSocketFactory();
|
||||
|
||||
/**
|
||||
* Supplies the {@link SocketFactory} to be used to
|
||||
* create new {@link Socket}s.
|
||||
* @return the SocketFactory
|
||||
*/
|
||||
SocketFactory getSocketFactory();
|
||||
/**
|
||||
* Supplies the {@link SocketFactory} to be used to create new {@link Socket}s.
|
||||
* @return the SocketFactory
|
||||
*/
|
||||
SocketFactory getSocketFactory();
|
||||
|
||||
}
|
||||
|
||||
@@ -28,21 +28,19 @@ import java.net.Socket;
|
||||
public interface TcpSocketSupport {
|
||||
|
||||
/**
|
||||
* Performs any further modifications to the server socket
|
||||
* after the connection factory has created the socket and
|
||||
* set any configured attributes, before invoking
|
||||
* Performs any further modifications to the server socket after the connection
|
||||
* factory has created the socket and set any configured attributes, before invoking
|
||||
* {@link ServerSocket#accept()}.
|
||||
* @param serverSocket The ServerSocket
|
||||
*/
|
||||
void postProcessServerSocket(ServerSocket serverSocket);
|
||||
void postProcessServerSocket(ServerSocket serverSocket);
|
||||
|
||||
/**
|
||||
* Performs any further modifications to the {@link Socket} after
|
||||
* the socket has been created by a client, or accepted by
|
||||
* a server, and after any configured atributes have been
|
||||
* set.
|
||||
* @param socket The Socket
|
||||
*/
|
||||
void postProcessSocket(Socket socket);
|
||||
/**
|
||||
* Performs any further modifications to the {@link Socket} after the socket has been
|
||||
* created by a client, or accepted by a server, and after any configured atributes
|
||||
* have been set.
|
||||
* @param socket The Socket
|
||||
*/
|
||||
void postProcessSocket(Socket socket);
|
||||
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class TestingUtilities {
|
||||
}
|
||||
|
||||
if (n++ > delay) {
|
||||
throw new IllegalStateException ("Server didn't start listening.");
|
||||
throw new IllegalStateException("Server didn't start listening.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public final class TestingUtilities {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
if (n++ > 200) {
|
||||
throw new IllegalStateException ("Server didn't stop listening.");
|
||||
throw new IllegalStateException("Server didn't stop listening.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class MultiClientTests {
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
|
||||
for (int i = 0; i < drivers; i++) {
|
||||
Thread t = new Thread( new Runnable() {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UnicastSendingMessageHandler sender = new UnicastSendingMessageHandler(
|
||||
@@ -85,10 +85,10 @@ public class MultiClientTests {
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
for (int i = 0; i < drivers * 3 ; i++) {
|
||||
for (int i = 0; i < drivers * 3; i++) {
|
||||
queueIn.send(MessageBuilder.withPayload(payload).build());
|
||||
}
|
||||
for (int i = 0; i < drivers * 3 ; i++) {
|
||||
for (int i = 0; i < drivers * 3; i++) {
|
||||
Message<byte[]> messageOut = (Message<byte[]>) queue.receive(10000);
|
||||
assertNotNull(messageOut);
|
||||
Assert.assertEquals(payload, new String(messageOut.getPayload()));
|
||||
@@ -116,7 +116,7 @@ public class MultiClientTests {
|
||||
|
||||
for (int i = 0; i < drivers; i++) {
|
||||
final int j = i;
|
||||
Thread t = new Thread( new Runnable() {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UnicastSendingMessageHandler sender = new UnicastSendingMessageHandler(
|
||||
@@ -138,10 +138,10 @@ public class MultiClientTests {
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
for (int i = 0; i < drivers * 3 ; i++) {
|
||||
for (int i = 0; i < drivers * 3; i++) {
|
||||
queueIn.send(MessageBuilder.withPayload(payload).build());
|
||||
}
|
||||
for (int i = 0; i < drivers * 3 ; i++) {
|
||||
for (int i = 0; i < drivers * 3; i++) {
|
||||
Message<byte[]> messageOut = (Message<byte[]>) queue.receive(20000);
|
||||
assertNotNull(messageOut);
|
||||
Assert.assertEquals(payload, new String(messageOut.getPayload()));
|
||||
@@ -169,7 +169,7 @@ public class MultiClientTests {
|
||||
|
||||
for (int i = 0; i < drivers; i++) {
|
||||
final int j = i;
|
||||
Thread t = new Thread( new Runnable() {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UnicastSendingMessageHandler sender = new UnicastSendingMessageHandler(
|
||||
@@ -191,10 +191,10 @@ public class MultiClientTests {
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
for (int i = 0; i < drivers * 3 ; i++) {
|
||||
for (int i = 0; i < drivers * 3; i++) {
|
||||
queueIn.send(MessageBuilder.withPayload(payload).build());
|
||||
}
|
||||
for (int i = 0; i < drivers * 3 ; i++) {
|
||||
for (int i = 0; i < drivers * 3; i++) {
|
||||
Message<byte[]> messageOut = (Message<byte[]>) queue.receive(10000);
|
||||
assertNotNull(messageOut);
|
||||
Assert.assertEquals(payload, new String(messageOut.getPayload()));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ public class RegexUtilsTests {
|
||||
* Verify that we properly escape all special characters for matching regex
|
||||
*/
|
||||
@Test
|
||||
public void testRegex () {
|
||||
public void testRegex() {
|
||||
String s = "xxx$^[]{()}+*\\?|.xxx";
|
||||
assertEquals("xxx\\$\\^\\[\\]\\{\\(\\)\\}\\+\\*\\\\\\?\\|\\.xxx", RegexUtils.escapeRegexSpecials(s));
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class StoredProcExecutor implements BeanFactoryAware, InitializingBean {
|
||||
* Custom Stored Procedure parameters that may contain static values
|
||||
* or Strings representing an {@link Expression}.
|
||||
*/
|
||||
private volatile List<ProcedureParameter>procedureParameters;
|
||||
private volatile List<ProcedureParameter> procedureParameters;
|
||||
|
||||
private volatile boolean isFunction = false;
|
||||
|
||||
@@ -181,7 +181,7 @@ public class StoredProcExecutor implements BeanFactoryAware, InitializingBean {
|
||||
+ "Stored Procedure Name or a Stored Procedure Name Expression.");
|
||||
}
|
||||
|
||||
if (this.procedureParameters != null ) {
|
||||
if (this.procedureParameters != null) {
|
||||
|
||||
if (this.sqlParameterSourceFactory == null) {
|
||||
ExpressionEvaluatingSqlParameterSourceFactory expressionSourceFactory =
|
||||
|
||||
@@ -73,12 +73,13 @@ public class StoredProcJmxManagedBeanTests {
|
||||
// MessageHandler
|
||||
|
||||
final Set<ObjectName> messageHandlerObjectNames = server.queryNames(
|
||||
ObjectName.getInstance("org.springframework.integration.jdbc.test:name=outboundChannelAdapter.adapter.storedProcExecutor,*"),
|
||||
ObjectName.getInstance(
|
||||
"org.springframework.integration.jdbc.test:name=outboundChannelAdapter.adapter.storedProcExecutor,*"),
|
||||
null);
|
||||
assertEquals(1, messageHandlerObjectNames.size());
|
||||
ObjectName messageHandlerObjectName = messageHandlerObjectNames.iterator().next();
|
||||
Map<String, Object> messageHandlerCacheStatistics =
|
||||
(Map<String, Object>) server.getAttribute(messageHandlerObjectName, "JdbcCallOperationsCacheStatisticsAsMap");
|
||||
Map<String, Object> messageHandlerCacheStatistics = (Map<String, Object>) server
|
||||
.getAttribute(messageHandlerObjectName, "JdbcCallOperationsCacheStatisticsAsMap");
|
||||
|
||||
assertEquals(11, messageHandlerCacheStatistics.size());
|
||||
|
||||
@@ -89,13 +90,12 @@ public class StoredProcJmxManagedBeanTests {
|
||||
assertEquals(0L, messageHandlerCacheStatistics.get("missCount"));
|
||||
|
||||
// StoredProcOutboundGateway
|
||||
final Set<ObjectName> storedProcOutboundGatewayObjectNames = server.queryNames(
|
||||
ObjectName.getInstance("org.springframework.integration.jdbc.test:name=my gateway.storedProcExecutor,*"),
|
||||
null);
|
||||
final Set<ObjectName> storedProcOutboundGatewayObjectNames = server.queryNames(ObjectName
|
||||
.getInstance("org.springframework.integration.jdbc.test:name=my gateway.storedProcExecutor,*"), null);
|
||||
assertEquals(1, storedProcOutboundGatewayObjectNames.size());
|
||||
ObjectName storedProcOutboundGatewayObjectName = storedProcOutboundGatewayObjectNames.iterator().next();
|
||||
Map<String, Object> storedProcOutboundGatewayCacheStatistics =
|
||||
(Map<String, Object>) server.getAttribute(storedProcOutboundGatewayObjectName, "JdbcCallOperationsCacheStatisticsAsMap");
|
||||
Map<String, Object> storedProcOutboundGatewayCacheStatistics = (Map<String, Object>) server
|
||||
.getAttribute(storedProcOutboundGatewayObjectName, "JdbcCallOperationsCacheStatisticsAsMap");
|
||||
|
||||
assertEquals(11, messageHandlerCacheStatistics.size());
|
||||
|
||||
@@ -107,10 +107,15 @@ public class StoredProcJmxManagedBeanTests {
|
||||
|
||||
// StoredProcPollingChannelAdapter
|
||||
|
||||
final Set<ObjectName> storedProcPollingChannelAdapterObjectNames = server.queryNames(ObjectName.getInstance("org.springframework.integration.jdbc.test:name=inbound-channel-adapter.storedProcExecutor,*"), null);
|
||||
final Set<ObjectName> storedProcPollingChannelAdapterObjectNames = server.queryNames(
|
||||
ObjectName.getInstance(
|
||||
"org.springframework.integration.jdbc.test:name=inbound-channel-adapter.storedProcExecutor,*"),
|
||||
null);
|
||||
assertEquals(1, storedProcPollingChannelAdapterObjectNames.size());
|
||||
ObjectName storedProcPollingChannelAdapterObjectName = storedProcPollingChannelAdapterObjectNames.iterator().next();
|
||||
Map<String, Object>storedProcPollingChannelAdapterCacheStatistics = (Map<String, Object>) server.getAttribute(storedProcPollingChannelAdapterObjectName, "JdbcCallOperationsCacheStatisticsAsMap");
|
||||
ObjectName storedProcPollingChannelAdapterObjectName = storedProcPollingChannelAdapterObjectNames.iterator()
|
||||
.next();
|
||||
Map<String, Object> storedProcPollingChannelAdapterCacheStatistics = (Map<String, Object>) server
|
||||
.getAttribute(storedProcPollingChannelAdapterObjectName, "JdbcCallOperationsCacheStatisticsAsMap");
|
||||
|
||||
assertEquals(11, storedProcPollingChannelAdapterCacheStatistics.size());
|
||||
|
||||
@@ -188,7 +193,8 @@ public class StoredProcJmxManagedBeanTests {
|
||||
|
||||
static class Consumer {
|
||||
|
||||
private final BlockingQueue<Message<Collection<User>>> messages = new LinkedBlockingQueue<Message<Collection<User>>>();
|
||||
private final BlockingQueue<Message<Collection<User>>> messages =
|
||||
new LinkedBlockingQueue<Message<Collection<User>>>();
|
||||
|
||||
@ServiceActivator
|
||||
public void receive(Message<Collection<User>> message) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -189,7 +189,7 @@ public class StoredProcMessageHandlerDerbyIntegrationTests {
|
||||
final List<ProcedureParameter> procedureParameters = new ArrayList<ProcedureParameter>();
|
||||
procedureParameters.add(new ProcedureParameter("USERNAME", null, "headers[business_id] + '_' + payload.username"));
|
||||
procedureParameters.add(new ProcedureParameter("password", "static_password", null));
|
||||
procedureParameters.add(new ProcedureParameter("email", "static_email" , null));
|
||||
procedureParameters.add(new ProcedureParameter("email", "static_email", null));
|
||||
|
||||
storedProcExecutor.setProcedureParameters(procedureParameters);
|
||||
storedProcExecutor.setBeanFactory(mock(BeanFactory.class));
|
||||
|
||||
@@ -39,62 +39,61 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext // close at the end after class
|
||||
public class StoredProcPollingChannelAdapterWithNamespace2IntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private AbstractApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
private Consumer consumer;
|
||||
@Autowired
|
||||
private AbstractApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
private Consumer consumer;
|
||||
|
||||
@Test
|
||||
public void pollH2DatabaseUsingStoredProcedureCall() throws Exception {
|
||||
List<Message<List<Integer>>> received = new ArrayList<Message<List<Integer>>>();
|
||||
public void pollH2DatabaseUsingStoredProcedureCall() throws Exception {
|
||||
List<Message<List<Integer>>> received = new ArrayList<Message<List<Integer>>>();
|
||||
|
||||
received.add(consumer.poll(60000));
|
||||
received.add(consumer.poll(60000));
|
||||
|
||||
Message<List<Integer>> message = received.get(0);
|
||||
context.stop();
|
||||
assertNotNull(message);
|
||||
assertNotNull(message.getPayload());
|
||||
assertTrue(message.getPayload() instanceof List<?>);
|
||||
Message<List<Integer>> message = received.get(0);
|
||||
context.stop();
|
||||
assertNotNull(message);
|
||||
assertNotNull(message.getPayload());
|
||||
assertTrue(message.getPayload() instanceof List<?>);
|
||||
|
||||
List<Integer> resultList = message.getPayload();
|
||||
List<Integer> resultList = message.getPayload();
|
||||
|
||||
assertTrue(resultList.size() == 1);
|
||||
assertTrue(resultList.size() == 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static class Counter {
|
||||
static class Counter {
|
||||
|
||||
private final AtomicInteger count = new AtomicInteger();
|
||||
private final AtomicInteger count = new AtomicInteger();
|
||||
|
||||
public Integer next() throws InterruptedException {
|
||||
if (count.get() > 2) {
|
||||
//prevent message overload
|
||||
return null;
|
||||
}
|
||||
return Integer.valueOf(count.incrementAndGet());
|
||||
}
|
||||
}
|
||||
public Integer next() throws InterruptedException {
|
||||
if (count.get() > 2) {
|
||||
// prevent message overload
|
||||
return null;
|
||||
}
|
||||
return Integer.valueOf(count.incrementAndGet());
|
||||
}
|
||||
}
|
||||
|
||||
static class Consumer {
|
||||
|
||||
static class Consumer {
|
||||
private final BlockingQueue<Message<List<Integer>>> messages = new LinkedBlockingQueue<Message<List<Integer>>>();
|
||||
|
||||
private final BlockingQueue<Message<List<Integer>>> messages = new LinkedBlockingQueue<Message<List<Integer>>>();
|
||||
@ServiceActivator
|
||||
public void receive(Message<List<Integer>> message) {
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
@ServiceActivator
|
||||
public void receive(Message<List<Integer>>message) {
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
Message<List<Integer>> poll(long timeoutInMillis) throws InterruptedException {
|
||||
return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
Message<List<Integer>> poll(long timeoutInMillis) throws InterruptedException {
|
||||
return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,56 +48,55 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@DirtiesContext // close at the end after class
|
||||
public class StoredProcPollingChannelAdapterWithNamespaceIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private AbstractApplicationContext context;
|
||||
@Autowired
|
||||
private AbstractApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
private Consumer consumer;
|
||||
@Autowired
|
||||
private Consumer consumer;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void pollH2DatabaseUsingStoredProcedureCall() throws Exception {
|
||||
List<Message<?>> received = new ArrayList<Message<?>>();
|
||||
public void pollH2DatabaseUsingStoredProcedureCall() throws Exception {
|
||||
List<Message<?>> received = new ArrayList<Message<?>>();
|
||||
|
||||
received.add(consumer.poll(60000));
|
||||
received.add(consumer.poll(60000));
|
||||
|
||||
Message<?> message = received.get(0);
|
||||
context.stop();
|
||||
assertNotNull(message);
|
||||
assertNotNull(message.getPayload());
|
||||
assertNotNull(message.getPayload() instanceof Collection<?>);
|
||||
Message<?> message = received.get(0);
|
||||
context.stop();
|
||||
assertNotNull(message);
|
||||
assertNotNull(message.getPayload());
|
||||
assertNotNull(message.getPayload() instanceof Collection<?>);
|
||||
|
||||
List<Integer> primeNumbers = (List<Integer>) message.getPayload();
|
||||
List<Integer> primeNumbers = (List<Integer>) message.getPayload();
|
||||
|
||||
assertThat(primeNumbers, contains(2, 3, 5, 7));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static class Counter {
|
||||
static class Counter {
|
||||
|
||||
private final AtomicInteger count = new AtomicInteger();
|
||||
private final AtomicInteger count = new AtomicInteger();
|
||||
|
||||
public Integer next() throws InterruptedException {
|
||||
if (count.get() > 2) {
|
||||
//prevent message overload
|
||||
return null;
|
||||
}
|
||||
return Integer.valueOf(count.incrementAndGet());
|
||||
}
|
||||
}
|
||||
public Integer next() throws InterruptedException {
|
||||
if (count.get() > 2) {
|
||||
// prevent message overload
|
||||
return null;
|
||||
}
|
||||
return Integer.valueOf(count.incrementAndGet());
|
||||
}
|
||||
}
|
||||
|
||||
static class Consumer {
|
||||
|
||||
static class Consumer {
|
||||
private final BlockingQueue<Message<?>> messages = new LinkedBlockingQueue<Message<?>>();
|
||||
|
||||
private final BlockingQueue<Message<?>> messages = new LinkedBlockingQueue<Message<?>>();
|
||||
@ServiceActivator
|
||||
public void receive(Message<?> message) {
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
@ServiceActivator
|
||||
public void receive(Message<?>message) {
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
Message<?> poll(long timeoutInMillis) throws InterruptedException {
|
||||
return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
Message<?> poll(long timeoutInMillis) throws InterruptedException {
|
||||
return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,55 +46,54 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@DirtiesContext // close at the end after class
|
||||
public class StoredProcPollingChannelAdapterWithSpringContextIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private AbstractApplicationContext context;
|
||||
@Autowired
|
||||
private AbstractApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
private Consumer consumer;
|
||||
@Autowired
|
||||
private Consumer consumer;
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
List<Message<Collection<Integer>>> received = new ArrayList<Message<Collection<Integer>>>();
|
||||
public void test() throws Exception {
|
||||
List<Message<Collection<Integer>>> received = new ArrayList<Message<Collection<Integer>>>();
|
||||
|
||||
received.add(consumer.poll(2000));
|
||||
received.add(consumer.poll(2000));
|
||||
|
||||
Message<Collection<Integer>> message = received.get(0);
|
||||
context.stop();
|
||||
assertNotNull(message);
|
||||
assertNotNull(message.getPayload());
|
||||
assertNotNull(message.getPayload() instanceof Collection<?>);
|
||||
Message<Collection<Integer>> message = received.get(0);
|
||||
context.stop();
|
||||
assertNotNull(message);
|
||||
assertNotNull(message.getPayload());
|
||||
assertNotNull(message.getPayload() instanceof Collection<?>);
|
||||
|
||||
Collection<Integer> primeNumbers = message.getPayload();
|
||||
Collection<Integer> primeNumbers = message.getPayload();
|
||||
|
||||
assertTrue(primeNumbers.size() == 4);
|
||||
assertTrue(primeNumbers.size() == 4);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static class Counter {
|
||||
static class Counter {
|
||||
|
||||
private final AtomicInteger count = new AtomicInteger();
|
||||
private final AtomicInteger count = new AtomicInteger();
|
||||
|
||||
public Integer next() throws InterruptedException {
|
||||
if (count.get() > 2) {
|
||||
//prevent message overload
|
||||
return null;
|
||||
}
|
||||
return Integer.valueOf(count.incrementAndGet());
|
||||
}
|
||||
}
|
||||
public Integer next() throws InterruptedException {
|
||||
if (count.get() > 2) {
|
||||
// prevent message overload
|
||||
return null;
|
||||
}
|
||||
return Integer.valueOf(count.incrementAndGet());
|
||||
}
|
||||
}
|
||||
|
||||
static class Consumer {
|
||||
|
||||
static class Consumer {
|
||||
private final BlockingQueue<Message<Collection<Integer>>> messages = new LinkedBlockingQueue<Message<Collection<Integer>>>();
|
||||
|
||||
private final BlockingQueue<Message<Collection<Integer>>> messages = new LinkedBlockingQueue<Message<Collection<Integer>>>();
|
||||
@ServiceActivator
|
||||
public void receive(Message<Collection<Integer>> message) {
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
@ServiceActivator
|
||||
public void receive(Message<Collection<Integer>>message) {
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
Message<Collection<Integer>> poll(long timeoutInMillis) throws InterruptedException {
|
||||
return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
Message<Collection<Integer>> poll(long timeoutInMillis) throws InterruptedException {
|
||||
return messages.poll(timeoutInMillis, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,12 +133,12 @@ public class JdbcPollingChannelAdapterParserTests {
|
||||
this.jdbcTemplate.update("insert into item values(1,'',42)");
|
||||
Message<?> message = messagingTemplate.receive();
|
||||
assertNotNull(message);
|
||||
assertEquals(42, ((Map<?, ?>) ((List<?> ) message.getPayload()).get(0)).get("STATUS"));
|
||||
assertEquals(42, ((Map<?, ?>) ((List<?>) message.getPayload()).get(0)).get("STATUS"));
|
||||
this.jdbcTemplate.update("insert into item values(2,'',84)");
|
||||
this.appCtx.getBean(Status.class).which = 84;
|
||||
message = messagingTemplate.receive();
|
||||
assertNotNull(message);
|
||||
assertEquals(84, ((Map<?, ?>) ((List<?> ) message.getPayload()).get(0)).get("STATUS"));
|
||||
assertEquals(84, ((Map<?, ?>) ((List<?>) message.getPayload()).get(0)).get("STATUS"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,30 +16,31 @@
|
||||
|
||||
package org.springframework.integration.jdbc.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.jdbc.storedproc.ProcedureParameter;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.jdbc.core.SqlInOutParameter;
|
||||
import org.springframework.jdbc.core.SqlOutParameter;
|
||||
import org.springframework.jdbc.core.SqlParameter;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
/**
|
||||
* @author Gunnar Hillert
|
||||
@@ -86,7 +87,7 @@ public class StoredProcMessageHandlerParserTests {
|
||||
assertNotNull(procedureParameters);
|
||||
assertTrue(procedureParameters instanceof List);
|
||||
|
||||
List<ProcedureParameter>procedureParametersAsList = (List<ProcedureParameter>) procedureParameters;
|
||||
List<ProcedureParameter> procedureParametersAsList = (List<ProcedureParameter>) procedureParameters;
|
||||
|
||||
assertTrue(procedureParametersAsList.size() == 4);
|
||||
|
||||
@@ -129,7 +130,7 @@ public class StoredProcMessageHandlerParserTests {
|
||||
assertNotNull(sqlParameters);
|
||||
assertTrue(sqlParameters instanceof List);
|
||||
|
||||
List<SqlParameter>sqlParametersAsList = (List<SqlParameter>) sqlParameters;
|
||||
List<SqlParameter> sqlParametersAsList = (List<SqlParameter>) sqlParameters;
|
||||
|
||||
assertTrue(sqlParametersAsList.size() == 4);
|
||||
|
||||
|
||||
@@ -29,15 +29,16 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.jdbc.storedproc.PrimeMapper;
|
||||
import org.springframework.integration.jdbc.storedproc.ProcedureParameter;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.SqlInOutParameter;
|
||||
@@ -45,7 +46,7 @@ import org.springframework.jdbc.core.SqlOutParameter;
|
||||
import org.springframework.jdbc.core.SqlParameter;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
/**
|
||||
* @author Gunnar Hillert
|
||||
@@ -182,7 +183,7 @@ public class StoredProcOutboundGatewayParserTests {
|
||||
assertNotNull(procedureParameters);
|
||||
assertTrue(procedureParameters instanceof List);
|
||||
|
||||
List<ProcedureParameter>procedureParametersAsList = (List<ProcedureParameter>) procedureParameters;
|
||||
List<ProcedureParameter> procedureParametersAsList = (List<ProcedureParameter>) procedureParameters;
|
||||
|
||||
assertTrue(procedureParametersAsList.size() == 4);
|
||||
|
||||
@@ -248,7 +249,7 @@ public class StoredProcOutboundGatewayParserTests {
|
||||
assertNotNull(sqlParameters);
|
||||
assertTrue(sqlParameters instanceof List);
|
||||
|
||||
List<SqlParameter>sqlParametersAsList = (List<SqlParameter>) sqlParameters;
|
||||
List<SqlParameter> sqlParametersAsList = (List<SqlParameter>) sqlParameters;
|
||||
|
||||
assertTrue(sqlParametersAsList.size() == 4);
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ public class MySqlJdbcMessageStoreMultipleChannelTests {
|
||||
super();
|
||||
}
|
||||
|
||||
public void first(Message<?> message ) {
|
||||
public void first(Message<?> message) {
|
||||
|
||||
int sequenceNumber = new IntegrationMessageHeaderAccessor(message).getSequenceNumber();
|
||||
|
||||
@@ -161,7 +161,7 @@ public class MySqlJdbcMessageStoreMultipleChannelTests {
|
||||
countDownLatch1.countDown();
|
||||
}
|
||||
|
||||
public void second(Message<?> message ) {
|
||||
public void second(Message<?> message) {
|
||||
|
||||
int sequenceNumber = new IntegrationMessageHeaderAccessor(message).getSequenceNumber();
|
||||
LOG.info("Second handling sequence number: " + sequenceNumber + "; Message ID: " + message.getHeaders().getId());
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class DerbyFunctions {
|
||||
super();
|
||||
}
|
||||
|
||||
public static String convertStringToUpperCase( String invalue ) {
|
||||
public static String convertStringToUpperCase(String invalue) {
|
||||
return invalue.toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public final class DerbyStoredProcedures {
|
||||
Connection conn = DriverManager.getConnection("jdbc:default:connection");
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement("select MESSAGE_JSON from JSON_MESSAGE where MESSAGE_ID = ?");
|
||||
stmt.setString( 1, messageId);
|
||||
stmt.setString(1, messageId);
|
||||
ResultSet results = stmt.executeQuery();
|
||||
if (results.next()) {
|
||||
returnedData[0] = results.getClob(1);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class SubscribableJmsChannelTests {
|
||||
@Test
|
||||
public void queueReference() throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch(2);
|
||||
final List<Message<?>> receivedList1 = Collections.synchronizedList( new ArrayList<Message<?>>());
|
||||
final List<Message<?>> receivedList1 = Collections.synchronizedList(new ArrayList<Message<?>>());
|
||||
MessageHandler handler1 = new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) {
|
||||
@@ -107,7 +107,7 @@ public class SubscribableJmsChannelTests {
|
||||
latch.countDown();
|
||||
}
|
||||
};
|
||||
final List<Message<?>> receivedList2 = Collections.synchronizedList( new ArrayList<Message<?>>());
|
||||
final List<Message<?>> receivedList2 = Collections.synchronizedList(new ArrayList<Message<?>>());
|
||||
MessageHandler handler2 = new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) {
|
||||
@@ -140,7 +140,7 @@ public class SubscribableJmsChannelTests {
|
||||
@Test
|
||||
public void topicReference() throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch(4);
|
||||
final List<Message<?>> receivedList1 = Collections.synchronizedList( new ArrayList<Message<?>>());
|
||||
final List<Message<?>> receivedList1 = Collections.synchronizedList(new ArrayList<Message<?>>());
|
||||
MessageHandler handler1 = new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) {
|
||||
@@ -148,7 +148,7 @@ public class SubscribableJmsChannelTests {
|
||||
latch.countDown();
|
||||
}
|
||||
};
|
||||
final List<Message<?>> receivedList2 = Collections.synchronizedList( new ArrayList<Message<?>>());
|
||||
final List<Message<?>> receivedList2 = Collections.synchronizedList(new ArrayList<Message<?>>());
|
||||
MessageHandler handler2 = new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) {
|
||||
@@ -184,7 +184,7 @@ public class SubscribableJmsChannelTests {
|
||||
@Test
|
||||
public void queueName() throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch(2);
|
||||
final List<Message<?>> receivedList1 = Collections.synchronizedList( new ArrayList<Message<?>>());
|
||||
final List<Message<?>> receivedList1 = Collections.synchronizedList(new ArrayList<Message<?>>());
|
||||
MessageHandler handler1 = new MessageHandler() {
|
||||
|
||||
@Override
|
||||
@@ -193,7 +193,7 @@ public class SubscribableJmsChannelTests {
|
||||
latch.countDown();
|
||||
}
|
||||
};
|
||||
final List<Message<?>> receivedList2 = Collections.synchronizedList( new ArrayList<Message<?>>());
|
||||
final List<Message<?>> receivedList2 = Collections.synchronizedList(new ArrayList<Message<?>>());
|
||||
MessageHandler handler2 = new MessageHandler() {
|
||||
|
||||
@Override
|
||||
@@ -232,7 +232,7 @@ public class SubscribableJmsChannelTests {
|
||||
@Test
|
||||
public void topicName() throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch(4);
|
||||
final List<Message<?>> receivedList1 = Collections.synchronizedList( new ArrayList<Message<?>>());
|
||||
final List<Message<?>> receivedList1 = Collections.synchronizedList(new ArrayList<Message<?>>());
|
||||
MessageHandler handler1 = new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) {
|
||||
@@ -240,7 +240,7 @@ public class SubscribableJmsChannelTests {
|
||||
latch.countDown();
|
||||
}
|
||||
};
|
||||
final List<Message<?>> receivedList2 = Collections.synchronizedList( new ArrayList<Message<?>>());
|
||||
final List<Message<?>> receivedList2 = Collections.synchronizedList(new ArrayList<Message<?>>());
|
||||
MessageHandler handler2 = new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) {
|
||||
|
||||
@@ -133,8 +133,8 @@ public class OperationInvokingMessageHandler extends AbstractReplyProducingMessa
|
||||
}
|
||||
if (paramInfoArray.length == paramsFromMessage.size()) {
|
||||
int index = 0;
|
||||
Object values[] = new Object[paramInfoArray.length];
|
||||
String signature[] = new String[paramInfoArray.length];
|
||||
Object[] values = new Object[paramInfoArray.length];
|
||||
String[] signature = new String[paramInfoArray.length];
|
||||
for (MBeanParameterInfo paramInfo : paramInfoArray) {
|
||||
Object value = paramsFromMessage.get(paramInfo.getName());
|
||||
if (value == null) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.Attribute;
|
||||
import javax.management.MBeanException;
|
||||
import javax.management.MBeanServer;
|
||||
@@ -123,8 +124,11 @@ public class NotificationPublishingChannelAdapterParserTests {
|
||||
|
||||
@Test //INT-2275
|
||||
public void publishStringMessageWithinChain() throws Exception {
|
||||
assertNotNull(this.beanFactory.getBean("chainWithJmxNotificationPublishing$child.jmx-notification-publishing-channel-adapter-within-chain.handler",
|
||||
MessageHandler.class));
|
||||
assertNotNull(
|
||||
this.beanFactory.getBean(
|
||||
"chainWithJmxNotificationPublishing$child."
|
||||
+ "jmx-notification-publishing-channel-adapter-within-chain.handler",
|
||||
MessageHandler.class));
|
||||
assertNull(listener.lastNotification);
|
||||
Message<?> message = MessageBuilder.withPayload("XYZ")
|
||||
.setHeader(JmxHeaders.NOTIFICATION_TYPE, "test.type").build();
|
||||
@@ -134,10 +138,9 @@ public class NotificationPublishingChannelAdapterParserTests {
|
||||
assertEquals("XYZ", notification.getMessage());
|
||||
assertEquals("test.type", notification.getType());
|
||||
assertNull(notification.getUserData());
|
||||
Set<ObjectName> names = server.queryNames(
|
||||
new ObjectName("*:type=MessageHandler," +
|
||||
"name=chainWithJmxNotificationPublishing$child.jmx-notification-publishing-channel-adapter-within-chain,*")
|
||||
, null);
|
||||
Set<ObjectName> names = server
|
||||
.queryNames(new ObjectName("*:type=MessageHandler," + "name=chainWithJmxNotificationPublishing$child."
|
||||
+ "jmx-notification-publishing-channel-adapter-within-chain,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -192,7 +192,7 @@ public class IdempotentReceiverIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public HazelcastInstance hazelcastInstance() {
|
||||
return Hazelcast.newHazelcastInstance(new Config().setProperty( "hazelcast.logging.type", "log4j" ));
|
||||
return Hazelcast.newHazelcastInstance(new Config().setProperty("hazelcast.logging.type", "log4j"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.jpa.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Query;
|
||||
@@ -616,13 +617,13 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the max number of results to retrieve from the database. Defaults to
|
||||
* 0, which means that all possible objects shall be retrieved.
|
||||
* @param maxNumberOfResults Must not be negative.
|
||||
* @see Query#setMaxResults(int)
|
||||
*/
|
||||
public void setMaxNumberOfResults(int maxNumberOfResults) {
|
||||
* Set the max number of results to retrieve from the database. Defaults to
|
||||
* 0, which means that all possible objects shall be retrieved.
|
||||
* @param maxNumberOfResults Must not be negative.
|
||||
* @see Query#setMaxResults(int)
|
||||
*/
|
||||
public void setMaxNumberOfResults(int maxNumberOfResults) {
|
||||
this.setMaxResultsExpression(new LiteralExpression("" + maxNumberOfResults));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class AbstractJpaOperationsTests {
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
Assert.assertTrue( 1 == updatedRecords);
|
||||
Assert.assertTrue(1 == updatedRecords);
|
||||
Assert.assertNull(student.getRollNumber());
|
||||
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class AbstractJpaOperationsTests {
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
Assert.assertTrue( 1 == updatedRecords);
|
||||
Assert.assertTrue(1 == updatedRecords);
|
||||
Assert.assertNull(student.getRollNumber());
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class AbstractJpaOperationsTests {
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
Assert.assertTrue( 1 == updatedRecords);
|
||||
Assert.assertTrue(1 == updatedRecords);
|
||||
Assert.assertNull(student.getRollNumber());
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public class AbstractJpaOperationsTests {
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
Assert.assertTrue( 1 == updatedRecords);
|
||||
Assert.assertTrue(1 == updatedRecords);
|
||||
Assert.assertNull(student.getRollNumber());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
@@ -37,7 +38,7 @@ public final class Consumer {
|
||||
|
||||
private static final BlockingQueue<Message<Collection<?>>> MESSAGES = new LinkedBlockingQueue<Message<Collection<?>>>();
|
||||
|
||||
public synchronized void receive(Message<Collection<?>>message) {
|
||||
public synchronized void receive(Message<Collection<?>> message) {
|
||||
logger.info("Service Activator received Message: " + message);
|
||||
MESSAGES.add(message);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
|
||||
@Override // guarded by super#lifecycleLock
|
||||
protected void doStart() {
|
||||
final TaskScheduler scheduler = this.getTaskScheduler();
|
||||
Assert.notNull(scheduler, "'taskScheduler' must not be null" );
|
||||
Assert.notNull(scheduler, "'taskScheduler' must not be null");
|
||||
if (this.sendingTaskExecutor == null) {
|
||||
this.sendingTaskExecutor = Executors.newFixedThreadPool(1);
|
||||
}
|
||||
@@ -254,7 +254,7 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
|
||||
@Override
|
||||
public void run() {
|
||||
final TaskScheduler scheduler = getTaskScheduler();
|
||||
Assert.notNull(scheduler, "'taskScheduler' must not be null" );
|
||||
Assert.notNull(scheduler, "'taskScheduler' must not be null");
|
||||
/*
|
||||
* The following shouldn't be necessary because doStart() will have ensured we have
|
||||
* one. But, just in case...
|
||||
|
||||
@@ -852,7 +852,7 @@ public class ImapMailReceiverTests {
|
||||
receiver.setBeanFactory(mock(BeanFactory.class));
|
||||
receiver.afterPropertiesSet();
|
||||
|
||||
doAnswer(new Answer<Object> () {
|
||||
doAnswer(new Answer<Object>() {
|
||||
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class MongoDbMessageGroupStoreTests extends AbstractMongoDbMessageGroupSt
|
||||
|
||||
@Override
|
||||
protected MongoDbMessageStore getMessageGroupStore() throws Exception {
|
||||
MongoDbMessageStore mongoDbMessageStore = new MongoDbMessageStore( new SimpleMongoDbFactory(new MongoClient(), "test"));
|
||||
MongoDbMessageStore mongoDbMessageStore = new MongoDbMessageStore(new SimpleMongoDbFactory(new MongoClient(), "test"));
|
||||
mongoDbMessageStore.afterPropertiesSet();
|
||||
return mongoDbMessageStore;
|
||||
}
|
||||
|
||||
@@ -234,17 +234,7 @@ public class RedisQueueInboundGateway extends MessagingGatewaySupport implements
|
||||
Message<?> replyMessage = this.sendAndReceiveMessage(requestMessage);
|
||||
if (replyMessage != null) {
|
||||
if (this.extractPayload) {
|
||||
if (!(replyMessage.getPayload() instanceof byte[])) {
|
||||
if (replyMessage.getPayload() instanceof String && !this.serializerExplicitlySet) {
|
||||
value = stringSerializer.serialize((String) replyMessage.getPayload());
|
||||
}
|
||||
else {
|
||||
value = ((RedisSerializer<Object>) this.serializer).serialize(replyMessage.getPayload());
|
||||
}
|
||||
}
|
||||
else {
|
||||
value = (byte[]) replyMessage.getPayload();
|
||||
}
|
||||
value = extractReplyPayload(replyMessage);
|
||||
}
|
||||
else {
|
||||
if (this.serializer != null) {
|
||||
@@ -257,6 +247,23 @@ public class RedisQueueInboundGateway extends MessagingGatewaySupport implements
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private byte[] extractReplyPayload(Message<?> replyMessage) {
|
||||
byte[] value;
|
||||
if (!(replyMessage.getPayload() instanceof byte[])) {
|
||||
if (replyMessage.getPayload() instanceof String && !this.serializerExplicitlySet) {
|
||||
value = stringSerializer.serialize((String) replyMessage.getPayload());
|
||||
}
|
||||
else {
|
||||
value = ((RedisSerializer<Object>) this.serializer).serialize(replyMessage.getPayload());
|
||||
}
|
||||
}
|
||||
else {
|
||||
value = (byte[]) replyMessage.getPayload();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() {
|
||||
super.doStart();
|
||||
|
||||
@@ -97,7 +97,7 @@ public class RedisInboundChannelAdapterParserTests extends RedisAvailableTests {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Message<?> receive = receiveChannel.receive(2000);
|
||||
assertNotNull(receive);
|
||||
assertThat(receive.getPayload(), Matchers.<Object> isOneOf("Hello Redis from foo", "Hello Redis from bar"));
|
||||
assertThat(receive.getPayload(), Matchers.<Object>isOneOf("Hello Redis from foo", "Hello Redis from bar"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class RedisInboundChannelAdapterTests extends RedisAvailableTests {
|
||||
@Test
|
||||
@RedisAvailable
|
||||
public void testRedisInboundChannelAdapter() throws Exception {
|
||||
for (int iteration = 0; iteration < 10; iteration ++) {
|
||||
for (int iteration = 0; iteration < 10; iteration++) {
|
||||
testRedisInboundChannelAdapterGuts(iteration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class RedisOutboundGatewayTests extends RedisAvailableTests {
|
||||
@Test
|
||||
@RedisAvailable
|
||||
public void testGetCommand() {
|
||||
this.setDelCommandChannel.send(MessageBuilder.withPayload(new String[]{"foo", "bar"})
|
||||
this.setDelCommandChannel.send(MessageBuilder.withPayload(new String[] { "foo", "bar" })
|
||||
.setHeader(RedisHeaders.COMMAND, "SET").build());
|
||||
Message<?> receive = this.replyChannel.receive(1000);
|
||||
assertNotNull(receive);
|
||||
@@ -161,7 +161,7 @@ public class RedisOutboundGatewayTests extends RedisAvailableTests {
|
||||
byte[] value2 = "bar2".getBytes();
|
||||
connection.set("foo1".getBytes(), value1);
|
||||
connection.set("foo2".getBytes(), value2);
|
||||
this.mgetCommandChannel.send(MessageBuilder.withPayload(new String [] {"foo1", "foo2"}).build());
|
||||
this.mgetCommandChannel.send(MessageBuilder.withPayload(new String[] { "foo1", "foo2" }).build());
|
||||
Message<?> receive = this.replyChannel.receive(1000);
|
||||
assertNotNull(receive);
|
||||
assertThat((List<byte[]>) receive.getPayload(), Matchers.contains(value1, value2));
|
||||
|
||||
@@ -22,18 +22,21 @@ import javax.script.ScriptEngine;
|
||||
import org.springframework.integration.scripting.ScriptExecutor;
|
||||
|
||||
/**
|
||||
* A {@link ScriptExecutor} that implements special handling required for Python to emulate behavior similar to other JSR223 scripting languages.
|
||||
* A {@link ScriptExecutor} that implements special handling required for Python to
|
||||
* emulate behavior similar to other JSR223 scripting languages.
|
||||
* <p>
|
||||
* Script evaluation using the Jython implementation results in a <code>null</code> return value for normal variable expressions such as
|
||||
* <code>x=2</code>. As a work around, it is necessary to get the value of 'x' explicitly following the script evaluation. This class performs
|
||||
* simple parsing on the last line of the script to obtain the variable name, if any, and return its value.
|
||||
* Script evaluation using the Jython implementation results in a <code>null</code> return
|
||||
* value for normal variable expressions such as <code>x=2</code>. As a work around, it is
|
||||
* necessary to get the value of 'x' explicitly following the script evaluation. This
|
||||
* class performs simple parsing on the last line of the script to obtain the variable
|
||||
* name, if any, and return its value.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author Gary Russell
|
||||
* @since 2.1
|
||||
*
|
||||
*/
|
||||
public class PythonScriptExecutor extends AbstractScriptExecutor {
|
||||
public class PythonScriptExecutor extends AbstractScriptExecutor {
|
||||
|
||||
public PythonScriptExecutor() {
|
||||
super("python");
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @since 2.1
|
||||
*
|
||||
*/
|
||||
public class RubyScriptExecutor extends DefaultScriptExecutor {
|
||||
public class RubyScriptExecutor extends DefaultScriptExecutor {
|
||||
|
||||
static {
|
||||
if (ClassUtils.isPresent("org.jruby.embed.jsr223.JRubyEngine", System.class.getClassLoader())) {
|
||||
|
||||
@@ -43,8 +43,8 @@ public class DeriveLanguageFromExtensionTests {
|
||||
|
||||
@Test
|
||||
public void testParseLanguage() {
|
||||
String langs[] = { "ruby", "Groovy", "ECMAScript", "python" };
|
||||
Class<?> executors[] = {
|
||||
String[] langs = { "ruby", "Groovy", "ECMAScript", "python" };
|
||||
Class<?>[] executors = {
|
||||
RubyScriptExecutor.class,
|
||||
DefaultScriptExecutor.class,
|
||||
DefaultScriptExecutor.class,
|
||||
@@ -71,7 +71,8 @@ public class DeriveLanguageFromExtensionTests {
|
||||
@Test
|
||||
public void testBadExtension() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail1-context.xml", this.getClass());
|
||||
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail1-context.xml", this.getClass())
|
||||
.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("No suitable scripting engine found for extension 'xx'"));
|
||||
@@ -81,7 +82,8 @@ public class DeriveLanguageFromExtensionTests {
|
||||
@Test
|
||||
public void testNoExtension() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail2-context.xml", this.getClass());
|
||||
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail2-context.xml", this.getClass())
|
||||
.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unable to determine language for script 'foo'"));
|
||||
|
||||
@@ -46,23 +46,23 @@ public class PythonScriptExecutorTests {
|
||||
|
||||
@Test
|
||||
public void testLiteral() {
|
||||
Object obj = executor.executeScript(new StaticScriptSource("3+4") );
|
||||
Object obj = executor.executeScript(new StaticScriptSource("3+4"));
|
||||
assertEquals(7, obj);
|
||||
|
||||
obj = executor.executeScript(new StaticScriptSource("'hello,world'") );
|
||||
obj = executor.executeScript(new StaticScriptSource("'hello,world'"));
|
||||
assertEquals("hello,world", obj);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
public void test1() {
|
||||
Object obj = executor.executeScript(new StaticScriptSource("x=2") );
|
||||
Object obj = executor.executeScript(new StaticScriptSource("x=2"));
|
||||
assertEquals(2, obj);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() {
|
||||
Object obj = executor.executeScript(new StaticScriptSource("def foo(y):\n\tx=y\n\treturn y\nz=foo(2)") );
|
||||
Object obj = executor.executeScript(new StaticScriptSource("def foo(y):\n\tx=y\n\treturn y\nz=foo(2)"));
|
||||
assertEquals(2, obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public class StompMessageHandler extends AbstractMessageHandler implements Appli
|
||||
connectIfNecessary();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MessageDeliveryException(message, "The [" + this + "] could not deliver message." , e);
|
||||
throw new MessageDeliveryException(message, "The [" + this + "] could not deliver message.", e);
|
||||
}
|
||||
StompSession stompSession = this.stompSession;
|
||||
|
||||
|
||||
@@ -47,28 +47,28 @@ public final class SyslogHeaders {
|
||||
|
||||
public static final String MESSAGE = PREFIX + "MESSAGE";
|
||||
|
||||
public static final String APP_NAME = PREFIX + "APP_NAME" ;
|
||||
public static final String APP_NAME = PREFIX + "APP_NAME";
|
||||
|
||||
public static final String PROCID = PREFIX + "PROCID" ;
|
||||
public static final String PROCID = PREFIX + "PROCID";
|
||||
|
||||
public static final String MSGID = PREFIX + "MSGID" ;
|
||||
public static final String MSGID = PREFIX + "MSGID";
|
||||
|
||||
public static final String VERSION = PREFIX + "VERSION" ;
|
||||
public static final String VERSION = PREFIX + "VERSION";
|
||||
|
||||
public static final String STRUCTURED_DATA = PREFIX + "STRUCTURED_DATA" ;
|
||||
public static final String STRUCTURED_DATA = PREFIX + "STRUCTURED_DATA";
|
||||
|
||||
// Text versions of syslog numeric values
|
||||
public static final String SEVERITY_TEXT = PREFIX + "SEVERITY_TEXT" ;
|
||||
public static final String SEVERITY_TEXT = PREFIX + "SEVERITY_TEXT";
|
||||
|
||||
// Additional fields
|
||||
public static final String SOURCE_TYPE = PREFIX + "SOURCE_TYPE" ;
|
||||
public static final String SOURCE_TYPE = PREFIX + "SOURCE_TYPE";
|
||||
|
||||
public static final String SOURCE = PREFIX + "SOURCE" ;
|
||||
public static final String SOURCE = PREFIX + "SOURCE";
|
||||
|
||||
// full line when parse errors or retained original
|
||||
public static final String UNDECODED = PREFIX + "UNDECODED" ;
|
||||
public static final String UNDECODED = PREFIX + "UNDECODED";
|
||||
|
||||
public static final String DECODE_ERRORS = PREFIX + "DECODE_ERRORS" ;
|
||||
public static final String DECODE_ERRORS = PREFIX + "DECODE_ERRORS";
|
||||
|
||||
public static final String ERRORS = PREFIX + "ERRORS";
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class MapContentMatchers<T, V> extends
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
// @Override
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("an entry with key ").appendValue(key)
|
||||
.appendText(" and value matching ").appendDescriptionOf(
|
||||
|
||||
@@ -92,7 +92,7 @@ public class MockitoMessageMatchers {
|
||||
|
||||
public static <T> Message<?> messageWithHeaderEntry(String key,
|
||||
Matcher<T> valueMatcher) {
|
||||
return argThat(HeaderMatcher.<T> hasHeader(key, valueMatcher));
|
||||
return argThat(HeaderMatcher.<T>hasHeader(key, valueMatcher));
|
||||
}
|
||||
|
||||
public static Message<?> messageWithHeaderEntries(Map<String, ?> entries) {
|
||||
|
||||
@@ -33,10 +33,10 @@ import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
/**
|
||||
* Convenience class for testing Spring Integration request-response message scenarios. Users
|
||||
* create subclasses to execute on or more {@link RequestResponseScenario} tests. each scenario defines:
|
||||
* Convenience class for testing Spring Integration request-response message scenarios.
|
||||
* Users create subclasses to execute on or more {@link RequestResponseScenario} tests.
|
||||
* each scenario defines:
|
||||
* <ul>
|
||||
* <li>An inputChannelName</li>
|
||||
* <li>An outputChannelName</li>
|
||||
@@ -49,55 +49,57 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public abstract class AbstractRequestResponseScenarioTests {
|
||||
|
||||
private List<RequestResponseScenario> scenarios = null;
|
||||
private List<RequestResponseScenario> scenarios = null;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
scenarios = defineRequestResponseScenarios();
|
||||
}
|
||||
@Before
|
||||
public void setUp() {
|
||||
scenarios = defineRequestResponseScenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute each scenario. Instantiate the message channels, send the request message on the
|
||||
* input channel and invoke the validator on the response received on the output channel.
|
||||
* This can handle subscribable or pollable output channels.
|
||||
*/
|
||||
@Test
|
||||
public void testRequestResponseScenarios() {
|
||||
int i = 1;
|
||||
for (RequestResponseScenario scenario: scenarios) {
|
||||
String name = scenario.getName() == null ? "scenario-" + (i++) : scenario.getName();
|
||||
scenario.init();
|
||||
MessageChannel inputChannel = applicationContext.getBean(scenario.getInputChannelName(), MessageChannel.class);
|
||||
MessageChannel outputChannel = applicationContext.getBean(scenario.getOutputChannelName(), MessageChannel.class);
|
||||
if (outputChannel instanceof SubscribableChannel) {
|
||||
((SubscribableChannel) outputChannel).subscribe(scenario.getResponseValidator());
|
||||
}
|
||||
/**
|
||||
* Execute each scenario. Instantiate the message channels, send the request message
|
||||
* on the input channel and invoke the validator on the response received on the
|
||||
* output channel. This can handle subscribable or pollable output channels.
|
||||
*/
|
||||
@Test
|
||||
public void testRequestResponseScenarios() {
|
||||
int i = 1;
|
||||
for (RequestResponseScenario scenario : scenarios) {
|
||||
String name = scenario.getName() == null ? "scenario-" + (i++) : scenario.getName();
|
||||
scenario.init();
|
||||
MessageChannel inputChannel = applicationContext.getBean(scenario.getInputChannelName(),
|
||||
MessageChannel.class);
|
||||
MessageChannel outputChannel = applicationContext.getBean(scenario.getOutputChannelName(),
|
||||
MessageChannel.class);
|
||||
if (outputChannel instanceof SubscribableChannel) {
|
||||
((SubscribableChannel) outputChannel).subscribe(scenario.getResponseValidator());
|
||||
}
|
||||
|
||||
assertTrue(name + ": message not sent on " + scenario.getInputChannelName()
|
||||
, inputChannel.send(scenario.getMessage()));
|
||||
assertTrue(name + ": message not sent on " + scenario.getInputChannelName(),
|
||||
inputChannel.send(scenario.getMessage()));
|
||||
|
||||
if (outputChannel instanceof PollableChannel) {
|
||||
Message<?> response = ((PollableChannel) outputChannel).receive(10000);
|
||||
assertNotNull(name + ": receive timeout on " + scenario.getOutputChannelName(), response);
|
||||
scenario.getResponseValidator().handleMessage(response);
|
||||
}
|
||||
if (outputChannel instanceof PollableChannel) {
|
||||
Message<?> response = ((PollableChannel) outputChannel).receive(10000);
|
||||
assertNotNull(name + ": receive timeout on " + scenario.getOutputChannelName(), response);
|
||||
scenario.getResponseValidator().handleMessage(response);
|
||||
}
|
||||
|
||||
assertNotNull("message was not handled on " + outputChannel + " for scenario '" + name + "'.",
|
||||
assertNotNull("message was not handled on " + outputChannel + " for scenario '" + name + "'.",
|
||||
scenario.getResponseValidator().getLastMessage());
|
||||
|
||||
if (outputChannel instanceof SubscribableChannel) {
|
||||
((SubscribableChannel) outputChannel).unsubscribe(scenario.getResponseValidator());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Implement this method to define RequestResponse scenarios
|
||||
* @return - A List of {@link RequestResponseScenario}
|
||||
*/
|
||||
protected abstract List<RequestResponseScenario> defineRequestResponseScenarios();
|
||||
if (outputChannel instanceof SubscribableChannel) {
|
||||
((SubscribableChannel) outputChannel).unsubscribe(scenario.getResponseValidator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement this method to define RequestResponse scenarios
|
||||
* @return - A List of {@link RequestResponseScenario}
|
||||
*/
|
||||
protected abstract List<RequestResponseScenario> defineRequestResponseScenarios();
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class AbstractResponseValidator<T> implements MessageHandler {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
this.lastMessage = message;
|
||||
validateResponse((T) (extractPayload() ? message.getPayload() : message ));
|
||||
validateResponse((T) (extractPayload() ? message.getPayload() : message));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,9 +81,9 @@ public class StatusUpdatingMessageHandler extends AbstractMessageHandler {
|
||||
|
||||
TypeLocator typeLocator = this.evaluationContext.getTypeLocator();
|
||||
if (typeLocator instanceof StandardTypeLocator) {
|
||||
/*
|
||||
* Register the twitter api package so they don't need a FQCN for TweetData.
|
||||
*/
|
||||
/*
|
||||
* Register the twitter api package so they don't need a FQCN for TweetData.
|
||||
*/
|
||||
((StandardTypeLocator) typeLocator).registerImport("org.springframework.social.twitter.api");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class MarshallingWebServiceIntegrationTests {
|
||||
public void sendString() throws Exception {
|
||||
when(context.getResponse()).thenReturn(response);
|
||||
when(context.getRequest()).thenReturn(request);
|
||||
when(request.getPayloadSource()).thenReturn(stringSource );
|
||||
when(request.getPayloadSource()).thenReturn(stringSource);
|
||||
when(response.getPayloadResult()).thenReturn(stringResult);
|
||||
gateway.invoke(context);
|
||||
assertTrue(output.toString().endsWith(input));
|
||||
|
||||
@@ -53,7 +53,7 @@ public class StubMessageFactory implements WebServiceMessageFactory {
|
||||
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||
|
||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
InputSource is = new InputSource( new InputStreamReader(inputStream));
|
||||
InputSource is = new InputSource(new InputStreamReader(inputStream));
|
||||
Document document = builder.parse(is);
|
||||
return new DomPoxMessage(document, transformer, "text/xml");
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.mockito.Matchers;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
@@ -72,7 +72,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithReplyChannel() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithReplyChannel");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -95,11 +95,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
|
||||
Long sendTimeout = TestUtils.getPropertyValue(gateway, "messagingTemplate.sendTimeout", Long.class);
|
||||
assertEquals(Long.valueOf(777), sendTimeout);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithIgnoreEmptyResponseTrueByDefault() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithReplyChannel");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -108,11 +109,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
assertEquals(Boolean.TRUE, accessor.getPropertyValue("ignoreEmptyResponses"));
|
||||
Assert.assertEquals(Boolean.FALSE, accessor.getPropertyValue("requiresReply"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithIgnoreEmptyResponses() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithIgnoreEmptyResponsesFalseAndRequiresReplyTrue");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -121,11 +123,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
assertEquals(Boolean.FALSE, accessor.getPropertyValue("ignoreEmptyResponses"));
|
||||
Assert.assertEquals(Boolean.TRUE, accessor.getPropertyValue("requiresReply"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithDefaultSourceExtractor() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithDefaultSourceExtractor");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -133,11 +136,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
assertEquals("DefaultSourceExtractor", accessor.getPropertyValue("sourceExtractor").getClass().getSimpleName());
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithCustomSourceExtractor() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomSourceExtractor");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -146,11 +150,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
SourceExtractor<?> sourceExtractor = (SourceExtractor<?>) context.getBean("sourceExtractor");
|
||||
assertEquals(sourceExtractor, accessor.getPropertyValue("sourceExtractor"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithCustomRequestCallback() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomRequestCallback");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -159,11 +164,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback");
|
||||
assertEquals(callback, accessor.getPropertyValue("requestCallback"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithCustomMessageFactory() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomMessageFactory");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -173,11 +179,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
|
||||
WebServiceMessageFactory factory = (WebServiceMessageFactory) context.getBean("messageFactory");
|
||||
assertEquals(factory, accessor.getPropertyValue("messageFactory"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithCustomSourceExtractorAndMessageFactory() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomSourceExtractorAndMessageFactory");
|
||||
SourceExtractor<?> sourceExtractor = (SourceExtractor<?>) context.getBean("sourceExtractor");
|
||||
@@ -189,11 +196,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
|
||||
WebServiceMessageFactory factory = (WebServiceMessageFactory) context.getBean("messageFactory");
|
||||
assertEquals(factory, accessor.getPropertyValue("messageFactory"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithCustomFaultMessageResolver() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomFaultMessageResolver");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -203,12 +211,13 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
|
||||
FaultMessageResolver resolver = (FaultMessageResolver) context.getBean("faultMessageResolver");
|
||||
assertEquals(resolver, accessor.getPropertyValue("faultMessageResolver"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithCustomMessageSender() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomMessageSender");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -218,10 +227,11 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
|
||||
WebServiceMessageSender messageSender = (WebServiceMessageSender) context.getBean("messageSender");
|
||||
assertEquals(messageSender, ((WebServiceMessageSender[]) accessor.getPropertyValue("messageSenders"))[0]);
|
||||
context.close();
|
||||
}
|
||||
@Test
|
||||
public void simpleGatewayWithCustomMessageSenderList() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomMessageSenderList");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -232,12 +242,13 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
WebServiceMessageSender messageSender = (WebServiceMessageSender) context.getBean("messageSender");
|
||||
assertEquals(messageSender, ((WebServiceMessageSender[]) accessor.getPropertyValue("messageSenders"))[0]);
|
||||
assertEquals("Wrong number of message senders ",
|
||||
2 , ((WebServiceMessageSender[]) accessor.getPropertyValue("messageSenders")).length);
|
||||
2, ((WebServiceMessageSender[]) accessor.getPropertyValue("messageSenders")).length);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithCustomInterceptor() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomInterceptor");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -247,10 +258,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
|
||||
ClientInterceptor interceptor = context.getBean("interceptor", ClientInterceptor.class);
|
||||
assertEquals(interceptor, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors"))[0]);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithCustomInterceptorList() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomInterceptorList");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -261,12 +274,13 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
ClientInterceptor interceptor = context.getBean("interceptor", ClientInterceptor.class);
|
||||
assertEquals(interceptor, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors"))[0]);
|
||||
assertEquals("Wrong number of interceptors ",
|
||||
2 , ((ClientInterceptor[]) accessor.getPropertyValue("interceptors")).length);
|
||||
2, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors")).length);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithPoller() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithPoller");
|
||||
assertEquals(PollingConsumer.class, endpoint.getClass());
|
||||
@@ -276,20 +290,22 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(trigger);
|
||||
assertEquals("PeriodicTrigger had wrong period",
|
||||
5000, ((Long) accessor.getPropertyValue("period")).longValue());
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithOrder() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithOrderAndAutoStartupFalse");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(99, new DirectFieldAccessor(gateway).getPropertyValue("order"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithStartupFalse() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithOrderAndAutoStartupFalse");
|
||||
assertEquals(Boolean.FALSE, new DirectFieldAccessor(endpoint).getPropertyValue("autoStartup"));
|
||||
@@ -297,7 +313,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
|
||||
@Test
|
||||
public void marshallingGatewayWithAllInOneMarshaller() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithAllInOneMarshaller");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -305,11 +321,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
Marshaller marshaller = (Marshaller) context.getBean("marshallerAndUnmarshaller");
|
||||
assertEquals(marshaller, TestUtils.getPropertyValue(gateway, "marshaller", Marshaller.class));
|
||||
assertEquals(marshaller, TestUtils.getPropertyValue(gateway, "unmarshaller", Unmarshaller.class));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void marshallingGatewayWithSeparateMarshallerAndUnmarshaller() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithSeparateMarshallerAndUnmarshaller");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -318,11 +335,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
Unmarshaller unmarshaller = (Unmarshaller) context.getBean("unmarshaller");
|
||||
assertEquals(marshaller, TestUtils.getPropertyValue(gateway, "marshaller", Marshaller.class));
|
||||
assertEquals(unmarshaller, TestUtils.getPropertyValue(gateway, "unmarshaller", Unmarshaller.class));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void marshallingGatewayWithCustomRequestCallback() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomRequestCallback");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -331,11 +349,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback");
|
||||
assertEquals(callback, accessor.getPropertyValue("requestCallback"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void marshallingGatewayWithAllInOneMarshallerAndMessageFactory() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithAllInOneMarshallerAndMessageFactory");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -346,11 +365,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
|
||||
WebServiceMessageFactory messageFactory = (WebServiceMessageFactory) context.getBean("messageFactory");
|
||||
assertEquals(messageFactory, TestUtils.getPropertyValue(gateway, "webServiceTemplate.messageFactory"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void marshallingGatewayWithSeparateMarshallerAndUnmarshallerAndMessageFactory() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithSeparateMarshallerAndUnmarshallerAndMessageFactory");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -362,11 +382,12 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
assertEquals(unmarshaller, TestUtils.getPropertyValue(gateway, "unmarshaller", Unmarshaller.class));
|
||||
WebServiceMessageFactory messageFactory = (WebServiceMessageFactory) context.getBean("messageFactory");
|
||||
assertEquals(messageFactory, TestUtils.getPropertyValue(gateway, "webServiceTemplate.messageFactory"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGatewayWithDestinationProvider() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithDestinationProvider");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -379,34 +400,37 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
Object destinationProviderObject = new DirectFieldAccessor(
|
||||
accessor.getPropertyValue("webServiceTemplate")).getPropertyValue("destinationProvider");
|
||||
assertEquals("Wrong DestinationProvider", stubProvider, destinationProviderObject);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void advised() {
|
||||
adviceCalled = 0;
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithAdvice");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class);
|
||||
handler.handleMessage(new GenericMessage<String>("foo"));
|
||||
assertEquals(1, adviceCalled);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInt2718AdvisedInsideAChain() {
|
||||
adviceCalled = 0;
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageChannel channel = context.getBean("gatewayWithAdviceInsideAChain", MessageChannel.class);
|
||||
channel.send(new GenericMessage<String>("foo"));
|
||||
assertEquals(1, adviceCalled);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void jmsUri() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithJmsUri");
|
||||
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
|
||||
@@ -429,19 +453,22 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
verify(webServiceTemplate).sendAndReceive(eq("jms:wsQueue"),
|
||||
any(WebServiceMessageCallback.class),
|
||||
Matchers.<WebServiceMessageExtractor<Object>>any());
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
public void invalidGatewayWithBothUriAndDestinationProvider() {
|
||||
new ClassPathXmlApplicationContext("invalidGatewayWithBothUriAndDestinationProvider.xml", this.getClass());
|
||||
}
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
public void invalidGatewayWithBothUriAndDestinationProvider() {
|
||||
new ClassPathXmlApplicationContext("invalidGatewayWithBothUriAndDestinationProvider.xml", this.getClass())
|
||||
.close();
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
public void invalidGatewayWithNeitherUriNorDestinationProvider() {
|
||||
new ClassPathXmlApplicationContext("invalidGatewayWithNeitherUriNorDestinationProvider.xml", this.getClass());
|
||||
}
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
public void invalidGatewayWithNeitherUriNorDestinationProvider() {
|
||||
new ClassPathXmlApplicationContext("invalidGatewayWithNeitherUriNorDestinationProvider.xml", this.getClass())
|
||||
.close();
|
||||
}
|
||||
|
||||
public static class FooAdvice extends AbstractRequestHandlerAdvice {
|
||||
public static class FooAdvice extends AbstractRequestHandlerAdvice {
|
||||
|
||||
@Override
|
||||
protected Object doInvoke(ExecutionCallback callback, Object target, Message<?> message) throws Exception {
|
||||
@@ -449,5 +476,6 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TestXmlApplicationContext extends AbstractXmlApplicationContext {
|
||||
|
||||
public TestXmlApplicationContext(String ... xmlStrings) {
|
||||
resources = new Resource[xmlStrings.length];
|
||||
for (int i = 0 ; i < xmlStrings.length; i++) {
|
||||
for (int i = 0; i < xmlStrings.length; i++) {
|
||||
resources[i] = new TestResource(xmlStrings[i]);
|
||||
}
|
||||
refresh();
|
||||
@@ -50,10 +50,12 @@ public class TestXmlApplicationContext extends AbstractXmlApplicationContext {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class XPathRouterParserTests {
|
||||
ConfigurableApplicationContext appContext;
|
||||
|
||||
public EventDrivenConsumer buildContext(String routerDef) {
|
||||
appContext = TestXmlApplicationContextHelper.getTestAppContext( channelConfig + routerDef);
|
||||
appContext = TestXmlApplicationContextHelper.getTestAppContext(channelConfig + routerDef);
|
||||
appContext.getAutowireCapableBeanFactory().autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
|
||||
EventDrivenConsumer consumer = (EventDrivenConsumer) appContext.getBean("router");
|
||||
consumer.start();
|
||||
|
||||
@@ -41,7 +41,7 @@ public class XPathMessageSplitterTests {
|
||||
|
||||
private XPathMessageSplitter splitter;
|
||||
|
||||
private QueueChannel replyChannel = new QueueChannel();
|
||||
private final QueueChannel replyChannel = new QueueChannel();
|
||||
|
||||
|
||||
@Before
|
||||
@@ -81,7 +81,7 @@ public class XPathMessageSplitterTests {
|
||||
for (Message<?> message : docMessages) {
|
||||
assertTrue("unexpected payload type" + message.getPayload().getClass().getName(), message.getPayload() instanceof Document);
|
||||
Document docPayload = (Document) message.getPayload();
|
||||
assertEquals("Wrong root element name" , "order", docPayload.getDocumentElement().getLocalName());
|
||||
assertEquals("Wrong root element name", "order", docPayload.getDocumentElement().getLocalName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ public class JaxbMarshallingIntegrationTests extends AbstractJUnit4SpringContext
|
||||
person.setFirstName("john");
|
||||
marshallIn.send(new GenericMessage<Object>(person));
|
||||
GenericMessage<Result> res = (GenericMessage<Result>) marshalledOut.receive(2000);
|
||||
assertNotNull("No response recevied" , res);
|
||||
assertTrue("payload was not a DOMResult" , res.getPayload() instanceof DOMResult);
|
||||
assertNotNull("No response recevied", res);
|
||||
assertTrue("payload was not a DOMResult", res.getPayload() instanceof DOMResult);
|
||||
Document doc = (Document) ((DOMResult) res.getPayload()).getNode();
|
||||
assertEquals("Wrong name for root element ", "person", doc.getDocumentElement().getLocalName());
|
||||
}
|
||||
|
||||
@@ -52,21 +52,21 @@
|
||||
<!-- Coding -->
|
||||
<module name="CovariantEquals" />
|
||||
<module name="EmptyStatement" />
|
||||
<!-- <module name="EqualsHashCode" /> -->
|
||||
<module name="EqualsHashCode" />
|
||||
<!-- <module name="InnerAssignment" /> -->
|
||||
<!-- <module name="SimplifyBooleanExpression" /> -->
|
||||
<!-- <module name="SimplifyBooleanReturn" /> -->
|
||||
<!-- <module name="StringLiteralEquality" /> -->
|
||||
<!-- <module name="NestedForDepth"> -->
|
||||
<!-- <property name="max" value="3" /> -->
|
||||
<!-- </module> -->
|
||||
<!-- <module name="NestedIfDepth"> -->
|
||||
<!-- <property name="max" value="3" /> -->
|
||||
<!-- </module> -->
|
||||
<!-- <module name="NestedTryDepth"> -->
|
||||
<!-- <property name="max" value="3" /> -->
|
||||
<!-- </module> -->
|
||||
<!-- <module name="MultipleVariableDeclarations" /> -->
|
||||
<module name="SimplifyBooleanExpression" />
|
||||
<module name="SimplifyBooleanReturn" />
|
||||
<module name="StringLiteralEquality" />
|
||||
<module name="NestedForDepth">
|
||||
<property name="max" value="3" />
|
||||
</module>
|
||||
<module name="NestedIfDepth">
|
||||
<property name="max" value="4" />
|
||||
</module>
|
||||
<module name="NestedTryDepth">
|
||||
<property name="max" value="3" />
|
||||
</module>
|
||||
<module name="MultipleVariableDeclarations" />
|
||||
<module name="RequireThis">
|
||||
<property name="checkMethods" value="false" />
|
||||
</module>
|
||||
@@ -119,10 +119,12 @@
|
||||
<!-- </module> -->
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
<!-- <module name="CommentsIndentation" /> -->
|
||||
<!-- <module name="UpperEll" /> -->
|
||||
<!-- <module name="ArrayTypeStyle" /> -->
|
||||
<!-- <module name="OuterTypeFilename" /> -->
|
||||
<module name="CommentsIndentation">
|
||||
<property name="tokens" value="BLOCK_COMMENT_BEGIN" />
|
||||
</module>
|
||||
<module name="UpperEll" />
|
||||
<module name="ArrayTypeStyle" />
|
||||
<module name="OuterTypeFilename" />
|
||||
|
||||
<!-- Modifiers -->
|
||||
<module name="RedundantModifier" />
|
||||
@@ -155,14 +157,14 @@
|
||||
</module>
|
||||
|
||||
<!-- Whitespace -->
|
||||
<!-- <module name="GenericWhitespace" /> -->
|
||||
<!-- <module name="MethodParamPad" /> -->
|
||||
<!-- <module name="NoWhitespaceAfter" > -->
|
||||
<!-- <property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS, ARRAY_DECLARATOR"/> -->
|
||||
<!-- </module> -->
|
||||
<!-- <module name="NoWhitespaceBefore" /> -->
|
||||
<!-- <module name="ParenPad" /> -->
|
||||
<!-- <module name="TypecastParenPad" /> -->
|
||||
<module name="GenericWhitespace" />
|
||||
<module name="MethodParamPad" />
|
||||
<module name="NoWhitespaceAfter" >
|
||||
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS, ARRAY_DECLARATOR"/>
|
||||
</module>
|
||||
<module name="NoWhitespaceBefore" />
|
||||
<module name="ParenPad" />
|
||||
<module name="TypecastParenPad" />
|
||||
<module name="WhitespaceAfter" />
|
||||
<module name="WhitespaceAround" />
|
||||
|
||||
|
||||
63
src/checkstyle/fixParenPad.gradle
Normal file
63
src/checkstyle/fixParenPad.gradle
Normal file
@@ -0,0 +1,63 @@
|
||||
task fixParenPad << {
|
||||
fileTree("${buildDir}/reports/checkstyle").include('*.xml').each { report ->
|
||||
def xml = new XmlParser(false, false).parse(report)
|
||||
xml.file.each { f ->
|
||||
def errors = f.error
|
||||
def thisErrors = []
|
||||
errors.each { error ->
|
||||
if (error.@source == 'com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck' ||
|
||||
error.@source == 'com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheck') {
|
||||
thisErrors.add(error)
|
||||
}
|
||||
}
|
||||
if (thisErrors) {
|
||||
def errorInx = 0
|
||||
def error = thisErrors[errorInx++]
|
||||
def file = new File(f.@name)
|
||||
println "Fixing file $file ..."
|
||||
boolean headerFixed
|
||||
def outSource = ''
|
||||
file.eachLine { line, ln ->
|
||||
if (!headerFixed) {
|
||||
def matcher = line =~ /Copyright (20\d\d)(?:-(20\d\d))?/
|
||||
if (matcher.count) {
|
||||
def year1 = matcher[0][1]
|
||||
if (now != year1) {
|
||||
if (now != matcher[0][2]) {
|
||||
line = line.replaceFirst(/(20\d\d)(?:-20\d\d)?/, year1 + "-$now")
|
||||
}
|
||||
}
|
||||
headerFixed = true
|
||||
}
|
||||
}
|
||||
|
||||
if (error && ln == (error.@line as int)) {
|
||||
def message = error.@message
|
||||
def index = (error.@column as int) - 1
|
||||
def chars = line.toCharArray()
|
||||
for (int i = 0; i < index; i++) {
|
||||
if (chars[i] == '\t') { // tabs before code == 8
|
||||
index -= 7;
|
||||
}
|
||||
else if (chars[i] != ' ') { // tabs after code start are only counted as 1
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
line = line.substring(0, index) + line.substring(index + 1)
|
||||
|
||||
println "Fixed line $line"
|
||||
|
||||
while (error && ln == (error.@line as int)) {
|
||||
error = thisErrors[errorInx++]
|
||||
}
|
||||
}
|
||||
|
||||
outSource += line + System.lineSeparator()
|
||||
}
|
||||
file.write(outSource)
|
||||
println()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user