Fix integration against latest Spring Integration
This commit is contained in:
@@ -12,10 +12,10 @@ import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.ItemStreamException;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
public class ChunkMessageChannelItemWriter<T> extends StepExecutionListenerSupport implements ItemWriter<T>, ItemStream {
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.springframework.batch.integration.file;
|
||||
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.core.Message;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.item.ItemStreamException;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.core.Message;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -38,7 +38,7 @@ public class ResourcePayloadAsJobParameterStrategy implements MessageToJobParame
|
||||
* Convert a message payload which is a {@link Resource} to its URL
|
||||
* representation and load that into a job parameter.
|
||||
*
|
||||
* @see org.springframework.batch.integration.file.MessageToJobParametersStrategy#getJobParameters(org.springframework.integration.message.Message)
|
||||
* @see MessageToJobParametersStrategy#getJobParameters(Message)
|
||||
*/
|
||||
public JobParameters getJobParameters(Message<?> message) {
|
||||
JobParametersBuilder builder = new JobParametersBuilder();
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,10 +23,10 @@ import org.springframework.batch.core.step.AbstractStep;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,7 +90,7 @@ public class StepExecutionMessageHandler {
|
||||
if (!isRestart(jobInstance, lastStepExecution)) {
|
||||
stepExecution.setExecutionContext(new ExecutionContext());
|
||||
}
|
||||
|
||||
jobRepository.add(stepExecution);
|
||||
step.execute(stepExecution);
|
||||
|
||||
}
|
||||
|
||||
@@ -80,4 +80,11 @@ public class JobRepositorySupport implements JobRepository {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.repository.JobRepository#getLastJobExecution(java.lang.String, org.springframework.batch.core.JobParameters)
|
||||
*/
|
||||
public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.bus.MessageBus;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ import org.springframework.batch.support.transaction.ResourcelessTransactionMana
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.bus.MessageBus;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -305,6 +305,7 @@ public class ChunkMessageItemWriterIntegrationTests {
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParametersBuilder().addLong(
|
||||
"job.counter", jobCounter++).toJobParameters());
|
||||
StepExecution stepExecution = jobExecution.createStepExecution(step.getName());
|
||||
jobRepository.add(stepExecution);
|
||||
return stepExecution;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ import org.springframework.batch.support.transaction.ResourcelessTransactionMana
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -100,7 +100,7 @@ public class FileToMessagesJobFactoryBeanTests {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.integration.file.FileToMessagesJobFactoryBean#setChannel(org.springframework.integration.channel.MessageChannel)}.
|
||||
* {@link FileToMessagesJobFactoryBean#setChannel(MessageChannel)}.
|
||||
*/
|
||||
@Test
|
||||
public void testSetChannel() {
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
package org.springframework.batch.integration.file;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.integration.file.ResourcePayloadAsJobParameterStrategy;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
|
||||
/**
|
||||
@@ -36,7 +37,7 @@ public class ResourcePayloadAsJobParameterStrategyTests {
|
||||
private static final String INPUT_FILE_PATH = ResourcePayloadAsJobParameterStrategy.FILE_INPUT_PATH;
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.integration.file.ResourcePayloadAsJobParameterStrategy#getJobParameters(org.springframework.integration.message.Message)}.
|
||||
* Test method for {@link ResourcePayloadAsJobParameterStrategy#getJobParameters(Message)}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetJobParameters() {
|
||||
@@ -46,7 +47,7 @@ public class ResourcePayloadAsJobParameterStrategyTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.integration.file.ResourcePayloadAsJobParameterStrategy#getJobParameters(org.springframework.integration.message.Message)}.
|
||||
* Test method for {@link ResourcePayloadAsJobParameterStrategy#getJobParameters(Message)}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetJobParametersWithWrongPayload() {
|
||||
|
||||
@@ -28,10 +28,10 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.Splitter;
|
||||
import org.springframework.integration.bus.MessageBus;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
@@ -26,12 +26,10 @@ import java.util.Collections;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.integration.adapter.MessageHandler;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.ThreadLocalChannel;
|
||||
import org.springframework.integration.endpoint.ServiceActivatorEndpoint;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -43,8 +41,7 @@ public class MessageChannelItemWriterTests {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.integration.item.MessageChannelItemWriter#setChannel(org.springframework.integration.channel.MessageChannel)}
|
||||
* .
|
||||
* {@link MessageChannelItemWriter#setChannel(MessageChannel)} .
|
||||
*/
|
||||
@Test
|
||||
public void testSetChannel() {
|
||||
@@ -89,12 +86,11 @@ public class MessageChannelItemWriterTests {
|
||||
@Test
|
||||
public void testWriteWithRollbackOnEndpoint() throws Exception {
|
||||
DirectChannel channel = new DirectChannel();
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(new MessageHandler() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
channel.subscribe(new MessageConsumer() {
|
||||
public void onMessage(Message<?> message) {
|
||||
throw new RuntimeException("Planned failure");
|
||||
}
|
||||
});
|
||||
channel.subscribe(endpoint);
|
||||
MessageChannelItemWriter<String> writer = new MessageChannelItemWriter<String>();
|
||||
writer.setChannel(channel);
|
||||
try {
|
||||
@@ -104,7 +100,7 @@ public class MessageChannelItemWriterTests {
|
||||
catch (RuntimeException e) {
|
||||
// INT-377: this assertion fails because the exception is wrapped
|
||||
// too tightly
|
||||
assertEquals("Planned failure", e.getCause().getMessage());
|
||||
assertEquals("Planned failure", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.batch.integration.job;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
@@ -47,6 +48,11 @@ public class MessageOrientedStepIntegrationTests {
|
||||
@Autowired
|
||||
@Qualifier("job")
|
||||
private Job job;
|
||||
|
||||
@After
|
||||
public void shutdown() {
|
||||
bus.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
|
||||
@@ -34,11 +34,11 @@ import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.channel.ThreadLocalChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@ import org.springframework.batch.integration.JobSupport;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.bus.MessageBus;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageHeaders;
|
||||
import org.springframework.integration.message.MessagingException;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -75,7 +75,7 @@ public class JobLaunchingMessageHandlerIntegrationTests {
|
||||
JobParametersBuilder builder = new JobParametersBuilder();
|
||||
builder.addString("dontclash", "12");
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put(MessageHeaders.RETURN_ADDRESS, "response");
|
||||
map.put(MessageHeaders.REPLY_CHANNEL, "response");
|
||||
MessageHeaders headers = new MessageHeaders(map);
|
||||
GenericMessage<JobLaunchRequest> trigger = new GenericMessage<JobLaunchRequest>(new JobLaunchRequest(job,
|
||||
builder.toJobParameters()), headers);
|
||||
|
||||
@@ -1,66 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
|
||||
|
||||
<bean id="jobLauncher"
|
||||
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
|
||||
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
|
||||
<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
|
||||
|
||||
<bean id="jobRepository"
|
||||
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean"/>
|
||||
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
|
||||
<property name="transactionManager" ref="transactionManager"/>
|
||||
</bean>
|
||||
|
||||
<bean id="simpleJob"
|
||||
class="org.springframework.batch.core.job.SimpleJob"
|
||||
abstract="true">
|
||||
<bean id="simpleJob" class="org.springframework.batch.core.job.SimpleJob" abstract="true">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="restartable" value="true" />
|
||||
</bean>
|
||||
<bean id="taskletStep"
|
||||
class="org.springframework.batch.core.step.tasklet.TaskletStep" abstract="true">
|
||||
<bean id="taskletStep" class="org.springframework.batch.core.step.tasklet.TaskletStep" abstract="true">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="allowStartIfComplete" value="true" />
|
||||
</bean>
|
||||
<bean id="simpleStep"
|
||||
class="org.springframework.batch.core.step.item.SimpleStepFactoryBean"
|
||||
abstract="true">
|
||||
<bean id="simpleStep" class="org.springframework.batch.core.step.item.SimpleStepFactoryBean" abstract="true">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="startLimit" value="100" />
|
||||
<property name="commitInterval" value="1" />
|
||||
</bean>
|
||||
<bean id="skipLimitStep"
|
||||
class="org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean"
|
||||
parent="simpleStep" abstract="true">
|
||||
<bean id="skipLimitStep" class="org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean" parent="simpleStep"
|
||||
abstract="true">
|
||||
<property name="skipLimit" value="0" />
|
||||
</bean>
|
||||
<bean id="customEditorConfigurer"
|
||||
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
|
||||
<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
|
||||
<property name="customEditors">
|
||||
<map>
|
||||
<entry key="int[]">
|
||||
<bean
|
||||
class="org.springframework.batch.support.IntArrayPropertyEditor" />
|
||||
<bean class="org.springframework.batch.support.IntArrayPropertyEditor" />
|
||||
</entry>
|
||||
<entry
|
||||
key="org.springframework.batch.item.file.transform.Range[]">
|
||||
<bean
|
||||
class="org.springframework.batch.item.file.transform.RangeArrayPropertyEditor" />
|
||||
<entry key="org.springframework.batch.item.file.transform.Range[]">
|
||||
<bean class="org.springframework.batch.item.file.transform.RangeArrayPropertyEditor" />
|
||||
</entry>
|
||||
<entry key="java.util.Date">
|
||||
<bean
|
||||
class="org.springframework.beans.propertyeditors.CustomDateEditor">
|
||||
<bean class="org.springframework.beans.propertyeditors.CustomDateEditor">
|
||||
<constructor-arg>
|
||||
<bean class="java.text.SimpleDateFormat">
|
||||
<constructor-arg value="yyyyMMdd" />
|
||||
|
||||
Reference in New Issue
Block a user