IN PROGRESS - issue BATCH-453: Killed batches cannot be restarted

http://jira.springframework.org/browse/BATCH-453

Updated SimpleJobRepository to check if JobExecution status has been set to 'STOPPING' in the database.
This commit is contained in:
lucasward
2008-08-22 03:06:13 +00:00
parent 632f61987a
commit 838bae2c25
7 changed files with 67 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package org.springframework.batch.core.repository.dao;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
@@ -196,4 +197,15 @@ public abstract class AbstractJobExecutionDaoTests extends AbstractTransactional
JobExecution value = dao.getJobExecution(54321L);
assertNull(value);
}
@Transactional
@Test
public void testUpdateExecutionStatus(){
dao.saveJobExecution(execution);
execution.setStatus(BatchStatus.COMPLETED);
dao.synchronizeStatus(execution);
assertEquals(BatchStatus.STARTING, execution.getStatus());
}
}

View File

@@ -1,8 +1,13 @@
package org.springframework.batch.core.repository.dao;
import static org.junit.Assert.*;
import org.springframework.batch.core.BatchStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -32,5 +37,5 @@ public class JdbcJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
protected StepExecutionDao getStepExecutionDao() {
return stepExecutionDao;
}
}

View File

@@ -24,6 +24,7 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
@@ -184,5 +185,16 @@ public class SimpleJobRepositoryTests {
long lastUpdated = stepExecution.getLastUpdated().getTime();
assertTrue(lastUpdated > (before - 1000));
}
@Test
public void testInterrupted(){
jobExecution.setStatus(BatchStatus.STOPPING);
StepExecution stepExecution = new StepExecution("stepName", jobExecution);
stepExecution.setId(323L);
jobRepository.update(stepExecution);
assertTrue(stepExecution.isTerminateOnly());
}
}