diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java index b2b699c02..2124d5f8d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java @@ -117,6 +117,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor * @param bean * @return */ + @SuppressWarnings("unchecked") private Object injectDefaults(Object bean) { if (bean instanceof JobParserJobFactoryBean) { JobParserJobFactoryBean fb = (JobParserJobFactoryBean) bean; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java index 9439ccd33..ed43b2c38 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java @@ -19,12 +19,11 @@ package org.springframework.batch.core.explore.support; import org.springframework.batch.core.repository.dao.ExecutionContextDao; import org.springframework.batch.core.repository.dao.JobExecutionDao; import org.springframework.batch.core.repository.dao.JobInstanceDao; -import org.springframework.batch.core.repository.dao.MapExecutionContextDao; -import org.springframework.batch.core.repository.dao.MapJobExecutionDao; -import org.springframework.batch.core.repository.dao.MapJobInstanceDao; -import org.springframework.batch.core.repository.dao.MapStepExecutionDao; import org.springframework.batch.core.repository.dao.StepExecutionDao; +import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.util.Assert; /** * A {@link FactoryBean} that automates the creation of a @@ -33,26 +32,53 @@ import org.springframework.beans.factory.FactoryBean; * @author Dave Syer * @since 2.0 */ -public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean { +public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean implements InitializingBean { + + private MapJobRepositoryFactoryBean repositoryFactory; + + /** + * Create an instance with the provided {@link MapJobRepositoryFactoryBean} + * as a source of Dao instances. + * @param repositoryFactory + */ + public MapJobExplorerFactoryBean(MapJobRepositoryFactoryBean repositoryFactory) { + this.repositoryFactory = repositoryFactory; + } + + /** + * Create a factory with no {@link MapJobRepositoryFactoryBean}. It must be + * injected as a property. + */ + public MapJobExplorerFactoryBean() { + } + + /** + * @throws Exception + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() + */ + public void afterPropertiesSet() throws Exception { + Assert.state(repositoryFactory!=null, "A MapJobExplorerFactoryBean must be provided"); + repositoryFactory.afterPropertiesSet(); + } @Override protected JobExecutionDao createJobExecutionDao() throws Exception { - return new MapJobExecutionDao(); + return repositoryFactory.getJobExecutionDao(); } @Override protected JobInstanceDao createJobInstanceDao() throws Exception { - return new MapJobInstanceDao(); + return repositoryFactory.getJobInstanceDao(); } @Override protected StepExecutionDao createStepExecutionDao() throws Exception { - return new MapStepExecutionDao(); + return repositoryFactory.getStepExecutionDao(); } @Override protected ExecutionContextDao createExecutionContextDao() throws Exception { - return new MapExecutionContextDao(); + return repositoryFactory.getExecutionContextDao(); } public Object getObject() throws Exception { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java index e6868d77f..54248be6e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java @@ -32,13 +32,13 @@ import org.springframework.batch.support.transaction.TransactionAwareProxyFactor */ public class MapExecutionContextDao implements ExecutionContextDao { - private static Map contextsByStepExecutionId = TransactionAwareProxyFactory + private Map contextsByStepExecutionId = TransactionAwareProxyFactory .createTransactionalMap(); - private static Map contextsByJobExecutionId = TransactionAwareProxyFactory + private Map contextsByJobExecutionId = TransactionAwareProxyFactory .createTransactionalMap(); - public static void clear() { + public void clear() { contextsByJobExecutionId.clear(); contextsByStepExecutionId.clear(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java index a03110abb..531041532 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java @@ -36,11 +36,11 @@ import org.springframework.util.Assert; */ public class MapJobExecutionDao implements JobExecutionDao { - private static Map executionsById = TransactionAwareProxyFactory.createTransactionalMap(); + private Map executionsById = TransactionAwareProxyFactory.createTransactionalMap(); - private static long currentId = 0; + private long currentId = 0; - public static void clear() { + public void clear() { executionsById.clear(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java index 36c0fe301..eec8dfd4e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java @@ -33,11 +33,11 @@ import org.springframework.util.Assert; */ public class MapJobInstanceDao implements JobInstanceDao { - private static Collection jobInstances = TransactionAwareProxyFactory.createTransactionalSet(); + private Collection jobInstances = TransactionAwareProxyFactory.createTransactionalSet(); - private static long currentId = 0; + private long currentId = 0; - public static void clear() { + public void clear() { jobInstances.clear(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java index 0ef3d61b7..b6ee7084c 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java @@ -34,15 +34,15 @@ import org.springframework.util.Assert; */ public class MapStepExecutionDao implements StepExecutionDao { - private static Map> executionsByJobExecutionId = TransactionAwareProxyFactory + private Map> executionsByJobExecutionId = TransactionAwareProxyFactory .createTransactionalMap(); - private static Map executionsByStepExecutionId = TransactionAwareProxyFactory + private Map executionsByStepExecutionId = TransactionAwareProxyFactory .createTransactionalMap(); - private static long currentId = 0; + private long currentId = 0; - public static void clear() { + public void clear() { executionsByJobExecutionId.clear(); executionsByStepExecutionId.clear(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java index 5d6747e88..9ac6e611e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java @@ -113,20 +113,32 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I this.transactionManager = transactionManager; } + /** + * The transaction manager used in this factory. Useful to inject into steps + * and jobs, to ensure that they are using the same instance. + * + * @return the transactionManager + */ + public PlatformTransactionManager getTransactionManager() { + return transactionManager; + } + private void initializeProxy() throws Exception { - proxyFactory = new ProxyFactory(); - TransactionInterceptor advice = new TransactionInterceptor(transactionManager, PropertiesConverter - .stringToProperties("create*=PROPAGATION_REQUIRES_NEW," + isolationLevelForCreate - + "\ngetLastJobExecution*=PROPAGATION_REQUIRES_NEW," + isolationLevelForCreate - + "\n*=PROPAGATION_REQUIRED")); - DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(advice); - NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut(); - pointcut.addMethodName("*"); - advisor.setPointcut(pointcut); - proxyFactory.addAdvisor(advisor); - proxyFactory.setProxyTargetClass(false); - proxyFactory.addInterface(JobRepository.class); - proxyFactory.setTarget(getTarget()); + if (proxyFactory == null) { + proxyFactory = new ProxyFactory(); + TransactionInterceptor advice = new TransactionInterceptor(transactionManager, PropertiesConverter + .stringToProperties("create*=PROPAGATION_REQUIRES_NEW," + isolationLevelForCreate + + "\ngetLastJobExecution*=PROPAGATION_REQUIRES_NEW," + isolationLevelForCreate + + "\n*=PROPAGATION_REQUIRED")); + DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(advice); + NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut(); + pointcut.addMethodName("*"); + advisor.setPointcut(pointcut); + proxyFactory.addAdvisor(advisor); + proxyFactory.setProxyTargetClass(false); + proxyFactory.addInterface(JobRepository.class); + proxyFactory.setTarget(getTarget()); + } } public void afterPropertiesSet() throws Exception { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBean.java index f422eff66..2d1584540 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBean.java @@ -26,6 +26,7 @@ import org.springframework.batch.core.repository.dao.MapStepExecutionDao; import org.springframework.batch.core.repository.dao.StepExecutionDao; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.beans.factory.FactoryBean; +import org.springframework.transaction.PlatformTransactionManager; /** * A {@link FactoryBean} that automates the creation of a @@ -33,7 +34,7 @@ import org.springframework.beans.factory.FactoryBean; * implementations. This repository is only really intended for use in testing * and rapid prototyping. In such settings you might find that * {@link ResourcelessTransactionManager} is useful (as long as your business - * logic does not use a relational database). Not suited for use in + * logic does not use a relational database). Not suited for use in * multi-threaded jobs with splits, although it should be safe to use in a * multi-threaded step. * @@ -41,35 +42,79 @@ import org.springframework.beans.factory.FactoryBean; */ public class MapJobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean { + private MapJobExecutionDao jobExecutionDao; + + private MapJobInstanceDao jobInstanceDao; + + private MapStepExecutionDao stepExecutionDao; + + private MapExecutionContextDao executionContextDao; + + /** + * Create a new instance with a {@link ResourcelessTransactionManager}. + */ + public MapJobRepositoryFactoryBean() { + this(new ResourcelessTransactionManager()); + } + + /** + * Create a new instance with the provided transaction manager. + * + * @param transactionManager + */ + public MapJobRepositoryFactoryBean(PlatformTransactionManager transactionManager) { + setTransactionManager(transactionManager); + } + + public JobExecutionDao getJobExecutionDao() { + return jobExecutionDao; + } + + public JobInstanceDao getJobInstanceDao() { + return jobInstanceDao; + } + + public StepExecutionDao getStepExecutionDao() { + return stepExecutionDao; + } + + public ExecutionContextDao getExecutionContextDao() { + return executionContextDao; + } + /** * Convenience method to clear all the map daos globally, removing all * entities. */ - public static void clear() { - MapJobInstanceDao.clear(); - MapJobExecutionDao.clear(); - MapStepExecutionDao.clear(); - MapExecutionContextDao.clear(); + public void clear() { + jobInstanceDao.clear(); + jobExecutionDao.clear(); + stepExecutionDao.clear(); + executionContextDao.clear(); } @Override protected JobExecutionDao createJobExecutionDao() throws Exception { - return new MapJobExecutionDao(); + jobExecutionDao = new MapJobExecutionDao(); + return jobExecutionDao; } @Override protected JobInstanceDao createJobInstanceDao() throws Exception { - return new MapJobInstanceDao(); + jobInstanceDao = new MapJobInstanceDao(); + return jobInstanceDao; } @Override protected StepExecutionDao createStepExecutionDao() throws Exception { - return new MapStepExecutionDao(); + stepExecutionDao = new MapStepExecutionDao(); + return stepExecutionDao; } @Override protected ExecutionContextDao createExecutionContextDao() throws Exception { - return new MapExecutionContextDao(); + executionContextDao = new MapExecutionContextDao(); + return executionContextDao; } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractJobParserTests.java index dd87f88b8..42a1aeea6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractJobParserTests.java @@ -42,13 +42,16 @@ public abstract class AbstractJobParserTests { @Autowired private JobRepository jobRepository; + + @Autowired + private MapJobRepositoryFactoryBean mapJobRepositoryFactoryBean; @Autowired protected ArrayList stepNamesList = new ArrayList(); @Before public void setUp() { - MapJobRepositoryFactoryBean.clear(); + mapJobRepositoryFactoryBean.clear(); stepNamesList.clear(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/BranchStepJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/BranchStepJobParserTests.java index 8272a1bac..ee2e22837 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/BranchStepJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/BranchStepJobParserTests.java @@ -23,7 +23,6 @@ import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.BatchStatus; @@ -32,7 +31,6 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -51,11 +49,6 @@ public class BranchStepJobParserTests { @Autowired private JobRepository jobRepository; - @Before - public void setUp() { - MapJobRepositoryFactoryBean.clear(); - } - @Test public void testBranchStep() throws Exception { assertNotNull(job); @@ -70,4 +63,5 @@ public class BranchStepJobParserTests { assertTrue(names.contains("job.s3")); assertFalse(names.contains("job.s2")); } + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java index 8fd272709..f1df01054 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java @@ -18,7 +18,6 @@ package org.springframework.batch.core.configuration.xml; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.BatchStatus; @@ -29,7 +28,6 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.job.flow.FlowExecutionStatus; import org.springframework.batch.core.job.flow.JobExecutionDecider; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.test.context.ContextConfiguration; @@ -50,11 +48,6 @@ public class DecisionJobParserTests { @Autowired private JobRepository jobRepository; - @Before - public void setUp() { - MapJobRepositoryFactoryBean.clear(); - } - @Test public void testDecisionState() throws Exception { assertNotNull(job); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DuplicateTransitionJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DuplicateTransitionJobParserTests.java index 7ba6a1b27..0f52093f1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DuplicateTransitionJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DuplicateTransitionJobParserTests.java @@ -16,18 +16,16 @@ package org.springframework.batch.core.configuration.xml; import org.junit.Test; -import org.junit.internal.runners.JUnit4ClassRunner; -import org.junit.runner.RunWith; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.util.ClassUtils; /** * @author Dan Garrette + * @author Dave Syer * @since 2.0 */ -@RunWith(JUnit4ClassRunner.class) -public class DuplicateTransitionJobParserTests extends AbstractJobParserTests { +public class DuplicateTransitionJobParserTests { @Test(expected = BeanDefinitionStoreException.class) public void testNextAttributeWithNestedElement() throws Exception { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowJobParserTests.java index a7a930c54..69bbccceb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowJobParserTests.java @@ -63,10 +63,13 @@ public class FlowJobParserTests { @Autowired private JobRepository jobRepository; + + @Autowired + private MapJobRepositoryFactoryBean mapJobRepositoryFactoryBean; @Before public void setUp() { - MapJobRepositoryFactoryBean.clear(); + mapJobRepositoryFactoryBean.clear(); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/OneStepJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/OneStepJobParserTests.java index 6bafd6cac..7941f24e8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/OneStepJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/OneStepJobParserTests.java @@ -18,7 +18,6 @@ package org.springframework.batch.core.configuration.xml; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.BatchStatus; @@ -26,7 +25,6 @@ import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.test.context.ContextConfiguration; @@ -48,11 +46,6 @@ public class OneStepJobParserTests { @Autowired private JobRepository jobRepository; - @Before - public void setUp() { - MapJobRepositoryFactoryBean.clear(); - } - @Test public void testOneStep() throws Exception { assertNotNull(job); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/RepositoryJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/RepositoryJobParserTests.java index 2542b4e63..ebbdf264e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/RepositoryJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/RepositoryJobParserTests.java @@ -18,7 +18,6 @@ package org.springframework.batch.core.configuration.xml; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.BatchStatus; @@ -26,7 +25,6 @@ import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.test.context.ContextConfiguration; @@ -48,11 +46,6 @@ public class RepositoryJobParserTests { @Autowired private JobRepository jobRepository; - @Before - public void setUp() { - MapJobRepositoryFactoryBean.clear(); - } - @Test public void testTaskletStepWithBadListener() throws Exception { assertNotNull(job); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitJobParserTests.java index 980d584d5..85d0ea8c9 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitJobParserTests.java @@ -18,7 +18,6 @@ package org.springframework.batch.core.configuration.xml; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.BatchStatus; @@ -26,7 +25,6 @@ import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.test.context.ContextConfiguration; @@ -48,11 +46,6 @@ public class SplitJobParserTests { @Autowired private JobRepository jobRepository; - @Before - public void setUp() { - MapJobRepositoryFactoryBean.clear(); - } - @Test public void testSplitJob() throws Exception { assertNotNull(job); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithBasicProcessTaskJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithBasicProcessTaskJobParserTests.java index 44443ba7a..4d39bcb7a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithBasicProcessTaskJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithBasicProcessTaskJobParserTests.java @@ -19,7 +19,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.BatchStatus; @@ -28,7 +27,6 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepListener; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.item.ItemStream; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -68,11 +66,6 @@ public class StepWithBasicProcessTaskJobParserTests { @Autowired private StepParserStepFactoryBean factory; - @Before - public void setUp() { - MapJobRepositoryFactoryBean.clear(); - } - @Test public void testStepWithTask() throws Exception { assertNotNull(job); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithFaultTolerantProcessTaskJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithFaultTolerantProcessTaskJobParserTests.java index 18c45db7d..548c7573b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithFaultTolerantProcessTaskJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithFaultTolerantProcessTaskJobParserTests.java @@ -19,7 +19,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.BatchStatus; @@ -28,7 +27,6 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepListener; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.item.ItemStream; import org.springframework.batch.retry.RetryListener; import org.springframework.beans.factory.annotation.Autowired; @@ -74,11 +72,6 @@ public class StepWithFaultTolerantProcessTaskJobParserTests { @Autowired private StepParserStepFactoryBean factory; - @Before - public void setUp() { - MapJobRepositoryFactoryBean.clear(); - } - @Test public void testStepWithTask() throws Exception { assertNotNull(job); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithSimpleTaskJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithSimpleTaskJobParserTests.java index 6243bff40..5417228c9 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithSimpleTaskJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithSimpleTaskJobParserTests.java @@ -19,7 +19,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.BatchStatus; @@ -29,7 +28,6 @@ import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.Step; import org.springframework.batch.core.job.flow.FlowJob; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -54,11 +52,6 @@ public class StepWithSimpleTaskJobParserTests { @Qualifier("listener") private TestListener listener; - @Before - public void setUp() { - MapJobRepositoryFactoryBean.clear(); - } - @Test public void testJob() throws Exception { assertNotNull(job); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TwoStepJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TwoStepJobParserTests.java index eac44ae5a..dd7876eb1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TwoStepJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TwoStepJobParserTests.java @@ -18,7 +18,6 @@ package org.springframework.batch.core.configuration.xml; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.BatchStatus; @@ -26,7 +25,6 @@ import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -46,11 +44,6 @@ public class TwoStepJobParserTests { @Autowired private JobRepository jobRepository; - @Before - public void setUp() { - MapJobRepositoryFactoryBean.clear(); - } - @Test public void testTwoStep() throws Exception { assertNotNull(job); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/MapJobExplorerFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/MapJobExplorerFactoryBeanTests.java index 83ed253fb..bcacf3fd5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/MapJobExplorerFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/MapJobExplorerFactoryBeanTests.java @@ -1,25 +1,35 @@ package org.springframework.batch.core.exlore.support; +import static org.junit.Assert.assertEquals; + import org.junit.Test; +import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.explore.JobExplorer; import org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; /** * Tests for {@link MapJobExplorerFactoryBean}. */ public class MapJobExplorerFactoryBeanTests { - private MapJobExplorerFactoryBean tested = new MapJobExplorerFactoryBean(); - /** - * Use the factory to create repository and check the repository remembers + * Use the factory to create repository and check the explorer remembers * created executions. */ @Test - public void testCreateRepository() throws Exception { + public void testCreateExplorer() throws Exception { + + MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean(); + ((JobRepository)repositoryFactory.getObject()).createJobExecution("foo", new JobParameters()); + + MapJobExplorerFactoryBean tested = new MapJobExplorerFactoryBean(repositoryFactory); + tested.afterPropertiesSet(); + JobExplorer explorer = (JobExplorer) tested.getObject(); - explorer.findRunningJobExecutions("foo"); + assertEquals(1, explorer.findRunningJobExecutions("foo").size()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/MapJobExplorerIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/MapJobExplorerIntegrationTests.java index c38022115..76d532672 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/MapJobExplorerIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/exlore/support/MapJobExplorerIntegrationTests.java @@ -33,7 +33,6 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.core.task.SimpleAsyncTaskExecutor; /** @@ -47,12 +46,8 @@ public class MapJobExplorerIntegrationTests { @Test public void testRunningJobExecution() throws Exception { - MapJobRepositoryFactoryBean.clear(); - SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean(); - ResourcelessTransactionManager transactionManager = new ResourcelessTransactionManager(); - repositoryFactory.setTransactionManager(transactionManager); repositoryFactory.afterPropertiesSet(); JobRepository jobRepository = (JobRepository) repositoryFactory.getObject(); jobLauncher.setJobRepository(jobRepository); @@ -69,7 +64,7 @@ public class MapJobExplorerIntegrationTests { return RepeatStatus.FINISHED; } }); - step.setTransactionManager(transactionManager); + step.setTransactionManager(repositoryFactory.getTransactionManager()); step.setJobRepository(jobRepository); step.afterPropertiesSet(); job.addStep(step); @@ -79,7 +74,7 @@ public class MapJobExplorerIntegrationTests { jobLauncher.run(job, new JobParametersBuilder().addString("test", getClass().getName()).toJobParameters()); Thread.sleep(500L); - JobExplorer explorer = (JobExplorer) new MapJobExplorerFactoryBean().getObject(); + JobExplorer explorer = (JobExplorer) new MapJobExplorerFactoryBean(repositoryFactory).getObject(); Set executions = explorer.findRunningJobExecutions("job"); assertEquals(1, executions.size()); assertEquals(1, executions.iterator().next().getStepExecutions().size()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java index 943bbe514..9a568e042 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java @@ -38,7 +38,6 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.step.StepSupport; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; /** * @author Dave Syer @@ -51,9 +50,7 @@ public class ExtendedAbstractJobTests { @Before public void setUp() throws Exception { - MapJobRepositoryFactoryBean.clear(); MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); - factory.setTransactionManager(new ResourcelessTransactionManager()); jobRepository = (JobRepository) factory.getObject(); job = new StubJob("job", jobRepository); } @@ -166,9 +163,7 @@ public class ExtendedAbstractJobTests { } } - MapJobRepositoryFactoryBean.clear(); MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); - factory.setTransactionManager(new ResourcelessTransactionManager()); factory.afterPropertiesSet(); JobRepository repository = (JobRepository) factory.getObject(); job.setJobRepository(repository); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java index 3a3205094..2cb62dff3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java @@ -99,10 +99,6 @@ public class SimpleJobTests { @Before public void setUp() throws Exception { - MapJobInstanceDao.clear(); - MapJobExecutionDao.clear(); - MapStepExecutionDao.clear(); - MapExecutionContextDao.clear(); jobInstanceDao = new MapJobInstanceDao(); jobExecutionDao = new MapJobExecutionDao(); stepExecutionDao = new MapStepExecutionDao(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java index 64683abae..50454b431 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java @@ -42,14 +42,8 @@ import org.springframework.batch.core.job.flow.support.state.SplitState; import org.springframework.batch.core.job.flow.support.state.StepState; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.dao.JobExecutionDao; -import org.springframework.batch.core.repository.dao.MapExecutionContextDao; -import org.springframework.batch.core.repository.dao.MapJobExecutionDao; -import org.springframework.batch.core.repository.dao.MapJobInstanceDao; -import org.springframework.batch.core.repository.dao.MapStepExecutionDao; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; -import org.springframework.batch.core.repository.support.SimpleJobRepository; import org.springframework.batch.core.step.StepSupport; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; /** * @author Dave Syer @@ -69,13 +63,9 @@ public class FlowJobTests { @Before public void setUp() throws Exception { - MapJobRepositoryFactoryBean.clear(); MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); - factory.setTransactionManager(new ResourcelessTransactionManager()); factory.afterPropertiesSet(); - jobExecutionDao = new MapJobExecutionDao(); - jobRepository = new SimpleJobRepository(new MapJobInstanceDao(), jobExecutionDao, new MapStepExecutionDao(), - new MapExecutionContextDao()); + jobExecutionDao = factory.getJobExecutionDao(); jobRepository = (JobRepository) factory.getObject(); job.setJobRepository(jobRepository); jobExecution = jobRepository.createJobExecution("job", new JobParameters()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java index afeeb5c7b..f888eb0ba 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java @@ -34,7 +34,6 @@ import org.springframework.batch.core.partition.StepExecutionSplitter; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.step.StepSupport; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; /** * @author Dave Syer @@ -50,9 +49,7 @@ public class PartitionStepTests { @Before public void setUp() throws Exception { - MapJobRepositoryFactoryBean.clear(); MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); - factory.setTransactionManager(new ResourcelessTransactionManager()); jobRepository = (JobRepository) factory.getObject(); step.setJobRepository(jobRepository); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java index 998fecf6d..e54b8b300 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java @@ -17,7 +17,6 @@ import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; public class SimpleStepExecutionSplitterTests { @@ -31,14 +30,13 @@ public class SimpleStepExecutionSplitterTests { public void setUp() throws Exception { step = new TaskletStep("step"); MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); - factory.setTransactionManager(new ResourcelessTransactionManager()); jobRepository = (JobRepository) factory.getObject(); } @Test public void testSimpleStepExecutionProviderJobRepositoryStep() throws Exception { - SimpleStepExecutionSplitter provider = new SimpleStepExecutionSplitter(jobRepository, step); - Set execs = provider.split(stepExecution, 2); + SimpleStepExecutionSplitter splitter = new SimpleStepExecutionSplitter(jobRepository, step); + Set execs = splitter.split(stepExecution, 2); assertEquals(2, execs.size()); for (StepExecution execution : execs) { @@ -49,12 +47,12 @@ public class SimpleStepExecutionSplitterTests { @Test public void testSimpleStepExecutionProviderJobRepositoryStepPartitioner() throws Exception { final Map map = Collections.singletonMap("foo", new ExecutionContext()); - SimpleStepExecutionSplitter provider = new SimpleStepExecutionSplitter(jobRepository, step, new Partitioner() { + SimpleStepExecutionSplitter splitter = new SimpleStepExecutionSplitter(jobRepository, step, new Partitioner() { public Map partition(int gridSize) { return map; } }); - assertEquals(1, provider.split(stepExecution, 2).size()); + assertEquals(1, splitter.split(stepExecution, 2).size()); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapExecutionContextDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapExecutionContextDaoTests.java index 80f090890..497ddc58e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapExecutionContextDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapExecutionContextDaoTests.java @@ -17,19 +17,16 @@ public class MapExecutionContextDaoTests extends AbstractExecutionContextDaoTest @Override protected JobInstanceDao getJobInstanceDao() { - MapJobInstanceDao.clear(); return new MapJobInstanceDao(); } @Override protected JobExecutionDao getJobExecutionDao() { - MapJobExecutionDao.clear(); return new MapJobExecutionDao(); } @Override protected StepExecutionDao getStepExecutionDao() { - MapStepExecutionDao.clear(); return new MapStepExecutionDao(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java index a442cdd02..d0a83d5f7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java @@ -16,8 +16,6 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests { @Override protected JobExecutionDao getJobExecutionDao() { - MapJobExecutionDao.clear(); - MapJobInstanceDao.clear(); return new MapJobExecutionDao(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java index 0070e7574..8912a5b05 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java @@ -7,7 +7,6 @@ import org.junit.internal.runners.JUnit4ClassRunner; public class MapJobInstanceDaoTests extends AbstractJobInstanceDaoTests { protected JobInstanceDao getJobInstanceDao() { - MapJobInstanceDao.clear(); return new MapJobInstanceDao(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java index d0196b12b..db27a4efc 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java @@ -20,9 +20,6 @@ public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests { } protected JobRepository getJobRepository() { - MapJobInstanceDao.clear(); - MapJobExecutionDao.clear(); - MapStepExecutionDao.clear(); return new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(), new MapExecutionContextDao()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBeanTests.java index 82a538133..5e04a8303 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBeanTests.java @@ -8,7 +8,6 @@ import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.job.JobSupport; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; /** * Tests for {@link MapJobRepositoryFactoryBean}. @@ -23,7 +22,6 @@ public class MapJobRepositoryFactoryBeanTests { */ @Test public void testCreateRepository() throws Exception { - tested.setTransactionManager(new ResourcelessTransactionManager()); tested.afterPropertiesSet(); JobRepository repository = (JobRepository) tested.getObject(); Job job = new JobSupport("jobName"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java index e74165d24..936aa2a82 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java @@ -94,10 +94,6 @@ public class FaultTolerantStepFactoryBeanRetryTests { @Before public void setUp() throws Exception { - MapJobInstanceDao.clear(); - MapJobExecutionDao.clear(); - MapStepExecutionDao.clear(); - factory = new FaultTolerantStepFactoryBean(); factory.setBeanName("step"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java index e0fd37e90..a7e4a59b1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java @@ -77,9 +77,7 @@ public class FaultTolerantStepFactoryBeanRollbackTests { factory.setSkippableExceptionClasses(getExceptionMap(Exception.class)); - MapJobRepositoryFactoryBean.clear(); MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean(); - repositoryFactory.setTransactionManager(new ResourcelessTransactionManager()); repositoryFactory.afterPropertiesSet(); repository = (JobRepository) repositoryFactory.getObject(); factory.setJobRepository(repository); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java index e84491230..e0d295c4f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java @@ -103,9 +103,7 @@ public class FaultTolerantStepFactoryBeanTests { factory .setSkippableExceptionClasses(getExceptionMap(SkippableException.class, SkippableRuntimeException.class)); - MapJobRepositoryFactoryBean.clear(); MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean(); - repositoryFactory.setTransactionManager(new ResourcelessTransactionManager()); repositoryFactory.afterPropertiesSet(); repository = (JobRepository) repositoryFactory.getObject(); factory.setJobRepository(repository); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java index 30f4e0b17..44bf34adb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java @@ -81,9 +81,6 @@ public class SimpleStepFactoryBeanTests { public void setUp() throws Exception { job.setJobRepository(repository); job.setBeanName("simpleJob"); - MapJobInstanceDao.clear(); - MapJobExecutionDao.clear(); - MapStepExecutionDao.clear(); } @Test(expected = IllegalArgumentException.class) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java index d8fcb8296..e9a61deda 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java @@ -32,7 +32,6 @@ import org.springframework.batch.core.launch.support.SimpleJobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.support.transaction.ResourcelessTransactionManager; /** * @author Dave Syer @@ -48,10 +47,8 @@ public class JobStepTests { @Before public void setUp() throws Exception { - MapJobRepositoryFactoryBean.clear(); step.setName("step"); MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); - factory.setTransactionManager(new ResourcelessTransactionManager()); jobRepository = (JobRepository) factory.getObject(); step.setJobRepository(jobRepository); JobExecution jobExecution = jobRepository.createJobExecution("job", new JobParameters()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java index 7a8e0cd98..f3631ecdc 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java @@ -56,9 +56,6 @@ public class StepExecutorInterruptionTests extends TestCase { private Field semaphore; public void setUp() throws Exception { - MapJobInstanceDao.clear(); - MapJobExecutionDao.clear(); - MapStepExecutionDao.clear(); jobRepository = new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(), new MapExecutionContextDao()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java index e7e33df61..2d43c97c1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java @@ -113,9 +113,6 @@ public class TaskletStepTests { @Before public void setUp() throws Exception { - MapJobInstanceDao.clear(); - MapStepExecutionDao.clear(); - MapJobExecutionDao.clear(); transactionManager = new ResourcelessTransactionManager();