diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/BatchStatus.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/BatchStatus.java index 529c67867..4df8cdf0d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/BatchStatus.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/BatchStatus.java @@ -18,6 +18,8 @@ package org.springframework.batch.core.domain; import java.io.Serializable; +import org.springframework.util.Assert; + /** * Typesafe enumeration representing the status of an artifact within the * batch environment. See Effective Java Programming by Joshua Bloch for more @@ -69,6 +71,7 @@ public class BatchStatus implements Serializable{ * @throws IllegalArgumentException if no status matches provided string. */ public static BatchStatus getStatus(String statusAsString) { + Assert.notNull(statusAsString, "Cannot match null to valid status."); final String upperCaseStatusAsString = statusAsString.toUpperCase(); for (int i = 0; i < VALUES.length; i++) { if (VALUES[i].toString().equals(upperCaseStatusAsString)) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobIdentifier.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobIdentifier.java index b4fd06b68..4edeed07d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobIdentifier.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobIdentifier.java @@ -36,11 +36,11 @@ public interface JobIdentifier { public String getName(); /** - * A simple getter for the {@link JobInstanceProperties} that also identify + * A simple getter for the {@link JobParameters} that also identify * this job. * * @return JobRuntimeParameters */ - public JobInstanceProperties getJobInstanceProperties(); + public JobParameters getJobInstanceProperties(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInstance.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInstance.java index 28dca4c9f..da967b099 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInstance.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInstance.java @@ -35,7 +35,7 @@ public class JobInstance extends Entity { private List stepInstances = new ArrayList(); - private JobInstanceProperties jobInstanceProperties; + private JobParameters jobParameters; private Job job; @@ -44,14 +44,14 @@ public class JobInstance extends Entity { private int jobExecutionCount; - public JobInstance(Long id, JobInstanceProperties jobInstanceProperties) { + public JobInstance(Long id, JobParameters jobParameters) { super(id); - Assert.notNull(jobInstanceProperties, "JobInstanceProperties must not be null."); - this.jobInstanceProperties = jobInstanceProperties; + Assert.notNull(jobParameters, "JobInstanceProperties must not be null."); + this.jobParameters = jobParameters; } - public JobInstance(Long id, JobInstanceProperties jobInstanceProperties, Job job){ - this(id, jobInstanceProperties); + public JobInstance(Long id, JobParameters jobParameters, Job job){ + this(id, jobParameters); this.job = job; } @@ -86,8 +86,8 @@ public class JobInstance extends Entity { /** * @return JobInstanceProperties */ - public JobInstanceProperties getJobInstanceProperties() { - return jobInstanceProperties; + public JobParameters getJobInstanceProperties() { + return jobParameters; } /** @@ -102,7 +102,7 @@ public class JobInstance extends Entity { } public String toString() { - return super.toString()+", JobInstanceProperties=["+ jobInstanceProperties +"]" + + return super.toString()+", JobInstanceProperties=["+ jobParameters +"]" + ", Job=[" + job + "]"; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInstanceProperties.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParameters.java similarity index 91% rename from spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInstanceProperties.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParameters.java index 0607fe6bd..3eb44e143 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInstanceProperties.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParameters.java @@ -25,7 +25,7 @@ import org.apache.commons.lang.builder.HashCodeBuilder; * @author Lucas Ward * @since 1.0 */ -public class JobInstanceProperties { +public class JobParameters { private final Map stringMap; @@ -38,7 +38,7 @@ public class JobInstanceProperties { * that this constructor should only be used if an empty parameters is needed, since * JobRuntimeParameters is immutable. */ - public JobInstanceProperties(){ + public JobParameters(){ this.stringMap = new LinkedHashMap(); this.longMap = new LinkedHashMap(); this.dateMap = new LinkedHashMap(); @@ -46,14 +46,14 @@ public class JobInstanceProperties { /** * Create a new parameters object based upon three maps for each of the three - * data types. See {@link JobInstancePropertiesBuilder} for an easier way to + * data types. See {@link JobParametersBuilder} for an easier way to * create paramters. * * @param stringMap * @param longMap * @param dateMap */ - public JobInstanceProperties(Map stringMap, Map longMap, Map dateMap){ + public JobParameters(Map stringMap, Map longMap, Map dateMap){ super(); validateMap(stringMap, String.class); @@ -168,13 +168,9 @@ public class JobInstanceProperties { return tempMap; } - public boolean isEmtpy(){ - return dateMap.isEmpty() && longMap.isEmpty() && stringMap.isEmpty(); - } - public boolean equals(Object obj) { - if(obj instanceof JobInstanceProperties == false){ + if(obj instanceof JobParameters == false){ return false; } @@ -182,7 +178,7 @@ public class JobInstanceProperties { return true; } - JobInstanceProperties parameters = (JobInstanceProperties)obj; + JobParameters parameters = (JobParameters)obj; //Since the type contained by each map is known, it's safe to call Map.equals() if(getParameters().equals(parameters.getParameters())){ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInstancePropertiesBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParametersBuilder.java similarity index 59% rename from spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInstancePropertiesBuilder.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParametersBuilder.java index de0009db9..56e8ffe99 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobInstancePropertiesBuilder.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobParametersBuilder.java @@ -10,33 +10,35 @@ import java.util.Map; import org.springframework.util.Assert; /** - * Helper class for creating JobRuntimeParameters. Useful because of all JobRuntimeParameters - * are immutable, and require 3 separate maps of the three supported types to ensure typesafety. - * Once created, it can be used in the same was a java.lang.StringBuilder (except, order is irrelevant), - * by adding various parameters types and creating a valid JobRuntimeParametres once finished. + * Helper class for creating {@link JobParameters}. Useful because of all + * {@link JobParameters} are immutable, and require 3 separate maps of the three + * supported types to ensure typesafety. Once created, it can be used in the + * same was a java.lang.StringBuilder (except, order is irrelevant), by adding + * various parameters types and creating a valid JobRuntimeParametres once + * finished. * * @author Lucas Ward * @since 1.0 - * @see JobInstanceProperties + * @see JobParameters */ -public class JobInstancePropertiesBuilder { +public class JobParametersBuilder { private final Map stringMap; - + private final Map longMap; - + private final Map dateMap; - + /** - * Default constructor. Initializes the builder + * Default constructor. Initializes the builder */ - public JobInstancePropertiesBuilder() { - + public JobParametersBuilder() { + this.stringMap = new HashMap(); this.longMap = new HashMap(); this.dateMap = new HashMap(); } - + /** * Add a new String parameter for the given key. * @@ -44,12 +46,12 @@ public class JobInstancePropertiesBuilder { * @param parameter - runtime parameter * @return a refernece to this object. */ - public JobInstancePropertiesBuilder addString(String key, String parameter){ + public JobParametersBuilder addString(String key, String parameter) { Assert.notNull(parameter, "Parameter must not be null."); stringMap.put(key, parameter); return this; } - + /** * Add a new Date parameter for the given key. * @@ -57,12 +59,12 @@ public class JobInstancePropertiesBuilder { * @param parameter - runtime parameter * @return a refernece to this object. */ - public JobInstancePropertiesBuilder addDate(String key, Date parameter){ + public JobParametersBuilder addDate(String key, Date parameter) { Assert.notNull(parameter, "Parameter must not be null."); dateMap.put(key, new Date(parameter.getTime())); return this; } - + /** * Add a new Long parameter for the given key. * @@ -70,19 +72,19 @@ public class JobInstancePropertiesBuilder { * @param parameter - runtime parameter * @return a refernece to this object. */ - public JobInstancePropertiesBuilder addLong(String key, Long parameter){ + public JobParametersBuilder addLong(String key, Long parameter) { Assert.notNull(parameter, "Parameter must not be null."); longMap.put(key, parameter); return this; } - + /** - * Conversion method that takes the current state of this builder and returns it as - * a JobruntimeParameters object. + * Conversion method that takes the current state of this builder and + * returns it as a JobruntimeParameters object. * * @return a valid JobRuntimeParameters object. */ - public JobInstanceProperties toJobParameters(){ - return new JobInstanceProperties(stringMap, longMap, dateMap); + public JobParameters toJobParameters() { + return new JobParameters(stringMap, longMap, dateMap); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java index b06fec0da..6502be12d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java @@ -20,7 +20,7 @@ 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.JobParameters; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; @@ -53,7 +53,7 @@ public interface JobRepository { * exists, its persisted values (including ID) will be returned in a new * {@link JobInstance} object. If no previous run is found, a new job will * be created and returned. - * @param jobInstanceProperties TODO + * @param jobParameters TODO * @param jobConfiguration * describes the configuration for this job * @@ -64,7 +64,7 @@ public interface JobRepository { * */ public JobExecution createJobExecution(Job job, - JobInstanceProperties jobInstanceProperties) + JobParameters jobParameters) throws JobExecutionAlreadyRunningException; /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/JobIdentifierFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/JobParametersFactory.java similarity index 62% rename from spring-batch-core/src/main/java/org/springframework/batch/core/runtime/JobIdentifierFactory.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/runtime/JobParametersFactory.java index c2ffdaf54..2d580e4c9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/JobIdentifierFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/JobParametersFactory.java @@ -16,29 +16,31 @@ package org.springframework.batch.core.runtime; -import org.springframework.batch.core.domain.JobIdentifier; +import java.util.Properties; + +import org.springframework.batch.core.domain.JobParameters; /** - * A factory for {@link JobIdentifier} instances. A job can be + * A factory for {@link JobParameters} instances. A job can be * executed with many possible runtime parameters, which identify the instance * of the job. This factory allows job identifiers to be created with different - * properties according to the {@link JobIdentifier} strategy required. For + * properties according to the {@link JobParameters} strategy required. For * example some projects or jobs need a schedule date as part of the - * {@link JobIdentifier} and some do not (e.g. for an ad-hoc execution a simple + * {@link JobParameters} and some do not (e.g. for an ad-hoc execution a simple * label might be enough). * * * @author Dave Syer * */ -public interface JobIdentifierFactory { +public interface JobParametersFactory { /** - * Get a new {@link JobIdentifier} instance. + * Get a new {@link JobParameters} instance. * - * @param name - * the name of the job. - * @return a {@link JobIdentifier} with the same name. + * @param properties + * the runtime parameters in the form of String literals. + * @return a {@link JobParameters} properties converted to the correct types. */ - public JobIdentifier getJobIdentifier(String name); + public JobParameters getJobParameters(Properties properties); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifier.java b/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifier.java index e8da50f4c..917209246 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifier.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifier.java @@ -18,7 +18,7 @@ package org.springframework.batch.core.runtime; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.springframework.batch.core.domain.JobIdentifier; -import org.springframework.batch.core.domain.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.util.ClassUtils; @@ -32,7 +32,7 @@ import org.springframework.util.ClassUtils; public class SimpleJobIdentifier implements JobIdentifier { private String name; - private JobInstanceProperties runtimeParameters; + private JobParameters runtimeParameters; /** * Default constructor. Since there it is required that the Identifier at least have a name, @@ -47,10 +47,10 @@ public class SimpleJobIdentifier implements JobIdentifier { * @param name */ public SimpleJobIdentifier(String name) { - this(name, new JobInstanceProperties()); + this(name, new JobParameters()); } - public SimpleJobIdentifier(String name, JobInstanceProperties runtimeParameters){ + public SimpleJobIdentifier(String name, JobParameters runtimeParameters){ this.name = name; this.runtimeParameters = runtimeParameters; } @@ -62,7 +62,7 @@ public class SimpleJobIdentifier implements JobIdentifier { return this.name; } - public JobInstanceProperties getJobInstanceProperties() { + public JobParameters getJobInstanceProperties() { return runtimeParameters; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactory.java deleted file mode 100644 index a880fca45..000000000 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.springframework.batch.core.runtime; - -import org.springframework.batch.core.domain.JobIdentifier; - - -/** - * Factory for {@link SimpleJobIdentifier} instances. - * - * @author Dave Syer - * - */ -public class SimpleJobIdentifierFactory implements JobIdentifierFactory { - - /** - * Create a {@link JobIdentifier} with the given name. - * - * @param name the name for the {@link JobIdentifier} - * @return a {@link JobIdentifier} with the given name. - * - * @see org.springframework.batch.core.runtime.JobIdentifierFactory#getJobIdentifier(java.lang.String) - */ - public JobIdentifier getJobIdentifier(String name) { - return new SimpleJobIdentifier(name); - } - -} diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/BatchStatusTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/BatchStatusTests.java index 89719ab8d..319280e0b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/BatchStatusTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/BatchStatusTests.java @@ -55,6 +55,19 @@ public class BatchStatusTests extends TestCase { } } + /** + * Test method for {@link org.springframework.batch.core.domain.BatchStatus#getStatus(java.lang.String)}. + */ + public void testGetStatusNullCode() { + try{ + BatchStatus.getStatus(null); + fail(); + } + catch(IllegalArgumentException ex){ + //expected + } + } + public void testSerialization() throws Exception{ ByteArrayOutputStream bout = new ByteArrayOutputStream(); 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 bd14ad3fa..898a6ddeb 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 @@ -27,9 +27,9 @@ import org.springframework.batch.repeat.ExitStatus; */ public class JobExecutionTests extends TestCase { - private JobExecution execution = new JobExecution(new JobInstance(new Long(11), new JobInstanceProperties()), new Long(12)); + private JobExecution execution = new JobExecution(new JobInstance(new Long(11), new JobParameters()), new Long(12)); - private JobExecution context = new JobExecution(new JobInstance(new Long(11), new JobInstanceProperties(), new Job("foo")), new Long(12)); + private JobExecution context = new JobExecution(new JobInstance(new Long(11), new JobParameters(), new Job("foo")), new Long(12)); /** * Test method for @@ -85,7 +85,7 @@ public class JobExecutionTests extends TestCase { */ public void testGetJobId() { assertEquals(11, execution.getJobId().longValue()); - execution = new JobExecution(new JobInstance(new Long(23), new JobInstanceProperties()), null); + execution = new JobExecution(new JobInstance(new Long(23), new JobParameters()), null); assertEquals(23, execution.getJobId().longValue()); } 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 c5862d469..84fb475e4 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 @@ -25,7 +25,7 @@ import junit.framework.TestCase; */ public class JobInstanceTests extends TestCase { - private JobInstance instance = new JobInstance(new Long(11), new JobInstanceProperties(), new Job("job")); + private JobInstance instance = new JobInstance(new Long(11), new JobParameters(), new Job("job")); /** * Test method for {@link org.springframework.batch.core.domain.JobInstance#getStatus()}. @@ -66,7 +66,7 @@ public class JobInstanceTests extends TestCase { * Test method for {@link org.springframework.batch.core.domain.JobInstance#getIdentifier()}. */ public void testGetName() { - instance = new JobInstance(new Long(1), new JobInstanceProperties(), new Job("foo")); + instance = new JobInstance(new Long(1), new JobParameters(), new Job("foo")); assertEquals("foo", instance.getJobName()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobInstancePropertiesBuilderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobParametersBuilderTests.java similarity index 72% rename from spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobInstancePropertiesBuilderTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobParametersBuilderTests.java index b5aed8c71..ad47e962e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobInstancePropertiesBuilderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobParametersBuilderTests.java @@ -11,16 +11,16 @@ import junit.framework.TestCase; * @author Lucas Ward * */ -public class JobInstancePropertiesBuilderTests extends TestCase { +public class JobParametersBuilderTests extends TestCase { - JobInstancePropertiesBuilder parametersBuilder; + JobParametersBuilder parametersBuilder; Date date = new Date(System.currentTimeMillis()); protected void setUp() throws Exception { super.setUp(); - parametersBuilder = new JobInstancePropertiesBuilder(); + parametersBuilder = new JobParametersBuilder(); parametersBuilder.addDate("SCHEDULE_DATE", date); parametersBuilder.addLong("LONG", new Long(1)); parametersBuilder.addString("STRING", "string value"); @@ -28,7 +28,7 @@ public class JobInstancePropertiesBuilderTests extends TestCase { public void testToJobRuntimeParamters(){ - JobInstanceProperties parameters = parametersBuilder.toJobParameters(); + JobParameters parameters = parametersBuilder.toJobParameters(); assertEquals(parameters.getDate("SCHEDULE_DATE"), date); assertEquals(parameters.getLong("LONG"), new Long(1)); assertEquals(parameters.getString("STRING"), "string value"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobInstancePropertiesTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobParametersTests.java similarity index 81% rename from spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobInstancePropertiesTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobParametersTests.java index 773098b80..588ff7908 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobInstancePropertiesTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobParametersTests.java @@ -15,9 +15,9 @@ import junit.framework.TestCase; * @author Lucas Ward * */ -public class JobInstancePropertiesTests extends TestCase { +public class JobParametersTests extends TestCase { - JobInstanceProperties parameters; + JobParameters parameters; Map stringMap; @@ -33,7 +33,7 @@ public class JobInstancePropertiesTests extends TestCase { parameters = getNewParameters(); } - private JobInstanceProperties getNewParameters(){ + private JobParameters getNewParameters(){ stringMap = new HashMap(); stringMap.put("string.key1", "value1"); @@ -47,7 +47,7 @@ public class JobInstancePropertiesTests extends TestCase { dateMap.put("date.key1", date1 ); dateMap.put("date.key2", date2 ); - return new JobInstanceProperties(stringMap, longMap, dateMap); + return new JobParameters(stringMap, longMap, dateMap); } public void testBadLongConstructorException() throws Exception{ @@ -56,7 +56,7 @@ public class JobInstancePropertiesTests extends TestCase { badLongMap.put("key", "bad long"); try{ - new JobInstanceProperties(stringMap, badLongMap, dateMap); + new JobParameters(stringMap, badLongMap, dateMap); fail(); } catch(IllegalArgumentException ex){ @@ -70,7 +70,7 @@ public class JobInstancePropertiesTests extends TestCase { badMap.put("key", new Integer(2)); try{ - new JobInstanceProperties(badMap, longMap, dateMap); + new JobParameters(badMap, longMap, dateMap); fail(); } catch(IllegalArgumentException ex){ @@ -84,7 +84,7 @@ public class JobInstancePropertiesTests extends TestCase { badMap.put("key", new java.sql.Date(System.currentTimeMillis())); try{ - new JobInstanceProperties(stringMap, longMap, badMap); + new JobParameters(stringMap, longMap, badMap); fail(); } catch(IllegalArgumentException ex){ @@ -112,7 +112,7 @@ public class JobInstancePropertiesTests extends TestCase { public void testEquals(){ - JobInstanceProperties testParameters = getNewParameters(); + JobParameters testParameters = getNewParameters(); assertTrue(testParameters.equals(parameters)); } @@ -140,7 +140,7 @@ public class JobInstancePropertiesTests extends TestCase { dateMap.put("date.key2", date2 ); dateMap.put("date.key1", date1 ); - JobInstanceProperties testProps = new JobInstanceProperties(stringMap, longMap, dateMap); + JobParameters testProps = new JobParameters(stringMap, longMap, dateMap); props = testProps.getParameters(); stringBuilder = new StringBuilder(); @@ -152,15 +152,6 @@ public class JobInstancePropertiesTests extends TestCase { assertEquals(string1, string2); } - - public void testIsEmpty(){ - - JobInstanceProperties props = new JobInstanceProperties(); - assertTrue(props.isEmtpy()); - - props = new JobInstancePropertiesBuilder().addString("test", "test").toJobParameters(); - assertFalse(props.isEmtpy()); - } // Not sure how to properly test this since there is no order garuntee, commenting out for now. // diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepExecutionTests.java index ede5eed31..1168359bc 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepExecutionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepExecutionTests.java @@ -212,7 +212,7 @@ public class StepExecutionTests extends TestCase { } private StepExecution newStepExecution(Long long1, Long long2) { - JobInstance job = new JobInstance(new Long(3), new JobInstanceProperties()); + JobInstance job = new JobInstance(new Long(3), new JobParameters()); StepInstance step = new StepInstance(job, "foo", long1); StepExecution execution = new StepExecution(step, new JobExecution(job, long2), new Long(4)); return execution; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java index d4c37d970..192b1be21 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java @@ -71,7 +71,7 @@ public class StepInstanceTests extends TestCase { */ public void testGetJobInstance() { assertEquals(null, instance.getJobInstance()); - JobInstance jobInstance = new JobInstance(new Long(1), new JobInstanceProperties()); + JobInstance jobInstance = new JobInstance(new Long(1), new JobParameters()); instance = new StepInstance(jobInstance, null); assertEquals(jobInstance, instance.getJobInstance()); } @@ -79,7 +79,7 @@ public class StepInstanceTests extends TestCase { public void testGetJob(){ Job job = new Job("job"); - JobInstance jobInstance = new JobInstance(new Long(2), new JobInstanceProperties(), job); + JobInstance jobInstance = new JobInstance(new Long(2), new JobParameters(), job); instance = new StepInstance(jobInstance, null); assertEquals(job, instance.getJobInstance().getJob()); } @@ -98,12 +98,12 @@ public class StepInstanceTests extends TestCase { */ public void testGetJobId() { assertEquals(null, instance.getJobId()); - instance = new StepInstance(new JobInstance(new Long(23), new JobInstanceProperties()), null); + instance = new StepInstance(new JobInstance(new Long(23), new JobParameters()), null); assertEquals(23, instance.getJobId().longValue()); } public void testEqualsWithSameIdentifier() throws Exception { - JobInstance job = new JobInstance(new Long(100), new JobInstanceProperties()); + JobInstance job = new JobInstance(new Long(100), new JobParameters()); StepInstance step1 = new StepInstance(job, "foo", new Long(0)); StepInstance step2 = new StepInstance(job, "foo", new Long(0)); assertEquals(step1, step2); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactoryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactoryTests.java deleted file mode 100644 index dcb69da48..000000000 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/runtime/SimpleJobIdentifierFactoryTests.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.springframework.batch.core.runtime; - -import org.springframework.batch.core.domain.JobIdentifier; - -import junit.framework.TestCase; - -public class SimpleJobIdentifierFactoryTests extends TestCase { - - public void testGetJobIdentifier() { - JobIdentifier jobIdentifier = new SimpleJobIdentifierFactory().getJobIdentifier("foo"); - assertEquals("foo", jobIdentifier.getName()); - } - -} diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/JobIdentifierPropertyEditor.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/JobIdentifierPropertyEditor.java deleted file mode 100644 index 510f5f145..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/JobIdentifierPropertyEditor.java +++ /dev/null @@ -1,65 +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.bootstrap.support; - -import java.beans.PropertyEditorSupport; - -import org.springframework.batch.core.domain.Job; -import org.springframework.batch.core.domain.JobIdentifier; -import org.springframework.batch.core.runtime.JobIdentifierFactory; -import org.springframework.batch.core.runtime.SimpleJobIdentifierFactory; - -/** - * Simple adapter for a {@link JobIdentifierFactory} that can be used to convert - * from a {@link Job} name to a {@link JobIdentifier}. - * - * @author Dave Syer - * - */ -public class JobIdentifierPropertyEditor extends PropertyEditorSupport { - - private JobIdentifierFactory jobIdentifierFactory = new SimpleJobIdentifierFactory(); - - /** - * Public setter for the {@link JobIdentifierFactory}. - * @param jobIdentifierFactory the jobIdentifierFactory to set - */ - public void setJobIdentifierFactory(JobIdentifierFactory jobIdentifierFactory) { - this.jobIdentifierFactory = jobIdentifierFactory; - } - - /** - * Accept name of {@link Job} and create a {@link JobIdentifier}. - * - * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String) - */ - public void setAsText(String text) throws IllegalArgumentException { - setValue(jobIdentifierFactory.getJobIdentifier(text)); - } - - /** - * Extract the name from the {@link JobIdentifier}. - * - * @see java.beans.PropertyEditorSupport#getAsText() - */ - public String getAsText() { - JobIdentifier identifier = (JobIdentifier) getValue(); - if (identifier == null) { - return null; - } - return identifier.getName(); - } -} \ No newline at end of file diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/JobParametersPropertyEditor.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/JobParametersPropertyEditor.java new file mode 100644 index 000000000..5557248f4 --- /dev/null +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/JobParametersPropertyEditor.java @@ -0,0 +1,87 @@ +/* + * 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.bootstrap.support; + +import java.beans.PropertyEditorSupport; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.springframework.batch.core.domain.JobIdentifier; +import org.springframework.batch.core.domain.JobParameters; +import org.springframework.batch.core.domain.JobParametersBuilder; +import org.springframework.util.StringUtils; + +/** + * Factory for {@link JobParameters} instances using a simple naming convention + * for property keys. Key names ending with "(<type>)" where type is one + * of string, date, long are converted to the corresponding type. The default + * type is string. E.g. + * + *
+ * schedule.date(date)=2007/12/11 + * department.id(long)=2345 + *+ * + * The literal values are converted to the correct type using the default Spring + * strategies, augmented if necessary by the custom editors provided. + * + * TODO: finish this (only supports Strings so far). + * + * @author Dave Syer + * + */ +public class JobParametersPropertyEditor extends PropertyEditorSupport { + + /** + * Accept properties in the form of name=value pairs, delimited by either + * comma or new line (or both) and create {@link JobParameters}. + * + * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String) + */ + public void setAsText(String text) throws IllegalArgumentException { + JobParametersBuilder builder = new JobParametersBuilder(); + Properties properties = StringUtils.splitArrayElementsIntoProperties(StringUtils.tokenizeToStringArray(text, + ",\n"), "="); + for (Iterator iterator = properties.keySet().iterator(); iterator.hasNext();) { + String key = (String) iterator.next(); + key = StringUtils.tokenizeToStringArray(key, "(")[0]; + builder.addString(key, properties.getProperty(key)); + } + setValue(builder.toJobParameters()); + } + + /** + * Extract the name from the {@link JobIdentifier}. + * + * @see java.beans.PropertyEditorSupport#getAsText() + */ + public String getAsText() { + JobParameters params = (JobParameters) getValue(); + if (params == null) { + return null; + } + List builder = new ArrayList(); + Map map = params.getStringParameters(); + for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) { + String key = (String) iterator.next(); + builder.add(key+"="+map.get(key)); + } + return StringUtils.collectionToCommaDelimitedString(builder); + } +} \ No newline at end of file diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ScheduledJobInstancePropertiesFactory.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ScheduledJobParametersFactory.java similarity index 60% rename from spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ScheduledJobInstancePropertiesFactory.java rename to spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ScheduledJobParametersFactory.java index e29cd22e0..19ebe5b7a 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ScheduledJobInstancePropertiesFactory.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/ScheduledJobParametersFactory.java @@ -23,34 +23,32 @@ import java.util.Iterator; import java.util.Properties; import java.util.Map.Entry; -import org.springframework.batch.core.domain.JobInstanceProperties; -import org.springframework.batch.core.domain.JobInstancePropertiesBuilder; -import org.springframework.batch.core.domain.JobInstancePropertiesFactory; +import org.springframework.batch.core.domain.JobParameters; +import org.springframework.batch.core.domain.JobParametersBuilder; +import org.springframework.batch.core.runtime.JobParametersFactory; import org.springframework.util.Assert; /** * @author Lucas Ward * */ -public class ScheduledJobInstancePropertiesFactory implements - JobInstancePropertiesFactory { +public class ScheduledJobParametersFactory implements + JobParametersFactory { public static String SCHEDULE_DATE_KEY = "schedule.date"; public static String JOB_KEY = "job.key"; - private DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); + private DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); /* (non-Javadoc) - * @see org.springframework.batch.core.domain.JobInstancePropertiesFactory#getProperties(java.lang.String[]) + * @see org.springframework.batch.core.runtime.JobParametersFactory#getJobParameters(java.util.Properties) */ - public JobInstanceProperties getProperties(String[] args) { + public JobParameters getJobParameters(Properties props) { - Assert.notNull(args, "Factory arguments must not be null."); + Assert.notNull(props, "Factory arguments must not be null."); - JobInstancePropertiesBuilder propertiesBuilder = new JobInstancePropertiesBuilder(); + JobParametersBuilder propertiesBuilder = new JobParametersBuilder(); - Properties props = parseArgs(args); - for(Iterator it = props.entrySet().iterator(); it.hasNext();){ Entry entry = (Entry)it.next(); if(entry.getKey().equals(SCHEDULE_DATE_KEY)){ @@ -71,23 +69,10 @@ public class ScheduledJobInstancePropertiesFactory implements return propertiesBuilder.toJobParameters(); } - private Properties parseArgs(String[] args){ - Properties props = new Properties(); - - for(int i = 0; i < args.length; i++){ - String property = args[i]; - int equalsIndex = property.indexOf('='); - - if(equalsIndex == -1){ - throw new IllegalArgumentException("JobInstacePropertes argument invalid: [" + property + "]"); - } - String key = property.substring(0, equalsIndex); - props.put(key, property.substring(equalsIndex + 1)); - } - - return props; - } - + /** + * Public setter for injecting a date format. + * @param dateFormat a {@link DateFormat}, defaults to "yyyy/MM/dd" + */ public void setDateFormat(DateFormat dateFormat) { this.dateFormat = dateFormat; } 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 5498da9d5..6f111eb84 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 @@ -19,11 +19,10 @@ package org.springframework.batch.execution.bootstrap.support; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.domain.Job; -import org.springframework.batch.core.domain.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.JobLocator; import org.springframework.batch.core.domain.NoSuchJobException; import org.springframework.batch.core.executor.ExitCodeExceptionClassifier; -import org.springframework.batch.core.runtime.JobIdentifierFactory; import org.springframework.batch.execution.launch.JobLauncher; import org.springframework.batch.execution.step.simple.SimpleExitCodeExceptionClassifier; import org.springframework.batch.repeat.ExitStatus; @@ -225,7 +224,7 @@ public class SimpleCommandLineJobRunner { jobName = defaultJobName; } - status = launcher.run(jobLocator.getJob(jobName), new JobInstanceProperties()).getExitStatus(); + status = launcher.run(jobLocator.getJob(jobName), new JobParameters()).getExitStatus(); } catch (NoSuchJobException e) { logger.fatal("Could not locate JobConfiguration \"" + jobName + "\"", e); 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 867076fc1..de5b28c50 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,7 @@ 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.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; /** @@ -44,7 +44,7 @@ public interface JobLauncher { * by the properties already has an execution running. Throws * IllegalArgumentException if the job or jobInstanceProperties are null. */ - public JobExecution run(Job job, JobInstanceProperties jobParameters) + public JobExecution run(Job job, JobParameters jobParameters) throws 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 5b304f530..4a1b74b42 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 @@ -19,7 +19,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.domain.Job; import org.springframework.batch.core.domain.JobExecution; -import org.springframework.batch.core.domain.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.executor.JobExecutor; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobRepository; @@ -72,28 +72,28 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean{ * @return JobExecutionAlreadyRunningException if the JobInstance already exists and has * an execution already running. */ - public JobExecution run(final Job job, final JobInstanceProperties jobInstanceProperties) + public JobExecution run(final Job job, final JobParameters jobParameters) throws JobExecutionAlreadyRunningException { Assert.notNull(job, "The Job must not be null."); - Assert.notNull(jobInstanceProperties, "The JobInstanceProperties must not be null."); + Assert.notNull(jobParameters, "The JobInstanceProperties must not be null."); - final JobExecution jobExecution = jobRepository.createJobExecution(job, jobInstanceProperties); + final JobExecution jobExecution = jobRepository.createJobExecution(job, jobParameters); taskExecutor.execute(new Runnable(){ public void run() { try{ - logger.info("Job: [" + job + "] launched with the following parameters: [" + jobInstanceProperties + "]"); + logger.info("Job: [" + job + "] launched with the following parameters: [" + jobParameters + "]"); ExitStatus exitStatus = jobExecutor.run(job, jobExecution); //shouldn't need to set the exit status like this, I'm leaving it to make the latest change easier jobExecution.setExitStatus(exitStatus); logger.info("Job: [" + job + "] completed successfully with the following parameters: [" - + jobInstanceProperties + "]"); + + jobParameters + "]"); } catch(Throwable t){ logger.info("Job: [" + job + "] failed with the following parameters: [" - + jobInstanceProperties + "]", t); + + jobParameters + "]", t); rethrow(t); } } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java index edf7aa2bf..e997e1263 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java @@ -25,7 +25,7 @@ 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.JobParameters; import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; @@ -125,7 +125,7 @@ public class SimpleJobRepository implements JobRepository { * platform does not support the higher isolation levels). * * - * @see JobRepository#createJobExecution(Job, JobInstanceProperties) + * @see JobRepository#createJobExecution(Job, JobParameters) * * @throws BatchRestartException if more than one JobInstance if found or if * JobInstance.getJobExecutionCount() is greater than Job.getStartLimit() @@ -133,11 +133,11 @@ public class SimpleJobRepository implements JobRepository { * for the given {@link JobIdentifier} that is already running * */ - public JobExecution createJobExecution(Job job, JobInstanceProperties jobInstanceProperties) + public JobExecution createJobExecution(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException { Assert.notNull(job, "Job must not be null."); - Assert.notNull(jobInstanceProperties, "JobInstanceProperties must not be null."); + Assert.notNull(jobParameters, "JobInstanceProperties must not be null."); List jobs = new ArrayList(); JobInstance jobInstance; @@ -154,7 +154,7 @@ public class SimpleJobRepository implements JobRepository { * thread or process will block until this transaction has finished. */ - jobs = jobDao.findJobInstances(job.getName(), jobInstanceProperties); + jobs = jobDao.findJobInstances(job.getName(), jobParameters); } if (jobs.size() == 1) { @@ -176,7 +176,7 @@ public class SimpleJobRepository implements JobRepository { } else if (jobs.size() == 0) { // no job found, create one - jobInstance = createJobInstance(job, jobInstanceProperties); + jobInstance = createJobInstance(job, jobParameters); } else { // More than one job found, throw exception @@ -284,9 +284,9 @@ public class SimpleJobRepository implements JobRepository { * calling {@link JobDao#createJob(JobRuntimeInformation)} and then it's * list of StepConfigurations is passed to the createSteps method. */ - private JobInstance createJobInstance(Job job, JobInstanceProperties jobInstanceProperties) { + private JobInstance createJobInstance(Job job, JobParameters jobParameters) { - JobInstance jobInstance = jobDao.createJobInstance(job.getName(), jobInstanceProperties); + JobInstance jobInstance = jobDao.createJobInstance(job.getName(), jobParameters); jobInstance.setStepInstances(createStepInstances(jobInstance, job.getSteps())); return jobInstance; } 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 4f4369b7c..8a82165c7 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 @@ -31,7 +31,7 @@ import org.springframework.batch.core.domain.BatchStatus; 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.JobParameters; import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException; import org.springframework.batch.repeat.ExitStatus; import org.springframework.beans.factory.InitializingBean; @@ -120,25 +120,25 @@ public class JdbcJobDao implements JobDao, InitializingBean { * @throws IllegalArgumentException * if any {@link JobIdentifier} fields are null. */ - public JobInstance createJobInstance(String jobName, JobInstanceProperties jobInstanceProperties) { + public JobInstance createJobInstance(String jobName, JobParameters jobParameters) { Assert.notNull(jobName, "Job Name must not be null."); - Assert.notNull(jobInstanceProperties, "JobInstanceProperties must not be null."); + Assert.notNull(jobParameters, "JobInstanceProperties must not be null."); Long jobId = new Long(jobIncrementer.nextLongValue()); - Object[] parameters = new Object[] { jobId, jobName, createJobKey(jobInstanceProperties) }; + Object[] parameters = new Object[] { jobId, jobName, createJobKey(jobParameters) }; jdbcTemplate.update(getCreateJobQuery(), parameters, new int[] { Types.INTEGER, Types.VARCHAR, Types.VARCHAR}); - insertJobParameters(jobId, jobInstanceProperties); + insertJobParameters(jobId, jobParameters); - JobInstance jobInstance = new JobInstance(jobId, jobInstanceProperties); + JobInstance jobInstance = new JobInstance(jobId, jobParameters); return jobInstance; } - private String createJobKey(JobInstanceProperties jobInstanceProperties){ + private String createJobKey(JobParameters jobParameters){ - Map props = jobInstanceProperties.getParameters(); + Map props = jobParameters.getParameters(); StringBuilder stringBuilder = new StringBuilder(); for(Iterator it = props.entrySet().iterator();it.hasNext();){ Entry entry = (Entry)it.next(); @@ -166,18 +166,18 @@ public class JdbcJobDao implements JobDao, InitializingBean { * @throws IllegalArgumentException * if any {@link JobIdentifier} fields are null. */ - public List findJobInstances(final String jobName, final JobInstanceProperties jobInstanceProperties) { + public List findJobInstances(final String jobName, final JobParameters jobParameters) { Assert.notNull(jobName, "Job Name must not be null."); - Assert.notNull(jobInstanceProperties, "JobInstanceProperties must not be null."); + Assert.notNull(jobParameters, "JobInstanceProperties must not be null."); Object[] parameters = new Object[] { jobName, - createJobKey(jobInstanceProperties) }; + createJobKey(jobParameters) }; RowMapper rowMapper = new RowMapper() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { - JobInstance job = new JobInstance(new Long(rs.getLong(1)), jobInstanceProperties); + JobInstance job = new JobInstance(new Long(rs.getLong(1)), jobParameters); job.setStatus(BatchStatus.getStatus(rs.getString(2))); return job; @@ -242,7 +242,7 @@ public class JdbcJobDao implements JobDao, InitializingBean { * Convenience method that inserts all parameters from the provided JobParameters. * */ - private void insertJobParameters(Long jobId, JobInstanceProperties jobParameters){ + private void insertJobParameters(Long jobId, JobParameters jobParameters){ Map parameters = jobParameters.getStringParameters(); diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JobDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JobDao.java index 50e177d9b..07932b781 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JobDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JobDao.java @@ -21,7 +21,7 @@ import java.util.List; 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.JobParameters; /** * Data Access Object for jobs. @@ -40,7 +40,7 @@ public interface JobDao { * @param jobIdentifier * @return Job */ - public JobInstance createJobInstance(String jobName, JobInstanceProperties jobInstanceProperties); + public JobInstance createJobInstance(String jobName, JobParameters jobParameters); /** * Find all jobs that match the given JobIdentifier. If no jobs matching the @@ -50,7 +50,7 @@ public interface JobDao { * @return List of {@link JobInstance} objects matching * {@link JobIdentifier} */ - public List findJobInstances(String jobName, JobInstanceProperties jobInstanceProperties); + public List findJobInstances(String jobName, JobParameters jobParameters); /** * Update an existing Job. 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 4e6035446..ea2a9c8e1 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 @@ -25,7 +25,7 @@ import java.util.Set; 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.domain.JobParameters; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; public class MapJobDao implements JobDao { @@ -45,19 +45,19 @@ public class MapJobDao implements JobDao { executionsById.clear(); } - public JobInstance createJobInstance(String jobName, JobInstanceProperties jobInstanceProperties) { - JobInstance jobInstance = new JobInstance(new Long(currentId++), jobInstanceProperties); + public JobInstance createJobInstance(String jobName, JobParameters jobParameters) { + JobInstance jobInstance = new JobInstance(new Long(currentId++), jobParameters); jobInstance.setJob(new Job(jobName)); jobsById.put(jobInstance.getId(), jobInstance); return jobInstance; } - public List findJobInstances(String jobName, JobInstanceProperties jobInstanceProperties) { + public List findJobInstances(String jobName, JobParameters jobParameters) { List list = new ArrayList(); for (Iterator iter = jobsById.values().iterator(); iter.hasNext();) { JobInstance jobInstance = (JobInstance) iter.next(); - if (jobInstance.getJobName().equals(jobName) && jobInstance.getJobInstanceProperties().equals(jobInstanceProperties)) { + if (jobInstance.getJobName().equals(jobName) && jobInstance.getJobInstanceProperties().equals(jobParameters)) { list.add(jobInstance); } } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/DefaultJobIdentifier.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/DefaultJobIdentifier.java index e2189de70..92acf69f2 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/DefaultJobIdentifier.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/DefaultJobIdentifier.java @@ -16,8 +16,8 @@ package org.springframework.batch.execution.runtime; import org.springframework.batch.core.domain.JobIdentifier; -import org.springframework.batch.core.domain.JobInstanceProperties; -import org.springframework.batch.core.domain.JobInstancePropertiesBuilder; +import org.springframework.batch.core.domain.JobParameters; +import org.springframework.batch.core.domain.JobParametersBuilder; import org.springframework.batch.core.runtime.SimpleJobIdentifier; /** @@ -48,10 +48,10 @@ public class DefaultJobIdentifier extends SimpleJobIdentifier implements * @param name the name for the job */ public DefaultJobIdentifier(String name, String key) { - this(name, new JobInstancePropertiesBuilder().addString(JOB_KEY, key).toJobParameters()); + this(name, new JobParametersBuilder().addString(JOB_KEY, key).toJobParameters()); } - public DefaultJobIdentifier(String name, JobInstanceProperties parameters){ + public DefaultJobIdentifier(String name, JobParameters parameters){ super(name, parameters); } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/DefaultJobIdentifierFactory.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/DefaultJobIdentifierFactory.java deleted file mode 100644 index daecea530..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/DefaultJobIdentifierFactory.java +++ /dev/null @@ -1,43 +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.runtime; - -import org.springframework.batch.core.domain.JobIdentifier; -import org.springframework.batch.core.runtime.JobIdentifierFactory; - -/** - * {@link JobIdentifierFactory} for creating {@link DefaultJobIdentifierFactory} - * instances. - * - * @author Dave Syer - * - */ -public class DefaultJobIdentifierFactory implements JobIdentifierFactory { - - protected String key = "key"; - - public JobIdentifier getJobIdentifier(String name) { - - DefaultJobIdentifier runtimeInformation = new DefaultJobIdentifier(name, key); - return runtimeInformation; - } - - public void setJobKey(String key) { - this.key = key; - } - -} diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifier.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifier.java index aeee9aeef..334a3ee09 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifier.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifier.java @@ -19,7 +19,7 @@ package org.springframework.batch.execution.runtime; import java.util.Date; import org.springframework.batch.core.domain.JobIdentifier; -import org.springframework.batch.core.domain.JobInstancePropertiesBuilder; +import org.springframework.batch.core.domain.JobParametersBuilder; /** * Convenient {@link JobIdentifier} implementation that identifies itself by a @@ -59,7 +59,7 @@ public class ScheduledJobIdentifier extends DefaultJobIdentifier implements JobI * @param scheduleDate a timestamp */ public ScheduledJobIdentifier(String name, Date scheduleDate) { - super(name, new JobInstancePropertiesBuilder().addDate(SCHEDULE_DATE, scheduleDate).toJobParameters()); + super(name, new JobParametersBuilder().addDate(SCHEDULE_DATE, scheduleDate).toJobParameters()); } /** @@ -70,7 +70,7 @@ public class ScheduledJobIdentifier extends DefaultJobIdentifier implements JobI * @param scheduleDate a timestamp */ public ScheduledJobIdentifier(String name, String key, Date scheduleDate) { - super(name, new JobInstancePropertiesBuilder().addString(ScheduledJobIdentifier.JOB_KEY, key).addDate( + super(name, new JobParametersBuilder().addString(ScheduledJobIdentifier.JOB_KEY, key).addDate( SCHEDULE_DATE, scheduleDate).toJobParameters()); } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifierFactory.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifierFactory.java deleted file mode 100644 index 37dc5a1ce..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifierFactory.java +++ /dev/null @@ -1,62 +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.runtime; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.springframework.batch.core.domain.JobIdentifier; -import org.springframework.batch.core.runtime.JobIdentifierFactory; - -/** - * {@link JobIdentifierFactory} for creating {@link ScheduledJobIdentifier} - * instances. - * - * @author Dave Syer - * - */ -public class ScheduledJobIdentifierFactory extends DefaultJobIdentifierFactory implements JobIdentifierFactory { - - private Date scheduleDate; - - private DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); - - public JobIdentifier getJobIdentifier(String name) { - - initDate(); - ScheduledJobIdentifier identifier = new ScheduledJobIdentifier(name, key, scheduleDate); - return identifier; - } - - public void setScheduleDate(Date scheduleDate) { - this.scheduleDate = scheduleDate; - } - - public void setDateFormat(DateFormat dateFormat){ - this.dateFormat = dateFormat; - } - - private void initDate() { - try { - scheduleDate = dateFormat.parse("19700101"); - } catch (ParseException e) { - throw new IllegalStateException("Could not parse trivial date 19700101"); - } - } -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/JobIdentifierPropertyEditorTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/JobIdentifierPropertyEditorTests.java deleted file mode 100644 index 71e118170..000000000 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/JobIdentifierPropertyEditorTests.java +++ /dev/null @@ -1,62 +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.bootstrap.support; - -import org.springframework.batch.core.domain.JobIdentifier; -import org.springframework.batch.core.runtime.SimpleJobIdentifierFactory; - -import junit.framework.TestCase; - -/** - * @author Dave Syer - * - */ -public class JobIdentifierPropertyEditorTests extends TestCase { - - private JobIdentifierPropertyEditor editor = new JobIdentifierPropertyEditor(); - - /** - * Test method for {@link org.springframework.batch.execution.bootstrap.support.JobIdentifierPropertyEditor#setJobIdentifierFactory(org.springframework.batch.core.runtime.JobIdentifierFactory)}. - */ - public void testSetJobIdentifierFactory() { - editor.setJobIdentifierFactory(new SimpleJobIdentifierFactory() { - public JobIdentifier getJobIdentifier(String name) { - return super.getJobIdentifier("test:"+name); - } - }); - editor.setAsText("foo"); - JobIdentifier identifier = (JobIdentifier) editor.getValue(); - assertEquals("test:foo", identifier.getName()); - } - - /** - * Test method for {@link org.springframework.batch.execution.bootstrap.support.JobIdentifierPropertyEditor#setAsText(java.lang.String)}. - */ - public void testSetAsTextString() { - editor.setAsText("foo"); - JobIdentifier identifier = (JobIdentifier) editor.getValue(); - assertEquals("foo", identifier.getName()); - } - - /** - * Test method for {@link org.springframework.batch.execution.bootstrap.support.JobIdentifierPropertyEditor#getAsText()}. - */ - public void testGetAsText() { - editor.setAsText("foo"); - assertEquals("foo", editor.getAsText()); - } - -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/JobParametersPropertyEditorTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/JobParametersPropertyEditorTests.java new file mode 100644 index 000000000..1caad23ee --- /dev/null +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/JobParametersPropertyEditorTests.java @@ -0,0 +1,49 @@ +/* + * 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.bootstrap.support; + +import junit.framework.TestCase; + +import org.springframework.batch.core.domain.JobParameters; + +/** + * @author Dave Syer + * + */ +public class JobParametersPropertyEditorTests extends TestCase { + + private JobParametersPropertyEditor editor = new JobParametersPropertyEditor(); + + /** + * Test method for + * {@link org.springframework.batch.execution.bootstrap.support.JobParametersPropertyEditor#setAsText(java.lang.String)}. + */ + public void testSetAsTextString() { + editor.setAsText("foo=bar"); + JobParameters identifier = (JobParameters) editor.getValue(); + assertEquals("bar", identifier.getString("foo")); + } + + /** + * Test method for + * {@link org.springframework.batch.execution.bootstrap.support.JobParametersPropertyEditor#getAsText()}. + */ + public void testGetAsText() { + editor.setAsText("foo=bar,spam=bucket"); + assertEquals("foo=bar,spam=bucket", editor.getAsText()); + } + +} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/ScheduledJobInstancePropertiesFactoryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/ScheduledJobInstancePropertiesFactoryTests.java index 5ddb4d4a0..b716fead3 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/ScheduledJobInstancePropertiesFactoryTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/ScheduledJobInstancePropertiesFactoryTests.java @@ -18,62 +18,48 @@ package org.springframework.batch.execution.bootstrap.support; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; - -import org.springframework.batch.core.domain.JobInstanceProperties; +import java.util.Properties; import junit.framework.TestCase; +import org.springframework.batch.core.domain.JobParameters; +import org.springframework.util.StringUtils; + /** * @author Lucas Ward * */ public class ScheduledJobInstancePropertiesFactoryTests extends TestCase { - ScheduledJobInstancePropertiesFactory factory; + ScheduledJobParametersFactory factory; DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); protected void setUp() throws Exception { super.setUp(); - factory = new ScheduledJobInstancePropertiesFactory(); + factory = new ScheduledJobParametersFactory(); } public void testGetProperties() throws Exception{ String jobKey = "job.key=myKey"; - String scheduleDate = "schedule.date=01/23/2008"; + String scheduleDate = "schedule.date=2008/01/23"; String vendorId = "vendor.id=33243243"; String[] args = new String[]{jobKey, scheduleDate, vendorId}; - JobInstanceProperties props = factory.getProperties(args); + JobParameters props = factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "=")); assertNotNull(props); assertEquals("myKey", props.getString("job.key")); assertEquals("33243243", props.getString("vendor.id")); Date date = dateFormat.parse("01/23/2008"); assertEquals(date, props.getDate("schedule.date")); } - - public void testInvalidFormat(){ - String jobKey = "job.key-myKey"; - - String[] args = new String[]{jobKey}; - - try{ - factory.getProperties(args); - fail(); - } - catch(IllegalArgumentException ex){ - //expected - } - } - public void testEmptyArgs(){ - String[] args = new String[]{}; - JobInstanceProperties props = factory.getProperties(args); - assertTrue(props.isEmtpy()); + JobParameters props = factory.getJobParameters(new Properties()); + assertTrue(props.getParameters().isEmpty()); } } 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 b68ca4c50..c8943cf0a 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 @@ -20,7 +20,7 @@ import junit.framework.TestCase; 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.domain.JobParameters; import org.springframework.batch.repeat.ExitStatus; import org.springframework.beans.factory.access.BeanFactoryLocator; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; @@ -158,7 +158,7 @@ public class SimpleCommandLineJobRunnerTests extends TestCase { } private void setReturnValue(ExitStatus status) { - JobExecution execution = new JobExecution(new JobInstance(new Long(1), new JobInstanceProperties(), new Job("foo"))); + JobExecution execution = new JobExecution(new JobInstance(new Long(1), new JobParameters(), new Job("foo"))); execution.setExitStatus(status); jobLauncher.setReturnValue(execution); 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 92c6346af..b97507d7b 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,7 +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.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.execution.launch.JobLauncher; @@ -30,7 +30,7 @@ public class StubJobLauncher implements JobLauncher { return isRunning; } - public JobExecution run(Job job, JobInstanceProperties jobInstanceProperties) + public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException { lastRunCalled = RUN_JOB_IDENTIFIER; return returnValue; 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 3607c5f67..ce8393180 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 @@ -25,7 +25,7 @@ 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.JobInstance; -import org.springframework.batch.core.domain.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; @@ -97,7 +97,7 @@ public class DefaultJobExecutorTests extends TestCase { private Job jobConfiguration; - private JobInstanceProperties jobInstanceProperties = new JobInstanceProperties(); + private JobParameters jobParameters = new JobParameters(); private DefaultJobExecutor jobExecutor; @@ -127,7 +127,7 @@ public class DefaultJobExecutorTests extends TestCase { jobConfiguration.setName("testJob"); jobConfiguration.setSteps(stepConfigurations); - jobExecution = jobRepository.createJobExecution(jobConfiguration, jobInstanceProperties); + jobExecution = jobRepository.createJobExecution(jobConfiguration, jobParameters); job = jobExecution.getJobInstance(); List steps = job.getStepInstances(); @@ -282,7 +282,7 @@ public class DefaultJobExecutorTests extends TestCase { * Check JobRepository to ensure status is being saved. */ private void checkRepository(BatchStatus status, ExitStatus exitStatus) { - assertEquals(job, jobDao.findJobInstances(job.getJobName(), jobInstanceProperties).get(0)); + assertEquals(job, jobDao.findJobInstances(job.getJobName(), jobParameters).get(0)); // because map dao stores in memory, it can be checked directly assertEquals(status, job.getStatus()); JobExecution jobExecution = (JobExecution) jobDao diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java index a290cbe17..3dde16e93 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java @@ -21,7 +21,7 @@ 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.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.executor.JobExecutor; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.repeat.ExitStatus; @@ -41,7 +41,7 @@ public class SimpleJobLauncherTests extends TestCase { private MockControl repositoryControl = MockControl.createControl(JobRepository.class); private Job job = new Job("foo"); - private JobInstanceProperties jobInstanceProperties = new JobInstanceProperties(); + private JobParameters jobParameters = new JobParameters(); protected void setUp() throws Exception { super.setUp(); @@ -62,7 +62,7 @@ public class SimpleJobLauncherTests extends TestCase { JobExecution jobExecution = new JobExecution(null); - jobRepository.createJobExecution(job, jobInstanceProperties); + jobRepository.createJobExecution(job, jobParameters); repositoryControl.setReturnValue(jobExecution); jobExecutor.run(job, jobExecution); executorControl.setDefaultReturnValue(ExitStatus.FINISHED); @@ -70,7 +70,7 @@ public class SimpleJobLauncherTests extends TestCase { repositoryControl.replay(); executorControl.replay(); - jobLauncher.run(job, jobInstanceProperties); + jobLauncher.run(job, jobParameters); assertEquals(ExitStatus.FINISHED, jobExecution.getExitStatus()); repositoryControl.verify(); 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 644b470b6..7cf3be12f 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 @@ -26,7 +26,7 @@ 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.JobInstance; -import org.springframework.batch.core.domain.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.executor.StepExecutor; import org.springframework.batch.core.executor.StepExecutorFactory; @@ -114,7 +114,7 @@ public class SimpleJobTests extends TestCase { jobConfiguration.addStep(new SimpleStep(getTasklet("foo", "bar"))); jobConfiguration.addStep(new SimpleStep(getTasklet("spam"))); - JobInstance job = repository.createJobExecution(jobConfiguration, new JobInstanceProperties()).getJobInstance(); + JobInstance job = repository.createJobExecution(jobConfiguration, new JobParameters()).getJobInstance(); JobExecution jobExecutionContext = new JobExecution(job); @@ -163,7 +163,7 @@ public class SimpleJobTests extends TestCase { module.afterPropertiesSet(); jobConfiguration.addStep(step); - JobExecution jobExecution = repository.createJobExecution(jobConfiguration, new JobInstanceProperties()); + JobExecution jobExecution = repository.createJobExecution(jobConfiguration, new JobParameters()); jobExecutor.run(jobConfiguration, jobExecution); assertEquals(BatchStatus.COMPLETED, jobExecution.getJobInstance().getStatus()); @@ -186,7 +186,7 @@ public class SimpleJobTests extends TestCase { module.afterPropertiesSet(); jobConfiguration.addStep(step); - JobExecution jobExecution = repository.createJobExecution(jobConfiguration, new JobInstanceProperties()); + JobExecution jobExecution = repository.createJobExecution(jobConfiguration, new JobParameters()); JobInstance job = jobExecution.getJobInstance(); try { jobExecutor.run(jobConfiguration, jobExecution); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java index 4c4db8e61..64bb9a5d3 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java @@ -28,8 +28,8 @@ 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.domain.JobInstancePropertiesBuilder; +import org.springframework.batch.core.domain.JobParameters; +import org.springframework.batch.core.domain.JobParametersBuilder; import org.springframework.batch.core.domain.Step; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; @@ -53,7 +53,7 @@ public class SimpleJobRepositoryTests extends TestCase { Job jobConfiguration; - JobInstanceProperties jobInstanceProperties; + JobParameters jobParameters; Step stepConfiguration1; @@ -86,7 +86,7 @@ public class SimpleJobRepositoryTests extends TestCase { jobRepository = new SimpleJobRepository(jobDao, stepDao); - jobInstanceProperties = new JobInstancePropertiesBuilder().toJobParameters(); + jobParameters = new JobParametersBuilder().toJobParameters(); jobConfiguration = new Job(); @@ -103,7 +103,7 @@ public class SimpleJobRepositoryTests extends TestCase { jobConfiguration.setSteps(stepConfigurations); - databaseJob = new JobInstance(new Long(1), jobInstanceProperties) { + databaseJob = new JobInstance(new Long(1), jobParameters) { public JobExecution createJobExecution() { jobExecution = super.createJobExecution(); return jobExecution; @@ -125,9 +125,9 @@ public class SimpleJobRepositoryTests extends TestCase { List jobExecutions = new ArrayList(); - jobDao.findJobInstances(jobConfiguration.getName(), jobInstanceProperties); + jobDao.findJobInstances(jobConfiguration.getName(), jobParameters); jobDaoControl.setReturnValue(jobExecutions); - jobDao.createJobInstance(jobConfiguration.getName(), jobInstanceProperties); + jobDao.createJobInstance(jobConfiguration.getName(), jobParameters); jobDaoControl.setReturnValue(databaseJob); stepDao.createStep(databaseJob, "TestStep1"); stepDaoControl.setReturnValue(databaseStep1); @@ -144,7 +144,7 @@ public class SimpleJobRepositoryTests extends TestCase { }); stepDaoControl.replay(); jobDaoControl.replay(); - JobInstance job = jobRepository.createJobExecution(jobConfiguration, jobInstanceProperties).getJobInstance(); + JobInstance job = jobRepository.createJobExecution(jobConfiguration, jobParameters).getJobInstance(); assertTrue(job.equals(databaseJob)); List jobSteps = job.getStepInstances(); Iterator it = jobSteps.iterator(); @@ -156,7 +156,7 @@ public class SimpleJobRepositoryTests extends TestCase { public void testRestartedJob() throws Exception{ List jobs = new ArrayList(); - jobDao.findJobInstances(jobConfiguration.getName(), jobInstanceProperties); + jobDao.findJobInstances(jobConfiguration.getName(), jobParameters); jobs.add(databaseJob); jobDaoControl.setReturnValue(jobs); stepDao.findStep(databaseJob, "TestStep1"); @@ -191,7 +191,7 @@ public class SimpleJobRepositoryTests extends TestCase { }); jobDaoControl.setVoidCallable(); jobDaoControl.replay(); - JobInstance job = jobRepository.createJobExecution(jobConfiguration, jobInstanceProperties).getJobInstance(); + JobInstance job = jobRepository.createJobExecution(jobConfiguration, jobParameters).getJobInstance(); assertTrue(job.equals(databaseJob)); List jobSteps = job.getStepInstances(); Iterator it = jobSteps.iterator(); @@ -208,13 +208,13 @@ public class SimpleJobRepositoryTests extends TestCase { List jobs = new ArrayList(); jobs.add(databaseJob); - jobs.add(new JobInstance(new Long(127), jobInstanceProperties)); - jobDao.findJobInstances(jobConfiguration.getName(), jobInstanceProperties); + jobs.add(new JobInstance(new Long(127), jobParameters)); + jobDao.findJobInstances(jobConfiguration.getName(), jobParameters); jobDaoControl.setReturnValue(jobs); jobDaoControl.replay(); try{ - jobRepository.createJobExecution(jobConfiguration, jobInstanceProperties); + jobRepository.createJobExecution(jobConfiguration, jobParameters); fail("Expected BatchRestartException"); }catch(BatchRestartException e){ //expected @@ -228,7 +228,7 @@ public class SimpleJobRepositoryTests extends TestCase { jobConfiguration.setStartLimit(1); List jobs = new ArrayList(); - jobDao.findJobInstances(jobConfiguration.getName(), jobInstanceProperties); + jobDao.findJobInstances(jobConfiguration.getName(), jobParameters); jobs.add(databaseJob); jobDaoControl.setReturnValue(jobs); stepDao.findStep(databaseJob, "TestStep1"); @@ -246,7 +246,7 @@ public class SimpleJobRepositoryTests extends TestCase { jobDaoControl.replay(); try{ - jobRepository.createJobExecution(jobConfiguration, jobInstanceProperties); + jobRepository.createJobExecution(jobConfiguration, jobParameters); fail(); }catch(BatchRestartException ex){ //expected @@ -261,9 +261,9 @@ public class SimpleJobRepositoryTests extends TestCase { List jobs = new ArrayList(); jobConfiguration.setRestartable(false); - jobDao.findJobInstances(jobConfiguration.getName(), jobInstanceProperties); + jobDao.findJobInstances(jobConfiguration.getName(), jobParameters); jobDaoControl.setReturnValue(jobs); - jobDao.createJobInstance(jobConfiguration.getName(), jobInstanceProperties); + jobDao.createJobInstance(jobConfiguration.getName(), jobParameters); jobDaoControl.setReturnValue(databaseJob); stepDao.createStep(databaseJob, "TestStep1"); stepDaoControl.setReturnValue(databaseStep1); @@ -280,7 +280,7 @@ public class SimpleJobRepositoryTests extends TestCase { }); stepDaoControl.replay(); jobDaoControl.replay(); - JobInstance job = jobRepository.createJobExecution(jobConfiguration, jobInstanceProperties).getJobInstance(); + JobInstance job = jobRepository.createJobExecution(jobConfiguration, jobParameters).getJobInstance(); assertTrue(job.equals(databaseJob)); List jobSteps = job.getStepInstances(); Iterator it = jobSteps.iterator(); @@ -295,7 +295,7 @@ public class SimpleJobRepositoryTests extends TestCase { // failure scenario - no ID JobInstance updateJob; try { - updateJob = new JobInstance(null, jobInstanceProperties); + updateJob = new JobInstance(null, jobParameters); jobRepository.update(updateJob); fail(); } @@ -304,7 +304,7 @@ public class SimpleJobRepositoryTests extends TestCase { } // successful update - updateJob = new JobInstance(new Long(0L), jobInstanceProperties); + updateJob = new JobInstance(new Long(0L), jobParameters); jobDao.update(updateJob); jobDaoControl.replay(); jobRepository.update(updateJob); @@ -326,7 +326,7 @@ public class SimpleJobRepositoryTests extends TestCase { public void testSaveOrUpdateValidJobExecution() throws Exception { - JobExecution jobExecution = new JobExecution(new JobInstance(new Long(1), jobInstanceProperties)); + JobExecution jobExecution = new JobExecution(new JobInstance(new Long(1), jobParameters)); // new execution - call save on job dao jobDao.save(jobExecution); @@ -401,9 +401,9 @@ public class SimpleJobRepositoryTests extends TestCase { List jobs = new ArrayList(); - jobDao.findJobInstances(jobConfiguration.getName(), jobInstanceProperties); + jobDao.findJobInstances(jobConfiguration.getName(), jobParameters); jobDaoControl.setReturnValue(jobs); - jobDao.createJobInstance(jobConfiguration.getName(), jobInstanceProperties); + jobDao.createJobInstance(jobConfiguration.getName(), jobParameters); jobDaoControl.setReturnValue(databaseJob); stepDao.createStep(databaseJob, "TestStep1"); databaseStep1.setRestartData(null); @@ -422,7 +422,7 @@ public class SimpleJobRepositoryTests extends TestCase { }); stepDaoControl.replay(); jobDaoControl.replay(); - JobInstance job = jobRepository.createJobExecution(jobConfiguration, jobInstanceProperties).getJobInstance(); + JobInstance job = jobRepository.createJobExecution(jobConfiguration, jobParameters).getJobInstance(); List jobSteps = job.getStepInstances(); Iterator it = jobSteps.iterator(); StepInstance step = (StepInstance) it.next(); @@ -435,7 +435,7 @@ public class SimpleJobRepositoryTests extends TestCase { public void testFindStepsFixesInvalidRestartData() throws Exception{ List jobs = new ArrayList(); - jobDao.findJobInstances(jobConfiguration.getName(), jobInstanceProperties); + jobDao.findJobInstances(jobConfiguration.getName(), jobParameters); jobs.add(databaseJob); jobDaoControl.setReturnValue(jobs); stepDao.findStep(databaseJob, "TestStep1"); @@ -465,7 +465,7 @@ public class SimpleJobRepositoryTests extends TestCase { } }); jobDaoControl.replay(); - JobInstance job = jobRepository.createJobExecution(jobConfiguration, jobInstanceProperties).getJobInstance(); + JobInstance job = jobRepository.createJobExecution(jobConfiguration, jobParameters).getJobInstance(); assertTrue(job.equals(databaseJob)); List jobSteps = job.getStepInstances(); Iterator it = jobSteps.iterator(); 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 a24361d48..770110451 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 @@ -24,8 +24,8 @@ 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.JobInstance; -import org.springframework.batch.core.domain.JobInstanceProperties; -import org.springframework.batch.core.domain.JobInstancePropertiesBuilder; +import org.springframework.batch.core.domain.JobParameters; +import org.springframework.batch.core.domain.JobParametersBuilder; import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException; import org.springframework.batch.repeat.ExitStatus; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; @@ -40,7 +40,7 @@ public abstract class AbstractJobDaoTests extends protected JobDao jobDao; - protected JobInstanceProperties jobInstanceProperties = new JobInstancePropertiesBuilder().addString("job.key", "jobKey").toJobParameters(); + protected JobParameters jobParameters = new JobParametersBuilder().addString("job.key", "jobKey").toJobParameters(); protected JobInstance jobInstance; @@ -71,7 +71,7 @@ public abstract class AbstractJobDaoTests extends job = new Job("Job1"); // Create job. - jobInstance = jobDao.createJobInstance(job.getName(), jobInstanceProperties); + jobInstance = jobDao.createJobInstance(job.getName(), jobParameters); // Create an execution jobExecutionStartTime = new Date(System.currentTimeMillis()); @@ -97,17 +97,17 @@ public abstract class AbstractJobDaoTests extends public void testFindNonExistentJob() { // No job should be found since it hasn't been created. - List jobs = jobDao.findJobInstances("nonexistentJob", jobInstanceProperties); + List jobs = jobDao.findJobInstances("nonexistentJob", jobParameters); assertTrue(jobs.size() == 0); } public void testFindJob() { - List jobs = jobDao.findJobInstances(job.getName(), jobInstanceProperties); + List jobs = jobDao.findJobInstances(job.getName(), jobParameters); assertTrue(jobs.size() == 1); JobInstance tempJob = (JobInstance) jobs.get(0); assertTrue(jobInstance.equals(tempJob)); - assertEquals(jobInstanceProperties, tempJob.getJobInstanceProperties()); + assertEquals(jobParameters, tempJob.getJobInstanceProperties()); } public void testFindJobWithNullRuntime() { @@ -127,18 +127,18 @@ public abstract class AbstractJobDaoTests extends */ public void testCreateJobWithExistingName() { - jobDao.createJobInstance("ScheduledJob", jobInstanceProperties); + jobDao.createJobInstance("ScheduledJob", jobParameters); // Modifying the key should bring back a completely different // JobInstance - JobInstanceProperties tempProps = new JobInstancePropertiesBuilder().addString("job.key", "testKey1") + JobParameters tempProps = new JobParametersBuilder().addString("job.key", "testKey1") .toJobParameters(); List jobs; - jobs = jobDao.findJobInstances("ScheduledJob", jobInstanceProperties); + jobs = jobDao.findJobInstances("ScheduledJob", jobParameters); assertEquals(1, jobs.size()); JobInstance jobInstance = (JobInstance) jobs.get(0); - assertEquals(jobInstanceProperties, jobInstance.getJobInstanceProperties()); + assertEquals(jobParameters, jobInstance.getJobInstanceProperties()); jobs = jobDao.findJobInstances("ScheduledJob", tempProps); assertEquals(0, jobs.size()); @@ -151,7 +151,7 @@ public abstract class AbstractJobDaoTests extends jobDao.update(jobInstance); // The job just updated should be found, with the saved status. - List jobs = jobDao.findJobInstances(job.getName(), jobInstanceProperties); + List jobs = jobDao.findJobInstances(job.getName(), jobParameters); assertTrue(jobs.size() == 1); JobInstance tempJob = (JobInstance) jobs.get(0); assertTrue(jobInstance.equals(tempJob)); @@ -237,7 +237,7 @@ public abstract class AbstractJobDaoTests extends public void testZeroExecutionCount() { - JobInstance testJob = jobDao.createJobInstance("test", new JobInstanceProperties()); + JobInstance testJob = jobDao.createJobInstance("test", new JobParameters()); // no jobExecutions saved for new job, count should be 0 assertEquals(jobDao.getJobExecutionCount(testJob.getId()), 0); } @@ -245,7 +245,7 @@ public abstract class AbstractJobDaoTests extends public void testJobWithSimpleJobIdentifier() throws Exception { // Create job. - jobInstance = jobDao.createJobInstance("test", jobInstanceProperties); + jobInstance = jobDao.createJobInstance("test", jobParameters); List jobs = jdbcTemplate.queryForList( "SELECT * FROM BATCH_JOB_INSTANCE where ID=?", new Object[] { jobInstance @@ -257,12 +257,12 @@ public abstract class AbstractJobDaoTests extends public void testJobWithDefaultJobIdentifier() throws Exception { // Create job. - jobInstance = jobDao.createJobInstance("testDefault", jobInstanceProperties); + jobInstance = jobDao.createJobInstance("testDefault", jobParameters); - List jobs = jobDao.findJobInstances("testDefault", jobInstanceProperties); + List jobs = jobDao.findJobInstances("testDefault", jobParameters); assertEquals(1, jobs.size()); - assertEquals(jobInstanceProperties.getString("job.key"), ((JobInstance) jobs.get(0)) + assertEquals(jobParameters.getString("job.key"), ((JobInstance) jobs.get(0)) .getJobInstanceProperties().getString("job.key")); } 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 bdbc5bb7e..b58d4d569 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 @@ -24,7 +24,7 @@ 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.JobInstance; -import org.springframework.batch.core.domain.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.core.executor.ExitCodeExceptionClassifier; @@ -59,7 +59,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour protected JobExecution jobExecution; - protected JobInstanceProperties jobInstanceProperties = new JobInstanceProperties(); + protected JobParameters jobParameters = new JobParameters(); public void setJobDao(JobDao jobDao) { this.jobDao = jobDao; @@ -83,7 +83,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour */ protected void onSetUpInTransaction() throws Exception { Job job = new Job("TestJob"); - jobInstance = jobDao.createJobInstance(job.getName(), jobInstanceProperties); + jobInstance = jobDao.createJobInstance(job.getName(), jobParameters); step1 = stepDao.createStep(jobInstance, "TestStep1"); step2 = stepDao.createStep(jobInstance, "TestStep2"); jobExecution = new JobExecution(step2.getJobInstance()); @@ -127,7 +127,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour public void testFindStepsNotSaved(){ //no steps are saved for given id, empty list should be returned - List steps = stepDao.findSteps(new JobInstance(new Long(38922), jobInstanceProperties)); + List steps = stepDao.findSteps(new JobInstance(new Long(38922), jobParameters)); assertEquals(steps.size(), 0); } 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 ad42f7b91..1676fc771 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 @@ -21,7 +21,7 @@ import java.util.List; import junit.framework.TestCase; import org.springframework.batch.core.domain.JobInstance; -import org.springframework.batch.core.domain.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; @@ -67,7 +67,7 @@ public class JdbcJobDaoQueryTests extends TestCase { return 1; } }); - sqlDao.save(new JobInstance(new Long(11), new JobInstanceProperties()).createJobExecution()); + sqlDao.save(new JobInstance(new Long(11), new JobParameters()).createJobExecution()); assertEquals(1, list.size()); String query = (String) list.get(0); assertTrue("Query did not contain FOO_:" + query, query.indexOf("FOO_") >= 0); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcStepDaoPrefixTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcStepDaoPrefixTests.java index 2149f4b5e..c89fd880a 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcStepDaoPrefixTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/JdbcStepDaoPrefixTests.java @@ -8,7 +8,7 @@ import org.easymock.MockControl; import org.springframework.batch.core.domain.BatchStatus; 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.domain.JobParameters; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.dao.DataAccessException; @@ -31,7 +31,7 @@ public class JdbcStepDaoPrefixTests extends TestCase { MockJdbcTemplate jdbcTemplate = new MockJdbcTemplate(); - JobInstance job = new JobInstance(new Long(1), new JobInstanceProperties()); + JobInstance job = new JobInstance(new Long(1), new JobParameters()); StepInstance step = new StepInstance(job, "foo", new Long(1)); StepExecution stepExecution = new StepExecution(step, new JobExecution(job), null); @@ -97,7 +97,7 @@ public class JdbcStepDaoPrefixTests extends TestCase { public void testModifiedFindSteps(){ stepDao.setTablePrefix("FOO_"); - stepDao.findSteps(new JobInstance(new Long(1), new JobInstanceProperties())); + stepDao.findSteps(new JobInstance(new Long(1), new JobParameters())); assertTrue(jdbcTemplate.getSqlStatement().indexOf("FOO_STEP") != -1); } @@ -128,7 +128,7 @@ public class JdbcStepDaoPrefixTests extends TestCase { } public void testDefaultFindSteps(){ - stepDao.findSteps(new JobInstance(new Long(1), new JobInstanceProperties())); + stepDao.findSteps(new JobInstance(new Long(1), new JobParameters())); assertTrue(jdbcTemplate.getSqlStatement().indexOf("BATCH_STEP") != -1); } 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 94150b07e..35d6d3b50 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 @@ -22,52 +22,52 @@ 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.domain.JobParameters; public class MapJobDaoTests extends TestCase { MapJobDao dao = new MapJobDao(); - JobInstanceProperties jobInstanceProperties = new JobInstanceProperties(); + JobParameters jobParameters = new JobParameters(); protected void setUp() throws Exception { MapJobDao.clear(); } public void testCreateAndRetrieveSingle() throws Exception { - JobInstance job = dao.createJobInstance("foo", jobInstanceProperties); - List result = dao.findJobInstances("foo", jobInstanceProperties); + JobInstance job = dao.createJobInstance("foo", jobParameters); + List result = dao.findJobInstances("foo", jobParameters); assertTrue(result.contains(job)); } public void testCreateAndRetrieveMultiple() throws Exception { - JobInstance job = dao.createJobInstance("foo", jobInstanceProperties); - job = dao.createJobInstance("bar", jobInstanceProperties); - List result = dao.findJobInstances("bar", jobInstanceProperties); + JobInstance job = dao.createJobInstance("foo", jobParameters); + job = dao.createJobInstance("bar", jobParameters); + List result = dao.findJobInstances("bar", jobParameters); assertEquals(1, result.size()); assertTrue(result.contains(job)); } public void testNoExecutionsForNewJob() throws Exception { - JobInstance job = dao.createJobInstance("foo", jobInstanceProperties); + JobInstance job = dao.createJobInstance("foo", jobParameters); assertEquals(0, dao.getJobExecutionCount(job.getId())); } public void testSaveExecutionUpdatesId() throws Exception { - JobInstance job = dao.createJobInstance("foo", jobInstanceProperties); + JobInstance job = dao.createJobInstance("foo", jobParameters); JobExecution execution = new JobExecution(job); assertNull(execution.getId()); dao.save(execution); assertNotNull(execution.getId()); } public void testCorrectExecutionCountForExistingJob() throws Exception { - JobInstance job = dao.createJobInstance("foo", jobInstanceProperties); + JobInstance job = dao.createJobInstance("foo", jobParameters); dao.save(new JobExecution(job)); assertEquals(1, dao.getJobExecutionCount(job.getId())); } public void testMultipleExecutionsPerExisting() throws Exception { - JobInstance job = dao.createJobInstance("foo", jobInstanceProperties); + JobInstance job = dao.createJobInstance("foo", jobParameters); dao.save(new JobExecution(job)); Thread.sleep(50L); // Hack, hack, hackety, hack - job executions are not unique if created too close together! dao.save(new JobExecution(job)); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java index 8d3fcba5c..0b46d89fa 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java @@ -23,7 +23,7 @@ import junit.framework.TestCase; import org.springframework.batch.core.domain.BatchStatus; import org.springframework.batch.core.domain.JobInstance; -import org.springframework.batch.core.domain.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.execution.repository.dao.MapStepDao; @@ -41,7 +41,7 @@ public class MapStepDaoTests extends TestCase { protected void setUp() throws Exception { MapStepDao.clear(); - job = new JobInstance(new Long(jobId++), new JobInstanceProperties()); + job = new JobInstance(new Long(jobId++), new JobParameters()); step = dao.createStep(job, "foo"); } @@ -75,12 +75,12 @@ public class MapStepDaoTests extends TestCase { } public void testFindWithEmptyResults() throws Exception { - List result = dao.findSteps(new JobInstance(new Long(22), new JobInstanceProperties())); + List result = dao.findSteps(new JobInstance(new Long(22), new JobParameters())); assertEquals(0, result.size()); } public void testFindSingleWithEmptyResults() throws Exception { - StepInstance result = dao.findStep(new JobInstance(new Long(22), new JobInstanceProperties()), "bar"); + StepInstance result = dao.findStep(new JobInstance(new Long(22), new JobParameters()), "bar"); assertEquals(null, result); } 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 ff7408c8a..bf039d89f 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 @@ -24,7 +24,7 @@ import junit.framework.TestCase; 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.domain.JobParameters; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.execution.scope.SimpleStepContext; @@ -64,7 +64,7 @@ public class BatchResourceFactoryBeanTests extends TestCase { resourceFactory.setRootDirectory(rootDir); SimpleStepContext context = new SimpleStepContext(); - jobInstance = new JobInstance(new Long(0), new JobInstanceProperties()); + jobInstance = new JobInstance(new Long(0), new JobParameters()); jobInstance.setJob(new Job("testJob")); JobExecution jobExecution = new JobExecution(jobInstance); StepInstance step = new StepInstance(jobInstance, "bar"); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/runtime/DefaultJobIdentifierFactoryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/runtime/DefaultJobIdentifierFactoryTests.java deleted file mode 100644 index 07dd5ed6b..000000000 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/runtime/DefaultJobIdentifierFactoryTests.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.springframework.batch.execution.runtime; - -import junit.framework.TestCase; - -import org.springframework.batch.core.domain.JobIdentifier; - -public class DefaultJobIdentifierFactoryTests extends TestCase { - - public void testGetJobIdentifier() { - JobIdentifier jobIdentifier = new ScheduledJobIdentifierFactory().getJobIdentifier("foo"); - assertEquals("foo", jobIdentifier.getName()); - } - -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifierFactoryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifierFactoryTests.java deleted file mode 100644 index dddb04595..000000000 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/runtime/ScheduledJobIdentifierFactoryTests.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.springframework.batch.execution.runtime; - -import junit.framework.TestCase; - -import org.springframework.batch.core.domain.JobIdentifier; - -public class ScheduledJobIdentifierFactoryTests extends TestCase { - - public void testGetJobIdentifier() { - JobIdentifier jobIdentifier = new DefaultJobIdentifierFactory().getJobIdentifier("foo"); - assertEquals("foo", jobIdentifier.getName()); - } - -} 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 898b1e751..5b45c4173 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 @@ -25,7 +25,7 @@ import junit.framework.TestCase; 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.domain.JobParameters; import org.springframework.batch.core.domain.StepContribution; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; @@ -105,7 +105,7 @@ public class DefaultStepExecutorTests extends TestCase { template.setCompletionPolicy(new SimpleCompletionPolicy(1)); stepExecutor.setChunkOperations(template); - jobInstance = new JobInstance(new Long(0), new JobInstanceProperties()); + jobInstance = new JobInstance(new Long(0), new JobParameters()); jobInstance.setJob(new Job("FOO")); } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/JobRepositorySupport.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/JobRepositorySupport.java index b07bba05e..437d50d6a 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/JobRepositorySupport.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/JobRepositorySupport.java @@ -18,7 +18,7 @@ package org.springframework.batch.execution.step.simple; 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.domain.JobParameters; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.core.repository.JobRepository; @@ -32,7 +32,7 @@ public class JobRepositorySupport implements JobRepository { /* (non-Javadoc) * @see org.springframework.batch.container.common.repository.JobRepository#findOrCreateJob(org.springframework.batch.container.common.domain.JobConfiguration) */ - public JobExecution createJobExecution(Job jobConfiguration, JobInstanceProperties jobInstanceProperties) { + public JobExecution createJobExecution(Job jobConfiguration, JobParameters jobParameters) { return null; } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorFactoryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorFactoryTests.java index f19910ae6..930a770e7 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorFactoryTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorFactoryTests.java @@ -22,7 +22,7 @@ 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.domain.JobParameters; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.core.domain.StepSupport; @@ -66,7 +66,7 @@ public class SimpleStepExecutorFactoryTests extends TestCase { SimpleStepExecutor executor = (SimpleStepExecutor) factory .getExecutor(configuration); StepExecution stepExecution = new StepExecution(new StepInstance( - new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobInstanceProperties()), + new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobParameters()), new Long(12))); try { executor.process(configuration, stepExecution); @@ -93,7 +93,7 @@ public class SimpleStepExecutorFactoryTests extends TestCase { SimpleStepExecutor executor = (SimpleStepExecutor) factory .getExecutor(configuration); StepExecution stepExecution = new StepExecution(new StepInstance( - new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobInstanceProperties()), + new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobParameters()), new Long(12))); try { executor.process(configuration, stepExecution); @@ -131,7 +131,7 @@ public class SimpleStepExecutorFactoryTests extends TestCase { SimpleStepExecutor executor = (SimpleStepExecutor) factory .getExecutor(configuration); StepExecution stepExecution = new StepExecution(new StepInstance( - new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobInstanceProperties()), + new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobParameters()), new Long(12))); executor.process(configuration, stepExecution); assertEquals(2, list.size()); 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 619aebfd6..3cfd810ad 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 @@ -24,7 +24,7 @@ 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.JobInstance; -import org.springframework.batch.core.domain.JobInstanceProperties; +import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.core.domain.StepSupport; @@ -63,7 +63,7 @@ public class StepExecutorInterruptionTests extends TestCase { stepConfiguration = new SimpleStep(); jobConfiguration.addStep(stepConfiguration); jobConfiguration.setBeanName("testJob"); - job = jobRepository.createJobExecution(jobConfiguration, new JobInstanceProperties()).getJobInstance(); + job = jobRepository.createJobExecution(jobConfiguration, new JobParameters()).getJobInstance(); executor = new SimpleStepExecutor(); } @@ -73,7 +73,7 @@ public class StepExecutorInterruptionTests extends TestCase { List steps = job.getStepInstances(); final StepInstance step = (StepInstance) steps.get(0); - JobExecution jobExecutionContext = new JobExecution(new JobInstance(new Long(0L), new JobInstanceProperties())); + JobExecution jobExecutionContext = new JobExecution(new JobInstance(new Long(0L), new JobParameters())); final StepExecution stepExecution = new StepExecution(step, jobExecutionContext); stepConfiguration.setTasklet(new Tasklet() { public ExitStatus execute() throws Exception { 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 fdaf0e92c..80341cd28 100644 --- a/spring-batch-execution/src/test/resources/simple-container-definition.xml +++ b/spring-batch-execution/src/test/resources/simple-container-definition.xml @@ -72,12 +72,6 @@ class="org.springframework.batch.execution.repository.dao.MapStepDao" /> -