Update for SI latest interface changes. Transactional stuff still broken, but now it compiles.

This commit is contained in:
dsyer
2008-08-01 06:57:18 +00:00
parent ccb2467cce
commit 96cbf19f2e
9 changed files with 64 additions and 52 deletions

View File

@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.annotation.Handler;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.message.BlockingSource;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.test.context.ContextConfiguration;
@@ -26,7 +27,7 @@ public class SmokeTests {
@Autowired
@Qualifier("smokeout")
private MessageChannel smokeout;
private BlockingSource<String> smokeout;
// This has to be static because the MessageBus registers the handler
// more than once (every time a test instance is created), but only one of
@@ -48,7 +49,7 @@ public class SmokeTests {
@Test
public void testVanillaSendAndReceive() throws Exception {
smokein.send(new GenericMessage<String>("foo"));
Message<?> message = smokeout.receive(100);
Message<String> message = smokeout.receive(100);
String result = (String) (message == null ? null : message.getPayload());
assertEquals("foo: 1", result);
assertEquals(1, count);

View File

@@ -32,7 +32,7 @@ import org.springframework.batch.repeat.ExitStatus;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.test.context.ContextConfiguration;
@@ -47,11 +47,11 @@ public class ChunkMessageItemWriterIntegrationTests {
@Autowired
@Qualifier("requests")
private MessageChannel requests;
private PollableChannel requests;
@Autowired
@Qualifier("replies")
private MessageChannel replies;
private PollableChannel replies;
private SimpleStepFactoryBean<Object> factory;
@@ -59,6 +59,7 @@ public class ChunkMessageItemWriterIntegrationTests {
private static long jobCounter;
@SuppressWarnings("unchecked")
@Before
public void setUp() {
@@ -71,8 +72,8 @@ public class ChunkMessageItemWriterIntegrationTests {
factory.setItemWriter(writer);
factory.setCommitInterval(4);
writer.setReplyChannel(replies);
writer.setRequestChannel(requests);
writer.setSource(replies);
writer.setTarget(requests);
TestItemWriter.count = 0;

View File

@@ -28,6 +28,7 @@ import org.springframework.core.io.Resource;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.Splitter;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.test.context.ContextConfiguration;
@@ -48,7 +49,7 @@ public class ResourceSplitterIntegrationTests {
@Autowired
@Qualifier("requests")
private MessageChannel requests;
private PollableChannel requests;
/*
* This is so cool (but see INT-190)...<br/>

View File

@@ -22,7 +22,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.message.Message;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -36,7 +36,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
public class MessageChannelItemWriterIntegrationTests {
@Autowired
private MessageChannel channel;
private PollableChannel channel;
@Autowired
private ItemWriter<String> itemWriter;

View File

@@ -33,11 +33,13 @@ import org.springframework.batch.core.StepExecution;
import org.springframework.batch.integration.JobRepositorySupport;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.channel.ThreadLocalChannel;
import org.springframework.integration.dispatcher.DirectChannel;
import org.springframework.integration.message.BlockingSource;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageSource;
import org.springframework.integration.message.MessageTarget;
import org.springframework.util.ReflectionUtils;
@@ -53,15 +55,16 @@ public class MessageOrientedStepTests {
private DirectChannel requestChannel;
private MessageChannel replyChannel;
private PollableChannel replyChannel;
@SuppressWarnings("unchecked")
@Before
public void createStep() {
replyChannel = new ThreadLocalChannel();
requestChannel = new DirectChannel();
step.setName("step");
step.setRequestChannel(requestChannel);
step.setReplyChannel(replyChannel);
step.setTarget(requestChannel);
step.setSource(replyChannel);
step.setStartLimit(10);
step.setJobRepository(new JobRepositorySupport());
JobInstance jobInstance = new JobInstance(0L, new JobParameters(), "job");
@@ -70,12 +73,12 @@ public class MessageOrientedStepTests {
/**
* Test method for
* {@link org.springframework.batch.integration.job.MessageOrientedStep#setRequestChannel(org.springframework.integration.channel.MessageChannel)}.
* {@link org.springframework.batch.integration.job.MessageOrientedStep#setTarget(MessageTarget)}.
*/
@Test
public void testSetRequestChannel() {
Method method = ReflectionUtils.findMethod(MessageOrientedStep.class, "setRequestChannel",
new Class<?>[] { MessageChannel.class });
Method method = ReflectionUtils.findMethod(MessageOrientedStep.class, "setTarget",
new Class<?>[] { MessageTarget.class });
assertNotNull(method);
Annotation[] annotations = AnnotationUtils.getAnnotations(method);
assertEquals(1, annotations.length);
@@ -84,12 +87,12 @@ public class MessageOrientedStepTests {
/**
* Test method for
* {@link org.springframework.batch.integration.job.MessageOrientedStep#setReplyChannel(org.springframework.integration.channel.MessageChannel)}.
* {@link org.springframework.batch.integration.job.MessageOrientedStep#setSource(MessageSource)}.
*/
@Test
public void testSetReplyChannel() {
Method method = ReflectionUtils.findMethod(MessageOrientedStep.class, "setReplyChannel",
new Class<?>[] { MessageChannel.class });
Method method = ReflectionUtils.findMethod(MessageOrientedStep.class, "setSource",
new Class<?>[] { BlockingSource.class });
assertNotNull(method);
Annotation[] annotations = AnnotationUtils.getAnnotations(method);
assertEquals(1, annotations.length);

View File

@@ -15,7 +15,7 @@ import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.integration.JobSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHandlingException;
@@ -30,11 +30,11 @@ public class JobLaunchingMessageHandlerIntegrationTests {
@Autowired
@Qualifier("requests")
private MessageChannel requestChannel;
private PollableChannel requestChannel;
@Autowired
@Qualifier("response")
private MessageChannel responseChannel;
private PollableChannel responseChannel;
private JobSupport job = new JobSupport("testJob");

View File

@@ -37,6 +37,7 @@ import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageSource;
import org.springframework.integration.message.MessageTarget;
import org.springframework.integration.message.PollableSource;
import org.springframework.integration.scheduling.PollingSchedule;
import org.springframework.integration.scheduling.SimpleTaskScheduler;
import org.springframework.integration.scheduling.TaskScheduler;
@@ -385,7 +386,7 @@ public class PollableSourceRetryTests {
* @return
*/
private DirectChannel getChannel(MessageTarget handler, MessageSource<Object> source) {
DirectChannel channel = new DirectChannel(source);
DirectChannel channel = new DirectChannel();
channel.setName("input");
channel.subscribe(handler);
return channel;
@@ -400,7 +401,7 @@ public class PollableSourceRetryTests {
lifecycle.stop();
}
private MessageSource<Object> getPollableSource(List<String> list) {
private PollableSource<Object> getPollableSource(List<String> list) {
final ItemReader<String> reader = new ListItemReader<String>(list) {
public String read() {
String item = super.read();
@@ -408,10 +409,12 @@ public class PollableSourceRetryTests {
return item;
}
};
MessageSource<Object> source = new MessageSource<Object>() {
PollableSource<Object> source = new PollableSource<Object>() {
public Message<Object> receive() {
try {
return new GenericMessage<Object>(reader.read());
String payload = reader.read();
if (payload==null) return null;
return new GenericMessage<Object>(payload);
}
catch (RuntimeException e) {
throw e;