diff --git a/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml b/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml index 19dfea061..d52b3ecc2 100644 --- a/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml @@ -27,6 +27,9 @@ + + + diff --git a/spring-batch-samples/src/main/resources/simple-container-definition.xml b/spring-batch-samples/src/main/resources/simple-container-definition.xml index cdfa7387f..fdfed86b0 100644 --- a/spring-batch-samples/src/main/resources/simple-container-definition.xml +++ b/spring-batch-samples/src/main/resources/simple-container-definition.xml @@ -160,6 +160,10 @@ pointcut="execution( * org.springframework.batch.item.ItemProcessor+.process(Object)) and args(item)" method="doStronglyTypedLogging" /> + + diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java index fda58c4ff..7e25fb9fb 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/AbstractBatchLauncherTests.java @@ -19,7 +19,6 @@ package org.springframework.batch.sample; import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobInstanceProperties; import org.springframework.batch.execution.launch.JobLauncher; -import org.springframework.batch.execution.runtime.DefaultJobIdentifier; import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/FixedLengthImportJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/FixedLengthImportJobFunctionalTests.java index e18191c0c..343a1f07a 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/FixedLengthImportJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/FixedLengthImportJobFunctionalTests.java @@ -47,12 +47,14 @@ public class FixedLengthImportJobFunctionalTests extends AbstractValidatingBatch } /** - * check that records have been correctly written to database + * Check that records have been correctly written to database * @throws Exception */ protected void validatePostConditions() throws Exception { inputSource.open(); + + System.err.println(jdbcTemplate.queryForList("SELECT ID, ISIN, QUANTITY, PRICE, CUSTOMER FROM trade ORDER BY id")); jdbcTemplate.query("SELECT ID, ISIN, QUANTITY, PRICE, CUSTOMER FROM trade ORDER BY id", new RowCallbackHandler() { @@ -72,6 +74,7 @@ public class FixedLengthImportJobFunctionalTests extends AbstractValidatingBatch }); + System.err.println(inputSource.read()); assertNull(inputSource.read()); } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/GracefulShutdownFunctionalTest.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/GracefulShutdownFunctionalTest.java index 0ae823da0..3a92efb25 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/GracefulShutdownFunctionalTest.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/GracefulShutdownFunctionalTest.java @@ -16,14 +16,9 @@ package org.springframework.batch.sample; -import java.util.ArrayList; -import java.util.List; - import org.springframework.batch.core.domain.BatchStatus; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobInstanceProperties; -import org.springframework.batch.core.executor.StepInterruptedException; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; /** * Functional test for graceful shutdown. A batch container is started in a new thread, @@ -39,54 +34,16 @@ public class GracefulShutdownFunctionalTest extends AbstractBatchLauncherTests { } public void testLaunchJob() throws Exception { - final List errors = new ArrayList(); + final JobInstanceProperties jobInstanceProperties = new JobInstanceProperties(); - -// Thread jobThread = new Thread(){ -// public void run(){ -// try { -// launcher.run(getJob(), jobInstanceProperties); -// } -// catch (RuntimeException e) { -// if (!(e.getCause() instanceof StepInterruptedException)) { -// errors.add(e); -// } -// } -// catch (Exception e) { -// errors.add(e); -// } -// } -// }; -// -// jobThread.start(); -// -// //give the thread a second to start up -// Thread.sleep(200); -// -// assertTrue(launcher.isRunning()); -// assertTrue(jobThread.isAlive()); -// -// //stop the job -// -// launcher.stop(); -// -// //it takes a little while for it to shut down. -// Thread.sleep(1000); -// -// assertFalse(launcher.isRunning()); -// assertFalse(jobThread.isAlive()); -// -// if (!errors.isEmpty()) { -// Exception e = (Exception) errors.get(0); -// e.printStackTrace(); -// fail("Unexpected Exception: "+e); -// } - JobExecution jobExecution = launcher.run(getJob(), jobInstanceProperties); - assertEquals(BatchStatus.STARTED, jobExecution.getExitStatus()); - + Thread.sleep(200); + + assertEquals(BatchStatus.STARTED, jobExecution.getStatus()); + assertTrue(jobExecution.isRunning()); + jobExecution.stop(); int count = 0; @@ -95,6 +52,7 @@ public class GracefulShutdownFunctionalTest extends AbstractBatchLauncherTests { } assertFalse(jobExecution.isRunning()); + } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java index 4b8c9c5fc..385698d85 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java @@ -17,8 +17,6 @@ package org.springframework.batch.sample; import org.springframework.batch.core.domain.JobInstanceProperties; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; -import org.springframework.batch.io.exception.BatchCriticalException; import org.springframework.jdbc.core.JdbcOperations; /** diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java index 3f1115973..00dba3fdf 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java @@ -22,8 +22,6 @@ import org.springframework.transaction.support.TransactionTemplate; public class JdbcJobRepositoryTests extends AbstractTransactionalDataSourceSpringContextTests { - private ScheduledJobIdentifier jobIdentifier; - private JobRepository repository; private Job jobConfiguration; @@ -43,7 +41,7 @@ public class JdbcJobRepositoryTests extends AbstractTransactionalDataSourceSprin } protected void onSetUpInTransaction() throws Exception { - jobIdentifier = new ScheduledJobIdentifier("Job1", "TestStream", + new ScheduledJobIdentifier("Job1", "TestStream", new SimpleDateFormat("yyyyMMdd").parse("20070505")); jobConfiguration = new Job("test-job"); jobConfiguration.setRestartable(true); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/processor/StagingItemProcessorTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/processor/StagingItemProcessorTests.java index 2db9f9801..2721e5045 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/processor/StagingItemProcessorTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/processor/StagingItemProcessorTests.java @@ -6,7 +6,6 @@ import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.JobInstanceProperties; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.batch.execution.scope.SimpleStepContext; import org.springframework.batch.execution.scope.StepSynchronizationManager; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java index ece977869..7bd527497 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java @@ -5,7 +5,6 @@ import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.JobInstanceProperties; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.batch.execution.scope.SimpleStepContext; import org.springframework.batch.execution.scope.StepSynchronizationManager; import org.springframework.batch.repeat.context.RepeatContextSupport;