OPEN - issue BATCH-304: BatchCommandLineLauncher simplified and rename
http://jira.springframework.org/browse/BATCH-304 First part of JobParameters and retirement of JobIdentifier. Tests are borken, but not by these changes so I figure I have to get them in!
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
@@ -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 + "]";
|
||||
}
|
||||
|
||||
|
||||
@@ -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())){
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
@@ -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.
|
||||
//
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
*
|
||||
* <pre>
|
||||
* schedule.date(date)=2007/12/11
|
||||
* department.id(long)=2345
|
||||
* </pre>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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).
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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"));
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -72,12 +72,6 @@
|
||||
class="org.springframework.batch.execution.repository.dao.MapStepDao" />
|
||||
<!-- init-method="clear"/-->
|
||||
|
||||
<bean id="jobRuntimeInformationFactory"
|
||||
class="org.springframework.batch.execution.runtime.ScheduledJobIdentifierFactory">
|
||||
<property name="jobKey" value="TestStream" />
|
||||
<property name="scheduleDate" value="20070505" />
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.batch.execution.bootstrap.support.SimpleJvmExitCodeMapper" />
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
<property name="customEditors">
|
||||
<map>
|
||||
<entry key="org.springframework.batch.core.domain.JobIdentifier">
|
||||
<bean class="org.springframework.batch.execution.bootstrap.support.JobIdentifierPropertyEditor"/>
|
||||
<bean class="org.springframework.batch.execution.bootstrap.support.JobParametersPropertyEditor"/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
|
||||
@@ -90,12 +90,6 @@
|
||||
<bean id="mapStepDao" lazy-init="true"
|
||||
class="org.springframework.batch.execution.repository.dao.MapStepDao"/>
|
||||
|
||||
<bean id="jobRuntimeInformationFactory"
|
||||
class="org.springframework.batch.execution.runtime.ScheduledJobIdentifierFactory">
|
||||
<property name="jobKey" value="TestStream" />
|
||||
<property name="scheduleDate" value="20070505" />
|
||||
</bean>
|
||||
|
||||
<bean id="jdbcTemplate"
|
||||
class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
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.execution.launch.JobLauncher;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -81,6 +81,6 @@ public abstract class AbstractBatchLauncherTests extends
|
||||
*
|
||||
*/
|
||||
public void testLaunchJob() throws Exception {
|
||||
launcher.run(job, new JobInstanceProperties());
|
||||
launcher.run(job, new JobParameters());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public abstract class AbstractCustomerCreditIncreaseTests extends AbstractValida
|
||||
});
|
||||
}
|
||||
});
|
||||
System.err.println(creditsBeforeUpdate);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,6 +76,8 @@ public abstract class AbstractCustomerCreditIncreaseTests extends AbstractValida
|
||||
|
||||
final List matches = new ArrayList();
|
||||
|
||||
System.err.println(jdbcTemplate.queryForList(ALL_CUSTOMERS));
|
||||
|
||||
new TransactionTemplate(transactionManager).execute(new TransactionCallback() {
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
jdbcTemplate.query(ALL_CUSTOMERS, new RowMapper() {
|
||||
|
||||
@@ -30,9 +30,9 @@ import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
public abstract class AbstractValidatingBatchLauncherTests extends AbstractBatchLauncherTests {
|
||||
|
||||
public void testLaunchJob() throws Exception {
|
||||
// validatePreConditions();
|
||||
validatePreConditions();
|
||||
super.testLaunchJob();
|
||||
// validatePostConditions();
|
||||
validatePostConditions();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.batch.sample;
|
||||
|
||||
import org.springframework.batch.core.domain.BatchStatus;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
|
||||
/**
|
||||
* Functional test for graceful shutdown. A batch container is started in a new thread,
|
||||
@@ -35,9 +35,9 @@ public class GracefulShutdownFunctionalTest extends AbstractBatchLauncherTests {
|
||||
|
||||
public void testLaunchJob() throws Exception {
|
||||
|
||||
final JobInstanceProperties jobInstanceProperties = new JobInstanceProperties();
|
||||
final JobParameters jobParameters = new JobParameters();
|
||||
|
||||
JobExecution jobExecution = launcher.run(getJob(), jobInstanceProperties);
|
||||
JobExecution jobExecution = launcher.run(getJob(), jobParameters);
|
||||
|
||||
Thread.sleep(200);
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@ public class HibernateFailureJobFunctionalTests extends
|
||||
* @see org.springframework.batch.sample.AbstractValidatingBatchLauncherTests#testLaunchJob()
|
||||
*/
|
||||
public void testLaunchJob() throws Exception {
|
||||
validatePreConditions();
|
||||
writer.setFailOnFlush(2);
|
||||
|
||||
int before = jdbcTemplate.queryForInt("SELECT COUNT(*) from CUSTOMER");
|
||||
@@ -65,7 +64,6 @@ public class HibernateFailureJobFunctionalTests extends
|
||||
assertEquals(1, writer.getErrors().size());
|
||||
throw e;
|
||||
}
|
||||
validatePostConditions();
|
||||
int after = jdbcTemplate.queryForInt("SELECT COUNT(*) from CUSTOMER");
|
||||
assertEquals(before, after);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.jdbc.core.JdbcOperations;
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public class RestartFunctionalTests extends AbstractBatchLauncherTests {
|
||||
|
||||
// load the application context and launch the job
|
||||
private void runJob() throws Exception {
|
||||
launcher.run(getJob(), new JobInstanceProperties());
|
||||
launcher.run(getJob(), new JobParameters());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,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.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.execution.runtime.ScheduledJobIdentifier;
|
||||
@@ -77,7 +77,7 @@ public class JdbcJobRepositoryTests extends AbstractTransactionalDataSourceSprin
|
||||
public void testFindOrCreateJob() throws Exception {
|
||||
jobConfiguration.setName("foo");
|
||||
int before = getJdbcTemplate().queryForInt("SELECT COUNT(*) FROM BATCH_JOB_INSTANCE");
|
||||
JobExecution execution = repository.createJobExecution(jobConfiguration, new JobInstanceProperties());
|
||||
JobExecution execution = repository.createJobExecution(jobConfiguration, new JobParameters());
|
||||
int after = getJdbcTemplate().queryForInt("SELECT COUNT(*) FROM BATCH_JOB_INSTANCE");
|
||||
assertEquals(before + 1, after);
|
||||
assertNotNull(execution.getId());
|
||||
@@ -122,7 +122,7 @@ public class JdbcJobRepositoryTests extends AbstractTransactionalDataSourceSprin
|
||||
|
||||
jobConfiguration.setName("spam");
|
||||
|
||||
JobExecution execution = repository.createJobExecution(jobConfiguration, new JobInstanceProperties());
|
||||
JobExecution execution = repository.createJobExecution(jobConfiguration, new JobParameters());
|
||||
cacheJobIds(execution);
|
||||
execution.setEndTime(new Timestamp(System.currentTimeMillis()));
|
||||
repository.saveOrUpdate(execution);
|
||||
@@ -172,7 +172,7 @@ public class JdbcJobRepositoryTests extends AbstractTransactionalDataSourceSprin
|
||||
new TransactionTemplate(transactionManager).execute(new TransactionCallback() {
|
||||
public Object doInTransaction(org.springframework.transaction.TransactionStatus status) {
|
||||
try {
|
||||
JobExecution execution = repository.createJobExecution(jobConfiguration, new JobInstanceProperties());
|
||||
JobExecution execution = repository.createJobExecution(jobConfiguration, new JobParameters());
|
||||
cacheJobIds(execution);
|
||||
list.add(execution);
|
||||
Thread.sleep(1000);
|
||||
@@ -192,7 +192,7 @@ public class JdbcJobRepositoryTests extends AbstractTransactionalDataSourceSprin
|
||||
}).start();
|
||||
|
||||
Thread.sleep(400);
|
||||
JobExecution execution = repository.createJobExecution(jobConfiguration, new JobInstanceProperties());
|
||||
JobExecution execution = repository.createJobExecution(jobConfiguration, new JobParameters());
|
||||
cacheJobIds(execution);
|
||||
|
||||
int count = 0;
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.springframework.batch.sample.item.processor;
|
||||
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;
|
||||
@@ -30,7 +30,7 @@ public class StagingItemProcessorTests extends
|
||||
.open();
|
||||
stepScopeContext.setStepExecution(new StepExecution(new StepInstance(
|
||||
new Long(11)), new JobExecution(new JobInstance(new Long(12),
|
||||
new JobInstanceProperties(), new Job("job")))));
|
||||
new JobParameters(), new Job("job")))));
|
||||
super.prepareTestInstance();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.springframework.batch.sample.item.reader;
|
||||
|
||||
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;
|
||||
@@ -40,7 +40,7 @@ public class StagingItemReaderTests extends
|
||||
jobId = new Long(11);
|
||||
stepScopeContext.setStepExecution(new StepExecution(new StepInstance(
|
||||
new Long(12)), new JobExecution(new JobInstance(jobId,
|
||||
new JobInstanceProperties()))));
|
||||
new JobParameters()))));
|
||||
RepeatSynchronizationManager.register(new RepeatContextSupport(null));
|
||||
super.prepareTestInstance();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user