diff --git a/execution/src/main/java/org/springframework/batch/execution/repository/dao/HibernateJobDao.java b/execution/src/main/java/org/springframework/batch/execution/repository/dao/HibernateJobDao.java index 2b245eb02..4ea5947e8 100644 --- a/execution/src/main/java/org/springframework/batch/execution/repository/dao/HibernateJobDao.java +++ b/execution/src/main/java/org/springframework/batch/execution/repository/dao/HibernateJobDao.java @@ -22,9 +22,9 @@ import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate.criterion.Expression; import org.springframework.batch.core.domain.JobExecution; +import org.springframework.batch.core.domain.JobIdentifier; import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException; -import org.springframework.batch.core.runtime.JobIdentifier; import org.springframework.batch.execution.runtime.ScheduledJobIdentifier; import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; diff --git a/execution/src/main/java/org/springframework/batch/execution/repository/dao/SqlStepDao.java b/execution/src/main/java/org/springframework/batch/execution/repository/dao/SqlStepDao.java index eadbf00c1..f0915805c 100644 --- a/execution/src/main/java/org/springframework/batch/execution/repository/dao/SqlStepDao.java +++ b/execution/src/main/java/org/springframework/batch/execution/repository/dao/SqlStepDao.java @@ -26,7 +26,6 @@ import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; -import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException; import org.springframework.batch.execution.repository.dao.SqlJobDao.JobExecutionRowMapper; import org.springframework.batch.repeat.ExitStatus; import org.springframework.batch.restart.GenericRestartData; diff --git a/execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java b/execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java index 8b1552973..4fdb27eae 100644 --- a/execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java +++ b/execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java @@ -25,17 +25,16 @@ import junit.framework.TestCase; import org.easymock.MockControl; import org.springframework.batch.core.configuration.JobConfiguration; import org.springframework.batch.core.configuration.StepConfiguration; +import org.springframework.batch.core.configuration.StepConfigurationSupport; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.core.repository.BatchRestartException; import org.springframework.batch.core.runtime.SimpleJobIdentifier; -import org.springframework.batch.core.tasklet.Tasklet; import org.springframework.batch.execution.repository.dao.JobDao; import org.springframework.batch.execution.repository.dao.StepDao; import org.springframework.batch.restart.GenericRestartData; -import org.springframework.dao.IncorrectResultSizeDataAccessException; /* * Test SimpleJobRepository. The majority of test cases are tested using EasyMock, @@ -88,9 +87,9 @@ public class SimpleJobRepositoryTests extends TestCase { jobConfiguration.setName("RepositoryTest"); jobConfiguration.setRestartable(true); - stepConfiguration1 = new StubStepConfiguration("TestStep1"); + stepConfiguration1 = new StepConfigurationSupport("TestStep1"); - stepConfiguration2 = new StubStepConfiguration("TestStep2"); + stepConfiguration2 = new StepConfigurationSupport("TestStep2"); List stepConfigurations = new ArrayList(); stepConfigurations.add(stepConfiguration1); @@ -169,15 +168,15 @@ public class SimpleJobRepositoryTests extends TestCase { List jobs = new ArrayList(); jobs.add(databaseJob); - jobs.add(new JobInstance(jobRuntimeInformation)); + jobs.add(new JobInstance(jobRuntimeInformation, new Long(127))); jobDao.findJobs(jobRuntimeInformation); jobDaoControl.setReturnValue(jobs); jobDaoControl.replay(); try{ jobRepository.findOrCreateJob(jobConfiguration, jobRuntimeInformation); - fail(); - }catch(IncorrectResultSizeDataAccessException ex){ + fail("Expected BatchRestartException"); + }catch(BatchRestartException e){ //expected } @@ -406,37 +405,4 @@ public class SimpleJobRepositoryTests extends TestCase { assertTrue(step.equals(databaseStep2)); } - /** - * @author Dave Syer - * - */ - private class StubStepConfiguration implements StepConfiguration { - - private String name; - - /** - * @param name - */ - public StubStepConfiguration(String name) { - this.name = name; - } - - public Tasklet getTasklet() { - return null; - } - - public String getName() { - return name; - } - - public int getStartLimit() { - return 1; - } - - public boolean isAllowStartIfComplete() { - return true; - } - - } - } diff --git a/execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java b/execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java index d930db3ea..6f4ca5c62 100644 --- a/execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java +++ b/execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java @@ -16,8 +16,6 @@ package org.springframework.batch.execution.repository.dao; -import java.sql.ResultSet; -import java.sql.SQLException; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.List; @@ -30,7 +28,6 @@ import org.springframework.batch.core.repository.NoSuchBatchDomainObjectExceptio import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.batch.execution.runtime.ScheduledJobIdentifier; import org.springframework.batch.repeat.ExitStatus; -import org.springframework.jdbc.core.RowMapper; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; import org.springframework.util.ClassUtils; @@ -41,10 +38,6 @@ import org.springframework.util.ClassUtils; public abstract class AbstractJobDaoTests extends AbstractTransactionalDataSourceSpringContextTests { - private static final String GET_JOB_EXECUTION = "SELECT JOB_ID, START_TIME, END_TIME, STATUS, " - + "CONTINUABLE, EXIT_CODE, EXIT_MESSAGE from " - + "BATCH_JOB_EXECUTION where ID = ?"; - protected JobDao jobDao; protected ScheduledJobIdentifier jobRuntimeInformation;