From 69f6d8891ad120ffbb236f451d108c76e160560b Mon Sep 17 00:00:00 2001 From: dsyer Date: Wed, 23 Jan 2008 09:08:09 +0000 Subject: [PATCH] Tidy up build problems overnight. --- .../batch/core/domain/Entity.java | 1 - .../batch/core/domain/JobExecutionTests.java | 1 - .../batch/core/domain/JobInstanceTests.java | 3 - .../support/SimpleCommandLineJobRunner.java | 1 - .../execution/launch/DefaultJobLauncher.java | 168 ---------- .../batch/execution/launch/JobLauncher.java | 1 - .../execution/launch/SimpleJobLauncher.java | 9 +- .../execution/repository/dao/JdbcJobDao.java | 59 ---- .../execution/repository/dao/MapJobDao.java | 1 - .../resource/BatchResourceFactoryBean.java | 1 - .../SimpleCommandLineJobRunnerTests.java | 1 - .../bootstrap/support/StubJobLauncher.java | 2 - .../job/DefaultJobExecutorTests.java | 1 - .../execution/launch/InterruptJobTests.java | 122 ------- .../launch/SimpleJobExecutorFacadeTests.java | 304 ------------------ .../execution/launch/SimpleJobTests.java | 8 - .../launch/TaskExecutorJobLauncherTests.java | 232 ------------- .../repository/dao/AbstractJobDaoTests.java | 5 - .../repository/dao/AbstractStepDaoTests.java | 2 - .../repository/dao/JdbcJobDaoQueryTests.java | 1 - .../repository/dao/MapJobDaoTests.java | 1 - .../BatchResourceFactoryBeanTests.java | 4 - .../step/simple/DefaultStepExecutorTests.java | 1 - .../simple/StepExecutorInterruptionTests.java | 3 - .../resources/simple-container-definition.xml | 219 ++++++------- 25 files changed, 118 insertions(+), 1033 deletions(-) delete mode 100644 spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/DefaultJobLauncher.java delete mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/InterruptJobTests.java delete mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobExecutorFacadeTests.java delete mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/TaskExecutorJobLauncherTests.java diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Entity.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Entity.java index 70b8eb6a0..598b40ad1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Entity.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Entity.java @@ -18,7 +18,6 @@ package org.springframework.batch.core.domain; import java.io.Serializable; -import org.springframework.util.Assert; import org.springframework.util.ClassUtils; /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobExecutionTests.java index 47d5d5fb4..bd14ad3fa 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobExecutionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobExecutionTests.java @@ -19,7 +19,6 @@ import java.util.Date; import junit.framework.TestCase; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.batch.repeat.ExitStatus; /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobInstanceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobInstanceTests.java index 692bd9d9c..c5862d469 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobInstanceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobInstanceTests.java @@ -17,9 +17,6 @@ package org.springframework.batch.core.domain; import java.util.Collections; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; - - import junit.framework.TestCase; /** diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunner.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunner.java index 7ae721691..63d0a2c28 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunner.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunner.java @@ -110,7 +110,6 @@ public class SimpleCommandLineJobRunner { private ExitCodeExceptionClassifier exceptionClassifier = new SimpleExitCodeExceptionClassifier(); private JobLauncher launcher; - private JobLocator jobLocator; private SystemExiter systemExiter = new JvmSystemExiter(); diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/DefaultJobLauncher.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/DefaultJobLauncher.java deleted file mode 100644 index 8e711a614..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/DefaultJobLauncher.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.batch.execution.launch; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.springframework.batch.core.domain.Job; -import org.springframework.batch.core.domain.JobExecution; -import org.springframework.batch.core.domain.JobIdentifier; -import org.springframework.batch.core.domain.JobLocator; -import org.springframework.batch.core.domain.NoSuchJobException; -import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.core.executor.JobExecutor; -import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; -import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.repeat.ExitStatus; -import org.springframework.core.task.SimpleAsyncTaskExecutor; -import org.springframework.core.task.TaskExecutor; - -/** - * A test implementation of the JobLauncher interface. It exists solely to work - * through interface design issues for the JobLauncher, JobRepository, - * JobLocator, and JobExecutor interfaces. It is designed for simplicity, and - * despite unit testing may not be completely threadsafe, and therefore should - * not be used. - * - * Rather than using a JobExecutorFacade, a JobExecutor is worked with directly. - * Not every method of the JobLauncher interface is used. Instead, new versions - * that take JobIdentifier as an argument were added. A JobExecution is - * considered to be running if it's JobIdentifier (the one it was ran with) - * exists in the HashMap execution registry. When a JobExecutor is finished - * processing it removes it's identifier from the map. - * - * @author Lucas Ward - * - */ -public class DefaultJobLauncher implements JobLauncher { - - private Map jobExecutionRegistry = new HashMap(); - - private Object monitor = new Object(); - - private JobRepository jobRepository; - - private JobLocator jobLocator; - - private JobExecutor jobExecutor; - - private TaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); - - /* - * (non-Javadoc) - * - * @see org.springframework.batch.execution.launch.JobLauncher#isRunning() - */ - public boolean isRunning() { - return false; - } - - /* - * (non-Javadoc) - * - * @see org.springframework.batch.execution.launch.JobLauncher#run(org.springframework.batch.core.domain.JobIdentifier) - */ - public JobExecution run(JobIdentifier jobIdentifier) throws NoSuchJobException, JobExecutionAlreadyRunningException { - - JobExecution jobExecution; - - synchronized (monitor) { - if (jobExecutionRegistry.containsKey(jobIdentifier)) { - throw new JobExecutionAlreadyRunningException("Job: " + jobIdentifier + "is already running."); - } - - Job job = jobLocator.getJob(jobIdentifier.getName()); - jobExecution = jobRepository.findOrCreateJob(job, jobIdentifier); - jobExecutionRegistry.put(jobIdentifier, jobExecution); - - runJobExecution(job, jobExecution, jobIdentifier); - } - - return jobExecution; - } - - private void runJobExecution(final Job job, final JobExecution jobExecution, final JobIdentifier jobIdentifier) { - - taskExecutor.execute(new Runnable() { - - public void run() { - ExitStatus status = jobExecutor.run(job, jobExecution); - jobExecution.setExitStatus(status); - synchronized (monitor) { - jobExecutionRegistry.remove(jobIdentifier); - } - } - }); - } - - /* - * (non-Javadoc) - * - * @see org.springframework.batch.execution.launch.JobLauncher#stop() - */ - public void stop() { - // TODO add code to stop ALL jobExecutions - } - - public void stop(JobIdentifier jobIdentifier) { - - synchronized (monitor) { - - if(!jobExecutionRegistry.containsKey(jobIdentifier)){ - return; - } - - JobExecution jobExecution = (JobExecution)jobExecutionRegistry.get(jobIdentifier); - - for (Iterator iter = jobExecution.getStepExecutions().iterator(); iter - .hasNext();) { - StepExecution context = (StepExecution) iter.next(); - context.setTerminateOnly(); - } - - } - } - - public boolean isRunning(JobIdentifier jobIdentifier) { - - synchronized (monitor) { - if (jobExecutionRegistry.containsKey(jobIdentifier)) { - return true; - } - else { - return false; - } - } - } - - public void setJobRepository(JobRepository jobRepository) { - this.jobRepository = jobRepository; - } - - public void setJobLocator(JobLocator jobLocator) { - this.jobLocator = jobLocator; - } - - public void setJobExecutor(JobExecutor jobExecutor) { - this.jobExecutor = jobExecutor; - } - - public void setTaskExecutor(TaskExecutor taskExecutor) { - this.taskExecutor = taskExecutor; - } -} diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java index 5424a8927..c6c8f9001 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/JobLauncher.java @@ -17,7 +17,6 @@ package org.springframework.batch.execution.launch; import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobExecution; -import org.springframework.batch.core.domain.JobIdentifier; import org.springframework.batch.core.domain.JobInstanceProperties; import org.springframework.batch.core.domain.NoSuchJobException; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java index 8e8eb2a3b..49b44140f 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java @@ -73,8 +73,15 @@ public class SimpleJobLauncher implements JobLauncher { catch(Throwable t){ logger.info("Job: [" + job + "] failed with the following parameters: [" + jobInstanceProperties + "]", t); - throw new RuntimeException(t); + rethrow(t); } + } + + private void rethrow(Throwable t) { + if (t instanceof RuntimeException) { + throw (RuntimeException) t; + } + throw new RuntimeException(t); }}); return jobExecution; diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobDao.java index 783ee6c97..4f4369b7c 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcJobDao.java @@ -20,7 +20,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; import java.sql.Types; -import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -33,13 +32,10 @@ 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.domain.JobInstanceProperties; -import org.springframework.batch.core.domain.JobInstancePropertiesBuilder; import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException; import org.springframework.batch.repeat.ExitStatus; import org.springframework.beans.factory.InitializingBean; -import org.springframework.dao.DataRetrievalFailureException; import org.springframework.jdbc.core.JdbcOperations; -import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; import org.springframework.util.Assert; @@ -447,19 +443,6 @@ public class JdbcJobDao implements JobDao, InitializingBean { "JobExecution status cannot be null."); } - /** - * Validate {@link JobIdentifier}. Due to differing requirements, it is - * acceptable for any field to be blank, however null fields may cause odd - * and vague exception reports from the database driver. - */ - private void validateJobIdentifier(JobIdentifier jobIdentifier) { - - Assert.notNull(jobIdentifier, "JobIdentifier cannot be null."); - Assert.notNull(jobIdentifier.getName(), - "JobIdentifier name cannot be null."); - Assert.notNull(jobIdentifier.getJobInstanceProperties(), "JobIdentifier runtime parameters must not be null."); - } - /** * Re-usable mapper for {@link JobExecution} instances. * @@ -493,49 +476,7 @@ public class JdbcJobDao implements JobDao, InitializingBean { } } - - /* - * Private inner class for mapping values from the JOB_PARAMETERS table into the java - * JobParameters class. TODO: is this going to be used? If not can we delete it? - */ - private static class JobParameterCallbackHandler implements RowCallbackHandler{ - - private JobInstancePropertiesBuilder parametersBuilder; - public JobParameterCallbackHandler() { - parametersBuilder = new JobInstancePropertiesBuilder(); - } - - public void processRow(ResultSet rs) throws SQLException { - - ParameterType parameterType = ParameterType.getType(rs.getString("TYPE_CD")); - - String key = rs.getString("KEY"); - - if(parameterType == ParameterType.STRING){ - parametersBuilder.addString(key, rs.getString("STRING_VAL")); - } - else if(parameterType == ParameterType.LONG){ - parametersBuilder.addLong(key, new Long(rs.getLong("LONG_VAL"))); - } - else if(parameterType == ParameterType.DATE){ - //I debated about just passing the Timestamp in, however, I didn't want there to be any equality - //issues when comparing a java.util.Date to a timestamp. - Timestamp ts = rs.getTimestamp("DATE_VAL"); - parametersBuilder.addDate(key, new Date(ts.getTime())); - } - else{ - //invalid type code, error out. - throw new DataRetrievalFailureException("Invalid JobParameter type"); - } - } - - public JobInstanceProperties getJobParmeters(){ - return parametersBuilder.toJobParameters(); - } - - } - private static class ParameterType { private final String type; diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/MapJobDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/MapJobDao.java index 2e465088d..4e6035446 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/MapJobDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/MapJobDao.java @@ -24,7 +24,6 @@ import java.util.Set; import org.springframework.batch.core.domain.Job; 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.domain.JobInstanceProperties; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/resource/BatchResourceFactoryBean.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/resource/BatchResourceFactoryBean.java index 7cb933598..48a8f4e10 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/resource/BatchResourceFactoryBean.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/resource/BatchResourceFactoryBean.java @@ -18,7 +18,6 @@ package org.springframework.batch.execution.resource; import java.io.File; -import org.springframework.batch.core.domain.JobIdentifier; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.execution.scope.StepContext; import org.springframework.batch.execution.scope.StepContextAware; diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunnerTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunnerTests.java index 183012d00..b68ca4c50 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunnerTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleCommandLineJobRunnerTests.java @@ -21,7 +21,6 @@ import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.JobInstanceProperties; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.batch.repeat.ExitStatus; import org.springframework.beans.factory.access.BeanFactoryLocator; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/StubJobLauncher.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/StubJobLauncher.java index fb0ab0928..92c6346af 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/StubJobLauncher.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/StubJobLauncher.java @@ -2,9 +2,7 @@ package org.springframework.batch.execution.bootstrap.support; import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobExecution; -import org.springframework.batch.core.domain.JobIdentifier; import org.springframework.batch.core.domain.JobInstanceProperties; -import org.springframework.batch.core.domain.NoSuchJobException; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.execution.launch.JobLauncher; diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/DefaultJobExecutorTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/DefaultJobExecutorTests.java index 0574b2de3..3607c5f67 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/DefaultJobExecutorTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/DefaultJobExecutorTests.java @@ -35,7 +35,6 @@ import org.springframework.batch.core.executor.StepExecutor; import org.springframework.batch.core.executor.StepExecutorFactory; import org.springframework.batch.core.executor.StepInterruptedException; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.batch.core.tasklet.Tasklet; import org.springframework.batch.execution.repository.SimpleJobRepository; import org.springframework.batch.execution.repository.dao.JobDao; diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/InterruptJobTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/InterruptJobTests.java deleted file mode 100644 index 6cd9930fb..000000000 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/InterruptJobTests.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.batch.execution.launch; - -import java.util.Collections; - -import junit.framework.TestCase; - -import org.springframework.batch.core.domain.Job; -import org.springframework.batch.core.domain.JobExecution; -import org.springframework.batch.core.domain.NoSuchJobException; -import org.springframework.batch.core.executor.JobExecutor; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; -import org.springframework.batch.execution.bootstrap.support.ThreadInterruptJobExecutionListener; -import org.springframework.batch.execution.configuration.MapJobRegistry; -import org.springframework.batch.execution.launch.JobExecutorFacade; -import org.springframework.batch.execution.launch.SimpleJobExecutorFacade; -import org.springframework.batch.execution.repository.SimpleJobRepository; -import org.springframework.batch.execution.repository.dao.MapJobDao; -import org.springframework.batch.execution.repository.dao.MapStepDao; -import org.springframework.batch.io.exception.BatchCriticalException; -import org.springframework.batch.repeat.ExitStatus; -import org.springframework.core.task.SimpleAsyncTaskExecutor; -import org.springframework.core.task.TaskExecutor; - -/** - * @author Dave Syer - * - */ -public class InterruptJobTests extends TestCase { - - //JabExecutorFacade is deprecated. -// public void testInterruptUsingListener() throws Exception { -// -// // final InterruptibleFacade facade = new InterruptibleFacade(); -// // facade.setListener(new ThreadInterruptJobExecutionListener()); -// final SimpleJobExecutorFacade facade = new SimpleJobExecutorFacade(); -// facade.setJobExecutor(new InterruptibleJobExecutor()); -// -// facade.setJobRepository(new SimpleJobRepository(new MapJobDao(), -// new MapStepDao())); -// -// facade.setJobExecutionListeners(Collections -// .singletonList(new ThreadInterruptJobExecutionListener())); -// -// MapJobRegistry registry = new MapJobRegistry(); -// facade.setJobLocator(registry); -// -// registry.register(new Job("foo")); -// final SimpleJobIdentifier identifier = new SimpleJobIdentifier("foo"); -// final JobExecution execution = facade.createExecutionFrom(identifier); -// -// TaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); -// Runnable launcherRunnable = new Runnable() { -// public void run() { -// try { -// facade.start(execution); -// } catch (NoSuchJobException e) { -// fail("Unexpected NoSuchJobConfigurationException"); -// } -// } -// }; -// -// taskExecutor.execute(launcherRunnable); -// -// // give the thread a second to start up -// Thread.sleep(100); -// assertTrue(facade.isRunning()); -// facade.stop(execution); -// Thread.sleep(100); -// assertFalse(facade.isRunning()); -// } - - public void testBlank(){} - - /** - * Simple {@link JobExecutorFacade} that can be used to test thread - * interruption. Mimics the implementation of the - * {@link SimpleJobExecutorFacade} with the use of a listener, but silently - * allows the current thread to be interrupted. - * - * @author Dave Syer - * - */ - private class InterruptibleJobExecutor implements JobExecutor { - - /* - * (non-Javadoc) - * - * @see org.springframework.batch.core.executor.JobExecutor#run(org.springframework.batch.core.configuration.JobConfiguration, - * org.springframework.batch.core.domain.JobExecution) - */ - public ExitStatus run(Job configuration, - JobExecution execution) throws BatchCriticalException { - try { - // 1 seconds should be long enough to allow the thread to be - // run and for interrupt to be called; - Thread.sleep(3000); - return ExitStatus.FAILED; - - } catch (InterruptedException ex) { - // thread interrupted, allow to exit normally - return ExitStatus.FAILED; - } - } - - } - -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobExecutorFacadeTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobExecutorFacadeTests.java deleted file mode 100644 index d33a98549..000000000 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobExecutorFacadeTests.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.execution.launch; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; - -import org.easymock.MockControl; -import org.springframework.batch.core.domain.Job; -import org.springframework.batch.core.domain.JobExecution; -import org.springframework.batch.core.domain.JobInstance; -import org.springframework.batch.core.domain.JobInstanceProperties; -import org.springframework.batch.core.executor.JobExecutor; -import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; - -/** - * SimpleBatchContainer unit tests. - * - * SimpleJobExector should be removed, commented out the tests in case they were useful. - * - * @author Lucas Ward - * @author Dave Syer - */ -public class SimpleJobExecutorFacadeTests extends TestCase { - - private SimpleJobExecutorFacade jobExecutorFacade = new SimpleJobExecutorFacade(); - - private JobExecutor jobExecutor; - - private JobRepository jobRepository; - - private MockControl jobRepositoryControl = MockControl.createControl(JobRepository.class); - - private Job jobConfiguration = new Job(); - - private volatile boolean running = false; - - private SimpleJobIdentifier jobIdentifier = new SimpleJobIdentifier("TestJob"); - - private JobInstanceProperties jobInstanceProperties = new JobInstanceProperties(); - - private JobExecution jobExecution = new JobExecution(new JobInstance(new Long(0), jobInstanceProperties)); - - private List list = new ArrayList(); - - protected void setUp() throws Exception { - - super.setUp(); - jobConfiguration.setBeanName("TestJob"); - jobExecutorFacade.setJobExecutor(jobExecutor); - jobRepository = (JobRepository) jobRepositoryControl.getMock(); - jobExecutorFacade.setJobRepository(jobRepository); - - } - -// public void testCreateNewExecution() throws Exception { -// -// JobInstance job = setUpFacadeForNormalStart(); -// jobExecution = jobExecutorFacade.createExecutionFrom(jobIdentifier); -// assertEquals(job, jobExecution.getJobInstance()); -// jobRepositoryControl.verify(); -// -// } -// - public void testNormalStart() throws Exception { -// -// JobInstance job = setUpFacadeForNormalStart(); -// jobExecution = jobExecutorFacade.createExecutionFrom(jobIdentifier); -// jobExecutorFacade.start(jobExecution); -// assertEquals(job, jobExecution.getJobInstance()); -// jobRepositoryControl.verify(); -// - } -// -// private JobInstance setUpFacadeForNormalStart() throws Exception { -// jobIdentifier = new SimpleJobIdentifier("bar"); -// jobExecutor = new JobExecutor() { -// public ExitStatus run(Job configuration, JobExecution execution) throws BatchCriticalException { -// jobExecution = execution; -// return ExitStatus.FINISHED; -// } -// }; -// jobExecutorFacade.setJobExecutor(jobExecutor); -// JobInstance job = new JobInstance(new Long(0), jobInstanceProperties); -// jobExecution = new JobExecution(job); -// jobRepository.createJobExecution(jobConfiguration, null); -// jobRepositoryControl.setReturnValue(jobExecution); -// jobRepositoryControl.replay(); -// jobExecutorFacade -// .setJobLocator(new JobLocator() { -// public Job getJob(String name) -// throws NoSuchJobException { -// return jobConfiguration; -// } -// }); -// job.setJob(new Job()); -// return job; -// } -// -//// public void testIsRunning() throws Exception { -//// jobExecutorFacade.setJobExecutor(new JobExecutor() { -//// public ExitStatus run(Job configuration, -//// JobExecution execution) throws BatchCriticalException { -//// while (running) { -//// try { -//// Thread.sleep(100L); -//// } catch (InterruptedException e) { -//// throw new BatchCriticalException( -//// "Interrupted unexpectedly!"); -//// } -//// } -//// return ExitStatus.FINISHED; -//// } -//// }); -//// jobExecutorFacade -//// .setJobLocator(new JobLocator() { -//// public Job getJob(String name) -//// throws NoSuchJobException { -//// return jobConfiguration; -//// } -//// }); -//// -//// running = true; -//// new Thread(new Runnable() { -//// public void run() { -//// try { -//// jobExecutorFacade.start(jobExecution); -//// } catch (NoSuchJobException e) { -//// throw new IllegalStateException("Shouldn't happen"); -//// } -//// } -//// }).start(); -//// // Give Thread time to start -//// Thread.sleep(100L); -//// assertTrue(jobExecutorFacade.isRunning()); -//// running = false; -//// int count = 0; -//// while (jobExecutorFacade.isRunning() && count++ < 5) { -//// Thread.sleep(100L); -//// } -//// assertFalse(jobExecutorFacade.isRunning()); -//// } -// -// public void testInvalidInitialisation() throws Exception { -// -// jobExecutorFacade = new SimpleJobExecutorFacade(); -// -// try { -// jobExecutorFacade.afterPropertiesSet(); -// fail("Expected IllegalStateException"); -// } -// catch (IllegalArgumentException ex) { -// // expected -// } -// } -// -//// public void testStopWithNoJob() throws Exception { -//// SimpleJobIdentifier runtimeInformation = new SimpleJobIdentifier( -//// "TestJob"); -//// JobExecution execution = new JobExecution(new JobInstance( -//// new Long(0), jobInstanceProperties)); -//// try { -//// jobExecutorFacade.stop(execution); -//// fail("Expected NoSuchJobExecutionException"); -//// } catch (NoSuchJobExecutionException e) { -//// // expected -//// assertTrue("Wrong message in exception: "+e.getMessage(), e.getMessage().indexOf("TestJob") >= 0); -//// } -//// } -// -// public void testStop() throws Exception { -// SimpleJobIdentifier runtimeInformation = new SimpleJobIdentifier( -// "TestJob"); -// JobExecution execution = new JobExecution(new JobInstance( -// new Long(0), jobInstanceProperties)); -// -// List listeners = new ArrayList(); -// listeners.add(new JobExecutionListenerSupport() { -// public void onStop(JobExecution execution) { -// list.add("one"); -// } -// }); -// jobExecutorFacade.setJobExecutionListeners(listeners); -// -// registerExecution(runtimeInformation, execution); -// -// jobExecutorFacade.stop(execution); -// -// assertTrue(stepExecution.isTerminateOnly()); -// assertEquals(1, list.size()); -// } -// -// public void testStatisticsWithNoContext() throws Exception { -// assertNotNull(jobExecutorFacade.getStatistics()); -// } -// -// public void testStatisticsWithContext() throws Exception { -// SimpleJobIdentifier runtimeInformation = new SimpleJobIdentifier( -// "TestJob"); -// JobExecution execution = new JobExecution(new JobInstance( -// new Long(0), jobInstanceProperties)); -// registerExecution(runtimeInformation, execution); -// execution.createStepExecution(new StepInstance(jobInstance, "step")); -// Properties statistics = jobExecutorFacade.getStatistics(); -// assertNotNull(statistics); -// assertTrue(statistics.containsKey("job1.step1")); -// } -// -// public void testJobAlreadyExecutingLocally() throws Exception { -// SimpleJobIdentifier runtimeInformation = new SimpleJobIdentifier( -// "TestJob"); -// JobExecution execution = new JobExecution(new JobInstance( -// new Long(0), jobInstanceProperties)); -// registerExecution(runtimeInformation, execution); -// try { -// jobExecutorFacade.createExecutionFrom(runtimeInformation); -// fail("Expected JobExecutionAlreadyRunningException"); -// } -// catch (JobExecutionAlreadyRunningException e) { -// // expected -// assertTrue("Message does not contain TestJob: " + e.getMessage(), e.getMessage().indexOf("TestJob") >= 0); -// } -// } -// -// public void testListenersCalledLastOnStop() throws Exception { -// List listeners = new ArrayList(); -// listeners.add(new JobExecutionListenerSupport() { -// public void onStop(JobExecution execution) { -// list.add("one"); -// } -// }); -// listeners.add(new JobExecutionListenerSupport() { -// public void onStop(JobExecution execution) { -// list.add("two"); -// } -// }); -// jobExecutorFacade.setJobExecutionListeners(listeners); -// jobExecutorFacade.onStop(jobExecution); -// assertEquals(2, list.size()); -// assertEquals("two", list.get(1)); -// } -// -// public void testListenersCalledLastOnAfter() throws Exception { -// List listeners = new ArrayList(); -// listeners.add(new JobExecutionListenerSupport() { -// public void after(JobExecution execution) { -// list.add("two"); -// } -// }); -// listeners.add(new JobExecutionListenerSupport() { -// public void after(JobExecution execution) { -// list.add("one"); -// } -// }); -// jobExecutorFacade.setJobExecutionListeners(listeners); -// jobExecutorFacade.after(jobExecution); -// assertEquals(2, list.size()); -// assertEquals("two", list.get(1)); -// } -// -// public void testOrderedListenersCalledFirstOnBefore() throws Exception { -// List listeners = new ArrayList(); -// listeners.add(new JobExecutionListenerSupport() { -// public void before(JobExecution execution) { -// list.add("one"); -// } -// }); -// listeners.add(new JobExecutionListenerSupport() { -// public void before(JobExecution execution) { -// list.add("two"); -// } -// }); -// jobExecutorFacade.setJobExecutionListeners(listeners); -// jobExecutorFacade.before(jobExecution); -// assertEquals(2, list.size()); -// assertEquals("two", list.get(1)); -// } -// -// private void registerExecution(SimpleJobIdentifier runtimeInformation, JobExecution execution) -// throws NoSuchFieldException, IllegalAccessException { -// Field field = SimpleJobExecutorFacade.class.getDeclaredField("jobExecutionRegistry"); -// ReflectionUtils.makeAccessible(field); -// Map map = (Map) field.get(jobExecutorFacade); -// map.put(runtimeInformation, execution); -// } - -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java index 57ee5460c..644b470b6 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java @@ -25,19 +25,16 @@ import junit.framework.TestCase; import org.springframework.batch.core.domain.BatchStatus; import org.springframework.batch.core.domain.Job; 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.domain.JobInstanceProperties; import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.executor.StepExecutor; import org.springframework.batch.core.executor.StepExecutorFactory; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.batch.core.tasklet.Tasklet; import org.springframework.batch.execution.job.DefaultJobExecutor; import org.springframework.batch.execution.repository.SimpleJobRepository; import org.springframework.batch.execution.repository.dao.MapJobDao; import org.springframework.batch.execution.repository.dao.MapStepDao; -import org.springframework.batch.execution.runtime.ScheduledJobIdentifierFactory; import org.springframework.batch.execution.step.SimpleStep; import org.springframework.batch.execution.step.simple.SimpleStepExecutor; import org.springframework.batch.execution.tasklet.ItemOrientedTasklet; @@ -114,9 +111,6 @@ public class SimpleJobTests extends TestCase { public void testSimpleJob() throws Exception { Job jobConfiguration = new Job(); - JobIdentifier runtimeInformation = new ScheduledJobIdentifierFactory() - .getJobIdentifier("real.job"); - jobConfiguration.addStep(new SimpleStep(getTasklet("foo", "bar"))); jobConfiguration.addStep(new SimpleStep(getTasklet("spam"))); @@ -134,7 +128,6 @@ public class SimpleJobTests extends TestCase { public void testSimpleJobWithRecovery() throws Exception { Job jobConfiguration = new Job(); - JobIdentifier runtimeInformation = new SimpleJobIdentifier("real.job"); final List throwables = new ArrayList(); RepeatTemplate chunkOperations = new RepeatTemplate(); @@ -183,7 +176,6 @@ public class SimpleJobTests extends TestCase { public void testExceptionTerminates() throws Exception { Job jobConfiguration = new Job(); - JobIdentifier runtimeInformation = new SimpleJobIdentifier("real.job"); final ItemOrientedTasklet module = getTasklet(new String[] { "foo", "bar", "spam" }); Step step = new SimpleStep(module); module.setItemProcessor(new ItemProcessor() { diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/TaskExecutorJobLauncherTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/TaskExecutorJobLauncherTests.java deleted file mode 100644 index 90b38fb00..000000000 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/TaskExecutorJobLauncherTests.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.execution.launch; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.Timer; -import java.util.TimerTask; - -import junit.framework.TestCase; - -import org.easymock.MockControl; -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.domain.NoSuchJobException; -import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; -import org.springframework.batch.core.runtime.SimpleJobIdentifierFactory; -import org.springframework.batch.repeat.ExitStatus; -import org.springframework.batch.statistics.StatisticsProvider; -import org.springframework.batch.support.PropertiesConverter; -import org.springframework.context.ApplicationEvent; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.core.task.SimpleAsyncTaskExecutor; -import org.springframework.scheduling.timer.TimerTaskExecutor; - -public class TaskExecutorJobLauncherTests extends TestCase { - - private SimpleJobLauncher launcher = new SimpleJobLauncher(); - - protected void setUp() throws Exception { - super.setUp(); - } - - - //Under construction -// public void testStopContainer() throws Exception { -// -// // Important (otherwise start() does not return!) -// launcher.setTaskExecutor(new SimpleAsyncTaskExecutor()); -// -// InterruptibleContainer container = new InterruptibleContainer(); -// -// JobExecution execution = launcher.run(new SimpleJobIdentifier("foo")); -// // give the thread some time to start up... -// Thread.sleep(100); -// assertTrue(launcher.isRunning()); -// launcher.stop(); -// // ...and to shut down: -// Thread.sleep(400); -// assertFalse(launcher.isRunning()); -// assertEquals("COMPLETED_BY_TEST", execution.getExitStatus().getExitCode()); -// } -// -// public void testStopContainerWhenJobNotRunning() throws Exception { -// -// final List list = new ArrayList(); -// -// // Important (otherwise start() does not return!) -// TimerTaskExecutor taskExecutor = new TimerTaskExecutor(new Timer() { -// public void schedule(final TimerTask task, long delay) { -// TimerTask wrapper = new TimerTask() { -// public void run() { -// list.add(task); -// task.run(); -// } -// }; -// super.schedule(wrapper, 400); -// } -// }); -// taskExecutor.afterPropertiesSet(); -// launcher.setTaskExecutor(taskExecutor); -// -// InterruptibleContainer container = new InterruptibleContainer(); -// launcher.setJobExecutorFacade(container); -// -// JobExecution execution = launcher.run(new SimpleJobIdentifier("foo")); -// // give the thread some time to start up... -// Thread.sleep(100); -// // The launcher thinks it has started the job... -// assertTrue(launcher.isRunning()); -// // ...but the task has not been started yet -// assertEquals(0, list.size()); -// launcher.stop(); -// // ...and to shut down: -// Thread.sleep(1000); -// assertFalse(launcher.isRunning()); -// // The timer task has been started... -// assertEquals(1, list.size()); -// // ...but the job is not executed -// assertEquals(ExitStatus.UNKNOWN, execution.getExitStatus()); -// } -// -// public void testRunTwice() throws Exception { -// -// // Important (otherwise start() does not return!) -// launcher.setTaskExecutor(new SimpleAsyncTaskExecutor()); -// -// InterruptibleContainer container = new InterruptibleContainer(); -// launcher.setJobExecutorFacade(container); -// -// launcher.run(new SimpleJobIdentifier("foo")); -// // give the thread some time to start up: -// Thread.sleep(100); -// assertTrue(launcher.isRunning()); -// try { -// launcher.run(new SimpleJobIdentifier("foo")); -// fail("Expected JobExecutionAlreadyRunningException"); -// } catch (JobExecutionAlreadyRunningException e) { -// // expected -// } -// // give the thread some time to start up... -// Thread.sleep(100); -// launcher.stop(); -// // ...and to shut down: -// Thread.sleep(400); -// assertFalse(launcher.isRunning()); -// } -// -// public void testStatisticsRetrieved() throws Exception { -// MockControl control = MockControl -// .createControl(JobExecutorFacadeWithStatistics.class); -// JobExecutorFacadeWithStatistics batchContainer = (JobExecutorFacadeWithStatistics) control -// .getMock(); -// launcher.setJobExecutorFacade(batchContainer); -// -// Properties properties = PropertiesConverter.stringToProperties("a=b"); -// control.expectAndReturn(batchContainer.getStatistics(), properties); -// -// control.replay(); -// assertEquals(properties, launcher.getStatistics()); -// control.verify(); -// } -// -// public void testStatisticsNotRetrieved() throws Exception { -// MockControl control = MockControl -// .createControl(JobExecutorFacade.class); -// JobExecutorFacade batchContainer = (JobExecutorFacade) control -// .getMock(); -// launcher.setJobExecutorFacade(batchContainer); -// -// Properties properties = new Properties(); -// control.replay(); -// assertEquals(properties, launcher.getStatistics()); -// control.verify(); -// } -// - public void testPublishApplicationEvent() throws Exception { -// final List list = new ArrayList(); -// launcher.setApplicationEventPublisher(new ApplicationEventPublisher() { -// public void publishEvent(ApplicationEvent event) { -// list.add(event); -// } -// }); -// -// MockControl control = MockControl -// .createControl(JobExecutorFacade.class); -// JobExecutorFacade facade = (JobExecutorFacade) control.getMock(); -// launcher.setJobExecutorFacade(facade); -// SimpleJobIdentifier jobRuntimeInformation = new SimpleJobIdentifier( -// "spam"); -// JobExecution execution = new JobExecution(new JobInstance( -// jobRuntimeInformation, null)); -// control.expectAndReturn(facade -// .createExecutionFrom(jobRuntimeInformation), execution); -// facade.start(execution); -// control.setThrowable(new NoSuchJobException("SPAM")); -// -// control.replay(); -// launcher.run(jobRuntimeInformation); -// assertEquals(1, list.size()); -// control.verify(); - } -// -// private class InterruptibleContainer implements JobExecutorFacade { -// private volatile boolean running = true; -// -// private void start() { -// while (running) { -// try { -// // 1 seconds should be long enough to allow the thread to be -// // started and -// // for interrupt to be called; -// Thread.sleep(300); -// } catch (InterruptedException ex) { -// // thread interrupted, allow to exit normally -// } -// } -// } -// -// public void start(JobExecution execution) -// throws NoSuchJobException { -// start(); -// execution.setExitStatus(new ExitStatus(false, "COMPLETED_BY_TEST")); -// } -// -// public JobExecution createExecutionFrom(JobIdentifier jobIdentifier) -// throws NoSuchJobException { -// return new JobExecution(new JobInstance(jobIdentifier, null)); -// } -// -// public void stop(JobExecution execution) { -// running = false; -// } -// -// public boolean isRunning() { -// // not needed -// return false; -// } -// } -// -// private interface JobExecutorFacadeWithStatistics extends -// JobExecutorFacade, StatisticsProvider { -// } - -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java index e6423d26e..a24361d48 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractJobDaoTests.java @@ -16,7 +16,6 @@ package org.springframework.batch.execution.repository.dao; -import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; @@ -28,9 +27,6 @@ import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.JobInstanceProperties; import org.springframework.batch.core.domain.JobInstancePropertiesBuilder; import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; -import org.springframework.batch.execution.runtime.DefaultJobIdentifier; -import org.springframework.batch.execution.runtime.ScheduledJobIdentifier; import org.springframework.batch.repeat.ExitStatus; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; import org.springframework.util.ClassUtils; @@ -247,7 +243,6 @@ public abstract class AbstractJobDaoTests extends } public void testJobWithSimpleJobIdentifier() throws Exception { - SimpleJobIdentifier jobIdentifier = new SimpleJobIdentifier("Job1"); // Create job. jobInstance = jobDao.createJobInstance("test", jobInstanceProperties); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java index 6fecb337d..bdbc5bb7e 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java @@ -23,13 +23,11 @@ import java.util.Properties; import org.springframework.batch.core.domain.BatchStatus; import org.springframework.batch.core.domain.Job; 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.domain.JobInstanceProperties; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.core.executor.ExitCodeExceptionClassifier; -import org.springframework.batch.execution.runtime.ScheduledJobIdentifier; import org.springframework.batch.repeat.ExitStatus; import org.springframework.batch.restart.GenericRestartData; import org.springframework.batch.restart.RestartData; diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcJobDaoQueryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcJobDaoQueryTests.java index d8baf471b..ad42f7b91 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcJobDaoQueryTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcJobDaoQueryTests.java @@ -22,7 +22,6 @@ import junit.framework.TestCase; import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.JobInstanceProperties; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapJobDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapJobDaoTests.java index 78ee1df63..94150b07e 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapJobDaoTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapJobDaoTests.java @@ -23,7 +23,6 @@ import junit.framework.TestCase; import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.JobInstanceProperties; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; public class MapJobDaoTests extends TestCase { diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/resource/BatchResourceFactoryBeanTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/resource/BatchResourceFactoryBeanTests.java index 2a7895943..ff7408c8a 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/resource/BatchResourceFactoryBeanTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/resource/BatchResourceFactoryBeanTests.java @@ -18,19 +18,15 @@ package org.springframework.batch.execution.resource; import java.io.File; import java.io.IOException; -import java.text.SimpleDateFormat; import junit.framework.TestCase; import org.springframework.batch.core.domain.Job; 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.domain.JobInstanceProperties; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; -import org.springframework.batch.execution.resource.BatchResourceFactoryBean; -import org.springframework.batch.execution.runtime.ScheduledJobIdentifier; import org.springframework.batch.execution.scope.SimpleStepContext; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.DefaultResourceLoader; diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/DefaultStepExecutorTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/DefaultStepExecutorTests.java index 6e81eff5b..898b1e751 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/DefaultStepExecutorTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/DefaultStepExecutorTests.java @@ -30,7 +30,6 @@ import org.springframework.batch.core.domain.StepContribution; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.core.domain.StepSupport; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.batch.core.tasklet.Tasklet; import org.springframework.batch.execution.repository.SimpleJobRepository; import org.springframework.batch.execution.repository.dao.MapJobDao; diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/StepExecutorInterruptionTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/StepExecutorInterruptionTests.java index 307c5de7a..619aebfd6 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/StepExecutorInterruptionTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/StepExecutorInterruptionTests.java @@ -23,7 +23,6 @@ import junit.framework.TestCase; import org.springframework.batch.core.domain.BatchStatus; import org.springframework.batch.core.domain.Job; 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.domain.JobInstanceProperties; import org.springframework.batch.core.domain.StepExecution; @@ -31,7 +30,6 @@ import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.core.domain.StepSupport; import org.springframework.batch.core.executor.StepInterruptedException; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.runtime.SimpleJobIdentifier; import org.springframework.batch.core.tasklet.Tasklet; import org.springframework.batch.execution.repository.SimpleJobRepository; import org.springframework.batch.execution.repository.dao.JobDao; @@ -64,7 +62,6 @@ public class StepExecutorInterruptionTests extends TestCase { Job jobConfiguration = new Job(); stepConfiguration = new SimpleStep(); jobConfiguration.addStep(stepConfiguration); - JobIdentifier runtimeInformation = new SimpleJobIdentifier("TestJob"); jobConfiguration.setBeanName("testJob"); job = jobRepository.createJobExecution(jobConfiguration, new JobInstanceProperties()).getJobInstance(); executor = new SimpleStepExecutor(); diff --git a/spring-batch-execution/src/test/resources/simple-container-definition.xml b/spring-batch-execution/src/test/resources/simple-container-definition.xml index efc9017f4..fdaf0e92c 100644 --- a/spring-batch-execution/src/test/resources/simple-container-definition.xml +++ b/spring-batch-execution/src/test/resources/simple-container-definition.xml @@ -1,114 +1,115 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +