diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java
index 731bca4e2..3c733f3ed 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java
@@ -15,10 +15,14 @@
*/
package org.springframework.batch.core.launch.support;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.Properties;
-import junit.framework.TestCase;
-
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
@@ -33,10 +37,10 @@ import org.springframework.util.ClassUtils;
* @author Lucas Ward
*
*/
-public class CommandLineJobRunnerTests extends TestCase {
+public class CommandLineJobRunnerTests {
private static final String JOB = ClassUtils.addResourcePathToPackagePath(CommandLineJobRunnerTests.class,
- "job.xml");
+ "job-with-environment.xml");
private static final String JOB_NAME = "test-job";
@@ -52,24 +56,22 @@ public class CommandLineJobRunnerTests extends TestCase {
private String[] args = new String[] { jobPath, jobName, jobKey, scheduleDate, vendorId };
- /*
- * (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
JobExecution jobExecution = new JobExecution(null, new Long(1));
ExitStatus exitStatus = ExitStatus.FINISHED;
jobExecution.setExitStatus(exitStatus);
StubJobLauncher.jobExecution = jobExecution;
}
+ @Test
public void testMain() {
CommandLineJobRunner.main(args);
- assertTrue("injected JobParametersConverter used instead of default", StubJobParametersConverter.called);
+ assertTrue("Injected JobParametersConverter not used instead of default", StubJobParametersConverter.called);
assertEquals(0, StubSystemExiter.getStatus());
}
+ @Test
public void testJobAlreadyRunning() throws Throwable {
StubJobLauncher.throwExecutionRunningException = true;
CommandLineJobRunner.main(args);
@@ -83,6 +85,7 @@ public class CommandLineJobRunnerTests extends TestCase {
// CommandLineJobRunner.main(args);
// }
+ @Test
public void testWithNoParameters() throws Throwable {
String[] args = new String[] { jobPath, jobName };
CommandLineJobRunner.main(args);
@@ -90,15 +93,15 @@ public class CommandLineJobRunnerTests extends TestCase {
assertEquals(new JobParameters(), StubJobLauncher.jobParameters);
}
+ @Test
public void testDestroyCallback() throws Throwable {
String[] args = new String[] { jobPath, jobName };
CommandLineJobRunner.main(args);
assertTrue(StubJobLauncher.destroyed);
}
- protected void tearDown() throws Exception {
- super.tearDown();
-
+ @After
+ public void tearDown() throws Exception {
StubJobLauncher.tearDown();
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunnerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunnerTests.java
index 4f907e081..106d1ba7b 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunnerTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunnerTests.java
@@ -42,7 +42,7 @@ public class JobRegistryBackgroundJobRunnerTests {
JobRegistryBackgroundJobRunner.getErrors().clear();
System.setProperty(JobRegistryBackgroundJobRunner.EMBEDDED, "");
JobRegistryBackgroundJobRunner.main(
- ClassUtils.addResourcePathToPackagePath(getClass(), "test-environment.xml"), ClassUtils
+ ClassUtils.addResourcePathToPackagePath(getClass(), "test-environment-with-registry.xml"), ClassUtils
.addResourcePathToPackagePath(getClass(), "job.xml"));
}
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/job-with-environment.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/job-with-environment.xml
new file mode 100644
index 000000000..5250864be
--- /dev/null
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/job-with-environment.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/job.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/job.xml
index 6d450fd05..05952ac09 100644
--- a/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/job.xml
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/job.xml
@@ -9,8 +9,6 @@
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
-
-
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/test-environment-with-registry.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/test-environment-with-registry.xml
new file mode 100644
index 000000000..b26bab52a
--- /dev/null
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/test-environment-with-registry.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/test-environment.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/test-environment.xml
index d442bb315..e78986e11 100644
--- a/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/test-environment.xml
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/test-environment.xml
@@ -11,8 +11,6 @@
class="org.springframework.batch.core.launch.support.CommandLineJobRunnerTests$StubJobLauncher"
destroy-method="destroy" />
-
-