BATCH-1668: added check for transaction in JobRepository
This commit is contained in:
@@ -13,6 +13,7 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -35,8 +36,18 @@ public class SimpleJobRepositoryProxyTests {
|
||||
private JobSupport job = new JobSupport("SimpleJobRepositoryProxyTestsJob");
|
||||
|
||||
@Transactional
|
||||
@Test(expected=IllegalStateException.class)
|
||||
@DirtiesContext
|
||||
public void testCreateAndFindWithExistingTransaction() throws Exception {
|
||||
assertFalse(advice.invoked);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
assertNotNull(jobExecution);
|
||||
assertTrue(advice.invoked);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndFind() throws Exception {
|
||||
@DirtiesContext
|
||||
public void testCreateAndFindNoTransaction() throws Exception {
|
||||
assertFalse(advice.invoked);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
|
||||
assertNotNull(jobExecution);
|
||||
|
||||
Reference in New Issue
Block a user