list) {
- StringBuffer buffer = new StringBuffer();
- for (String line : list) {
- if (!line.startsWith("//") && !line.startsWith("--")) {
- buffer.append(line + "\n");
- }
- }
- return buffer.toString();
- }
-
- public void setInitScripts(Resource[] initScripts) {
- this.initScripts = initScripts;
- }
-
- public void setDestroyScripts(Resource[] destroyScripts) {
- this.destroyScripts = destroyScripts;
- }
-
- public void setDataSource(DataSource dataSource) {
- this.dataSource = dataSource;
- }
-
- public void setIgnoreFailedDrop(boolean ignoreFailedDrop) {
- this.ignoreFailedDrop = ignoreFailedDrop;
- }
-
-}
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 81050a616..b68d633dd 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,35 +1,22 @@
-
+
- Example job to get you started. It provides a
- skeleton for
- a typical batch application.
-
+ Example job providing a skeleton for a typical batch application.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/archetypes/simple-cli/src/main/resources/batch.properties b/archetypes/simple-cli/src/main/resources/batch.properties
index 5c55586e4..dea386513 100644
--- a/archetypes/simple-cli/src/main/resources/batch.properties
+++ b/archetypes/simple-cli/src/main/resources/batch.properties
@@ -7,5 +7,9 @@ batch.jdbc.url=jdbc:hsqldb:mem:testdb;sql.enforce_strict_size=true
# batch.jdbc.url=jdbc:hsqldb:hsql://localhost:9005/samples
batch.jdbc.user=sa
batch.jdbc.password=
-batch.schema=
-batch.schema.script=org/springframework/batch/core/schema-hsqldb.sql
+batch.schema.script=classpath:org/springframework/batch/core/schema-hsqldb.sql
+batch.drop.script=classpath:org/springframework/batch/core/schema-drop-hsqldb.sql
+person.sql.location=classpath:support/person.sql
+person.test.data.location=classpath:support/sample-data.csv
+person.insert.sql=INSERT INTO people (first_name, last_name) VALUES (:firstName, :lastName)
+step1.commit.interval=5
diff --git a/archetypes/simple-cli/src/main/resources/launch-context.xml b/archetypes/simple-cli/src/main/resources/launch-context.xml
index dfc3b52b0..19c4f5ac5 100644
--- a/archetypes/simple-cli/src/main/resources/launch-context.xml
+++ b/archetypes/simple-cli/src/main/resources/launch-context.xml
@@ -1,59 +1,69 @@
-
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
-
-
-
-
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
diff --git a/archetypes/simple-cli/src/main/resources/log4j.properties b/archetypes/simple-cli/src/main/resources/log4j.properties
index fd06b94c7..2cdeeb81b 100644
--- a/archetypes/simple-cli/src/main/resources/log4j.properties
+++ b/archetypes/simple-cli/src/main/resources/log4j.properties
@@ -4,10 +4,5 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p %t [%c] - <%m>%n
-log4j.category.org.apache.activemq=ERROR
log4j.category.org.springframework.batch=DEBUG
log4j.category.org.springframework.transaction=INFO
-
-log4j.category.org.hibernate.SQL=DEBUG
-# for debugging datasource initialization
-# log4j.category.test.jdbc=DEBUG
diff --git a/archetypes/simple-cli/src/main/resources/support/person.sql b/archetypes/simple-cli/src/main/resources/support/person.sql
new file mode 100644
index 000000000..4e405e6de
--- /dev/null
+++ b/archetypes/simple-cli/src/main/resources/support/person.sql
@@ -0,0 +1,7 @@
+DROP TABLE people IF EXISTS;
+
+CREATE TABLE people (
+ person_id BIGINT IDENTITY NOT NULL PRIMARY KEY,
+ first_name VARCHAR(20),
+ last_name VARCHAR(20)
+);
diff --git a/archetypes/simple-cli/src/main/resources/support/sample-data.csv b/archetypes/simple-cli/src/main/resources/support/sample-data.csv
new file mode 100644
index 000000000..cead90f5a
--- /dev/null
+++ b/archetypes/simple-cli/src/main/resources/support/sample-data.csv
@@ -0,0 +1,5 @@
+Jill,Doe
+Joe,Doe
+Justin,Doe
+Jane,Doe
+John,Doe
diff --git a/archetypes/simple-cli/src/main/scripts/runJob.bat b/archetypes/simple-cli/src/main/scripts/runJob.bat
new file mode 100644
index 000000000..72ed089a4
--- /dev/null
+++ b/archetypes/simple-cli/src/main/scripts/runJob.bat
@@ -0,0 +1,8 @@
+@echo off
+
+IF NOT DEFINED JAVA_HOME (
+ echo Error: JAVA_HOME environment variable is not set.
+ EXIT /B
+)
+
+%JAVA_HOME%\bin\java -cp resources\;lib\* org.springframework.batch.core.launch.support.CommandLineJobRunner classpath:/launch-context.xml personJob
diff --git a/archetypes/simple-cli/src/main/scripts/runJob.sh b/archetypes/simple-cli/src/main/scripts/runJob.sh
new file mode 100644
index 000000000..fe9e1c8bd
--- /dev/null
+++ b/archetypes/simple-cli/src/main/scripts/runJob.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+if [ "$JAVA_HOME" = "" ]; then
+ echo "Error: JAVA_HOME environment variable is not set."
+ exit 1
+fi
+
+$JAVA_HOME/bin/java -cp resources/:lib/* org.springframework.batch.core.launch.support.CommandLineJobRunner classpath:/launch-context.xml personJob
diff --git a/archetypes/simple-cli/src/site/site.xml b/archetypes/simple-cli/src/site/site.xml
index 4bba09c7c..42b3b297e 100644
--- a/archetypes/simple-cli/src/site/site.xml
+++ b/archetypes/simple-cli/src/site/site.xml
@@ -1,25 +1,20 @@
+
+ Spring Batch: ${project.name}
+ index.html
+
-
- Spring Batch: ${project.name}
- index.html
-
-
-
- org.springframework.maven.skins
- maven-spring-skin
- 1.0.5
-
-
-
-
-
-
-
-
-
-
-
+
+ org.springframework.maven.skins
+ maven-spring-skin
+ 1.0.5
+
+
+
+
+
+
+
diff --git a/archetypes/simple-cli/src/test/java/example/ExampleItemReaderTests.java b/archetypes/simple-cli/src/test/java/example/ExampleItemReaderTests.java
deleted file mode 100644
index 46d83ddb0..000000000
--- a/archetypes/simple-cli/src/test/java/example/ExampleItemReaderTests.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package example;
-
-import junit.framework.TestCase;
-
-public class ExampleItemReaderTests extends TestCase {
-
- private ExampleItemReader reader = new ExampleItemReader();
-
- public void testReadOnce() throws Exception {
- assertEquals("Hello world!", reader.read());
- }
-
- public void testReadTwice() throws Exception {
- reader.read();
- assertEquals(null, reader.read());
- }
-
-}
diff --git a/archetypes/simple-cli/src/test/java/example/ExampleItemWriterTests.java b/archetypes/simple-cli/src/test/java/example/ExampleItemWriterTests.java
deleted file mode 100644
index b23ccbee2..000000000
--- a/archetypes/simple-cli/src/test/java/example/ExampleItemWriterTests.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package example;
-
-import junit.framework.TestCase;
-
-public class ExampleItemWriterTests extends TestCase {
-
- private ExampleItemWriter writer = new ExampleItemWriter();
-
- public void testWrite() throws Exception {
- writer.write(null); // nothing bad happens
- }
-
-}
diff --git a/archetypes/simple-cli/src/test/java/example/PersonItemProcessorTest.java b/archetypes/simple-cli/src/test/java/example/PersonItemProcessorTest.java
new file mode 100644
index 000000000..49f0d3da0
--- /dev/null
+++ b/archetypes/simple-cli/src/test/java/example/PersonItemProcessorTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package example;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+/**
+ *
+ * Example test case processing a {@link Person} using the {@link PersonItemProcessor}.
+ *
+ */
+public class PersonItemProcessorTest {
+ @Test
+ public void testProcessedPersonRecord() throws Exception {
+ final Person person = new Person();
+ person.setFirstName("Jane");
+ person.setLastName("Doe");
+
+ final Person processedPerson = new PersonItemProcessor().process(person);
+
+ assertEquals("First name does not match expected value.", "JANE", processedPerson.getFirstName());
+ assertEquals("Last name does not match expected value.", "DOE", processedPerson.getLastName());
+ }
+}
diff --git a/archetypes/simple-cli/src/test/java/example/ExampleJobConfigurationTests.java b/archetypes/simple-cli/src/test/java/example/PersonJobConfigurationTest.java
similarity index 54%
rename from archetypes/simple-cli/src/test/java/example/ExampleJobConfigurationTests.java
rename to archetypes/simple-cli/src/test/java/example/PersonJobConfigurationTest.java
index b722cbe90..96fbf4cce 100644
--- a/archetypes/simple-cli/src/test/java/example/ExampleJobConfigurationTests.java
+++ b/archetypes/simple-cli/src/test/java/example/PersonJobConfigurationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2007 the original author or authors.
+ * Copyright 2006-2013 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.
@@ -15,7 +15,8 @@
*/
package example;
-import static org.junit.Assert.*;
+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.BatchStatus;
@@ -30,10 +31,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@ContextConfiguration(locations = { "/test-context.xml" })
+/**
+ *
+ * Test cases asserting on the example job's configuration.
+ *
+ */
+@ContextConfiguration(locations = "/test-context.xml")
@RunWith(SpringJUnit4ClassRunner.class)
-public class ExampleJobConfigurationTests {
-
+public class PersonJobConfigurationTest {
@Autowired
private JobLauncher jobLauncher;
@@ -45,41 +50,47 @@ public class ExampleJobConfigurationTests {
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;
-
+
+ /**
+ *
+ * Creates a new {@link JobExecution} using a {@link JobLauncher}.
+ *
+ *
+ * @throws Exception if any {@link Exception}'s occur
+ */
@Test
public void testLaunchJobWithJobLauncher() throws Exception {
- JobExecution jobExecution = jobLauncher.run(job, new JobParameters());
- assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
+ final JobExecution jobExecution = jobLauncher.run(job, new JobParameters());
+ assertEquals("Batch status not COMPLETED", BatchStatus.COMPLETED, jobExecution.getStatus());
}
/**
- * Create a unique job instance and check it's execution completes
- * successfully - uses the convenience methods provided by the testing
- * superclass.
+ *
+ * Create a unique job instance and check it's execution completes successfully.
+ * Uses the convenience methods provided by the testing superclass.
+ *
+ *
+ * @throws Exception if any {@link Exception}'s occur
*/
@Test
public void testLaunchJob() throws Exception {
-
- JobExecution jobExecution = jobLauncherTestUtils.launchJob(jobLauncherTestUtils.getUniqueJobParameters());
- assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
+ final JobExecution jobExecution = jobLauncherTestUtils.launchJob(jobLauncherTestUtils.getUniqueJobParameters());
+ assertEquals("Batch status not COMPLETED", BatchStatus.COMPLETED, jobExecution.getStatus());
}
/**
- * Execute a fresh {@link JobInstance} using {@link JobOperator} - closer to
+ *
+ * Execute a fresh {@link JobInstance} using {@link JobOperator} which is closer to
* a remote invocation scenario.
+ *
+ *
+ * @throws Exception if any {@link Exception}'s occur
*/
@Test
public void testLaunchByJobOperator() throws Exception {
+ final long jobExecutionId = jobOperator.startNextInstance(jobLauncherTestUtils.getJob().getName());
- // assumes the job has a JobIncrementer set
- long jobExecutionId = jobOperator.startNextInstance(jobLauncherTestUtils.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));
-
+ final String result = jobOperator.getSummary(jobExecutionId);
+ assertTrue("Result does not contain status=COMPLETED", result.contains("status=" + BatchStatus.COMPLETED));
}
-
}
diff --git a/archetypes/simple-cli/src/test/resources/test-context.xml b/archetypes/simple-cli/src/test/resources/test-context.xml
index c4ec752e8..e14b4c2d6 100644
--- a/archetypes/simple-cli/src/test/resources/test-context.xml
+++ b/archetypes/simple-cli/src/test/resources/test-context.xml
@@ -1,13 +1,38 @@
-
+
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+