Java Reference
In-Depth Information
public void testCarProcessingStep() throws Exception {
jobLauncherUtils.launchStep("carProcessingStep", getParams())
assertFileEquals(new ClassPathResource(INPUT_FILE),
new FileSystemResource(OUTPUT_FILE));
private JobParameters getParams() {
return new JobParametersBuilder().addString("carFile", INPUT_FILE)
.addString("outputFile", "file:/" + OUTPUT_FILE)
As mentioned, the structure of this test should be familiar. It's the same as you've used for the past
few tests. However, a few aspects are interesting for this test. First is the bean jobLauncherUtils . This is
the utility class mentioned earlier. Spring autowires it into your test and autowires its own dependencies
to things like a datasource as well as a job launcher. Because of JobLauncherTestUtils ' need to be
autowired, you need to be sure to add it to your test-context.xml file. Listing 12-19 shows the contents
of the test-context.xml file for this test.
Listing 12-19. test-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
<import resource="launch-context.xml"/>
<import resource="jobs/carJob.xml"/>
<bean id="placeholderProperties"
<property name="location" value="" />
<property name="systemPropertiesModeName"
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="order" value="1" />
<bean id="jobLauncherUtils" class="org.springframework.batch.test.JobLauncherTestUtils"/>
Search WWH ::

Custom Search