INT-1389 removed all dependencies on StringMessage from unit tests in spring-integration-core

This commit is contained in:
Mark Fisher
2010-08-30 18:27:27 +00:00
parent a617a9ffef
commit a74595819e
90 changed files with 651 additions and 626 deletions

View File

@@ -22,7 +22,6 @@ import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -62,8 +61,8 @@ public class MessageSequenceComparatorTests {
@Test
public void testEqualWithDefaultValues() {
MessageSequenceComparator comparator = new MessageSequenceComparator();
StringMessage message1 = new StringMessage("test1");
StringMessage message2 = new StringMessage("test2");
Message<String> message1 = MessageBuilder.withPayload("test1").build();
Message<String> message2 = MessageBuilder.withPayload("test2").build();
assertEquals(0, comparator.compare(message1, message2));
}

View File

@@ -38,6 +38,7 @@ import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.ConversionServiceFactory;
@@ -49,10 +50,10 @@ import org.springframework.integration.annotation.Headers;
import org.springframework.integration.annotation.Payloads;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.SimpleMessageGroup;
@@ -377,8 +378,8 @@ public class MethodInvokingMessageGroupProcessorTests {
SingleAnnotationTestBean bean = new SingleAnnotationTestBean();
MethodInvokingMessageGroupProcessor aggregator = new MethodInvokingMessageGroupProcessor(bean);
SimpleMessageGroup group = new SimpleMessageGroup("FOO");
group.add(new StringMessage("foo"));
group.add(new StringMessage("bar"));
group.add(new GenericMessage<String>("foo"));
group.add(new GenericMessage<String>("bar"));
assertEquals("foo", aggregator.aggregatePayloads(group, null));
}
@@ -462,8 +463,8 @@ public class MethodInvokingMessageGroupProcessorTests {
NoAnnotationTestBean bean = new NoAnnotationTestBean();
MethodInvokingMessageGroupProcessor aggregator = new MethodInvokingMessageGroupProcessor(bean);
SimpleMessageGroup group = new SimpleMessageGroup("FOO");
group.add(new StringMessage("foo"));
group.add(new StringMessage("bar"));
group.add(new GenericMessage<String>("foo"));
group.add(new GenericMessage<String>("bar"));
assertEquals("foo", aggregator.aggregatePayloads(group, null));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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,7 +36,6 @@ import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.endpoint.PollingConsumer;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
@@ -80,7 +79,7 @@ public class ApplicationContextMessageBusTests {
TestApplicationContext context = TestUtils.createTestApplicationContext();
QueueChannel sourceChannel = new QueueChannel();
context.registerChannel("sourceChannel", sourceChannel);
sourceChannel.send(new StringMessage("test"));
sourceChannel.send(new GenericMessage<String>("test"));
QueueChannel targetChannel = new QueueChannel();
context.registerChannel("targetChannel", targetChannel);
context.refresh();
@@ -128,7 +127,7 @@ public class ApplicationContextMessageBusTests {
context.registerEndpoint("testEndpoint1", endpoint1);
context.registerEndpoint("testEndpoint2", endpoint2);
context.refresh();
inputChannel.send(new StringMessage("testing"));
inputChannel.send(new GenericMessage<String>("testing"));
Message<?> message1 = outputChannel1.receive(3000);
Message<?> message2 = outputChannel2.receive(0);
context.stop();
@@ -166,7 +165,7 @@ public class ApplicationContextMessageBusTests {
context.registerEndpoint("testEndpoint1", endpoint1);
context.registerEndpoint("testEndpoint2", endpoint2);
context.refresh();
inputChannel.send(new StringMessage("testing"));
inputChannel.send(new GenericMessage<String>("testing"));
latch.await(500, TimeUnit.MILLISECONDS);
assertEquals("both handlers should have been invoked", 0, latch.getCount());
Message<?> message1 = outputChannel1.receive(500);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.annotation.MessageEndpoint;
@@ -28,8 +29,8 @@ import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.handler.ServiceActivatingHandler;
@@ -63,7 +64,7 @@ public class DirectChannelSubscriptionTests {
EventDrivenConsumer endpoint = new EventDrivenConsumer(sourceChannel, serviceActivator);
context.registerEndpoint("testEndpoint", endpoint);
context.refresh();
this.sourceChannel.send(new StringMessage("foo"));
this.sourceChannel.send(new GenericMessage<String>("foo"));
Message<?> response = this.targetChannel.receive();
assertEquals("foo!", response.getPayload());
context.stop();
@@ -77,7 +78,7 @@ public class DirectChannelSubscriptionTests {
TestEndpoint endpoint = new TestEndpoint();
postProcessor.postProcessAfterInitialization(endpoint, "testEndpoint");
context.refresh();
this.sourceChannel.send(new StringMessage("foo"));
this.sourceChannel.send(new GenericMessage<String>("foo"));
Message<?> response = this.targetChannel.receive();
assertEquals("foo-from-annotated-endpoint", response.getPayload());
context.stop();
@@ -96,7 +97,7 @@ public class DirectChannelSubscriptionTests {
context.registerEndpoint("testEndpoint", endpoint);
context.refresh();
try {
this.sourceChannel.send(new StringMessage("foo"));
this.sourceChannel.send(new GenericMessage<String>("foo"));
}
finally {
context.stop();
@@ -114,7 +115,7 @@ public class DirectChannelSubscriptionTests {
postProcessor.postProcessAfterInitialization(endpoint, "testEndpoint");
context.refresh();
try {
this.sourceChannel.send(new StringMessage("foo"));
this.sourceChannel.send(new GenericMessage<String>("foo"));
}
finally {
context.stop();
@@ -125,7 +126,7 @@ public class DirectChannelSubscriptionTests {
static class TestBean {
public Message<?> handle(Message<?> message) {
return new StringMessage(message.getPayload() + "!");
return new GenericMessage<String>(message.getPayload() + "!");
}
}
@@ -135,7 +136,7 @@ public class DirectChannelSubscriptionTests {
@ServiceActivator(inputChannel="sourceChannel", outputChannel="targetChannel")
public Message<?> handle(Message<?> message) {
return new StringMessage(message.getPayload() + "-from-annotated-endpoint");
return new GenericMessage<String>(message.getPayload() + "-from-annotated-endpoint");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -25,8 +25,8 @@ import java.util.List;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -36,9 +36,9 @@ public class ChannelPurgerTests {
@Test
public void testPurgeAllWithoutSelector() {
QueueChannel channel = new QueueChannel();
channel.send(new StringMessage("test1"));
channel.send(new StringMessage("test2"));
channel.send(new StringMessage("test3"));
channel.send(new GenericMessage<String>("test1"));
channel.send(new GenericMessage<String>("test2"));
channel.send(new GenericMessage<String>("test3"));
ChannelPurger purger = new ChannelPurger(channel);
List<Message<?>> purgedMessages = purger.purge();
assertEquals(3, purgedMessages.size());
@@ -48,9 +48,9 @@ public class ChannelPurgerTests {
@Test
public void testPurgeAllWithSelector() {
QueueChannel channel = new QueueChannel();
channel.send(new StringMessage("test1"));
channel.send(new StringMessage("test2"));
channel.send(new StringMessage("test3"));
channel.send(new GenericMessage<String>("test1"));
channel.send(new GenericMessage<String>("test2"));
channel.send(new GenericMessage<String>("test3"));
ChannelPurger purger = new ChannelPurger(new MessageSelector() {
public boolean accept(Message<?> message) {
return false;
@@ -64,9 +64,9 @@ public class ChannelPurgerTests {
@Test
public void testPurgeNoneWithSelector() {
QueueChannel channel = new QueueChannel();
channel.send(new StringMessage("test1"));
channel.send(new StringMessage("test2"));
channel.send(new StringMessage("test3"));
channel.send(new GenericMessage<String>("test1"));
channel.send(new GenericMessage<String>("test2"));
channel.send(new GenericMessage<String>("test3"));
ChannelPurger purger = new ChannelPurger(new MessageSelector() {
public boolean accept(Message<?> message) {
return true;
@@ -82,9 +82,9 @@ public class ChannelPurgerTests {
@Test
public void testPurgeSubsetWithSelector() {
QueueChannel channel = new QueueChannel();
channel.send(new StringMessage("test1"));
channel.send(new StringMessage("test2"));
channel.send(new StringMessage("test3"));
channel.send(new GenericMessage<String>("test1"));
channel.send(new GenericMessage<String>("test2"));
channel.send(new GenericMessage<String>("test3"));
ChannelPurger purger = new ChannelPurger(new MessageSelector() {
public boolean accept(Message<?> message) {
return (message.getPayload().equals("test2"));
@@ -102,10 +102,10 @@ public class ChannelPurgerTests {
public void testMultipleChannelsWithNoSelector() {
QueueChannel channel1 = new QueueChannel();
QueueChannel channel2 = new QueueChannel();
channel1.send(new StringMessage("test1"));
channel1.send(new StringMessage("test2"));
channel2.send(new StringMessage("test1"));
channel2.send(new StringMessage("test2"));
channel1.send(new GenericMessage<String>("test1"));
channel1.send(new GenericMessage<String>("test2"));
channel2.send(new GenericMessage<String>("test1"));
channel2.send(new GenericMessage<String>("test2"));
ChannelPurger purger = new ChannelPurger(channel1, channel2);
List<Message<?>> purgedMessages = purger.purge();
assertEquals(4, purgedMessages.size());
@@ -117,12 +117,12 @@ public class ChannelPurgerTests {
public void testMultipleChannelsWithSelector() {
QueueChannel channel1 = new QueueChannel();
QueueChannel channel2 = new QueueChannel();
channel1.send(new StringMessage("test1"));
channel1.send(new StringMessage("test2"));
channel1.send(new StringMessage("test3"));
channel2.send(new StringMessage("test1"));
channel2.send(new StringMessage("test2"));
channel2.send(new StringMessage("test3"));
channel1.send(new GenericMessage<String>("test1"));
channel1.send(new GenericMessage<String>("test2"));
channel1.send(new GenericMessage<String>("test3"));
channel2.send(new GenericMessage<String>("test1"));
channel2.send(new GenericMessage<String>("test2"));
channel2.send(new GenericMessage<String>("test3"));
ChannelPurger purger = new ChannelPurger(new MessageSelector() {
public boolean accept(Message<?> message) {
return (message.getPayload().equals("test2"));
@@ -144,10 +144,10 @@ public class ChannelPurgerTests {
public void testPurgeNoneWithSelectorAndMultipleChannels() {
QueueChannel channel1 = new QueueChannel();
QueueChannel channel2 = new QueueChannel();
channel1.send(new StringMessage("test1"));
channel1.send(new StringMessage("test2"));
channel2.send(new StringMessage("test1"));
channel2.send(new StringMessage("test2"));
channel1.send(new GenericMessage<String>("test1"));
channel1.send(new GenericMessage<String>("test2"));
channel2.send(new GenericMessage<String>("test1"));
channel2.send(new GenericMessage<String>("test2"));
ChannelPurger purger = new ChannelPurger(new MessageSelector() {
public boolean accept(Message<?> message) {
return true;

View File

@@ -38,7 +38,6 @@ import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.core.ErrorMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -49,13 +48,13 @@ public class DatatypeChannelTests {
@Test
public void supportedType() {
MessageChannel channel = createChannel(String.class);
assertTrue(channel.send(new StringMessage("test")));
assertTrue(channel.send(new GenericMessage<String>("test")));
}
@Test(expected = MessageDeliveryException.class)
public void unsupportedTypeAndNoConversionService() {
MessageChannel channel = createChannel(Integer.class);
channel.send(new StringMessage("123"));
channel.send(new GenericMessage<String>("123"));
}
@Test
@@ -63,7 +62,7 @@ public class DatatypeChannelTests {
QueueChannel channel = createChannel(Integer.class);
ConversionService conversionService = ConversionServiceFactory.createDefaultConversionService();
channel.setConversionService(conversionService);
assertTrue(channel.send(new StringMessage("123")));
assertTrue(channel.send(new GenericMessage<String>("123")));
}
@Test(expected = MessageDeliveryException.class)
@@ -139,7 +138,7 @@ public class DatatypeChannelTests {
@Test
public void multipleTypes() {
MessageChannel channel = createChannel(String.class, Integer.class);
assertTrue(channel.send(new StringMessage("test1")));
assertTrue(channel.send(new GenericMessage<String>("test1")));
assertTrue(channel.send(new GenericMessage<Integer>(2)));
Exception exception = null;
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +26,8 @@ import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
import org.springframework.integration.dispatcher.UnicastingDispatcher;
@@ -42,7 +42,7 @@ public class DirectChannelTests {
DirectChannel channel = new DirectChannel();
ThreadNameExtractingTestTarget target = new ThreadNameExtractingTestTarget();
channel.subscribe(target);
StringMessage message = new StringMessage("test");
GenericMessage<String> message = new GenericMessage<String>("test");
assertTrue(channel.send(message));
assertEquals(Thread.currentThread().getName(), target.threadName);
DirectFieldAccessor channelAccessor = new DirectFieldAccessor(channel);
@@ -58,7 +58,7 @@ public class DirectChannelTests {
final DirectChannel channel = new DirectChannel();
ThreadNameExtractingTestTarget target = new ThreadNameExtractingTestTarget(latch);
channel.subscribe(target);
final StringMessage message = new StringMessage("test");
final GenericMessage<String> message = new GenericMessage<String>("test");
new Thread(new Runnable() {
public void run() {
channel.send(message);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -31,8 +31,8 @@ import org.junit.Test;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
@@ -50,7 +50,7 @@ public class ExecutorChannelTests {
CountDownLatch latch = new CountDownLatch(1);
TestHandler handler = new TestHandler(latch);
channel.subscribe(handler);
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
latch.await(1000, TimeUnit.MILLISECONDS);
assertEquals(0, latch.getCount());
assertNotNull(handler.thread);
@@ -73,7 +73,7 @@ public class ExecutorChannelTests {
channel.subscribe(handler2);
channel.subscribe(handler3);
for (int i = 0; i < numberOfMessages; i++) {
channel.send(new StringMessage("test-" + i));
channel.send(new GenericMessage<String>("test-" + i));
}
latch.await(3000, TimeUnit.MILLISECONDS);
assertEquals(0, latch.getCount());
@@ -107,7 +107,7 @@ public class ExecutorChannelTests {
channel.subscribe(handler3);
handler2.shouldFail = true;
for (int i = 0; i < numberOfMessages; i++) {
channel.send(new StringMessage("test-" + i));
channel.send(new GenericMessage<String>("test-" + i));
}
latch.await(3000, TimeUnit.MILLISECONDS);
assertEquals(0, latch.getCount());
@@ -140,7 +140,7 @@ public class ExecutorChannelTests {
channel.subscribe(handler3);
handler1.shouldFail = true;
for (int i = 0; i < numberOfMessages; i++) {
channel.send(new StringMessage("test-" + i));
channel.send(new GenericMessage<String>("test-" + i));
}
latch.await(3000, TimeUnit.MILLISECONDS);
assertEquals(0, latch.getCount());

View File

@@ -35,11 +35,11 @@ import org.junit.Test;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.core.ChannelResolutionException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.PollingConsumer;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.test.util.TestUtils;
@@ -86,7 +86,7 @@ public class MessagingTemplateTests {
public void send() {
MessagingTemplate template = new MessagingTemplate();
QueueChannel channel = new QueueChannel();
template.send(channel, new StringMessage("test"));
template.send(channel, new GenericMessage<String>("test"));
Message<?> reply = channel.receive(0);
assertNotNull(reply);
assertEquals("test", reply.getPayload());
@@ -97,7 +97,7 @@ public class MessagingTemplateTests {
QueueChannel channel = new QueueChannel();
MessagingTemplate template = new MessagingTemplate();
template.setDefaultChannel(channel);
template.send(new StringMessage("test"));
template.send(new GenericMessage<String>("test"));
Message<?> reply = channel.receive(0);
assertNotNull(reply);
assertEquals("test", reply.getPayload());
@@ -107,7 +107,7 @@ public class MessagingTemplateTests {
public void sendWithDefaultChannelProvidedByConstructor() {
QueueChannel channel = new QueueChannel();
MessagingTemplate template = new MessagingTemplate(channel);
template.send(new StringMessage("test"));
template.send(new GenericMessage<String>("test"));
Message<?> reply = channel.receive(0);
assertNotNull(reply);
assertEquals("test", reply.getPayload());
@@ -118,7 +118,7 @@ public class MessagingTemplateTests {
QueueChannel explicitChannel = new QueueChannel();
QueueChannel defaultChannel = new QueueChannel();
MessagingTemplate template = new MessagingTemplate(defaultChannel);
template.send(explicitChannel, new StringMessage("test"));
template.send(explicitChannel, new GenericMessage<String>("test"));
Message<?> reply = explicitChannel.receive(0);
assertNotNull(reply);
assertEquals("test", reply.getPayload());
@@ -128,13 +128,13 @@ public class MessagingTemplateTests {
@Test(expected = IllegalStateException.class)
public void sendWithoutChannelArgFailsIfNoDefaultAvailable() {
MessagingTemplate template = new MessagingTemplate();
template.send(new StringMessage("test"));
template.send(new GenericMessage<String>("test"));
}
@Test
public void receive() {
QueueChannel channel = new QueueChannel();
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
MessagingTemplate template = new MessagingTemplate();
Message<?> reply = template.receive(channel);
assertEquals("test", reply.getPayload());
@@ -143,7 +143,7 @@ public class MessagingTemplateTests {
@Test
public void receiveWithDefaultChannelProvidedBySetter() {
QueueChannel channel = new QueueChannel();
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
MessagingTemplate template = new MessagingTemplate();
template.setDefaultChannel(channel);
Message<?> reply = template.receive();
@@ -153,7 +153,7 @@ public class MessagingTemplateTests {
@Test
public void receiveWithDefaultChannelProvidedByConstructor() {
QueueChannel channel = new QueueChannel();
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
MessagingTemplate template = new MessagingTemplate(channel);
Message<?> reply = template.receive();
assertEquals("test", reply.getPayload());
@@ -163,7 +163,7 @@ public class MessagingTemplateTests {
public void receiveWithExplicitChannelTakesPrecedenceOverDefault() {
QueueChannel explicitChannel = new QueueChannel();
QueueChannel defaultChannel = new QueueChannel();
explicitChannel.send(new StringMessage("test"));
explicitChannel.send(new GenericMessage<String>("test"));
MessagingTemplate template = new MessagingTemplate(defaultChannel);
template.setReceiveTimeout(0);
Message<?> reply = template.receive(explicitChannel);
@@ -188,7 +188,7 @@ public class MessagingTemplateTests {
public void sendAndReceive() {
MessagingTemplate template = new MessagingTemplate();
template.setReceiveTimeout(3000);
Message<?> reply = template.sendAndReceive(this.requestChannel, new StringMessage("test"));
Message<?> reply = template.sendAndReceive(this.requestChannel, new GenericMessage<String>("test"));
assertEquals("TEST", reply.getPayload());
}
@@ -197,7 +197,7 @@ public class MessagingTemplateTests {
MessagingTemplate template = new MessagingTemplate();
template.setReceiveTimeout(3000);
template.setDefaultChannel(this.requestChannel);
Message<?> reply = template.sendAndReceive(new StringMessage("test"));
Message<?> reply = template.sendAndReceive(new GenericMessage<String>("test"));
assertEquals("TEST", reply.getPayload());
}
@@ -206,7 +206,7 @@ public class MessagingTemplateTests {
QueueChannel defaultChannel = new QueueChannel();
MessagingTemplate template = new MessagingTemplate(defaultChannel);
template.setReceiveTimeout(3000);
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
Message<?> reply = template.sendAndReceive(this.requestChannel, message);
assertEquals("TEST", reply.getPayload());
assertNull(defaultChannel.receive(0));
@@ -215,7 +215,7 @@ public class MessagingTemplateTests {
@Test(expected = IllegalStateException.class)
public void sendAndReceiveWithoutChannelArgFailsIfNoDefaultAvailable() {
MessagingTemplate template = new MessagingTemplate();
template.sendAndReceive(new StringMessage("test"));
template.sendAndReceive(new GenericMessage<String>("test"));
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,20 @@
package org.springframework.integration.channel;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -24,26 +38,18 @@ import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.integration.Message;
import org.springframework.integration.MessageRejectedException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
import org.springframework.integration.dispatcher.UnicastingDispatcher;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.*;
/**
* @author Oleg Zhurakousky
*/
@@ -72,7 +78,7 @@ public class MixedDispatcherConfigurationScenarioTests {
@Mock
private MessageHandler handlerC;
private Message<?> message = new StringMessage("test");
private Message<?> message = new GenericMessage<String>("test");
@Before

View File

@@ -32,8 +32,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -43,12 +43,12 @@ public class PriorityChannelTests {
@Test
public void testCapacityEnforced() {
PriorityChannel channel = new PriorityChannel(3);
assertTrue(channel.send(new StringMessage("test1"), 0));
assertTrue(channel.send(new StringMessage("test2"), 0));
assertTrue(channel.send(new StringMessage("test3"), 0));
assertFalse(channel.send(new StringMessage("test4"), 0));
assertTrue(channel.send(new GenericMessage<String>("test1"), 0));
assertTrue(channel.send(new GenericMessage<String>("test2"), 0));
assertTrue(channel.send(new GenericMessage<String>("test3"), 0));
assertFalse(channel.send(new GenericMessage<String>("test4"), 0));
channel.receive(0);
assertTrue(channel.send(new StringMessage("test5")));
assertTrue(channel.send(new GenericMessage<String>("test5")));
}
@Test
@@ -74,11 +74,11 @@ public class PriorityChannelTests {
@Test
public void testCustomComparator() {
PriorityChannel channel = new PriorityChannel(5, new StringPayloadComparator());
Message<?> messageA = new StringMessage("A");
Message<?> messageB = new StringMessage("B");
Message<?> messageC = new StringMessage("C");
Message<?> messageD = new StringMessage("D");
Message<?> messageE = new StringMessage("E");
Message<?> messageA = new GenericMessage<String>("A");
Message<?> messageB = new GenericMessage<String>("B");
Message<?> messageC = new GenericMessage<String>("C");
Message<?> messageD = new GenericMessage<String>("D");
Message<?> messageE = new GenericMessage<String>("E");
channel.send(messageC);
channel.send(messageA);
channel.send(messageE);
@@ -96,7 +96,7 @@ public class PriorityChannelTests {
PriorityChannel channel = new PriorityChannel(5);
Message<?> highPriority = createPriorityMessage(5);
Message<?> lowPriority = createPriorityMessage(-5);
Message<?> nullPriority = new StringMessage("test:NULL");
Message<?> nullPriority = new GenericMessage<String>("test:NULL");
channel.send(lowPriority);
channel.send(highPriority);
channel.send(nullPriority);
@@ -110,7 +110,7 @@ public class PriorityChannelTests {
PriorityChannel channel = new PriorityChannel();
Message<?> highPriority = createPriorityMessage(5);
Message<?> lowPriority = createPriorityMessage(-5);
Message<?> nullPriority = new StringMessage("test:NULL");
Message<?> nullPriority = new GenericMessage<String>("test:NULL");
channel.send(lowPriority);
channel.send(highPriority);
channel.send(nullPriority);
@@ -125,10 +125,10 @@ public class PriorityChannelTests {
final AtomicBoolean sentSecondMessage = new AtomicBoolean(false);
final CountDownLatch latch = new CountDownLatch(1);
Executor executor = Executors.newSingleThreadScheduledExecutor();
channel.send(new StringMessage("test-1"));
channel.send(new GenericMessage<String>("test-1"));
executor.execute(new Runnable() {
public void run() {
sentSecondMessage.set(channel.send(new StringMessage("test-2"), 10));
sentSecondMessage.set(channel.send(new GenericMessage<String>("test-2"), 10));
latch.countDown();
}
});
@@ -148,10 +148,10 @@ public class PriorityChannelTests {
final AtomicBoolean sentSecondMessage = new AtomicBoolean(false);
final CountDownLatch latch = new CountDownLatch(1);
Executor executor = Executors.newSingleThreadScheduledExecutor();
channel.send(new StringMessage("test-1"));
channel.send(new GenericMessage<String>("test-1"));
executor.execute(new Runnable() {
public void run() {
sentSecondMessage.set(channel.send(new StringMessage("test-2"), 3000));
sentSecondMessage.set(channel.send(new GenericMessage<String>("test-2"), 3000));
latch.countDown();
}
});
@@ -173,10 +173,10 @@ public class PriorityChannelTests {
final AtomicBoolean sentSecondMessage = new AtomicBoolean(false);
final CountDownLatch latch = new CountDownLatch(1);
Executor executor = Executors.newSingleThreadScheduledExecutor();
channel.send(new StringMessage("test-1"));
channel.send(new GenericMessage<String>("test-1"));
executor.execute(new Runnable() {
public void run() {
sentSecondMessage.set(channel.send(new StringMessage("test-2"), -1));
sentSecondMessage.set(channel.send(new GenericMessage<String>("test-2"), -1));
latch.countDown();
}
});

View File

@@ -33,7 +33,6 @@ import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.selector.UnexpiredMessageSelector;
/**
@@ -198,9 +197,9 @@ public class QueueChannelTests {
@Test
public void testClear() {
QueueChannel channel = new QueueChannel(2);
StringMessage message1 = new StringMessage("test1");
StringMessage message2 = new StringMessage("test2");
StringMessage message3 = new StringMessage("test3");
GenericMessage<String> message1 = new GenericMessage<String>("test1");
GenericMessage<String> message2 = new GenericMessage<String>("test2");
GenericMessage<String> message3 = new GenericMessage<String>("test3");
assertTrue(channel.send(message1));
assertTrue(channel.send(message2));
assertFalse(channel.send(message3, 0));
@@ -231,11 +230,11 @@ public class QueueChannelTests {
.setExpirationDate(future).build();
assertTrue(channel.send(expiredMessage, 0));
assertTrue(channel.send(unexpiredMessage, 0));
assertFalse(channel.send(new StringMessage("atCapacity"), 0));
assertFalse(channel.send(new GenericMessage<String>("atCapacity"), 0));
List<Message<?>> purgedMessages = channel.purge(new UnexpiredMessageSelector());
assertNotNull(purgedMessages);
assertEquals(1, purgedMessages.size());
assertTrue(channel.send(new StringMessage("roomAvailable"), 0));
assertTrue(channel.send(new GenericMessage<String>("roomAvailable"), 0));
}
}

View File

@@ -43,7 +43,6 @@ import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
import org.springframework.integration.dispatcher.UnicastingDispatcher;
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
@@ -147,7 +146,7 @@ public class ChannelParserTests {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("channelParserTests.xml", this
.getClass());
MessageChannel channel = (MessageChannel) context.getBean("integerChannel");
channel.send(new StringMessage("incorrect type"));
channel.send(new GenericMessage<String>("incorrect type"));
}
@Test
@@ -165,7 +164,7 @@ public class ChannelParserTests {
.getClass());
MessageChannel channel = (MessageChannel) context.getBean("stringOrNumberChannel");
assertTrue(channel.send(new GenericMessage<Integer>(123)));
assertTrue(channel.send(new StringMessage("accepted type")));
assertTrue(channel.send(new GenericMessage<String>("accepted type")));
}
@Test(expected = MessageDeliveryException.class)
@@ -183,7 +182,7 @@ public class ChannelParserTests {
PollableChannel channel = (PollableChannel) context.getBean("channelWithInterceptorRef");
TestChannelInterceptor interceptor = (TestChannelInterceptor) context.getBean("interceptor");
assertEquals(0, interceptor.getSendCount());
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
assertEquals(1, interceptor.getSendCount());
assertEquals(0, interceptor.getReceiveCount());
channel.receive();
@@ -195,7 +194,7 @@ public class ChannelParserTests {
ApplicationContext context = new ClassPathXmlApplicationContext("channelInterceptorParserTests.xml", this
.getClass());
PollableChannel channel = (PollableChannel) context.getBean("channelWithInterceptorInnerBean");
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
Message<?> transformed = channel.receive(1000);
assertEquals("TEST", transformed.getPayload());
}
@@ -223,10 +222,10 @@ public class ChannelParserTests {
ApplicationContext context = new ClassPathXmlApplicationContext("priorityChannelParserTests.xml", this
.getClass());
PollableChannel channel = (PollableChannel) context.getBean("priorityChannelWithCustomComparator");
channel.send(new StringMessage("C"));
channel.send(new StringMessage("A"));
channel.send(new StringMessage("D"));
channel.send(new StringMessage("B"));
channel.send(new GenericMessage<String>("C"));
channel.send(new GenericMessage<String>("A"));
channel.send(new GenericMessage<String>("D"));
channel.send(new GenericMessage<String>("B"));
Message<?> reply1 = channel.receive(0);
Message<?> reply2 = channel.receive(0);
Message<?> reply3 = channel.receive(0);
@@ -250,7 +249,7 @@ public class ChannelParserTests {
assertEquals(3, channel.receive(0).getPayload());
boolean threwException = false;
try {
channel.send(new StringMessage("wrong type"));
channel.send(new GenericMessage<String>("wrong type"));
}
catch (MessageDeliveryException e) {
assertEquals("wrong type", e.getFailedMessage().getPayload());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -17,8 +17,8 @@
package org.springframework.integration.channel.config;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -33,7 +33,7 @@ public class TestSource implements MessageSource<String> {
}
public Message<String> receive() {
return new StringMessage(this.text);
return new GenericMessage<String>(this.text);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -28,11 +28,12 @@ import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.config.TestChannelInterceptor;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -55,12 +56,12 @@ public class ThreadLocalChannelParserTests {
@Test
public void testSendInAnotherThread() throws Exception {
simpleChannel.send(new StringMessage("test"));
simpleChannel.send(new GenericMessage<String>("test"));
Executor otherThreadExecutor = Executors.newSingleThreadExecutor();
final CountDownLatch latch = new CountDownLatch(1);
otherThreadExecutor.execute(new Runnable() {
public void run() {
simpleChannel.send(new StringMessage("crap"));
simpleChannel.send(new GenericMessage<String>("crap"));
latch.countDown();
}
});
@@ -72,11 +73,11 @@ public class ThreadLocalChannelParserTests {
@Test
public void testReceiveInAnotherThread() throws Exception {
simpleChannel.send(new StringMessage("test-1.1"));
simpleChannel.send(new StringMessage("test-1.2"));
simpleChannel.send(new StringMessage("test-1.3"));
channelWithInterceptor.send(new StringMessage("test-2.1"));
channelWithInterceptor.send(new StringMessage("test-2.2"));
simpleChannel.send(new GenericMessage<String>("test-1.1"));
simpleChannel.send(new GenericMessage<String>("test-1.2"));
simpleChannel.send(new GenericMessage<String>("test-1.3"));
channelWithInterceptor.send(new GenericMessage<String>("test-2.1"));
channelWithInterceptor.send(new GenericMessage<String>("test-2.2"));
Executor otherThreadExecutor = Executors.newSingleThreadExecutor();
final List<Object> otherThreadResults = new ArrayList<Object>();
final CountDownLatch latch = new CountDownLatch(2);
@@ -108,7 +109,7 @@ public class ThreadLocalChannelParserTests {
@Test
public void testInterceptor() {
int before = interceptor.getSendCount();
channelWithInterceptor.send(new StringMessage("test"));
channelWithInterceptor.send(new GenericMessage<String>("test"));
assertEquals(before+1, interceptor.getSendCount());
}

View File

@@ -27,15 +27,16 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.channel.AbstractMessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.util.StringUtils;
/**
@@ -50,7 +51,7 @@ public class ChannelInterceptorTests {
@Test
public void testPreSendInterceptorReturnsMessage() {
channel.addInterceptor(new PreSendReturnsMessageInterceptor());
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
Message<?> result = channel.receive(0);
assertNotNull(result);
assertEquals("test", result.getPayload());
@@ -61,7 +62,7 @@ public class ChannelInterceptorTests {
public void testPreSendInterceptorReturnsNull() {
PreSendReturnsNullInterceptor interceptor = new PreSendReturnsNullInterceptor();
channel.addInterceptor(interceptor);
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
channel.send(message);
assertEquals(1, interceptor.getCount());
Message<?> result = channel.receive(0);
@@ -81,7 +82,7 @@ public class ChannelInterceptorTests {
invoked.set(true);
}
});
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
assertTrue(invoked.get());
}
@@ -104,10 +105,10 @@ public class ChannelInterceptorTests {
});
assertEquals(0, invokedCounter.get());
assertEquals(0, sentCounter.get());
singleItemChannel.send(new StringMessage("test1"));
singleItemChannel.send(new GenericMessage<String>("test1"));
assertEquals(1, invokedCounter.get());
assertEquals(1, sentCounter.get());
singleItemChannel.send(new StringMessage("test2"), 0);
singleItemChannel.send(new GenericMessage<String>("test2"), 0);
assertEquals(2, invokedCounter.get());
assertEquals(1, sentCounter.get());
}
@@ -115,7 +116,7 @@ public class ChannelInterceptorTests {
@Test
public void testPreReceiveInterceptorReturnsTrue() {
channel.addInterceptor(new PreReceiveReturnsTrueInterceptor());
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
channel.send(message);
Message<?> result = channel.receive(0);
assertEquals(1, PreReceiveReturnsTrueInterceptor.counter.get());
@@ -125,7 +126,7 @@ public class ChannelInterceptorTests {
@Test
public void testPreReceiveInterceptorReturnsFalse() {
channel.addInterceptor(new PreReceiveReturnsFalseInterceptor());
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
channel.send(message);
Message<?> result = channel.receive(0);
assertEquals(1, PreReceiveReturnsFalseInterceptor.counter.get());
@@ -151,7 +152,7 @@ public class ChannelInterceptorTests {
channel.receive(0);
assertEquals(1, invokedCount.get());
assertEquals(0, messageCount.get());
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
Message<?> result = channel.receive(0);
assertNotNull(result);
assertEquals(2, invokedCount.get());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +26,8 @@ import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -41,7 +41,7 @@ public class MessageSelectingInterceptorTests {
MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector);
QueueChannel channel = new QueueChannel();
channel.addInterceptor(interceptor);
assertTrue(channel.send(new StringMessage("test1")));
assertTrue(channel.send(new GenericMessage<String>("test1")));
}
@Test(expected=MessageDeliveryException.class)
@@ -51,7 +51,7 @@ public class MessageSelectingInterceptorTests {
MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector);
QueueChannel channel = new QueueChannel();
channel.addInterceptor(interceptor);
channel.send(new StringMessage("test1"));
channel.send(new GenericMessage<String>("test1"));
}
@Test
@@ -62,7 +62,7 @@ public class MessageSelectingInterceptorTests {
MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector1, selector2);
QueueChannel channel = new QueueChannel();
channel.addInterceptor(interceptor);
assertTrue(channel.send(new StringMessage("test1")));
assertTrue(channel.send(new GenericMessage<String>("test1")));
assertEquals(2, counter.get());
}
@@ -78,7 +78,7 @@ public class MessageSelectingInterceptorTests {
QueueChannel channel = new QueueChannel();
channel.addInterceptor(interceptor);
try {
channel.send(new StringMessage("test1"));
channel.send(new GenericMessage<String>("test1"));
}
catch (MessageDeliveryException e) {
exceptionThrown = true;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -24,9 +24,9 @@ import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -38,7 +38,7 @@ public class WireTapTests {
QueueChannel mainChannel = new QueueChannel();
QueueChannel secondaryChannel = new QueueChannel();
mainChannel.addInterceptor(new WireTap(secondaryChannel));
mainChannel.send(new StringMessage("testing"));
mainChannel.send(new GenericMessage<String>("testing"));
Message<?> original = mainChannel.receive(0);
assertNotNull(original);
Message<?> intercepted = secondaryChannel.receive(0);
@@ -51,7 +51,7 @@ public class WireTapTests {
QueueChannel mainChannel = new QueueChannel();
QueueChannel secondaryChannel = new QueueChannel();
mainChannel.addInterceptor(new WireTap(secondaryChannel, new TestSelector(false)));
mainChannel.send(new StringMessage("testing"));
mainChannel.send(new GenericMessage<String>("testing"));
Message<?> original = mainChannel.receive(0);
assertNotNull(original);
Message<?> intercepted = secondaryChannel.receive(0);
@@ -63,7 +63,7 @@ public class WireTapTests {
QueueChannel mainChannel = new QueueChannel();
QueueChannel secondaryChannel = new QueueChannel();
mainChannel.addInterceptor(new WireTap(secondaryChannel, new TestSelector(true)));
mainChannel.send(new StringMessage("testing"));
mainChannel.send(new GenericMessage<String>("testing"));
Message<?> original = mainChannel.receive(0);
assertNotNull(original);
Message<?> intercepted = secondaryChannel.receive(0);
@@ -82,7 +82,7 @@ public class WireTapTests {
QueueChannel secondaryChannel = new QueueChannel();
mainChannel.addInterceptor(new WireTap(secondaryChannel));
assertNull(secondaryChannel.receive(0));
Message<?> message = new StringMessage("testing");
Message<?> message = new GenericMessage<String>("testing");
mainChannel.send(message);
Message<?> original = mainChannel.receive(0);
Message<?> intercepted = secondaryChannel.receive(0);

View File

@@ -31,9 +31,9 @@ import org.springframework.integration.Message;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.context.BeanFactoryChannelResolver;
import org.springframework.integration.core.ChannelResolutionException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
@@ -108,7 +108,7 @@ public class ChannelAdapterParserTests {
assertTrue(adapter instanceof EventDrivenConsumer);
TestConsumer consumer = (TestConsumer) this.applicationContext.getBean("consumer");
assertNull(consumer.getLastMessage());
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
assertTrue(((MessageChannel) channel).send(message));
assertNotNull(consumer.getLastMessage());
assertEquals(message, consumer.getLastMessage());
@@ -126,7 +126,7 @@ public class ChannelAdapterParserTests {
assertTrue(adapter instanceof EventDrivenConsumer);
TestBean testBean = (TestBean) this.applicationContext.getBean("testBean");
assertNull(testBean.getMessage());
Message<?> message = new StringMessage("consumer test");
Message<?> message = new GenericMessage<String>("consumer test");
assertTrue(((MessageChannel) channel).send(message));
assertNotNull(testBean.getMessage());
assertEquals("consumer test", testBean.getMessage());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -27,10 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.Message;
import org.springframework.integration.MessageRejectedException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.StringUtils;
@@ -72,7 +72,7 @@ public class FilterParserTests {
@Test
public void filterWithSelectorAdapterAccepts() {
adapterInput.send(new StringMessage("test"));
adapterInput.send(new GenericMessage<String>("test"));
Message<?> reply = adapterOutput.receive(0);
assertNotNull(reply);
assertEquals("test", reply.getPayload());
@@ -80,14 +80,14 @@ public class FilterParserTests {
@Test
public void filterWithSelectorAdapterRejects() {
adapterInput.send(new StringMessage(""));
adapterInput.send(new GenericMessage<String>(""));
Message<?> reply = adapterOutput.receive(0);
assertNull(reply);
}
@Test
public void filterWithSelectorImplementationAccepts() {
implementationInput.send(new StringMessage("test"));
implementationInput.send(new GenericMessage<String>("test"));
Message<?> reply = implementationOutput.receive(0);
assertNotNull(reply);
assertEquals("test", reply.getPayload());
@@ -95,26 +95,26 @@ public class FilterParserTests {
@Test
public void filterWithSelectorImplementationRejects() {
implementationInput.send(new StringMessage(""));
implementationInput.send(new GenericMessage<String>(""));
Message<?> reply = implementationOutput.receive(0);
assertNull(reply);
}
@Test
public void exceptionThrowingFilterAccepts() {
exceptionInput.send(new StringMessage("test"));
exceptionInput.send(new GenericMessage<String>("test"));
Message<?> reply = implementationOutput.receive(0);
assertNotNull(reply);
}
@Test(expected = MessageRejectedException.class)
public void exceptionThrowingFilterRejects() {
exceptionInput.send(new StringMessage(""));
exceptionInput.send(new GenericMessage<String>(""));
}
@Test
public void filterWithDiscardChannel() {
discardInput.send(new StringMessage(""));
discardInput.send(new GenericMessage<String>(""));
Message<?> discard = discardOutput.receive(0);
assertNotNull(discard);
assertEquals("", discard.getPayload());
@@ -125,7 +125,7 @@ public class FilterParserTests {
public void filterWithDiscardChannelAndException() throws Exception {
Exception exception = null;
try {
discardAndExceptionInput.send(new StringMessage(""));
discardAndExceptionInput.send(new GenericMessage<String>(""));
}
catch (Exception e) {
exception = e;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.router.AbstractMessageRouter;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -62,7 +61,7 @@ public class RouterFactoryBeanDelegationTests {
@Test
public void routeWithMappedType() {
input.send(new StringMessage("test"));
input.send(new GenericMessage<String>("test"));
assertNull(discard.receive(0));
assertNotNull(strings.receive(0));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -28,8 +28,8 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.selector.MessageSelectorChain;
import org.springframework.integration.selector.MessageSelectorChain.VotingStrategy;
import org.springframework.test.context.ContextConfiguration;
@@ -55,7 +55,7 @@ public class SelectorChainParserTests {
assertEquals(VotingStrategy.ALL, this.getStrategy(chain));
assertEquals(selector1, selectors.get(0));
assertEquals(selector2, selectors.get(1));
assertTrue(chain.accept(new StringMessage("test")));
assertTrue(chain.accept(new GenericMessage<String>("test")));
}
@Test
@@ -87,10 +87,10 @@ public class SelectorChainParserTests {
assertEquals(VotingStrategy.MAJORITY_OR_TIE, this.getStrategy(chain4));
List<MessageSelector> selectorList4 = this.getSelectors(chain4);
assertEquals(selector6, selectorList4.get(0));
assertTrue(chain1.accept(new StringMessage("test1")));
assertTrue(chain2.accept(new StringMessage("test2")));
assertTrue(chain3.accept(new StringMessage("test3")));
assertTrue(chain4.accept(new StringMessage("test4")));
assertTrue(chain1.accept(new GenericMessage<String>("test1")));
assertTrue(chain2.accept(new GenericMessage<String>("test2")));
assertTrue(chain3.accept(new GenericMessage<String>("test3")));
assertTrue(chain4.accept(new GenericMessage<String>("test4")));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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,8 +29,8 @@ import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.test.util.TestUtils.TestApplicationContext;
@@ -54,7 +54,7 @@ public class ServiceActivatorAnnotationPostProcessorTests {
assertEquals(1, latch.getCount());
assertNull(testBean.getMessageText());
MessageChannel testChannel = (MessageChannel) context.getBean("testChannel");
testChannel.send(new StringMessage("test-123"));
testChannel.send(new GenericMessage<String>("test-123"));
latch.await(1000, TimeUnit.MILLISECONDS);
assertEquals(0, latch.getCount());
assertEquals("test-123", testBean.getMessageText());

View File

@@ -27,10 +27,11 @@ import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.scheduling.PollerMetadata;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.test.util.TestUtils.TestApplicationContext;
@@ -77,7 +78,7 @@ public class SourcePollingChannelAdapterFactoryBeanTests {
private static class TestSource implements MessageSource<String> {
public Message<String> receive() {
return new StringMessage("test");
return new GenericMessage<String>("test");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentMap;
import org.springframework.integration.Message;
import org.springframework.integration.aggregator.MessageSequenceComparator;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
/**
* @author Marius Bogoevici
@@ -47,7 +47,7 @@ public class TestAggregatorBean {
correlationId = message.getHeaders().getCorrelationId();
}
}
Message<?> returnedMessage = new StringMessage(buffer.toString());
Message<?> returnedMessage = new GenericMessage<String>(buffer.toString());
if (correlationId!=null) {
aggregatedMessages.put(correlationId, returnedMessage);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -17,17 +17,16 @@
package org.springframework.integration.config;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
*/
@SuppressWarnings("unchecked")
public class TestSource implements MessageSource {
public class TestSource implements MessageSource<String> {
public Message<?> receive() {
return new StringMessage("test");
public Message<String> receive() {
return new GenericMessage<String>("test");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,8 +23,8 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.core.StringMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -41,7 +41,7 @@ public class TopLevelSelectorParserTests {
@Test
public void topLevelSelector() {
MessageSelector selector = (MessageSelector) context.getBean("selector");
assertTrue(selector.accept(new StringMessage("test")));
assertTrue(selector.accept(new GenericMessage<String>("test")));
}
}

View File

@@ -28,9 +28,9 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.channel.interceptor.WireTap;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -44,7 +44,7 @@ public class WireTapParserTests {
MessageChannel mainChannel = (MessageChannel) context.getBean("noSelectors");
PollableChannel wireTapChannel = (PollableChannel) context.getBean("wireTapChannel");
assertNull(wireTapChannel.receive(0));
Message<?> original = new StringMessage("test");
Message<?> original = new GenericMessage<String>("test");
mainChannel.send(original);
Message<?> intercepted = wireTapChannel.receive(0);
assertNotNull(intercepted);
@@ -58,7 +58,7 @@ public class WireTapParserTests {
MessageChannel mainChannel = (MessageChannel) context.getBean("accepting");
PollableChannel wireTapChannel = (PollableChannel) context.getBean("wireTapChannel");
assertNull(wireTapChannel.receive(0));
Message<?> original = new StringMessage("test");
Message<?> original = new GenericMessage<String>("test");
mainChannel.send(original);
Message<?> intercepted = wireTapChannel.receive(0);
assertNotNull(intercepted);
@@ -72,7 +72,7 @@ public class WireTapParserTests {
MessageChannel mainChannel = (MessageChannel) context.getBean("rejecting");
PollableChannel wireTapChannel = (PollableChannel) context.getBean("wireTapChannel");
assertNull(wireTapChannel.receive(0));
Message<?> original = new StringMessage("test");
Message<?> original = new GenericMessage<String>("test");
mainChannel.send(original);
Message<?> intercepted = wireTapChannel.receive(0);
assertNull(intercepted);

View File

@@ -27,7 +27,7 @@ import org.springframework.integration.annotation.Filter;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.test.util.TestUtils.TestApplicationContext;
@@ -81,10 +81,10 @@ public class FilterAnnotationPostProcessorTests {
private void testValidFilter(Object filter) {
postProcessor.postProcessAfterInitialization(filter, "testFilter");
context.refresh();
inputChannel.send(new StringMessage("good"));
inputChannel.send(new GenericMessage<String>("good"));
Message<?> passed = outputChannel.receive(0);
assertNotNull(passed);
inputChannel.send(new StringMessage("bad"));
inputChannel.send(new GenericMessage<String>("bad"));
assertNull(outputChannel.receive(0));
context.stop();
}

View File

@@ -36,10 +36,10 @@ import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.context.BeanFactoryChannelResolver;
import org.springframework.integration.core.ChannelResolver;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.test.util.TestUtils.TestApplicationContext;
@@ -70,7 +70,7 @@ public class MessagingAnnotationPostProcessorTests {
"serviceActivatorAnnotationPostProcessorTests.xml", this.getClass());
MessageChannel inputChannel = (MessageChannel) context.getBean("inputChannel");
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
inputChannel.send(new StringMessage("world"));
inputChannel.send(new GenericMessage<String>("world"));
Message<?> reply = outputChannel.receive(0);
assertEquals("hello world", reply.getPayload());
context.stop();
@@ -82,7 +82,7 @@ public class MessagingAnnotationPostProcessorTests {
context.start();
MessageChannel inputChannel = (MessageChannel) context.getBean("inputChannel");
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
inputChannel.send(new StringMessage("world"));
inputChannel.send(new GenericMessage<String>("world"));
Message<?> message = outputChannel.receive(1000);
assertEquals("hello world", message.getPayload());
context.stop();
@@ -95,7 +95,7 @@ public class MessagingAnnotationPostProcessorTests {
context.start();
MessageChannel inputChannel = (MessageChannel) context.getBean("inputChannel");
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
inputChannel.send(new StringMessage("world"));
inputChannel.send(new GenericMessage<String>("world"));
Message<?> message = outputChannel.receive(1000);
assertEquals("hello world", message.getPayload());
context.stop();
@@ -108,7 +108,7 @@ public class MessagingAnnotationPostProcessorTests {
context.start();
MessageChannel inputChannel = (MessageChannel) context.getBean("inputChannel");
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
inputChannel.send(new StringMessage("123"));
inputChannel.send(new GenericMessage<String>("123"));
Message<?> message = outputChannel.receive(1000);
assertEquals(246, message.getPayload());
context.stop();
@@ -127,7 +127,7 @@ public class MessagingAnnotationPostProcessorTests {
context.refresh();
ChannelResolver channelResolver = new BeanFactoryChannelResolver(context);
MessageChannel testChannel = channelResolver.resolveChannelName("testChannel");
testChannel.send(new StringMessage("foo"));
testChannel.send(new GenericMessage<String>("foo"));
latch.await(1000, TimeUnit.MILLISECONDS);
assertEquals(0, latch.getCount());
assertEquals("foo", testBean.getMessageText());
@@ -176,7 +176,7 @@ public class MessagingAnnotationPostProcessorTests {
Object proxy = proxyFactory.getProxy();
postProcessor.postProcessAfterInitialization(proxy, "proxy");
context.refresh();
inputChannel.send(new StringMessage("world"));
inputChannel.send(new GenericMessage<String>("world"));
Message<?> message = outputChannel.receive(1000);
assertEquals("hello world", message.getPayload());
context.stop();
@@ -194,7 +194,7 @@ public class MessagingAnnotationPostProcessorTests {
postProcessor.afterPropertiesSet();
postProcessor.postProcessAfterInitialization(new SimpleAnnotatedEndpointSubclass(), "subclass");
context.refresh();
inputChannel.send(new StringMessage("world"));
inputChannel.send(new GenericMessage<String>("world"));
Message<?> message = outputChannel.receive(1000);
assertEquals("hello world", message.getPayload());
context.stop();
@@ -214,7 +214,7 @@ public class MessagingAnnotationPostProcessorTests {
Object proxy = proxyFactory.getProxy();
postProcessor.postProcessAfterInitialization(proxy, "proxy");
context.refresh();
inputChannel.send(new StringMessage("world"));
inputChannel.send(new GenericMessage<String>("world"));
Message<?> message = outputChannel.receive(1000);
assertEquals("hello world", message.getPayload());
context.stop();
@@ -232,7 +232,7 @@ public class MessagingAnnotationPostProcessorTests {
postProcessor.afterPropertiesSet();
postProcessor.postProcessAfterInitialization(new SimpleAnnotatedEndpointImplementation(), "impl");
context.refresh();
inputChannel.send(new StringMessage("ABC"));
inputChannel.send(new GenericMessage<String>("ABC"));
Message<?> message = outputChannel.receive(1000);
assertEquals("test-ABC", message.getPayload());
context.stop();
@@ -250,7 +250,7 @@ public class MessagingAnnotationPostProcessorTests {
postProcessor.afterPropertiesSet();
postProcessor.postProcessAfterInitialization(new SimpleAnnotatedEndpointImplementation(), "impl");
context.refresh();
inputChannel.send(new StringMessage("ABC"));
inputChannel.send(new GenericMessage<String>("ABC"));
Message<?> message = outputChannel.receive(1000);
assertEquals("test-ABC", message.getPayload());
context.stop();
@@ -270,7 +270,7 @@ public class MessagingAnnotationPostProcessorTests {
Object proxy = proxyFactory.getProxy();
postProcessor.postProcessAfterInitialization(proxy, "proxy");
context.refresh();
inputChannel.send(new StringMessage("ABC"));
inputChannel.send(new GenericMessage<String>("ABC"));
Message<?> message = outputChannel.receive(1000);
assertEquals("test-ABC", message.getPayload());
context.stop();
@@ -289,7 +289,7 @@ public class MessagingAnnotationPostProcessorTests {
TransformerAnnotationTestBean testBean = new TransformerAnnotationTestBean();
postProcessor.postProcessAfterInitialization(testBean, "testBean");
context.refresh();
inputChannel.send(new StringMessage("foo"));
inputChannel.send(new GenericMessage<String>("foo"));
Message<?> reply = outputChannel.receive(0);
assertEquals("FOO", reply.getPayload());
context.stop();

View File

@@ -26,7 +26,7 @@ import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.Router;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.test.util.TestUtils.TestApplicationContext;
@@ -57,7 +57,7 @@ public class RouterAnnotationPostProcessorTests {
TestRouter testRouter = new TestRouter();
postProcessor.postProcessAfterInitialization(testRouter, "test");
context.refresh();
inputChannel.send(new StringMessage("foo"));
inputChannel.send(new GenericMessage<String>("foo"));
Message<?> replyMessage = outputChannel.receive(0);
assertEquals("foo", replyMessage.getPayload());
context.stop();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -28,7 +28,7 @@ import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.Splitter;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.test.util.TestUtils.TestApplicationContext;
@@ -59,7 +59,7 @@ public class SplitterAnnotationPostProcessorTests {
TestSplitter splitter = new TestSplitter();
postProcessor.postProcessAfterInitialization(splitter, "testSplitter");
context.refresh();
inputChannel.send(new StringMessage("this.is.a.test"));
inputChannel.send(new GenericMessage<String>("this.is.a.test"));
Message<?> message1 = outputChannel.receive(500);
assertNotNull(message1);
assertEquals("this", message1.getPayload());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,8 +32,8 @@ import org.springframework.integration.MessageRejectedException;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
/**
@@ -53,11 +53,11 @@ public class SubscriberOrderTests {
context.refresh();
TestBean testBean = (TestBean) context.getBean("testBean");
MessageChannel channel = (MessageChannel) context.getBean("input");
channel.send(new StringMessage("test-1"));
channel.send(new StringMessage("test-2"));
channel.send(new StringMessage("test-3"));
channel.send(new StringMessage("test-4"));
channel.send(new StringMessage("test-5"));
channel.send(new GenericMessage<String>("test-1"));
channel.send(new GenericMessage<String>("test-2"));
channel.send(new GenericMessage<String>("test-3"));
channel.send(new GenericMessage<String>("test-4"));
channel.send(new GenericMessage<String>("test-5"));
List<Integer> calls = testBean.calls;
assertEquals(5, calls.size());
assertEquals(1, calls.get(0).intValue());
@@ -81,16 +81,16 @@ public class SubscriberOrderTests {
context.refresh();
TestBean testBean = (TestBean) context.getBean("testBean");
MessageChannel channel = (MessageChannel) context.getBean("input");
channel.send(new StringMessage("test-1"));
channel.send(new StringMessage("test-2"));
channel.send(new StringMessage("test-3"));
channel.send(new StringMessage("test-4"));
channel.send(new StringMessage("test-5"));
channel.send(new StringMessage("test-6"));
channel.send(new StringMessage("test-7"));
channel.send(new StringMessage("test-8"));
channel.send(new StringMessage("test-9"));
channel.send(new StringMessage("test-10"));
channel.send(new GenericMessage<String>("test-1"));
channel.send(new GenericMessage<String>("test-2"));
channel.send(new GenericMessage<String>("test-3"));
channel.send(new GenericMessage<String>("test-4"));
channel.send(new GenericMessage<String>("test-5"));
channel.send(new GenericMessage<String>("test-6"));
channel.send(new GenericMessage<String>("test-7"));
channel.send(new GenericMessage<String>("test-8"));
channel.send(new GenericMessage<String>("test-9"));
channel.send(new GenericMessage<String>("test-10"));
assertEquals(10, testBean.calls.size());
assertEquals(1, testBean.calls.get(0).intValue());
assertEquals(1, testBean.calls.get(1).intValue());
@@ -103,7 +103,7 @@ public class SubscriberOrderTests {
assertEquals(5, testBean.calls.get(8).intValue());
assertEquals(5, testBean.calls.get(9).intValue());
testBean.reset();
channel.send(new StringMessage("test-11"));
channel.send(new GenericMessage<String>("test-11"));
assertEquals(1, testBean.calls.size());
assertEquals(1, testBean.calls.get(0).intValue());
}
@@ -121,11 +121,11 @@ public class SubscriberOrderTests {
context.refresh();
TestBean testBean = (TestBean) context.getBean("testBean");
MessageChannel channel = (MessageChannel) context.getBean("input");
channel.send(new StringMessage("test-1"));
channel.send(new StringMessage("test-2"));
channel.send(new StringMessage("test-3"));
channel.send(new StringMessage("test-4"));
channel.send(new StringMessage("test-5"));
channel.send(new GenericMessage<String>("test-1"));
channel.send(new GenericMessage<String>("test-2"));
channel.send(new GenericMessage<String>("test-3"));
channel.send(new GenericMessage<String>("test-4"));
channel.send(new GenericMessage<String>("test-5"));
List<Integer> calls = testBean.calls;
assertEquals(5, calls.size());
assertEquals(1, calls.get(0).intValue());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentMap;
import org.springframework.integration.Message;
import org.springframework.integration.aggregator.MessageSequenceComparator;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.stereotype.Component;
/**
@@ -53,7 +53,7 @@ public class TestAnnotatedEndpointWithCustomizedAggregator {
correlationId = message.getHeaders().getCorrelationId();
}
}
Message<?> returnedMessage = new StringMessage(buffer.toString());
Message<?> returnedMessage = new GenericMessage<String>(buffer.toString());
aggregatedMessages.put(correlationId, returnedMessage);
return returnedMessage;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.integration.Message;
import org.springframework.integration.aggregator.MessageSequenceComparator;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
/**
* @author Marius Bogoevici
@@ -48,7 +48,7 @@ public class TestAnnotatedEndpointWithDefaultAggregator {
correlationId = message.getHeaders().getCorrelationId();
}
}
Message<?> returnedMessage = new StringMessage(buffer.toString());
Message<?> returnedMessage = new GenericMessage<String>(buffer.toString());
aggregatedMessages.put(correlationId, returnedMessage);
return returnedMessage;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -25,9 +25,9 @@ import java.util.concurrent.ConcurrentMap;
import org.springframework.integration.Message;
import org.springframework.integration.aggregator.MessageSequenceComparator;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.annotation.ReleaseStrategy;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.annotation.ReleaseStrategy;
import org.springframework.integration.core.GenericMessage;
/**
* @author Marius Bogoevici
@@ -49,7 +49,7 @@ public class TestAnnotatedEndpointWithReleaseStrategy {
correlationId = message.getHeaders().getCorrelationId();
}
}
Message<?> returnedMessage = new StringMessage(buffer.toString());
Message<?> returnedMessage = new GenericMessage<String>(buffer.toString());
aggregatedMessages.put(correlationId, returnedMessage);
return returnedMessage;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,15 +21,16 @@ import static org.junit.Assert.assertThat;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.message.MessageMatcher;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
@@ -68,7 +69,7 @@ public class BridgeParserTests extends AbstractJUnit4SpringContextTests {
@Test
public void pollableChannel() {
Message<?> message = new StringMessage("test1");
Message<?> message = new GenericMessage<String>("test1");
this.pollableChannel.send(message);
Message<?> reply = this.output1.receive(6000);
assertThat(message, sameExceptImmutableHeaders(reply));
@@ -76,7 +77,7 @@ public class BridgeParserTests extends AbstractJUnit4SpringContextTests {
@Test
public void subscribableChannel() {
Message<?> message = new StringMessage("test2");
Message<?> message = new GenericMessage<String>("test2");
this.subscribableChannel.send(message);
Message<?> reply = this.output2.receive(0);
assertThat(message, sameExceptImmutableHeaders(reply));

View File

@@ -13,18 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.config.xml;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -49,7 +51,7 @@ public class DelayerUsageTests {
@Test
public void testDelayWithDefaultScheduler(){
long start = System.currentTimeMillis();
inputA.send(new StringMessage("Hello"));
inputA.send(new GenericMessage<String>("Hello"));
outputA.receive();
assertTrue((System.currentTimeMillis() - start) >= 1000);
}
@@ -66,13 +68,13 @@ public class DelayerUsageTests {
@Test
public void testDelayWithCustomScheduler(){
long start = System.currentTimeMillis();
inputB.send(new StringMessage("1"));
inputB.send(new StringMessage("2"));
inputB.send(new StringMessage("3"));
inputB.send(new StringMessage("4"));
inputB.send(new StringMessage("5"));
inputB.send(new StringMessage("6"));
inputB.send(new StringMessage("7"));
inputB.send(new GenericMessage<String>("1"));
inputB.send(new GenericMessage<String>("2"));
inputB.send(new GenericMessage<String>("3"));
inputB.send(new GenericMessage<String>("4"));
inputB.send(new GenericMessage<String>("5"));
inputB.send(new GenericMessage<String>("6"));
inputB.send(new GenericMessage<String>("7"));
outputB1.receive();
outputB1.receive();
outputB1.receive();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -25,10 +25,10 @@ import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.gateway.TestService;
/**
@@ -50,7 +50,7 @@ public class GatewayParserTests {
public void testSolicitResponse() {
ApplicationContext context = new ClassPathXmlApplicationContext("gatewayParserTests.xml", this.getClass());
PollableChannel channel = (PollableChannel) context.getBean("replyChannel");
channel.send(new StringMessage("foo"));
channel.send(new GenericMessage<String>("foo"));
TestService service = (TestService) context.getBean("solicitResponse");
String result = service.solicitResponse();
assertEquals("foo", result);

View File

@@ -28,10 +28,10 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.gateway.SimpleMessagingGateway;
import org.springframework.integration.transformer.MessageTransformationException;
import org.springframework.test.context.ContextConfiguration;
@@ -52,7 +52,7 @@ public class HeaderEnricherTests {
public void replyChannel() {
PollableChannel replyChannel = context.getBean("testReplyChannel", PollableChannel.class);
MessageChannel inputChannel = context.getBean("replyChannelInput", MessageChannel.class);
inputChannel.send(new StringMessage("test"));
inputChannel.send(new GenericMessage<String>("test"));
Message<?> result = replyChannel.receive(0);
assertNotNull(result);
assertEquals("TEST", result.getPayload());
@@ -63,7 +63,7 @@ public class HeaderEnricherTests {
public void errorChannel() {
PollableChannel errorChannel = context.getBean("testErrorChannel", PollableChannel.class);
MessageChannel inputChannel = context.getBean("errorChannelInput", MessageChannel.class);
inputChannel.send(new StringMessage("test"));
inputChannel.send(new GenericMessage<String>("test"));
Message<?> errorMessage = errorChannel.receive(1000);
assertNotNull(errorMessage);
Object errorPayload = errorMessage.getPayload();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,20 @@
package org.springframework.integration.config.xml;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import junit.framework.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
@@ -28,21 +39,16 @@ import org.springframework.core.io.InputStreamResource;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.io.ByteArrayInputStream;
import java.util.*;
import static org.junit.Assert.assertEquals;
/**
* @author Oleg Zhurakousky
*/
@@ -257,7 +263,7 @@ public class InnerDefinitionHandlerAwareEndpointParserTests {
ApplicationContext ac = this.bootStrap(configProperty);
MessageChannel input = (MessageChannel) ac.getBean("inChannel");
PollableChannel output = (PollableChannel) ac.getBean("outChannel");
input.send(new StringMessage("foo"));
input.send(new GenericMessage<String>("foo"));
Message<?> reply = output.receive(0);
assertEquals("foo", reply.getPayload());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -28,7 +28,6 @@ import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -54,7 +53,7 @@ public class ObjectToStringTransformerParserTests {
@Test
public void directChannelWithStringMessage() {
directInput.send(new StringMessage("foo"));
directInput.send(new GenericMessage<String>("foo"));
Message<?> result = output.receive(0);
assertNotNull(result);
assertEquals("foo", result.getPayload());
@@ -62,7 +61,7 @@ public class ObjectToStringTransformerParserTests {
@Test
public void queueChannelWithStringMessage() {
queueInput.send(new StringMessage("foo"));
queueInput.send(new GenericMessage<String>("foo"));
Message<?> result = output.receive(3000);
assertNotNull(result);
assertEquals("foo", result.getPayload());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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,6 @@ import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.transformer.MessageTransformationException;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -60,7 +59,7 @@ public class PayloadSerializingTransformerParserTests {
@Test
public void directChannelWithStringMessage() throws Exception {
directInput.send(new StringMessage("foo"));
directInput.send(new GenericMessage<String>("foo"));
Message<?> result = output.receive(0);
assertNotNull(result);
assertTrue(result.getPayload() instanceof byte[]);
@@ -69,7 +68,7 @@ public class PayloadSerializingTransformerParserTests {
@Test
public void queueChannelWithStringMessage() throws Exception {
queueInput.send(new StringMessage("foo"));
queueInput.send(new GenericMessage<String>("foo"));
Message<?> result = output.receive(3000);
assertNotNull(result);
assertTrue(result.getPayload() instanceof byte[]);

View File

@@ -36,7 +36,7 @@ public class MessageHistoryTests {
@Test
public void addComponents() {
StringMessage original = new StringMessage("foo");
GenericMessage<String> original = new GenericMessage<String>("foo");
assertNull(MessageHistory.read(original));
Message<String> result1 = MessageHistory.write(original, new TestComponent(1));
MessageHistory history1 = MessageHistory.read(result1);

View File

@@ -16,25 +16,26 @@
package org.springframework.integration.dispatcher;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.matchers.JUnitMatchers;
import org.springframework.integration.Message;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.core.StringMessage;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.util.Arrays;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.matchers.JUnitMatchers;
import org.springframework.integration.Message;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.core.GenericMessage;
/**
* @author Iwein Fuld
*/
public class AggregateMessageDeliveryExceptionTests {
private Message<?> message = new StringMessage("foo");
private Message<?> message = new GenericMessage<String>("foo");
private AggregateMessageDeliveryException exception = new AggregateMessageDeliveryException(message,
"something went wrong", exceptionsList());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,9 +37,9 @@ import org.junit.Test;
import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -247,7 +247,7 @@ public class BroadcastingDispatcherTests {
MessageHandler target2 = new MessageStoringTestEndpoint(messages);
dispatcher.addHandler(target1);
dispatcher.addHandler(target2);
dispatcher.dispatch(new StringMessage("test"));
dispatcher.dispatch(new GenericMessage<String>("test"));
assertEquals(2, messages.size());
assertEquals(0, (int) messages.get(0).getHeaders().getSequenceNumber());
assertEquals(0, (int) messages.get(0).getHeaders().getSequenceSize());
@@ -266,7 +266,7 @@ public class BroadcastingDispatcherTests {
dispatcher.addHandler(target1);
dispatcher.addHandler(target2);
dispatcher.addHandler(target3);
Message<?> inputMessage = new StringMessage("test");
Message<?> inputMessage = new GenericMessage<String>("test");
Object originalId = inputMessage.getHeaders().getId();
dispatcher.dispatch(inputMessage);
assertEquals(3, messages.size());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -28,8 +28,8 @@ import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.MessageRejectedException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.handler.ServiceActivatingHandler;
import org.springframework.integration.message.TestHandlers;
@@ -43,7 +43,7 @@ public class FailOverDispatcherTests {
UnicastingDispatcher dispatcher = new UnicastingDispatcher();
final CountDownLatch latch = new CountDownLatch(1);
dispatcher.addHandler(createConsumer(TestHandlers.countDownHandler(latch)));
dispatcher.dispatch(new StringMessage("test"));
dispatcher.dispatch(new GenericMessage<String>("test"));
latch.await(500, TimeUnit.MILLISECONDS);
assertEquals(0, latch.getCount());
}
@@ -56,7 +56,7 @@ public class FailOverDispatcherTests {
final AtomicInteger counter2 = new AtomicInteger();
dispatcher.addHandler(createConsumer(TestHandlers.countingCountDownHandler(counter1, latch)));
dispatcher.addHandler(createConsumer(TestHandlers.countingCountDownHandler(counter2, latch)));
dispatcher.dispatch(new StringMessage("test"));
dispatcher.dispatch(new GenericMessage<String>("test"));
latch.await(500, TimeUnit.MILLISECONDS);
assertEquals(0, latch.getCount());
assertEquals("only 1 handler should have received the message", 1, counter1.get() + counter2.get());
@@ -70,7 +70,7 @@ public class FailOverDispatcherTests {
dispatcher.addHandler(target);
dispatcher.addHandler(target);
try {
dispatcher.dispatch(new StringMessage("test"));
dispatcher.dispatch(new GenericMessage<String>("test"));
}
catch (Exception e) {
// ignore
@@ -90,7 +90,7 @@ public class FailOverDispatcherTests {
dispatcher.addHandler(target3);
dispatcher.removeHandler(target2);
try {
dispatcher.dispatch(new StringMessage("test"));
dispatcher.dispatch(new GenericMessage<String>("test"));
}
catch (Exception e) {
// ignore
@@ -109,7 +109,7 @@ public class FailOverDispatcherTests {
dispatcher.addHandler(target2);
dispatcher.addHandler(target3);
try {
dispatcher.dispatch(new StringMessage("test1"));
dispatcher.dispatch(new GenericMessage<String>("test1"));
}
catch (Exception e) {
// ignore
@@ -117,7 +117,7 @@ public class FailOverDispatcherTests {
assertEquals(3, counter.get());
dispatcher.removeHandler(target2);
try {
dispatcher.dispatch(new StringMessage("test2"));
dispatcher.dispatch(new GenericMessage<String>("test2"));
}
catch (Exception e) {
// ignore
@@ -125,7 +125,7 @@ public class FailOverDispatcherTests {
assertEquals(5, counter.get());
dispatcher.removeHandler(target1);
try {
dispatcher.dispatch(new StringMessage("test3"));
dispatcher.dispatch(new GenericMessage<String>("test3"));
}
catch (Exception e) {
// ignore
@@ -140,14 +140,14 @@ public class FailOverDispatcherTests {
MessageHandler target = new CountingTestEndpoint(counter, false);
dispatcher.addHandler(target);
try {
dispatcher.dispatch(new StringMessage("test1"));
dispatcher.dispatch(new GenericMessage<String>("test1"));
}
catch (Exception e) {
// ignore
}
assertEquals(1, counter.get());
dispatcher.removeHandler(target);
dispatcher.dispatch(new StringMessage("test2"));
dispatcher.dispatch(new GenericMessage<String>("test2"));
}
@Test
@@ -160,7 +160,7 @@ public class FailOverDispatcherTests {
dispatcher.addHandler(target1);
dispatcher.addHandler(target2);
dispatcher.addHandler(target3);
assertTrue(dispatcher.dispatch(new StringMessage("test")));
assertTrue(dispatcher.dispatch(new GenericMessage<String>("test")));
assertEquals("only the first target should have been invoked", 1, counter.get());
}
@@ -174,7 +174,7 @@ public class FailOverDispatcherTests {
dispatcher.addHandler(target1);
dispatcher.addHandler(target2);
dispatcher.addHandler(target3);
assertTrue(dispatcher.dispatch(new StringMessage("test")));
assertTrue(dispatcher.dispatch(new GenericMessage<String>("test")));
assertEquals("first two targets should have been invoked", 2, counter.get());
}
@@ -189,7 +189,7 @@ public class FailOverDispatcherTests {
dispatcher.addHandler(target2);
dispatcher.addHandler(target3);
try {
assertFalse(dispatcher.dispatch(new StringMessage("test")));
assertFalse(dispatcher.dispatch(new GenericMessage<String>("test")));
}
catch (Exception e) {
// ignore

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -24,9 +24,9 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.util.TestTransactionManager;
import org.springframework.transaction.IllegalTransactionStateException;
import org.springframework.transaction.annotation.Propagation;
@@ -45,7 +45,7 @@ public class PollingTransactionTests {
PollableChannel output = (PollableChannel) context.getBean("output");
assertEquals(0, txManager.getCommitCount());
assertEquals(0, txManager.getRollbackCount());
input.send(new StringMessage("test"));
input.send(new GenericMessage<String>("test"));
txManager.waitForCompletion(1000);
Message<?> message = output.receive(0);
assertNotNull(message);
@@ -63,7 +63,7 @@ public class PollingTransactionTests {
PollableChannel output = (PollableChannel) context.getBean("output");
assertEquals(0, txManager.getCommitCount());
assertEquals(0, txManager.getRollbackCount());
input.send(new StringMessage("test"));
input.send(new GenericMessage<String>("test"));
txManager.waitForCompletion(1000);
Message<?> message = output.receive(0);
assertNull(message);
@@ -80,7 +80,7 @@ public class PollingTransactionTests {
PollableChannel input = (PollableChannel) context.getBean("input");
PollableChannel output = (PollableChannel) context.getBean("output");
assertEquals(0, txManager.getCommitCount());
input.send(new StringMessage("test"));
input.send(new GenericMessage<String>("test"));
Message<?> reply = output.receive(3000);
assertNotNull(reply);
txManager.waitForCompletion(3000);
@@ -97,7 +97,7 @@ public class PollingTransactionTests {
PollableChannel input = (PollableChannel) context.getBean("input");
PollableChannel output = (PollableChannel) context.getBean("output");
assertEquals(0, txManager.getCommitCount());
input.send(new StringMessage("test"));
input.send(new GenericMessage<String>("test"));
Message<?> reply = output.receive(3000);
assertNotNull(reply);
txManager.waitForCompletion(3000);
@@ -114,7 +114,7 @@ public class PollingTransactionTests {
PollableChannel input = (PollableChannel) context.getBean("input");
PollableChannel output = (PollableChannel) context.getBean("output");
assertEquals(0, txManager.getCommitCount());
input.send(new StringMessage("test"));
input.send(new GenericMessage<String>("test"));
Message<?> reply = output.receive(3000);
assertNotNull(reply);
assertEquals(0, txManager.getCommitCount());
@@ -130,7 +130,7 @@ public class PollingTransactionTests {
PollableChannel input = (PollableChannel) context.getBean("input");
PollableChannel output = (PollableChannel) context.getBean("output");
assertEquals(0, txManager.getCommitCount());
input.send(new StringMessage("test"));
input.send(new GenericMessage<String>("test"));
Message<?> reply = output.receive(3000);
assertNotNull(reply);
assertEquals(0, txManager.getCommitCount());
@@ -147,7 +147,7 @@ public class PollingTransactionTests {
PollableChannel output = (PollableChannel) context.getBean("output");
PollableChannel errorChannel = (PollableChannel) context.getBean("errorChannel");
assertEquals(0, txManager.getCommitCount());
input.send(new StringMessage("test"));
input.send(new GenericMessage<String>("test"));
Message<?> errorMessage = errorChannel.receive(3000);
assertNotNull(errorMessage);
Object payload = errorMessage.getPayload();

View File

@@ -20,11 +20,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.handler.ServiceActivatingHandler;
import org.springframework.integration.splitter.AbstractMessageSplitter;
import org.springframework.integration.splitter.MethodInvokingSplitter;
@@ -85,7 +86,7 @@ public class CorrelationIdTests {
@Test
public void testCorrelationNotCopiedFromRequestMessgeIdIfAlreadySetByHandler() throws Exception {
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
DirectChannel inputChannel = new DirectChannel();
QueueChannel outputChannel = new QueueChannel(1);
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(new TestBean(), "createMessage");
@@ -99,7 +100,7 @@ public class CorrelationIdTests {
@Test
public void testCorrelationIdWithSplitterWhenNotValueSetOnIncomingMessage() throws Exception {
Message<?> message = new StringMessage("test1,test2");
Message<?> message = new GenericMessage<String>("test1,test2");
QueueChannel testChannel = new QueueChannel();
MethodInvokingSplitter splitter = new MethodInvokingSplitter(
new TestBean(), TestBean.class.getMethod("split", String.class));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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,9 +36,9 @@ import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.MessageRejectedException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@@ -57,9 +57,9 @@ public class PollingConsumerEndpointTests {
private TestConsumer consumer = new TestConsumer();
private Message message = new StringMessage("test");
private Message message = new GenericMessage<String>("test");
private Message badMessage = new StringMessage("bad");
private Message badMessage = new GenericMessage<String>("bad");
private TestErrorHandler errorHandler = new TestErrorHandler();

View File

@@ -25,10 +25,10 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.core.ChannelResolutionException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -105,7 +105,7 @@ public class ReturnAddressTests {
"returnAddressTests.xml", this.getClass());
MessageChannel channel3 = (MessageChannel) context.getBean("channel3");
context.start();
StringMessage message = new StringMessage("*");
GenericMessage<String> message = new GenericMessage<String>("*");
channel3.send(message);
}
@@ -116,7 +116,7 @@ public class ReturnAddressTests {
MessageChannel channel4 = (MessageChannel) context.getBean("channel4");
PollableChannel replyChannel = (PollableChannel) context.getBean("replyChannel");
context.start();
StringMessage message = new StringMessage("*");
GenericMessage<String> message = new GenericMessage<String>("*");
channel4.send(message);
Message<?> response = replyChannel.receive(3000);
assertNotNull(response);

View File

@@ -28,8 +28,8 @@ import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.MessagingException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.channel.TestChannelResolver;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.handler.ServiceActivatingHandler;
/**
@@ -100,7 +100,7 @@ public class ServiceActivatorEndpointTests {
Object handler = new Object() {
@SuppressWarnings("unused")
public Message<?> handle(Message<?> message) {
return new StringMessage("foo" + message.getPayload());
return new GenericMessage<String>("foo" + message.getPayload());
}
};
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(handler, "handle");
@@ -210,7 +210,7 @@ public class ServiceActivatorEndpointTests {
@SuppressWarnings("unused")
public Message<?> handle(Message<?> message) {
return new StringMessage(message.getPayload().toString().toUpperCase());
return new GenericMessage<String>(message.getPayload().toString().toUpperCase());
}
}

View File

@@ -23,7 +23,7 @@ import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.handler.ServiceActivatingHandler;
/**
@@ -37,7 +37,7 @@ public class ServiceActivatorMethodResolutionTests {
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(testBean);
QueueChannel outputChannel = new QueueChannel();
serviceActivator.setOutputChannel(outputChannel);
serviceActivator.handleMessage(new StringMessage("foo"));
serviceActivator.handleMessage(new GenericMessage<String>("foo"));
Message<?> result = outputChannel.receive(0);
assertEquals("FOO", result.getPayload());
}
@@ -54,7 +54,7 @@ public class ServiceActivatorMethodResolutionTests {
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(testBean);
QueueChannel outputChannel = new QueueChannel();
serviceActivator.setOutputChannel(outputChannel);
serviceActivator.handleMessage(new StringMessage("foo"));
serviceActivator.handleMessage(new GenericMessage<String>("foo"));
Message<?> result = outputChannel.receive(0);
assertEquals("FOO", result.getPayload());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -19,7 +19,7 @@ package org.springframework.integration.endpoint.annotation;
import org.springframework.integration.Message;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
/**
* @author Mark Fisher
@@ -28,8 +28,8 @@ import org.springframework.integration.core.StringMessage;
public class MessageParameterAnnotatedEndpoint {
@ServiceActivator(inputChannel="inputChannel", outputChannel="outputChannel")
public StringMessage sayHello(Message<?> message) {
return new StringMessage("hello " + message.getPayload());
public Message<String> sayHello(Message<?> message) {
return new GenericMessage<String>("hello " + message.getPayload());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -24,9 +24,9 @@ import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -39,7 +39,7 @@ public class FilterContextTests {
"filterContextTests.xml", this.getClass());
MessageChannel input = (MessageChannel) context.getBean("input");
PollableChannel output = (PollableChannel) context.getBean("output");
input.send(new StringMessage("foo"));
input.send(new GenericMessage<String>("foo"));
Message<?> reply = output.receive(0);
assertNull(reply);
}
@@ -50,7 +50,7 @@ public class FilterContextTests {
"filterContextTests.xml", this.getClass());
MessageChannel input = (MessageChannel) context.getBean("input");
PollableChannel output = (PollableChannel) context.getBean("output");
input.send(new StringMessage("foobar"));
input.send(new GenericMessage<String>("foobar"));
Message<?> reply = output.receive(0);
assertEquals("foobar", reply.getPayload());
}

View File

@@ -27,10 +27,9 @@ import org.springframework.integration.Message;
import org.springframework.integration.MessageRejectedException;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.filter.MessageFilter;
/**
* @author Mark Fisher
@@ -44,7 +43,7 @@ public class MessageFilterTests {
return true;
}
});
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
QueueChannel output = new QueueChannel();
filter.setOutputChannel(output);
filter.handleMessage(message);
@@ -62,7 +61,7 @@ public class MessageFilterTests {
});
QueueChannel output = new QueueChannel();
filter.setOutputChannel(output);
filter.handleMessage(new StringMessage("test"));
filter.handleMessage(new GenericMessage<String>("test"));
assertNull(output.receive(0));
}
@@ -76,7 +75,7 @@ public class MessageFilterTests {
filter.setThrowExceptionOnRejection(true);
QueueChannel output = new QueueChannel();
filter.setOutputChannel(output);
filter.handleMessage(new StringMessage("test"));
filter.handleMessage(new GenericMessage<String>("test"));
}
@Test
@@ -91,7 +90,7 @@ public class MessageFilterTests {
filter.setOutputChannel(outputChannel);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter);
endpoint.start();
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
assertTrue(inputChannel.send(message));
Message<?> reply = outputChannel.receive(0);
assertNotNull(reply);
@@ -110,7 +109,7 @@ public class MessageFilterTests {
filter.setOutputChannel(outputChannel);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter);
endpoint.start();
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
assertTrue(inputChannel.send(message));
assertNull(outputChannel.receive(0));
}
@@ -128,7 +127,7 @@ public class MessageFilterTests {
filter.setThrowExceptionOnRejection(true);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter);
endpoint.start();
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
assertTrue(inputChannel.send(message));
}
@@ -146,7 +145,7 @@ public class MessageFilterTests {
filter.setDiscardChannel(discardChannel);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter);
endpoint.start();
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
assertTrue(inputChannel.send(message));
Message<?> reply = discardChannel.receive(0);
assertNotNull(reply);
@@ -169,7 +168,7 @@ public class MessageFilterTests {
filter.setThrowExceptionOnRejection(true);
EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter);
endpoint.start();
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
try {
assertTrue(inputChannel.send(message));
}

View File

@@ -25,7 +25,6 @@ import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -36,7 +35,7 @@ public class MethodInvokingSelectorTests {
@Test
public void acceptedWithMethodName() {
MethodInvokingSelector selector = new MethodInvokingSelector(new TestBean(), "acceptString");
assertTrue(selector.accept(new StringMessage("should accept")));
assertTrue(selector.accept(new GenericMessage<String>("should accept")));
}
@Test
@@ -44,7 +43,7 @@ public class MethodInvokingSelectorTests {
TestBean testBean = new TestBean();
Method method = testBean.getClass().getMethod("acceptString", new Class[] { Message.class });
MethodInvokingSelector selector = new MethodInvokingSelector(testBean, method);
assertTrue(selector.accept(new StringMessage("should accept")));
assertTrue(selector.accept(new GenericMessage<String>("should accept")));
}
@Test
@@ -64,7 +63,7 @@ public class MethodInvokingSelectorTests {
@Test
public void noArgMethodWithMethodName() {
MethodInvokingSelector selector = new MethodInvokingSelector(new TestBean(), "noArgs");
selector.accept(new StringMessage("test"));
selector.accept(new GenericMessage<String>("test"));
}
@Test
@@ -77,7 +76,7 @@ public class MethodInvokingSelectorTests {
@Test(expected = IllegalArgumentException.class)
public void voidReturningMethodWithMethodName() {
MethodInvokingSelector selector = new MethodInvokingSelector(new TestBean(), "returnVoid");
selector.accept(new StringMessage("test"));
selector.accept(new GenericMessage<String>("test"));
}
@Test(expected = IllegalArgumentException.class)
@@ -85,7 +84,7 @@ public class MethodInvokingSelectorTests {
TestBean testBean = new TestBean();
Method method = testBean.getClass().getMethod("returnVoid", new Class[] { Message.class });
MethodInvokingSelector selector = new MethodInvokingSelector(testBean, method);
selector.accept(new StringMessage("test"));
selector.accept(new GenericMessage<String>("test"));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -20,13 +20,14 @@ import junit.framework.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.integration.mapping.InboundMessageMapper;
import org.springframework.test.context.ContextConfiguration;
@@ -80,7 +81,7 @@ public class GatewayInvokingMessageHandlerTests {
Assert.assertEquals("oleg", message.getHeaders().get("name"));
}
});
channel.send(new StringMessage("hello"));
channel.send(new GenericMessage<String>("hello"));
}
@Test
@@ -177,7 +178,7 @@ public class GatewayInvokingMessageHandlerTests {
}
public MessageHandlingException echoWithMessagingException(String value) {
throw new MessageHandlingException(new StringMessage(value));
throw new MessageHandlingException(new GenericMessage<String>(value));
}
public RuntimeException echoWithErrorAsync(String value) {
throw new RuntimeException(value);

View File

@@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -38,10 +39,10 @@ import org.springframework.integration.Message;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.util.ReflectionUtils;
@@ -110,7 +111,7 @@ public class GatewayProxyFactoryBeanTests {
@Test
public void testSolicitResponse() throws Exception {
QueueChannel replyChannel = new QueueChannel();
replyChannel.send(new StringMessage("foo"));
replyChannel.send(new GenericMessage<String>("foo"));
GatewayProxyFactoryBean proxyFactory = new GatewayProxyFactoryBean();
proxyFactory.setServiceInterface(TestService.class);
proxyFactory.setDefaultRequestChannel(new DirectChannel());
@@ -129,7 +130,7 @@ public class GatewayProxyFactoryBeanTests {
new Thread(new Runnable() {
public void run() {
Message<?> input = requestChannel.receive();
StringMessage reply = new StringMessage(input.getPayload() + "456");
GenericMessage<String> reply = new GenericMessage<String>(input.getPayload() + "456");
((MessageChannel) input.getHeaders().getReplyChannel()).send(reply);
}
}).start();
@@ -208,7 +209,7 @@ public class GatewayProxyFactoryBeanTests {
proxyFactory.setBeanName("testGateway");
proxyFactory.afterPropertiesSet();
TestService service = (TestService) proxyFactory.getObject();
String result = service.requestReplyWithMessageParameter(new StringMessage("foo"));
String result = service.requestReplyWithMessageParameter(new GenericMessage<String>("foo"));
assertEquals("foobar", result);
}
@@ -218,7 +219,7 @@ public class GatewayProxyFactoryBeanTests {
new Thread(new Runnable() {
public void run() {
Message<?> input = requestChannel.receive();
StringMessage reply = new StringMessage(input.getPayload() + "bar");
GenericMessage<String> reply = new GenericMessage<String>(input.getPayload() + "bar");
((MessageChannel) input.getHeaders().getReplyChannel()).send(reply);
}
}).start();
@@ -285,7 +286,7 @@ public class GatewayProxyFactoryBeanTests {
new Thread(new Runnable() {
public void run() {
Message<?> input = requestChannel.receive();
StringMessage reply = new StringMessage(input.getPayload() + "bar");
GenericMessage<String> reply = new GenericMessage<String>(input.getPayload() + "bar");
((MessageChannel) input.getHeaders().getReplyChannel()).send(reply);
}
}).start();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -22,12 +22,13 @@ import static org.junit.Assert.assertThat;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.message.MessageMatcher;
/**
@@ -47,7 +48,7 @@ public class BridgeHandlerTests {
public void simpleBridge() {
QueueChannel outputChannel = new QueueChannel();
handler.setOutputChannel(outputChannel);
Message<?> request = new StringMessage("test");
Message<?> request = new GenericMessage<String>("test");
handler.handleMessage(request);
Message<?> reply = outputChannel.receive(0);
assertNotNull(reply);
@@ -56,7 +57,7 @@ public class BridgeHandlerTests {
@Test(expected = MessageHandlingException.class)
public void missingOutputChannelVerifiedAtRuntime() {
Message<?> request = new StringMessage("test");
Message<?> request = new GenericMessage<String>("test");
handler.handleMessage(request);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -34,9 +34,9 @@ import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.StringMessage;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
/**
@@ -230,7 +230,7 @@ public class DelayHandlerTests {
public void verifyShutdownWithoutWaitingByDefault() throws Exception {
DelayHandler delayHandler = new DelayHandler(5000);
delayHandler.afterPropertiesSet();
delayHandler.handleMessage(new StringMessage("foo"));
delayHandler.handleMessage(new GenericMessage<String>("foo"));
delayHandler.destroy();
final ThreadPoolTaskScheduler taskScheduler = (ThreadPoolTaskScheduler)
new DirectFieldAccessor(delayHandler).getPropertyValue("taskScheduler");
@@ -255,7 +255,7 @@ public class DelayHandlerTests {
DelayHandler delayHandler = new DelayHandler(5000);
delayHandler.setWaitForTasksToCompleteOnShutdown(true);
delayHandler.afterPropertiesSet();
delayHandler.handleMessage(new StringMessage("foo"));
delayHandler.handleMessage(new GenericMessage<String>("foo"));
delayHandler.destroy();
final ThreadPoolTaskScheduler taskScheduler = (ThreadPoolTaskScheduler)
new DirectFieldAccessor(delayHandler).getPropertyValue("taskScheduler");

View File

@@ -25,6 +25,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.internal.matchers.TypeSafeMatcher;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.support.GenericApplicationContext;
@@ -32,7 +33,6 @@ import org.springframework.context.support.StaticApplicationContext;
import org.springframework.core.io.Resource;
import org.springframework.expression.EvaluationException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.StringMessage;
/**
* @author Dave Syer
@@ -51,7 +51,7 @@ public class ExpressionEvaluatingMessageProcessorTests {
@Test
public void testProcessMessage() {
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor("payload");
assertEquals("foo", processor.processMessage(new StringMessage("foo")));
assertEquals("foo", processor.processMessage(new GenericMessage<String>("foo")));
}
@Test
@@ -64,7 +64,7 @@ public class ExpressionEvaluatingMessageProcessorTests {
}
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor("#target.stringify(payload)");
processor.getEvaluationContext().setVariable("target", new TestTarget());
assertEquals("2", processor.processMessage(new StringMessage("2")));
assertEquals("2", processor.processMessage(new GenericMessage<String>("2")));
}
@Test
@@ -76,7 +76,7 @@ public class ExpressionEvaluatingMessageProcessorTests {
}
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor("#target.ping(payload)");
processor.getEvaluationContext().setVariable("target", new TestTarget());
assertEquals(null, processor.processMessage(new StringMessage("2")));
assertEquals(null, processor.processMessage(new GenericMessage<String>("2")));
}
@Test
@@ -91,28 +91,28 @@ public class ExpressionEvaluatingMessageProcessorTests {
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor("#target.find(payload)");
processor.setBeanFactory(new GenericApplicationContext().getBeanFactory());
processor.getEvaluationContext().setVariable("target", new TestTarget());
String result = (String) processor.processMessage(new StringMessage("classpath:*.properties"));
String result = (String) processor.processMessage(new GenericMessage<String>("classpath:*.properties"));
assertTrue("Wrong result: "+result, result.contains("log4j.properties"));
}
@Test
public void testProcessMessageWithDollarInBrackets() {
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor("headers['$id']");
StringMessage message = new StringMessage("foo");
GenericMessage<String> message = new GenericMessage<String>("foo");
assertEquals(message.getHeaders().getId(), processor.processMessage(message));
}
@Test
public void testProcessMessageWithDollarPropertyAccess() {
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor("headers.$id");
StringMessage message = new StringMessage("foo");
GenericMessage<String> message = new GenericMessage<String>("foo");
assertEquals(message.getHeaders().getId(), processor.processMessage(message));
}
@Test
public void testProcessMessageWithStaticKey() {
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor("headers[headers.ID]");
StringMessage message = new StringMessage("foo");
GenericMessage<String> message = new GenericMessage<String>("foo");
assertEquals(message.getHeaders().getId(), processor.processMessage(message));
}
@@ -124,7 +124,7 @@ public class ExpressionEvaluatingMessageProcessorTests {
context.registerBeanDefinition("testString", beanDefinition);
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor("payload.concat(@testString)");
processor.setBeanFactory(context);
StringMessage message = new StringMessage("foo");
GenericMessage<String> message = new GenericMessage<String>("foo");
assertEquals("foobar", processor.processMessage(message));
}
@@ -136,7 +136,7 @@ public class ExpressionEvaluatingMessageProcessorTests {
context.registerBeanDefinition("testString", beanDefinition);
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor("@testString.concat(payload)");
processor.setBeanFactory(context);
StringMessage message = new StringMessage("foo");
GenericMessage<String> message = new GenericMessage<String>("foo");
assertEquals("barfoo", processor.processMessage(message));
}
@@ -155,7 +155,7 @@ public class ExpressionEvaluatingMessageProcessorTests {
}
});
ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor("payload.fixMe()");
assertEquals("foo", processor.processMessage(new StringMessage("foo")));
assertEquals("foo", processor.processMessage(new GenericMessage<String>("foo")));
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -22,7 +22,7 @@ import java.lang.reflect.Method;
import org.junit.Test;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.util.ReflectionUtils;
/**
@@ -43,7 +43,7 @@ public class HandlerMethodInheritanceTests {
public void overridingMethodResolves() {
Method[] candidates = HandlerMethodUtils.getCandidateHandlerMethods(new TestSubclass());
PayloadTypeMatchingHandlerMethodResolver resolver = new PayloadTypeMatchingHandlerMethodResolver(candidates);
Method resolved = resolver.resolveHandlerMethod(new StringMessage("test"));
Method resolved = resolver.resolveHandlerMethod(new GenericMessage<String>("test"));
Method expected = ReflectionUtils.findMethod(
TestSubclass.class, "test", new Class<?>[] { String.class });
assertEquals(expected, resolved);

View File

@@ -26,17 +26,17 @@ import java.util.Map;
import java.util.Properties;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.MessagingException;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Headers;
import org.springframework.integration.annotation.Payload;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -54,7 +54,7 @@ public class MethodInvokingMessageProcessorAnnotationTests {
public void optionalHeader() throws Exception {
Method method = TestService.class.getMethod("optionalHeader", Integer.class);
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(testService, method);
Object result = processor.processMessage(new StringMessage("foo"));
Object result = processor.processMessage(new GenericMessage<String>("foo"));
assertNull(result);
}
@@ -62,7 +62,7 @@ public class MethodInvokingMessageProcessorAnnotationTests {
public void requiredHeaderNotProvided() throws Exception {
Method method = TestService.class.getMethod("requiredHeader", Integer.class);
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(testService, method);
processor.processMessage(new StringMessage("foo"));
processor.processMessage(new GenericMessage<String>("foo"));
}
@Test

View File

@@ -32,13 +32,13 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.internal.matchers.TypeSafeMatcher;
import org.junit.rules.ExpectedException;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -70,7 +70,7 @@ public class MethodInvokingMessageProcessorTests {
}
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(new B(), "myMethod");
Message<?> message = (Message<?>) processor.processMessage(new StringMessage(""));
Message<?> message = (Message<?>) processor.processMessage(new GenericMessage<String>(""));
assertEquals("A", message.getHeaders().get("A"));
}
@@ -94,7 +94,7 @@ public class MethodInvokingMessageProcessorTests {
}
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(new B(), "myMethod");
Message<?> message = (Message<?>) processor.processMessage(new StringMessage(""));
Message<?> message = (Message<?>) processor.processMessage(new GenericMessage<String>(""));
assertEquals("B", message.getHeaders().get("B"));
}
@@ -119,7 +119,7 @@ public class MethodInvokingMessageProcessorTests {
}
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(new C(), "myMethod");
Message<?> message = (Message<?>) processor.processMessage(new StringMessage(""));
Message<?> message = (Message<?>) processor.processMessage(new GenericMessage<String>(""));
assertEquals("C", message.getHeaders().get("C"));
}
@@ -141,7 +141,7 @@ public class MethodInvokingMessageProcessorTests {
}
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(new C(), "myMethod");
Message<?> message = (Message<?>) processor.processMessage(new StringMessage(""));
Message<?> message = (Message<?>) processor.processMessage(new GenericMessage<String>(""));
assertEquals("C", message.getHeaders().get("C"));
}
@@ -149,7 +149,7 @@ public class MethodInvokingMessageProcessorTests {
public void payloadAsMethodParameterAndObjectAsReturnValue() {
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(new TestBean(),
"acceptPayloadAndReturnObject");
Object result = processor.processMessage(new StringMessage("testing"));
Object result = processor.processMessage(new GenericMessage<String>("testing"));
assertEquals("testing-1", result);
}
@@ -165,7 +165,7 @@ public class MethodInvokingMessageProcessorTests {
public void payloadAsMethodParameterAndMessageAsReturnValue() {
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(new TestBean(),
"acceptPayloadAndReturnMessage");
Message<?> result = (Message<?>) processor.processMessage(new StringMessage("testing"));
Message<?> result = (Message<?>) processor.processMessage(new GenericMessage<String>("testing"));
assertEquals("testing-2", result.getPayload());
}
@@ -173,7 +173,7 @@ public class MethodInvokingMessageProcessorTests {
public void messageAsMethodParameterAndObjectAsReturnValue() {
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(new TestBean(),
"acceptMessageAndReturnObject");
Object result = processor.processMessage(new StringMessage("testing"));
Object result = processor.processMessage(new GenericMessage<String>("testing"));
assertEquals("testing-3", result);
}
@@ -181,7 +181,7 @@ public class MethodInvokingMessageProcessorTests {
public void messageAsMethodParameterAndMessageAsReturnValue() {
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(new TestBean(),
"acceptMessageAndReturnMessage");
Message<?> result = (Message<?>) processor.processMessage(new StringMessage("testing"));
Message<?> result = (Message<?>) processor.processMessage(new GenericMessage<String>("testing"));
assertEquals("testing-4", result.getPayload());
}
@@ -189,7 +189,7 @@ public class MethodInvokingMessageProcessorTests {
public void messageSubclassAsMethodParameterAndMessageAsReturnValue() {
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(new TestBean(),
"acceptMessageSubclassAndReturnMessage");
Message<?> result = (Message<?>) processor.processMessage(new StringMessage("testing"));
Message<?> result = (Message<?>) processor.processMessage(new GenericMessage<String>("testing"));
assertEquals("testing-5", result.getPayload());
}
@@ -197,7 +197,7 @@ public class MethodInvokingMessageProcessorTests {
public void messageSubclassAsMethodParameterAndMessageSubclassAsReturnValue() {
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(new TestBean(),
"acceptMessageSubclassAndReturnMessageSubclass");
Message<?> result = (Message<?>) processor.processMessage(new StringMessage("testing"));
Message<?> result = (Message<?>) processor.processMessage(new GenericMessage<String>("testing"));
assertEquals("testing-6", result.getPayload());
}
@@ -249,7 +249,7 @@ public class MethodInvokingMessageProcessorTests {
AnnotatedTestService service = new AnnotatedTestService();
Method method = service.getClass().getMethod("messageOnly", Message.class);
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(service, method);
Object result = processor.processMessage(new StringMessage("foo"));
Object result = processor.processMessage(new GenericMessage<String>("foo"));
assertEquals("foo", result);
}
@@ -267,7 +267,7 @@ public class MethodInvokingMessageProcessorTests {
AnnotatedTestService service = new AnnotatedTestService();
Method method = service.getClass().getMethod("integerMethod", Integer.class);
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(service, method);
Object result = processor.processMessage(new StringMessage("456"));
Object result = processor.processMessage(new GenericMessage<String>("456"));
assertEquals(new Integer(456), result);
}
@@ -276,7 +276,7 @@ public class MethodInvokingMessageProcessorTests {
AnnotatedTestService service = new AnnotatedTestService();
Method method = service.getClass().getMethod("integerMethod", Integer.class);
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(service, method);
processor.processMessage(new StringMessage("foo"));
processor.processMessage(new GenericMessage<String>("foo"));
}
@Test
@@ -286,7 +286,7 @@ public class MethodInvokingMessageProcessorTests {
AnnotatedTestService service = new AnnotatedTestService();
Method method = service.getClass().getMethod("integerMethod", Integer.class);
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(service, method);
assertEquals("foo", processor.processMessage(new StringMessage("foo")));
assertEquals("foo", processor.processMessage(new GenericMessage<String>("foo")));
}
@Test
@@ -295,7 +295,7 @@ public class MethodInvokingMessageProcessorTests {
TestErrorService service = new TestErrorService();
Method method = service.getClass().getMethod("error", String.class);
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(service, method);
assertEquals("foo", processor.processMessage(new StringMessage("foo")));
assertEquals("foo", processor.processMessage(new GenericMessage<String>("foo")));
}
@Test
@@ -304,7 +304,7 @@ public class MethodInvokingMessageProcessorTests {
TestErrorService service = new TestErrorService();
Method method = service.getClass().getMethod("checked", String.class);
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(service, method);
assertEquals("foo", processor.processMessage(new StringMessage("foo")));
assertEquals("foo", processor.processMessage(new GenericMessage<String>("foo")));
}
@Test
@@ -406,7 +406,7 @@ public class MethodInvokingMessageProcessorTests {
}
public Message<?> acceptPayloadAndReturnMessage(String s) {
return new StringMessage(s + "-2");
return new GenericMessage<String>(s + "-2");
}
public String acceptMessageAndReturnObject(Message<?> m) {
@@ -414,15 +414,15 @@ public class MethodInvokingMessageProcessorTests {
}
public Message<?> acceptMessageAndReturnMessage(Message<?> m) {
return new StringMessage(m.getPayload() + "-4");
return new GenericMessage<String>(m.getPayload() + "-4");
}
public Message<?> acceptMessageSubclassAndReturnMessage(StringMessage m) {
return new StringMessage(m.getPayload() + "-5");
public Message<?> acceptMessageSubclassAndReturnMessage(GenericMessage<String> m) {
return new GenericMessage<String>(m.getPayload() + "-5");
}
public StringMessage acceptMessageSubclassAndReturnMessageSubclass(StringMessage m) {
return new StringMessage(m.getPayload() + "-6");
public GenericMessage<String> acceptMessageSubclassAndReturnMessageSubclass(GenericMessage<String> m) {
return new GenericMessage<String>(m.getPayload() + "-6");
}
public String acceptPayloadAndHeaderAndReturnObject(String s, @Header("number") Integer n) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@ import org.junit.Test;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -47,7 +46,7 @@ public class PayloadTypeMatchingHandlerMethodResolverTests {
public void stringPayload() throws Exception {
Class<?>[] types = new Class<?>[] { String.class };
Method expected = TestService.class.getMethod("stringPayload", types);
Method resolved = resolver.resolveHandlerMethod(new StringMessage("foo"));
Method resolved = resolver.resolveHandlerMethod(new GenericMessage<String>("foo"));
assertEquals(expected, resolved);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -28,7 +28,6 @@ import org.springframework.integration.Message;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -49,7 +48,7 @@ public class PayloadTypeMatchingHandlerMethodResolverWithMessageParameterTests {
public void stringPayload() throws Exception {
Class<?>[] types = new Class<?>[] { Message.class };
Method expected = TestService.class.getMethod("stringPayload", types);
Method resolved = resolver.resolveHandlerMethod(new StringMessage("foo"));
Method resolved = resolver.resolveHandlerMethod(new TestStringMessage("foo"));
assertEquals(expected, resolved);
}
@@ -115,9 +114,9 @@ public class PayloadTypeMatchingHandlerMethodResolverWithMessageParameterTests {
Method[] candidates = HandlerMethodUtils.getCandidateHandlerMethods(service);
PayloadTypeMatchingHandlerMethodResolver methodResovler
= new PayloadTypeMatchingHandlerMethodResolver(candidates);
Class<?>[] types = new Class<?>[] { StringMessage.class };
Class<?>[] types = new Class<?>[] { TestStringMessage.class };
Method expected = TestServiceWithMessageTypes.class.getMethod("stringMessage", types);
Message<?> message = new StringMessage("foo");
Message<?> message = new TestStringMessage("foo");
Method resolved = methodResovler.resolveHandlerMethod(message);
assertEquals(expected, resolved);
assertEquals("foo", resolved.invoke(service, message));
@@ -215,7 +214,7 @@ public class PayloadTypeMatchingHandlerMethodResolverWithMessageParameterTests {
public static class TestServiceWithMessageTypes {
public String stringMessage(StringMessage message) {
public String stringMessage(TestStringMessage message) {
return message.getPayload();
}
@@ -248,4 +247,14 @@ public class PayloadTypeMatchingHandlerMethodResolverWithMessageParameterTests {
public class TestFooImpl2Subclass extends TestFooImpl2 {
}
@SuppressWarnings("serial")
private static class TestStringMessage extends GenericMessage<String> {
private TestStringMessage(String payload) {
super(payload);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -25,7 +25,7 @@ import org.junit.Test;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Headers;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
/**
* @author Mark Fisher
@@ -61,7 +61,7 @@ public class StaticHandlerMethodResolverTests {
public void validPayloadMethod() throws Exception {
Method method = TestBean.class.getDeclaredMethod("payloadMethod", new Class<?>[] {String.class});
HandlerMethodResolver resolver = new StaticHandlerMethodResolver(method);
Method resolved = resolver.resolveHandlerMethod(new StringMessage("foo"));
Method resolved = resolver.resolveHandlerMethod(new GenericMessage<String>("foo"));
assertEquals(method, resolved);
}
@@ -75,7 +75,7 @@ public class StaticHandlerMethodResolverTests {
public void validHeaderMethod() throws Exception {
Method method = TestBean.class.getDeclaredMethod("headerMethod", new Class<?>[] {String.class});
HandlerMethodResolver resolver = new StaticHandlerMethodResolver(method);
Method resolved = resolver.resolveHandlerMethod(new StringMessage("foo"));
Method resolved = resolver.resolveHandlerMethod(new GenericMessage<String>("foo"));
assertEquals(method, resolved);
}
@@ -83,7 +83,7 @@ public class StaticHandlerMethodResolverTests {
public void validHeaderMapMethod() throws Exception {
Method method = TestBean.class.getDeclaredMethod("headerMapMethod", new Class<?>[] {Map.class});
HandlerMethodResolver resolver = new StaticHandlerMethodResolver(method);
Method resolved = resolver.resolveHandlerMethod(new StringMessage("foo"));
Method resolved = resolver.resolveHandlerMethod(new GenericMessage<String>("foo"));
assertEquals(method, resolved);
}
@@ -92,7 +92,7 @@ public class StaticHandlerMethodResolverTests {
Class<?>[] types = new Class<?>[] { String.class, String.class };
Method method = TestBean.class.getDeclaredMethod("payloadAndHeaderMethod", types);
HandlerMethodResolver resolver = new StaticHandlerMethodResolver(method);
Method resolved = resolver.resolveHandlerMethod(new StringMessage("foo"));
Method resolved = resolver.resolveHandlerMethod(new GenericMessage<String>("foo"));
assertEquals(method, resolved);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -30,7 +30,6 @@ import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.PollingConsumer;
import org.springframework.integration.handler.MethodInvokingMessageHandler;
import org.springframework.integration.test.util.TestUtils;
@@ -56,7 +55,7 @@ public class MethodInvokingMessageHandlerTests {
@Test(expected = MessagingException.class)
public void methodWithReturnValue() {
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
try {
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(new TestSink(), "methodWithReturnValue");
handler.handleMessage(message);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -24,7 +24,6 @@ import org.junit.Test;
import org.springframework.integration.MessagingException;
import org.springframework.integration.core.ErrorMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.selector.PayloadTypeSelector;
/**
@@ -35,19 +34,19 @@ public class PayloadTypeSelectorTests {
@Test
public void testAcceptedTypeIsSelected() {
PayloadTypeSelector selector = new PayloadTypeSelector(String.class);
assertTrue(selector.accept(new StringMessage("test")));
assertTrue(selector.accept(new GenericMessage<String>("test")));
}
@Test
public void testNonAcceptedTypeIsNotSelected() {
PayloadTypeSelector selector = new PayloadTypeSelector(Integer.class);
assertFalse(selector.accept(new StringMessage("test")));
assertFalse(selector.accept(new GenericMessage<String>("test")));
}
@Test
public void testMultipleAcceptedTypes() {
PayloadTypeSelector selector = new PayloadTypeSelector(String.class, Integer.class);
assertTrue(selector.accept(new StringMessage("test1")));
assertTrue(selector.accept(new GenericMessage<String>("test1")));
assertTrue(selector.accept(new GenericMessage<Integer>(2)));
assertFalse(selector.accept(new ErrorMessage(new RuntimeException())));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -31,7 +31,6 @@ import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.ErrorMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -51,7 +50,7 @@ public class ErrorMessageExceptionTypeRouterTests {
@Test
public void mostSpecificCause() {
Message<?> failedMessage = new StringMessage("foo");
Message<?> failedMessage = new GenericMessage<String>("foo");
IllegalArgumentException rootCause = new IllegalArgumentException("bad argument");
RuntimeException middleCause = new RuntimeException(rootCause);
MessageHandlingException error = new MessageHandlingException(failedMessage, "failed", middleCause);
@@ -73,7 +72,7 @@ public class ErrorMessageExceptionTypeRouterTests {
@Test
public void fallbackToNextMostSpecificCause() {
Message<?> failedMessage = new StringMessage("foo");
Message<?> failedMessage = new GenericMessage<String>("foo");
IllegalArgumentException rootCause = new IllegalArgumentException("bad argument");
RuntimeException middleCause = new RuntimeException(rootCause);
MessageHandlingException error = new MessageHandlingException(failedMessage, "failed", middleCause);
@@ -94,7 +93,7 @@ public class ErrorMessageExceptionTypeRouterTests {
@Test
public void fallbackToErrorMessageType() {
Message<?> failedMessage = new StringMessage("foo");
Message<?> failedMessage = new GenericMessage<String>("foo");
IllegalArgumentException rootCause = new IllegalArgumentException("bad argument");
RuntimeException middleCause = new RuntimeException(rootCause);
MessageHandlingException error = new MessageHandlingException(failedMessage, "failed", middleCause);
@@ -114,7 +113,7 @@ public class ErrorMessageExceptionTypeRouterTests {
@Test
public void fallbackToDefaultChannel() {
Message<?> failedMessage = new StringMessage("foo");
Message<?> failedMessage = new GenericMessage<String>("foo");
IllegalArgumentException rootCause = new IllegalArgumentException("bad argument");
RuntimeException middleCause = new RuntimeException(rootCause);
MessageHandlingException error = new MessageHandlingException(failedMessage, "failed", middleCause);
@@ -130,7 +129,7 @@ public class ErrorMessageExceptionTypeRouterTests {
@Test(expected = MessageDeliveryException.class)
public void noMatchAndNoDefaultChannel() {
Message<?> failedMessage = new StringMessage("foo");
Message<?> failedMessage = new GenericMessage<String>("foo");
IllegalArgumentException rootCause = new IllegalArgumentException("bad argument");
RuntimeException middleCause = new RuntimeException(rootCause);
MessageHandlingException error = new MessageHandlingException(failedMessage, "failed", middleCause);
@@ -146,7 +145,7 @@ public class ErrorMessageExceptionTypeRouterTests {
@Test
public void exceptionPayloadButNotErrorMessage() {
Message<?> failedMessage = new StringMessage("foo");
Message<?> failedMessage = new GenericMessage<String>("foo");
IllegalArgumentException rootCause = new IllegalArgumentException("bad argument");
RuntimeException middleCause = new RuntimeException(rootCause);
MessageHandlingException error = new MessageHandlingException(failedMessage, "failed", middleCause);
@@ -168,7 +167,7 @@ public class ErrorMessageExceptionTypeRouterTests {
@Test
public void intermediateCauseHasNoMappingButMostSpecificCauseDoes() {
Message<?> failedMessage = new StringMessage("foo");
Message<?> failedMessage = new GenericMessage<String>("foo");
IllegalArgumentException rootCause = new IllegalArgumentException("bad argument");
RuntimeException middleCause = new RuntimeException(rootCause);
MessageHandlingException error = new MessageHandlingException(failedMessage, "failed", middleCause);

View File

@@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.annotation.Header;
@@ -34,7 +35,6 @@ import org.springframework.integration.core.ChannelResolver;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -123,9 +123,9 @@ public class MethodInvokingRouterTests {
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new StringMessage("foo");
Message<String> barMessage = new StringMessage("bar");
Message<String> badMessage = new StringMessage("bad");
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1 = fooChannel.receive(0);
assertNotNull(result1);
@@ -155,9 +155,9 @@ public class MethodInvokingRouterTests {
}
private void doTestChannelInstanceResolutionByPayload(MethodInvokingRouter router, TestChannelResolver channelResolver) {
Message<String> fooMessage = new StringMessage("foo");
Message<String> barMessage = new StringMessage("bar");
Message<String> badMessage = new StringMessage("bad");
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
channelResolver.addChannel("foo-channel", fooChannel);
@@ -197,9 +197,9 @@ public class MethodInvokingRouterTests {
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new StringMessage("foo");
Message<String> barMessage = new StringMessage("bar");
Message<String> badMessage = new StringMessage("bad");
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1 = fooChannel.receive(0);
assertNotNull(result1);
@@ -234,9 +234,9 @@ public class MethodInvokingRouterTests {
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new StringMessage("foo");
Message<String> barMessage = new StringMessage("bar");
Message<String> badMessage = new StringMessage("bad");
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1a = fooChannel.receive(0);
Message<?> result1b = barChannel.receive(0);
@@ -277,9 +277,9 @@ public class MethodInvokingRouterTests {
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new StringMessage("foo");
Message<String> barMessage = new StringMessage("bar");
Message<String> badMessage = new StringMessage("bad");
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1a = fooChannel.receive(0);
assertNotNull(result1a);
@@ -320,9 +320,9 @@ public class MethodInvokingRouterTests {
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new StringMessage("foo");
Message<String> barMessage = new StringMessage("bar");
Message<String> badMessage = new StringMessage("bad");
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1a = fooChannel.receive(0);
assertNotNull(result1a);
@@ -363,9 +363,9 @@ public class MethodInvokingRouterTests {
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new StringMessage("foo");
Message<String> barMessage = new StringMessage("bar");
Message<String> badMessage = new StringMessage("bad");
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1a = fooChannel.receive(0);
Message<?> result1b = barChannel.receive(0);
@@ -406,9 +406,9 @@ public class MethodInvokingRouterTests {
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new StringMessage("foo");
Message<String> barMessage = new StringMessage("bar");
Message<String> badMessage = new StringMessage("bad");
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1a = fooChannel.receive(0);
Message<?> result1b = barChannel.receive(0);
@@ -449,9 +449,9 @@ public class MethodInvokingRouterTests {
channelResolver.addChannel("foo-channel", fooChannel);
channelResolver.addChannel("bar-channel", barChannel);
router.setChannelResolver(channelResolver);
Message<String> fooMessage = new StringMessage("foo");
Message<String> barMessage = new StringMessage("bar");
Message<String> badMessage = new StringMessage("bad");
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
router.handleMessage(fooMessage);
Message<?> result1a = fooChannel.receive(0);
Message<?> result1b = barChannel.receive(0);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -22,11 +22,12 @@ import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.channel.TestChannelResolver;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.util.CollectionUtils;
/**
@@ -48,7 +49,7 @@ public class MultiChannelRouterTests {
channelResolver.addChannel("channel1", channel1);
channelResolver.addChannel("channel2", channel2);
router.setChannelResolver(channelResolver);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
Message<?> result1 = channel1.receive(25);
assertNotNull(result1);
@@ -68,7 +69,7 @@ public class MultiChannelRouterTests {
};
TestChannelResolver channelResolver = new TestChannelResolver();
router.setChannelResolver(channelResolver);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}
@@ -80,7 +81,7 @@ public class MultiChannelRouterTests {
return CollectionUtils.arrayToList(new String[] {"noSuchChannel"});
}
};
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -31,7 +31,6 @@ import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -47,7 +46,7 @@ public class PayloadTypeRouterTests {
payloadTypeChannelMap.put(Integer.class, integerChannel);
PayloadTypeRouter router = new PayloadTypeRouter();
router.setPayloadTypeChannelMap(payloadTypeChannelMap);
Message<String> message1 = new StringMessage("test");
Message<String> message1 = new GenericMessage<String>("test");
Message<Integer> message2 = new GenericMessage<Integer>(123);
MessageChannel result1 = router.determineTargetChannel(message1);
MessageChannel result2 = router.determineTargetChannel(message2);
@@ -196,7 +195,7 @@ public class PayloadTypeRouterTests {
payloadTypeChannelMap.put(Integer.class, integerChannel);
PayloadTypeRouter router = new PayloadTypeRouter();
router.setPayloadTypeChannelMap(payloadTypeChannelMap);
Message<String> message1 = new StringMessage("test");
Message<String> message1 = new GenericMessage<String>("test");
Message<Integer> message2 = new GenericMessage<Integer>(123);
router.handleMessage(message1);
router.handleMessage(message2);
@@ -217,7 +216,7 @@ public class PayloadTypeRouterTests {
PayloadTypeRouter router = new PayloadTypeRouter();
router.setPayloadTypeChannelMap(payloadTypeChannelMap);
router.setDefaultOutputChannel(defaultChannel);
Message<String> message1 = new StringMessage("test");
Message<String> message1 = new GenericMessage<String>("test");
Message<Integer> message2 = new GenericMessage<Integer>(123);
router.handleMessage(message1);
router.handleMessage(message2);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -30,9 +30,9 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.integration.Message;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.router.RecipientListRouter.Recipient;
/**
@@ -68,7 +68,7 @@ public class RecipientListRouterTests {
RecipientListRouter router = new RecipientListRouter();
router.setChannels(channels);
router.afterPropertiesSet();
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
Message<?> result1 = channel1.receive(25);
assertNotNull(result1);
@@ -84,7 +84,7 @@ public class RecipientListRouterTests {
channel.setBeanName("channel");
RecipientListRouter router = new RecipientListRouter();
router.setChannels(Collections.singletonList((MessageChannel) channel));
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
Message<?> result1 = channel.receive(25);
assertNotNull(result1);
@@ -108,8 +108,8 @@ public class RecipientListRouterTests {
channels.add(channelB);
channels.add(channelC);
router.setChannels(channels);
channelA.send(new StringMessage("blocker"));
Message<String> message = new StringMessage("test");
channelA.send(new GenericMessage<String>("blocker"));
Message<String> message = new GenericMessage<String>("test");
try {
router.handleMessage(message);
}
@@ -138,8 +138,8 @@ public class RecipientListRouterTests {
channels.add(channelB);
channels.add(channelC);
router.setChannels(channels);
channelB.send(new StringMessage("blocker"));
Message<String> message = new StringMessage("test");
channelB.send(new GenericMessage<String>("blocker"));
Message<String> message = new GenericMessage<String>("test");
try {
router.handleMessage(message);
}
@@ -170,8 +170,8 @@ public class RecipientListRouterTests {
channels.add(channelB);
channels.add(channelC);
router.setChannels(channels);
channelC.send(new StringMessage("blocker"));
Message<String> message = new StringMessage("test");
channelC.send(new GenericMessage<String>("blocker"));
Message<String> message = new GenericMessage<String>("test");
try {
router.handleMessage(message);
}
@@ -205,8 +205,8 @@ public class RecipientListRouterTests {
channels.add(channelB);
channels.add(channelC);
router.setChannels(channels);
channelA.send(new StringMessage("blocker"));
Message<String> message = new StringMessage("test");
channelA.send(new GenericMessage<String>("blocker"));
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
Message<?> result1a = channelA.receive(0);
Message<?> result1b = channelB.receive(0);
@@ -235,8 +235,8 @@ public class RecipientListRouterTests {
channels.add(channelB);
channels.add(channelC);
router.setChannels(channels);
channelB.send(new StringMessage("blocker"));
Message<String> message = new StringMessage("test");
channelB.send(new GenericMessage<String>("blocker"));
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
Message<?> result1a = channelA.receive(0);
Message<?> result1b = channelB.receive(0);
@@ -265,8 +265,8 @@ public class RecipientListRouterTests {
channels.add(channelB);
channels.add(channelC);
router.setChannels(channels);
channelC.send(new StringMessage("blocker"));
Message<String> message = new StringMessage("test");
channelC.send(new GenericMessage<String>("blocker"));
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
Message<?> result1a = channelA.receive(0);
Message<?> result1b = channelB.receive(0);
@@ -290,7 +290,7 @@ public class RecipientListRouterTests {
channels.add(channelA);
channels.add(channelB);
router.setChannels(channels);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
Message<?> result1a = channelA.receive(0);
Message<?> result1b = channelB.receive(0);
@@ -318,7 +318,7 @@ public class RecipientListRouterTests {
channels.add(channelA);
channels.add(channelB);
router.setChannels(channels);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
Message<?> result1a = channelA.receive(0);
Message<?> result1b = channelB.receive(0);
@@ -368,7 +368,7 @@ public class RecipientListRouterTests {
recipients.add(new Recipient(channel5, new AlwaysFalseSelector()));
RecipientListRouter router = new RecipientListRouter();
router.setRecipients(recipients);
Message<?> message = new StringMessage("test");
Message<?> message = new GenericMessage<String>("test");
router.handleMessage(message);
Message<?> reply1 = channel1.receive(0);
assertEquals(message, reply1);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,14 +23,15 @@ import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.MessagingException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.channel.TestChannelResolver;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.util.CollectionUtils;
/**
@@ -45,7 +46,7 @@ public class RouterTests {
return null;
}
};
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}
@@ -57,7 +58,7 @@ public class RouterTests {
}
};
router.setResolutionRequired(true);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}
@@ -68,7 +69,7 @@ public class RouterTests {
return Collections.emptyList();
}
};
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}
@@ -80,7 +81,7 @@ public class RouterTests {
}
};
router.setResolutionRequired(true);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}
@@ -93,7 +94,7 @@ public class RouterTests {
};
TestChannelResolver channelResolver = new TestChannelResolver();
router.setChannelResolver(channelResolver);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}
@@ -107,7 +108,7 @@ public class RouterTests {
TestChannelResolver channelResolver = new TestChannelResolver();
router.setChannelResolver(channelResolver);
router.setResolutionRequired(true);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}
@@ -121,7 +122,7 @@ public class RouterTests {
};
TestChannelResolver channelResolver = new TestChannelResolver();
router.setChannelResolver(channelResolver);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}
@@ -136,7 +137,7 @@ public class RouterTests {
TestChannelResolver channelResolver = new TestChannelResolver();
router.setChannelResolver(channelResolver);
router.setResolutionRequired(true);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}
@@ -147,7 +148,7 @@ public class RouterTests {
return "notImportant";
}
};
router.handleMessage(new StringMessage("this should fail"));
router.handleMessage(new GenericMessage<String>("this should fail"));
}
@Test(expected = MessagingException.class)
@@ -158,7 +159,7 @@ public class RouterTests {
return CollectionUtils.arrayToList(new String[] { "notImportant" });
}
};
router.handleMessage(new StringMessage("this should fail"));
router.handleMessage(new GenericMessage<String>("this should fail"));
}
@Test
@@ -172,7 +173,7 @@ public class RouterTests {
GenericApplicationContext context = new GenericApplicationContext();
context.getBeanFactory().registerSingleton("testChannel", testChannel);
router.setBeanFactory(context);
router.handleMessage(new StringMessage("test"));
router.handleMessage(new GenericMessage<String>("test"));
Message<?> reply = testChannel.receive(0);
assertEquals("test", reply.getPayload());
}
@@ -189,7 +190,7 @@ public class RouterTests {
GenericApplicationContext context = new GenericApplicationContext();
context.getBeanFactory().registerSingleton("testChannel", testChannel);
router.setBeanFactory(context);
router.handleMessage(new StringMessage("test"));
router.handleMessage(new GenericMessage<String>("test"));
Message<?> reply = testChannel.receive(0);
assertEquals("test", reply.getPayload());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -25,8 +25,8 @@ import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.channel.TestChannelResolver;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -41,7 +41,7 @@ public class SingleChannelRouterTests {
return channel;
}
};
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
Message<?> result = channel.receive(25);
assertNotNull(result);
@@ -59,7 +59,7 @@ public class SingleChannelRouterTests {
TestChannelResolver channelResolver = new TestChannelResolver();
channelResolver.addChannel("testChannel", channel);
router.setChannelResolver(channelResolver);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
Message<?> result = channel.receive(25);
assertNotNull(result);
@@ -73,7 +73,7 @@ public class SingleChannelRouterTests {
return null;
}
};
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}
@@ -86,7 +86,7 @@ public class SingleChannelRouterTests {
};
TestChannelResolver channelResolver = new TestChannelResolver();
router.setChannelResolver(channelResolver);
Message<String> message = new StringMessage("test");
Message<String> message = new GenericMessage<String>("test");
router.handleMessage(message);
}

View File

@@ -20,6 +20,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.Collection;
import java.util.Collections;
@@ -39,16 +42,11 @@ import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.integration.router.AbstractMessageRouter;
import org.springframework.integration.router.MethodInvokingRouter;
import org.springframework.integration.test.util.TestUtils;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/**
* @author Mark Fisher
* @author Jonas Partner
@@ -63,11 +61,11 @@ public class RouterParserTests {
MessageChannel input = (MessageChannel) context.getBean("input");
PollableChannel output1 = (PollableChannel) context.getBean("output1");
PollableChannel output2 = (PollableChannel) context.getBean("output2");
input.send(new StringMessage("1"));
input.send(new GenericMessage<String>("1"));
Message<?> result1 = output1.receive(1000);
assertEquals("1", result1.getPayload());
assertNull(output2.receive(0));
input.send(new StringMessage("2"));
input.send(new GenericMessage<String>("2"));
Message<?> result2 = output2.receive(1000);
assertEquals("2", result2.getPayload());
assertNull(output1.receive(0));
@@ -82,7 +80,7 @@ public class RouterParserTests {
PollableChannel output1 = (PollableChannel) context.getBean("output1");
PollableChannel output2 = (PollableChannel) context.getBean("output2");
PollableChannel defaultOutput = (PollableChannel) context.getBean("defaultOutput");
input.send(new StringMessage("99"));
input.send(new GenericMessage<String>("99"));
assertNull(output1.receive(0));
assertNull(output2.receive(0));
Message<?> result = defaultOutput.receive(0);
@@ -96,7 +94,7 @@ public class RouterParserTests {
context.start();
MessageChannel input = (MessageChannel) context.getBean("inputForAbstractMessageRouterImplementation");
PollableChannel output = (PollableChannel) context.getBean("output3");
input.send(new StringMessage("test-implementation"));
input.send(new GenericMessage<String>("test-implementation"));
Message<?> result = output.receive(0);
assertNotNull(result);
assertEquals("test-implementation", result.getPayload());
@@ -109,7 +107,7 @@ public class RouterParserTests {
context.start();
MessageChannel input = (MessageChannel) context.getBean("inputForAnnotatedRouter");
PollableChannel output = (PollableChannel) context.getBean("output4");
input.send(new StringMessage("test-annotation"));
input.send(new GenericMessage<String>("test-annotation"));
Message<?> result = output.receive(0);
assertNotNull(result);
assertEquals("test-annotation", result.getPayload());
@@ -130,7 +128,7 @@ public class RouterParserTests {
"routerParserTests.xml", this.getClass());
context.start();
MessageChannel input = (MessageChannel) context.getBean("ignoreChannelNameResolutionFailuresInput");
input.send(new StringMessage("channelThatDoesNotExist"));
input.send(new GenericMessage<String>("channelThatDoesNotExist"));
}
@Test
@@ -165,7 +163,7 @@ public class RouterParserTests {
PollableChannel out1 = context.getBean("sequenceOut1", PollableChannel.class);
PollableChannel out2 = context.getBean("sequenceOut2", PollableChannel.class);
PollableChannel out3 = context.getBean("sequenceOut3", PollableChannel.class);
Message<?> originalMessage = new StringMessage("test");
Message<?> originalMessage = new GenericMessage<String>("test");
input.send(originalMessage);
Message<?> message1 = out1.receive(0);
Message<?> message2 = out2.receive(0);
@@ -189,7 +187,7 @@ public class RouterParserTests {
DirectChannel inputChannel = context.getBean("inputChannel", DirectChannel.class);
SubscribableChannel errorChannel = context.getBean("errorChannel", SubscribableChannel.class);
errorChannel.subscribe(handler);
inputChannel.send(new StringMessage("fail"));
inputChannel.send(new GenericMessage<String>("fail"));
verify(handler, times(1)).handleMessage(Mockito.any(Message.class));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,9 +23,9 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -39,7 +39,7 @@ public class SplitterParserTests {
context.start();
MessageChannel input = (MessageChannel) context.getBean("splitterAdapterWithRefAndMethodInput");
PollableChannel output = (PollableChannel) context.getBean("output");
input.send(new StringMessage("this.is.a.test"));
input.send(new GenericMessage<String>("this.is.a.test"));
Message<?> result1 = output.receive(1000);
assertEquals("this", result1.getPayload());
Message<?> result2 = output.receive(1000);
@@ -58,7 +58,7 @@ public class SplitterParserTests {
context.start();
MessageChannel input = (MessageChannel) context.getBean("splitterAdapterWithRefOnlyInput");
PollableChannel output = (PollableChannel) context.getBean("output");
input.send(new StringMessage("this.is.a.test"));
input.send(new GenericMessage<String>("this.is.a.test"));
Message<?> result1 = output.receive(1000);
assertEquals("this", result1.getPayload());
Message<?> result2 = output.receive(1000);
@@ -77,7 +77,7 @@ public class SplitterParserTests {
context.start();
MessageChannel input = (MessageChannel) context.getBean("splitterImplementationInput");
PollableChannel output = (PollableChannel) context.getBean("output");
input.send(new StringMessage("this.is.a.test"));
input.send(new GenericMessage<String>("this.is.a.test"));
Message<?> result1 = output.receive(1000);
assertEquals("this", result1.getPayload());
Message<?> result2 = output.receive(1000);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -22,15 +22,15 @@ import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
*/
public class MessageSelectorChainTests {
private final Message<?> message = new StringMessage("test");
private final Message<?> message = new GenericMessage<String>("test");
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -25,13 +25,13 @@ import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Splitter;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -42,7 +42,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitStringToStringArray() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = this.getSplitter("stringToStringArray");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -58,7 +58,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitStringToStringList() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = this.getSplitter("stringToStringList");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -74,7 +74,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitMessageToStringArray() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = this.getSplitter("messageToStringArray");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -90,7 +90,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitMessageToStringList() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = this.getSplitter("messageToStringList");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -106,7 +106,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitMessageToMessageArray() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = this.getSplitter("messageToMessageArray");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -122,7 +122,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitMessageToMessageList() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = this.getSplitter("messageToMessageList");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -138,7 +138,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitStringToMessageArray() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = this.getSplitter("stringToMessageArray");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -154,7 +154,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitStringToMessageList() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = this.getSplitter("stringToMessageList");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -170,7 +170,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitStringToStringArrayConfiguredByMethodName() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "stringToStringArray");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -186,7 +186,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitStringToStringListConfiguredByMethodName() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "stringToStringList");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -202,7 +202,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitMessageToStringArrayConfiguredByMethodName() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "messageToStringArray");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -218,7 +218,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitMessageToStringListConfiguredByMethodName() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "messageToStringList");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -234,7 +234,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitMessageToMessageArrayConfiguredByMethodName() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "messageToMessageArray");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -250,7 +250,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitMessageToMessageListConfiguredByMethodName() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "messageToMessageList");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -266,7 +266,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitStringToMessageArrayConfiguredByMethodName() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "stringToMessageArray");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -282,7 +282,7 @@ public class MethodInvokingSplitterTests {
@Test
public void splitStringToMessageListConfiguredByMethodName() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "stringToMessageList");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -321,7 +321,7 @@ public class MethodInvokingSplitterTests {
@Test
public void headerForObjectReturnValues() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = this.getSplitter("stringToStringArray");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -341,7 +341,7 @@ public class MethodInvokingSplitterTests {
@Test
public void headerForMessageReturnValues() throws Exception {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
MethodInvokingSplitter splitter = this.getSplitter("messageToMessageList");
QueueChannel replyChannel = new QueueChannel();
splitter.setOutputChannel(replyChannel);
@@ -401,7 +401,7 @@ public class MethodInvokingSplitterTests {
@Test
public void singleAnnotation() {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
SingleAnnotationTestBean annotatedBean = new SingleAnnotationTestBean();
MethodInvokingSplitter splitter = new MethodInvokingSplitter(annotatedBean);
QueueChannel replyChannel = new QueueChannel();
@@ -423,7 +423,7 @@ public class MethodInvokingSplitterTests {
@Test
public void singlePublicMethod() {
StringMessage message = new StringMessage("foo.bar");
GenericMessage<String> message = new GenericMessage<String>("foo.bar");
SinglePublicMethodTestBean testBean = new SinglePublicMethodTestBean();
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean);
QueueChannel replyChannel = new QueueChannel();
@@ -469,9 +469,9 @@ public class MethodInvokingSplitterTests {
public Message<String>[] messageToMessageArray(Message<?> input) {
String[] strings = input.getPayload().toString().split("\\.");
Message<String>[] messages = new StringMessage[strings.length];
Message<String>[] messages = new TestStringMessage[strings.length];
for (int i = 0; i < strings.length; i++) {
messages[i] = new StringMessage(strings[i]);
messages[i] = new TestStringMessage(strings[i]);
}
return messages;
}
@@ -480,16 +480,16 @@ public class MethodInvokingSplitterTests {
String[] strings = input.getPayload().toString().split("\\.");
List<Message<String>> messages = new ArrayList<Message<String>>();
for (String s : strings) {
messages.add(new StringMessage(s));
messages.add(new GenericMessage<String>(s));
}
return messages;
}
public Message<String>[] stringToMessageArray(String input) {
String[] strings = input.split("\\.");
Message<String>[] messages = new StringMessage[strings.length];
Message<String>[] messages = new TestStringMessage[strings.length];
for (int i = 0; i < strings.length; i++) {
messages[i] = new StringMessage(strings[i]);
messages[i] = new TestStringMessage(strings[i]);
}
return messages;
}
@@ -498,7 +498,7 @@ public class MethodInvokingSplitterTests {
String[] strings = input.split("\\.");
List<Message<String>> messages = new ArrayList<Message<String>>();
for (String s : strings) {
messages.add(new StringMessage(s));
messages.add(new GenericMessage<String>(s));
}
return messages;
}
@@ -567,4 +567,12 @@ public class MethodInvokingSplitterTests {
}
}
@SuppressWarnings("serial")
private static class TestStringMessage extends GenericMessage<String> {
private TestStringMessage(String payload) {
super(payload);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.store;
import static org.junit.Assert.assertEquals;
@@ -32,13 +33,13 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
/**
* @author Dave Syer
* @since 2.0
*
*/
public class MessageGroupQueueTests {
@@ -47,7 +48,7 @@ public class MessageGroupQueueTests {
@Test
public void testPutAndPoll() throws Exception {
MessageGroupQueue queue = new MessageGroupQueue(new SimpleMessageStore(), "FOO");
queue.put(new StringMessage("foo"));
queue.put(new GenericMessage<String>("foo"));
Message<?> result = queue.poll(100, TimeUnit.MILLISECONDS);
assertNotNull(result);
}
@@ -55,7 +56,7 @@ public class MessageGroupQueueTests {
@Test
public void testSize() throws Exception {
MessageGroupQueue queue = new MessageGroupQueue(new SimpleMessageStore(), "FOO");
queue.put(new StringMessage("foo"));
queue.put(new GenericMessage<String>("foo"));
assertEquals(1, queue.size());
queue.poll(100, TimeUnit.MILLISECONDS);
assertEquals(0, queue.size());
@@ -65,9 +66,9 @@ public class MessageGroupQueueTests {
public void testCapacityAfterExpiry() throws Exception {
SimpleMessageStore messageGroupStore = new SimpleMessageStore();
MessageGroupQueue queue = new MessageGroupQueue(messageGroupStore, "FOO", 2);
queue.put(new StringMessage("foo"));
queue.put(new GenericMessage<String>("foo"));
assertEquals(1, queue.remainingCapacity());
queue.put(new StringMessage("bar"));
queue.put(new GenericMessage<String>("bar"));
assertEquals(0, queue.remainingCapacity());
Message<?> result = queue.poll(100, TimeUnit.MILLISECONDS);
assertNotNull(result);
@@ -78,14 +79,14 @@ public class MessageGroupQueueTests {
public void testCapacityExceeded() throws Exception {
SimpleMessageStore messageGroupStore = new SimpleMessageStore();
MessageGroupQueue queue = new MessageGroupQueue(messageGroupStore, "FOO", 1);
queue.put(new StringMessage("foo"));
assertFalse(queue.offer(new StringMessage("bar"), 100, TimeUnit.MILLISECONDS));
queue.put(new GenericMessage<String>("foo"));
assertFalse(queue.offer(new GenericMessage<String>("bar"), 100, TimeUnit.MILLISECONDS));
}
@Test
public void testPutAndTake() throws Exception {
MessageGroupQueue queue = new MessageGroupQueue(new SimpleMessageStore(), "FOO");
queue.put(new StringMessage("foo"));
queue.put(new GenericMessage<String>("foo"));
Message<?> result = queue.take();
assertNotNull(result);
}
@@ -115,7 +116,7 @@ public class MessageGroupQueueTests {
public Boolean call() throws Exception {
boolean result = true;
for (int j = 0; j < maxPerTask; j++) {
result &= queue.add(new StringMessage("count=" + big + ":" + j));
result &= queue.add(new GenericMessage<String>("count=" + big + ":" + j));
if (!result) {
logger.warn("Failed to add");
}

View File

@@ -21,15 +21,14 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Dave Syer
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@@ -45,7 +44,7 @@ public class MessageStoreReaperTests {
@Test
public void testExpiry() throws Exception {
messageStore.addMessageToGroup("FOO", new StringMessage("foo"));
messageStore.addMessageToGroup("FOO", new GenericMessage<String>("foo"));
assertEquals(1, messageStore.getMessageGroup("FOO").size());
// wait for expiry...
Thread.sleep(200L);

View File

@@ -25,8 +25,9 @@ import java.util.Iterator;
import java.util.List;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.test.util.ReflectionTestUtils;
/**
@@ -65,7 +66,7 @@ public class MessageStoreTests {
private static class TestMessageStore extends AbstractMessageGroupStore {
MessageGroup testMessages = new SimpleMessageGroup(Arrays.asList(new StringMessage("foo")), "bar");
MessageGroup testMessages = new SimpleMessageGroup(Arrays.asList(new GenericMessage<String>("foo")), "bar");
private boolean removed = false;
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +16,16 @@
package org.springframework.integration.transformer;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
/**
* @author Jonas Partner
@@ -32,7 +34,7 @@ public class MessageTransformingChannelInterceptorTests {
private QueueChannel channel;
private StringMessage message;
private GenericMessage<String> message;
private TestTransformer transformer;
@@ -42,7 +44,7 @@ public class MessageTransformingChannelInterceptorTests {
@Before
public void setUp() {
channel = new QueueChannel();
message = new StringMessage("test");
message = new GenericMessage<String>("test");
transformer = new TestTransformer();
channelInterceptor = new MessageTransformingChannelInterceptor(transformer);
channel.addInterceptor(channelInterceptor);

View File

@@ -30,7 +30,6 @@ import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Transformer;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
/**
@@ -43,7 +42,7 @@ public class MethodInvokingTransformerTests {
TestBean testBean = new TestBean();
Method testMethod = testBean.getClass().getMethod("exclaim", String.class);
MethodInvokingTransformer transformer = new MethodInvokingTransformer(testBean, testMethod);
Message<?> message = new StringMessage("foo");
Message<?> message = new GenericMessage<String>("foo");
Message<?> result = transformer.transform(message);
assertEquals("FOO!", result.getPayload());
}
@@ -52,7 +51,7 @@ public class MethodInvokingTransformerTests {
public void simplePayloadConfiguredWithMethodName() throws Exception {
TestBean testBean = new TestBean();
MethodInvokingTransformer transformer = new MethodInvokingTransformer(testBean, "exclaim");
Message<?> message = new StringMessage("foo");
Message<?> message = new GenericMessage<String>("foo");
Message<?> result = transformer.transform(message);
assertEquals("FOO!", result.getPayload());
}
@@ -208,7 +207,7 @@ public class MethodInvokingTransformerTests {
public void nullReturningMethod() {
TestBean testBean = new TestBean();
MethodInvokingTransformer transformer = new MethodInvokingTransformer(testBean, "nullReturnValueTest");
StringMessage message = new StringMessage("test");
GenericMessage<String> message = new GenericMessage<String>("test");
Message<?> result = transformer.transform(message);
assertNull(result);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -22,7 +22,6 @@ import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -32,7 +31,7 @@ public class ObjectToStringTransformerTests {
@Test
public void stringPayload() {
Transformer transformer = new ObjectToStringTransformer();
Message<?> result = transformer.transform(new StringMessage("foo"));
Message<?> result = transformer.transform(new GenericMessage<String>("foo"));
assertEquals("foo", result.getPayload());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -30,7 +30,6 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -40,7 +39,7 @@ public class PayloadSerializingTransformerTests {
@Test
public void serializeString() throws Exception {
PayloadSerializingTransformer transformer = new PayloadSerializingTransformer();
Message<?> result = transformer.transform(new StringMessage("foo"));
Message<?> result = transformer.transform(new GenericMessage<String>("foo"));
Object payload = result.getPayload();
assertNotNull(payload);
assertTrue(payload instanceof byte[]);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -25,7 +25,6 @@ import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -35,7 +34,7 @@ public class PayloadTransformerTests {
@Test
public void testSuccessfulTransformation() {
TestPayloadTransformer transformer = new TestPayloadTransformer();
Message<?> message = new StringMessage("foo");
Message<?> message = new GenericMessage<String>("foo");
Message<?> result = transformer.transform(message);
assertEquals(3, result.getPayload());
}
@@ -43,7 +42,7 @@ public class PayloadTransformerTests {
@Test(expected=MessagingException.class)
public void testExceptionThrownByTransformer() {
TestPayloadTransformer transformer = new TestPayloadTransformer();
Message<?> message = new StringMessage("bad");
Message<?> message = new GenericMessage<String>("bad");
transformer.transform(message);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,9 +23,9 @@ import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
/**
* @author Mark Fisher
@@ -38,7 +38,7 @@ public class TransformerContextTests {
"transformerContextTests.xml", this.getClass());
MessageChannel input = (MessageChannel) context.getBean("input");
PollableChannel output = (PollableChannel) context.getBean("output");
input.send(new StringMessage("foo"));
input.send(new GenericMessage<String>("foo"));
Message<?> reply = output.receive(0);
assertEquals("FOO", reply.getPayload());
}