diff --git a/archetypes/simple-cli/pom.xml b/archetypes/simple-cli/pom.xml
index 9492460b4..4106e6f2f 100644
--- a/archetypes/simple-cli/pom.xml
+++ b/archetypes/simple-cli/pom.xml
@@ -76,6 +76,12 @@
spring-batch-infrastructure
${spring.batch.version}
+
+ org.springframework.batch
+ spring-batch-test
+ ${spring.batch.version}
+ test
+
commons-dbcp
commons-dbcp
diff --git a/archetypes/simple-cli/src/main/resources/META-INF/spring/module-context.xml b/archetypes/simple-cli/src/main/resources/META-INF/spring/module-context.xml
index 6ce314866..1ed874b14 100644
--- a/archetypes/simple-cli/src/main/resources/META-INF/spring/module-context.xml
+++ b/archetypes/simple-cli/src/main/resources/META-INF/spring/module-context.xml
@@ -1,13 +1,13 @@
Example job to get you started. It provides a
skeleton for a typical batch application.
-
+
@@ -17,6 +17,9 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/archetypes/simple-cli/src/test/java/example/ExampleJobConfigurationTests.java b/archetypes/simple-cli/src/test/java/example/ExampleJobConfigurationTests.java
index 2900f2d6d..2165ab5da 100644
--- a/archetypes/simple-cli/src/test/java/example/ExampleJobConfigurationTests.java
+++ b/archetypes/simple-cli/src/test/java/example/ExampleJobConfigurationTests.java
@@ -15,39 +15,55 @@
*/
package example;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.springframework.batch.core.Job;
-import org.springframework.batch.core.JobParameters;
-import org.springframework.batch.core.launch.JobLauncher;
+import org.springframework.batch.core.BatchStatus;
+import org.springframework.batch.core.JobExecution;
+import org.springframework.batch.core.JobInstance;
+import org.springframework.batch.core.launch.JobOperator;
+import org.springframework.batch.test.AbstractJobTests;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-/**
- * @author Dave Syer
- *
- */
-@ContextConfiguration(locations={"/launch-context.xml"})
+@ContextConfiguration(locations = { "/launch-context.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
-public class ExampleJobConfigurationTests {
-
- @Autowired
- private JobLauncher jobLauncher;
+public class ExampleJobConfigurationTests extends AbstractJobTests {
@Autowired
- private Job job;
-
- @Test
- public void testSimpleProperties() throws Exception {
- assertNotNull(jobLauncher);
- }
-
+ private JobOperator jobOperator;
+
+ /**
+ * Create a unique job instance and check it's execution completes
+ * successfully - uses the convenience methods provided by the testing
+ * superclass.
+ */
@Test
public void testLaunchJob() throws Exception {
- jobLauncher.run(job, new JobParameters());
+
+ JobExecution jobExecution = launchJob(getUniqueJobParameters());
+ assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
}
-
+
+ /**
+ * Execute a fresh {@link JobInstance} using {@link JobOperator} - closer to
+ * a remote invocation scenario.
+ */
+ @Test
+ public void testLaunchByJobOperator() throws Exception {
+
+ // assumes the job has a JobIncrementer set
+ long jobExecutionId = jobOperator.startNextInstance(getJob().getName());
+
+ // no need to wait for job completion in this case, the job is launched
+ // synchronously
+
+ String result = jobOperator.getSummary(jobExecutionId);
+ assertTrue(result.contains("status=" + BatchStatus.COMPLETED));
+
+ }
+
}