diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JdbcJobRepositoryTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JdbcJobRepositoryTests.java
index d322cd953..8614b2e4f 100644
--- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JdbcJobRepositoryTests.java
+++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JdbcJobRepositoryTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2008 the original author or authors.
+ * Copyright 2006-2013 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.
@@ -74,22 +74,22 @@ public class JdbcJobRepositoryTests {
public void onSetUpInTransaction() throws Exception {
job = new JobSupport("test-job");
job.setRestartable(true);
- jdbcTemplate.update("DELETE FROM BATCH_STEP_EXECUTION_CONTEXT");
- jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION_CONTEXT");
- jdbcTemplate.update("DELETE FROM BATCH_STEP_EXECUTION");
- jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION");
- jdbcTemplate.update("DELETE FROM BATCH_JOB_PARAMS");
- jdbcTemplate.update("DELETE FROM BATCH_JOB_INSTANCE");
+ jdbcTemplate.update("DELETE FROM BATCH_STEP_EXECUTION_CONTEXT");
+ jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION_CONTEXT");
+ jdbcTemplate.update("DELETE FROM BATCH_STEP_EXECUTION");
+ jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION_PARAMS");
+ jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION");
+ jdbcTemplate.update("DELETE FROM BATCH_JOB_INSTANCE");
}
@After
public void onTearDownAfterTransaction() throws Exception {
for (Long id : jobExecutionIds) {
- jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION_CONTEXT where JOB_EXECUTION_ID=?", id);
- jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION where JOB_EXECUTION_ID=?", id);
+ jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION_CONTEXT where JOB_EXECUTION_ID=?", id);
+ jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION where JOB_EXECUTION_ID=?", id);
}
for (Long id : jobIds) {
- jdbcTemplate.update("DELETE FROM BATCH_JOB_INSTANCE where JOB_INSTANCE_ID=?", id);
+ jdbcTemplate.update("DELETE FROM BATCH_JOB_INSTANCE where JOB_INSTANCE_ID=?", id);
}
for (Long id : jobIds) {
int count = jdbcTemplate.queryForInt(
@@ -188,8 +188,9 @@ public class JdbcJobRepositoryTests {
}
private void cacheJobIds(JobExecution execution) {
- if (execution == null)
+ if (execution == null) {
return;
+ }
jobExecutionIds.add(execution.getId());
jobIds.add(execution.getJobId());
}
diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/StepExecutionSerializationUtilsTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/StepExecutionSerializationUtilsTests.java
index 2c9d7de69..c2df1a748 100644
--- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/StepExecutionSerializationUtilsTests.java
+++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/StepExecutionSerializationUtilsTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2010 the original author or authors.
+ * Copyright 2006-2013 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.
@@ -34,14 +34,14 @@ import org.springframework.batch.support.SerializationUtils;
/**
* @author Dave Syer
- *
+ * @author Michael Minella
*/
public class StepExecutionSerializationUtilsTests {
@Test
public void testCycle() throws Exception {
StepExecution stepExecution = new StepExecution("step", new JobExecution(new JobInstance(123L,
- new JobParameters(), "job"), 321L), 11L);
+ "job"), 321L, new JobParameters()), 11L);
stepExecution.getExecutionContext().put("foo.bar.spam", 123);
StepExecution result = getCopy(stepExecution);
assertEquals(stepExecution, result);
@@ -49,7 +49,7 @@ public class StepExecutionSerializationUtilsTests {
@Test
public void testMultipleCycles() throws Throwable {
-
+
int count = 0;
int repeats = 100;
int threads = 10;
@@ -58,7 +58,7 @@ public class StepExecutionSerializationUtilsTests {
CompletionService completionService = new ExecutorCompletionService(executor);
for (int i = 0; i < repeats; i++) {
- final JobExecution jobExecution = new JobExecution(new JobInstance(123L, new JobParameters(), "job"), 321L);
+ final JobExecution jobExecution = new JobExecution(new JobInstance(123L, "job"), 321L, new JobParameters());
for (int j = 0; j < threads; j++) {
completionService.submit(new Callable() {
public StepExecution call() throws Exception {
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/DefaultJobKeyGenerator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/DefaultJobKeyGenerator.java
new file mode 100644
index 000000000..410037d26
--- /dev/null
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/DefaultJobKeyGenerator.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2006-2013 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.core;
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Default implementation of the {@link JobKeyGenerator} interface.
+ * This implementation provides a single hash value based on the JobParameters
+ * passed in. Only identifying parameters (per {@link JobParameter#isIdentifying()})
+ * are used in the calculation of the key.
+ *
+ * @author Michael Minella
+ * @since 2.2
+ */
+public class DefaultJobKeyGenerator implements JobKeyGenerator {
+
+ /**
+ * Generates the job key to be used based on the {@link JobParameters} instance
+ * provided.
+ */
+ @Override
+ public String generateKey(JobParameters source) {
+
+ Map props = source.getParameters();
+ StringBuffer stringBuffer = new StringBuffer();
+ List keys = new ArrayList(props.keySet());
+ Collections.sort(keys);
+ for (String key : keys) {
+ JobParameter jobParameter = props.get(key);
+ if(jobParameter.isIdentifying()) {
+ String value = jobParameter.getValue()==null ? "" : jobParameter.toString();
+ stringBuffer.append(key + "=" + value + ";");
+ }
+ }
+
+ MessageDigest digest;
+ try {
+ digest = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException e) {
+ throw new IllegalStateException(
+ "MD5 algorithm not available. Fatal (should be in the JDK).");
+ }
+
+ try {
+ byte[] bytes = digest.digest(stringBuffer.toString().getBytes(
+ "UTF-8"));
+ return String.format("%032x", new BigInteger(1, bytes));
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalStateException(
+ "UTF-8 encoding not available. Fatal (should be in the JDK).");
+ }
+ }
+}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/ItemWriteListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/ItemWriteListener.java
index cdaa345a5..755ee6659 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/ItemWriteListener.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/ItemWriteListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2008 the original author or authors.
+ * Copyright 2006-2013 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.
@@ -17,30 +17,31 @@ package org.springframework.batch.core;
import java.util.List;
+import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.item.ItemWriter;
/**
* Listener interface for the writing of items. Implementations
* of this interface will be notified before, after, and in case
* of any exception thrown while writing a list of items.
- *
+ *
* @author Lucas Ward
- *
+ *
*/
public interface ItemWriteListener extends StepListener {
/**
* Called before {@link ItemWriter#write(java.util.List)}
- *
+ *
* @param items to be written
*/
void beforeWrite(List extends S> items);
/**
- * Called after {@link ItemWriter#write(java.util.List)} This will be
- * called before any transaction is committed, and before
- * {@link ChunkListener#afterChunk()}
- *
+ * Called after {@link ItemWriter#write(java.util.List)} This will be
+ * called before any transaction is committed, and before
+ * {@link ChunkListener#afterChunk(ChunkContext)}
+ *
* @param items written items
*/
void afterWrite(List extends S> items);
@@ -50,7 +51,7 @@ public interface ItemWriteListener extends StepListener {
* transaction, but the transaction will normally be rolled back. There is
* no way to identify from this callback which of the items (if any) caused
* the error.
- *
+ *
* @param exception thrown from {@link ItemWriter}
* @param items attempted to be written.
*/
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java
index 9d7b50a20..ba50b838f 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java
@@ -34,11 +34,14 @@ import org.springframework.batch.item.ExecutionContext;
* Batch domain object representing the execution of a job.
*
* @author Lucas Ward
+ * @author Michael Minella
*
*/
@SuppressWarnings("serial")
public class JobExecution extends Entity {
+ private final JobParameters jobParameters;
+
private JobInstance jobInstance;
private volatile Collection stepExecutions = new CopyOnWriteArraySet();
@@ -61,13 +64,14 @@ public class JobExecution extends Entity {
/**
* Because a JobExecution isn't valid unless the job is set, this
- * constructor is the only valid one from a modelling point of view.
+ * constructor is the only valid one from a modeling point of view.
*
* @param job the job of which this execution is a part
*/
- public JobExecution(JobInstance job, Long id) {
+ public JobExecution(JobInstance job, Long id, JobParameters jobParameters) {
super(id);
this.jobInstance = job;
+ this.jobParameters = jobParameters == null ? new JobParameters() : jobParameters;
}
/**
@@ -75,12 +79,20 @@ public class JobExecution extends Entity {
*
* @param job the enclosing {@link JobInstance}
*/
- public JobExecution(JobInstance job) {
- this(job, null);
+ public JobExecution(JobInstance job, JobParameters jobParameters) {
+ this(job, null, jobParameters);
+ }
+
+ public JobExecution(Long id, JobParameters jobParameters) {
+ this(null, id, jobParameters);
}
public JobExecution(Long id) {
- super(id);
+ this(null, id, null);
+ }
+
+ public JobParameters getJobParameters() {
+ return this.jobParameters;
}
public Date getEndTime() {
@@ -319,8 +331,8 @@ public class JobExecution extends Entity {
@Override
public String toString() {
return super.toString()
- + String.format(", startTime=%s, endTime=%s, lastUpdated=%s, status=%s, exitStatus=%s, job=[%s]",
- startTime, endTime, lastUpdated, status, exitStatus, jobInstance);
+ + String.format(", startTime=%s, endTime=%s, lastUpdated=%s, status=%s, exitStatus=%s, job=[%s], jobParameters=[%s]",
+ startTime, endTime, lastUpdated, status, exitStatus, jobInstance, jobParameters);
}
/**
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java
index a1320dcda..dfe83d5fe 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java
@@ -19,8 +19,7 @@ package org.springframework.batch.core;
import org.springframework.util.Assert;
/**
- * Batch domain object representing a uniquely identifiable job run - it's
- * identity is given by the pair {@link Job} and {@link JobParameters}.
+ * Batch domain object representing a uniquely identifiable job run.
* JobInstance can be restarted multiple times in case of execution failure and
* it's lifecycle ends with first successful execution.
*
@@ -35,30 +34,20 @@ import org.springframework.util.Assert;
* @author Lucas Ward
* @author Dave Syer
* @author Robert Kasanicky
+ * @author Michael Minella
*
*/
-@SuppressWarnings("unchecked")
+@SuppressWarnings("serial")
public class JobInstance extends Entity {
- private final JobParameters jobParameters;
-
private final String jobName;
- public JobInstance(Long id, JobParameters jobParameters, String jobName) {
+ public JobInstance(Long id, String jobName) {
super(id);
Assert.hasLength(jobName);
- // Assert.hasLength(job.getName());
- this.jobParameters = jobParameters == null ? new JobParameters() : jobParameters;
this.jobName = jobName;
}
- /**
- * @return {@link JobParameters}
- */
- public JobParameters getJobParameters() {
- return jobParameters;
- }
-
/**
* @return the job name. (Equivalent to getJob().getName())
*/
@@ -68,7 +57,7 @@ public class JobInstance extends Entity {
@Override
public String toString() {
- return super.toString() + ", JobParameters=[" + jobParameters + "]" + ", Job=[" + jobName + "]";
+ return super.toString() + ", Job=[" + jobName + "]";
}
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobKeyGenerator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobKeyGenerator.java
new file mode 100644
index 000000000..54e0ba200
--- /dev/null
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobKeyGenerator.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2013-2013 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.core;
+
+/**
+ * Strategy interface for the generation of the key used in identifying
+ * unique {@link JobInstance}.
+ *
+ * @author Michael Minella
+ *
+ * @param The type of the source data used to calculate the key.
+ * @since 2.2
+ */
+public interface JobKeyGenerator {
+
+ /**
+ * Method to generate the unique key used to identify a job instance.
+ *
+ * @param source Source information used to generate the key
+ *
+ * @return a unique string identifying the job based on the information
+ * supplied
+ */
+ String generateKey(T source);
+}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java
index 6fc74b992..893887674 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java
@@ -21,10 +21,13 @@ import java.util.Date;
/**
* Domain representation of a parameter to a batch job. Only the following types
- * can be parameters: String, Long, Date, and Double.
+ * can be parameters: String, Long, Date, and Double. The identifying flag is
+ * used to indicate if the parameter is to be used as part of the identification of
+ * a job instance.
*
* @author Lucas Ward
* @author Dave Syer
+ * @author Michael Minella
* @since 2.0
*
*/
@@ -35,12 +38,58 @@ public class JobParameter implements Serializable {
private final ParameterType parameterType;
+ private final boolean identifying;
+
+ /**
+ * Construct a new JobParameter as a String.
+ */
+ public JobParameter(String parameter, boolean identifying) {
+ this.parameter = parameter;
+ parameterType = ParameterType.STRING;
+ this.identifying = identifying;
+ }
+
+ /**
+ * Construct a new JobParameter as a Long.
+ *
+ * @param parameter
+ */
+ public JobParameter(Long parameter, boolean identifying) {
+ this.parameter = parameter;
+ parameterType = ParameterType.LONG;
+ this.identifying = identifying;
+ }
+
+ /**
+ * Construct a new JobParameter as a Date.
+ *
+ * @param parameter
+ */
+ public JobParameter(Date parameter, boolean identifying) {
+ this.parameter = parameter;
+ parameterType = ParameterType.DATE;
+ this.identifying = identifying;
+ }
+
+ /**
+ * Construct a new JobParameter as a Double.
+ *
+ * @param parameter
+ */
+ public JobParameter(Double parameter, boolean identifying) {
+ this.parameter = parameter;
+ parameterType = ParameterType.DOUBLE;
+ this.identifying = identifying;
+ }
+
+
/**
* Construct a new JobParameter as a String.
*/
public JobParameter(String parameter) {
this.parameter = parameter;
parameterType = ParameterType.STRING;
+ this.identifying = true;
}
/**
@@ -51,6 +100,7 @@ public class JobParameter implements Serializable {
public JobParameter(Long parameter) {
this.parameter = parameter;
parameterType = ParameterType.LONG;
+ this.identifying = true;
}
/**
@@ -61,6 +111,7 @@ public class JobParameter implements Serializable {
public JobParameter(Date parameter) {
this.parameter = parameter;
parameterType = ParameterType.DATE;
+ this.identifying = true;
}
/**
@@ -71,6 +122,11 @@ public class JobParameter implements Serializable {
public JobParameter(Double parameter) {
this.parameter = parameter;
parameterType = ParameterType.DOUBLE;
+ this.identifying = true;
+ }
+
+ public boolean isIdentifying() {
+ return identifying;
}
/**
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobParametersBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobParametersBuilder.java
index 136701b5b..e4e5de7a5 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobParametersBuilder.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobParametersBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2007 the original author or authors.
+ * Copyright 2006-2013 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.
@@ -28,9 +28,13 @@ import org.springframework.util.Assert;
* to ensure typesafety. Once created, it can be used in the
* same was a java.lang.StringBuilder (except, order is irrelevant), by adding
* various parameter types and creating a valid {@link JobParameters} once
- * finished.
- *
+ * finished.
+ *
+ * Using the identifying flag indicates if the parameter will be used
+ * in the identification of a JobInstance. That flag defaults to true.
+ *
* @author Lucas Ward
+ * @author Michael Minella
* @since 1.0
* @see JobParameters
* @see JobParameter
@@ -55,57 +59,109 @@ public class JobParametersBuilder {
}
/**
- * Add a new String parameter for the given key.
- *
+ * Add a new identifying String parameter for the given key.
+ *
* @param key - parameter accessor.
* @param parameter - runtime parameter
- * @return a refernece to this object.
+ * @return a reference to this object.
*/
public JobParametersBuilder addString(String key, String parameter) {
- parameterMap.put(key, new JobParameter(parameter));
+ parameterMap.put(key, new JobParameter(parameter, true));
+ return this;
+ }
+
+ /**
+ * Add a new String parameter for the given key.
+ *
+ * @param key - parameter accessor.
+ * @param parameter - runtime parameter
+ * @param identifying - indicates if the parameter is used as part of identifying a job instance
+ * @return a reference to this object.
+ */
+ public JobParametersBuilder addString(String key, String parameter, boolean identifying) {
+ parameterMap.put(key, new JobParameter(parameter, identifying));
+ return this;
+ }
+
+ /**
+ * Add a new identifying {@link Date} parameter for the given key.
+ *
+ * @param key - parameter accessor.
+ * @param parameter - runtime parameter
+ * @return a reference to this object.
+ */
+ public JobParametersBuilder addDate(String key, Date parameter) {
+ parameterMap.put(key, new JobParameter(parameter, true));
return this;
}
/**
* Add a new {@link Date} parameter for the given key.
- *
+ *
* @param key - parameter accessor.
* @param parameter - runtime parameter
- * @return a refernece to this object.
+ * @param identifying - indicates if the parameter is used as part of identifying a job instance
+ * @return a reference to this object.
*/
- public JobParametersBuilder addDate(String key, Date parameter) {
- parameterMap.put(key, new JobParameter(parameter));
+ public JobParametersBuilder addDate(String key, Date parameter, boolean identifying) {
+ parameterMap.put(key, new JobParameter(parameter, identifying));
return this;
}
/**
- * Add a new Long parameter for the given key.
- *
+ * Add a new identifying Long parameter for the given key.
+ *
* @param key - parameter accessor.
* @param parameter - runtime parameter
* @return a reference to this object.
*/
public JobParametersBuilder addLong(String key, Long parameter) {
- parameterMap.put(key, new JobParameter(parameter));
+ parameterMap.put(key, new JobParameter(parameter, true));
return this;
}
-
+
/**
- * Add a new Double parameter for the given key.
- *
+ * Add a new Long parameter for the given key.
+ *
+ * @param key - parameter accessor.
+ * @param parameter - runtime parameter
+ * @param identifying - indicates if the parameter is used as part of identifying a job instance
+ * @return a reference to this object.
+ */
+ public JobParametersBuilder addLong(String key, Long parameter, boolean identifying) {
+ parameterMap.put(key, new JobParameter(parameter, identifying));
+ return this;
+ }
+
+ /**
+ * Add a new identifying Double parameter for the given key.
+ *
* @param key - parameter accessor.
* @param parameter - runtime parameter
* @return a reference to this object.
*/
public JobParametersBuilder addDouble(String key, Double parameter) {
- parameterMap.put(key, new JobParameter(parameter));
+ parameterMap.put(key, new JobParameter(parameter, true));
+ return this;
+ }
+
+ /**
+ * Add a new Double parameter for the given key.
+ *
+ * @param key - parameter accessor.
+ * @param parameter - runtime parameter
+ * @param identifying - indicates if the parameter is used as part of identifying a job instance
+ * @return a reference to this object.
+ */
+ public JobParametersBuilder addDouble(String key, Double parameter, boolean identifying) {
+ parameterMap.put(key, new JobParameter(parameter, identifying));
return this;
}
/**
* Conversion method that takes the current state of this builder and
* returns it as a JobruntimeParameters object.
- *
+ *
* @return a valid {@link JobParameters} object.
*/
public JobParameters toJobParameters() {
@@ -114,7 +170,7 @@ public class JobParametersBuilder {
/**
* Add a new {@link JobParameter} for the given key.
- *
+ *
* @param key - parameter accessor
* @param jobParameter - runtime parameter
* @return a reference to this object.
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java
index 07b20ffb7..96fa8a4fc 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java
@@ -385,10 +385,10 @@ public class StepExecution extends Entity {
* that is null
*/
public JobParameters getJobParameters() {
- if (jobExecution == null || jobExecution.getJobInstance() == null) {
+ if (jobExecution == null) {
return new JobParameters();
}
- return jobExecution.getJobInstance().getJobParameters();
+ return jobExecution.getJobParameters();
}
/**
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobLoader.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobLoader.java
index be7b270c3..7352ed702 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobLoader.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobLoader.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 the original author or authors.
+ * Copyright 2009-2013 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.
@@ -22,17 +22,17 @@ import org.springframework.batch.core.configuration.DuplicateJobException;
/**
* @author Dave Syer
- *
+ *
* @since 2.1
*/
public interface JobLoader {
/**
* Load an application context and register all the jobs.
- *
+ *
* @param factory a factory for an application context (containing jobs)
* @return a collection of the jobs created
- *
+ *
* @throws DuplicateJobException if a job with the same name was already
* registered
*/
@@ -43,12 +43,9 @@ public interface JobLoader {
* unregistered them if already registered. Implementations should also take
* care to close and clean up the application context previously created if
* possible (either from this factory or from one with the same jobs).
- *
+ *
* @param factory a factory for an application context (containing jobs)
* @return a collection of the jobs created
- *
- * @throws DuplicateJobException if a job with the same name was already
- * registered
*/
Collection reload(ApplicationContextFactory factory);
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java
index 7c1d8c000..8c14839d8 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java
@@ -54,6 +54,7 @@ import org.springframework.util.StringUtils;
* {@link #setNumberFormat(NumberFormat)}).
*
* @author Dave Syer
+ * @author Michael Minella
*
*/
public class DefaultJobParametersConverter implements JobParametersConverter {
@@ -66,6 +67,10 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
private static final String DOUBLE_TYPE = "(double)";
+ private static final String NON_IDENTIFYING_FLAG = "-";
+
+ private static final String IDENTIFYING_FLAG = "+";
+
private static NumberFormat DEFAULT_NUMBER_FORMAT = NumberFormat.getInstance(Locale.US);
private DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
@@ -96,6 +101,14 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
Entry
- *
+ *
*
* With any launch of a batch job within Spring Batch, a Spring context
* containing the {@link Job} and some execution context has to be created. This
@@ -82,7 +82,7 @@ import org.springframework.util.StringUtils;
* exception is thrown by this class, it will be mapped to an integer and
* returned.
*
- *
+ *
*
* Notice a property is available to set the {@link SystemExiter}. This class is
* used to exit from the main method, rather than calling System.exit()
@@ -91,16 +91,16 @@ import org.springframework.util.StringUtils;
* possible to do, however it is a complex solution, much more so than
* strategizing the exiter.
*
- *
+ *
*
* The arguments to this class can be provided on the command line (separated by
* spaces), or through stdin (separated by new line). They are as follows:
*
@@ -116,13 +116,13 @@ import org.springframework.util.StringUtils;
* specified in the form of key=value pairs.
*
*
- *
+ *
*
* If the -next option is used the parameters on the command line
* (if any) are appended to those retrieved from the incrementer, overriding any
* with the same key.
*
- *
+ *
*
* The combined application context must contain only one instance of
* {@link JobLauncher}. The job parameters passed in to the command line will be
@@ -133,14 +133,14 @@ import org.springframework.util.StringUtils;
* application context (if there is one, or a
* {@link DefaultJobParametersConverter} otherwise). Below is an example
* arguments list: "
- *
+ *
*
* Once arguments have been successfully parsed, autowiring will be used to set
* various dependencies. The {@JobLauncher} for example, will be
@@ -152,7 +152,7 @@ import org.springframework.util.StringUtils;
* it will be used, if not the beanFactory will be asked, using the
* jobIdentifier as the bean id.
*
- *
+ *
* @author Dave Syer
* @author Lucas Ward
* @since 1.0
@@ -178,9 +178,11 @@ public class CommandLineJobRunner {
private JobRepository jobRepository;
+ private final static List VALID_OPTS = Arrays.asList(new String [] {"-restart", "-next", "-stop", "-abandon"});
+
/**
* Injection setter for the {@link JobLauncher}.
- *
+ *
* @param launcher the launcher to set
*/
public void setLauncher(JobLauncher launcher) {
@@ -196,7 +198,7 @@ public class CommandLineJobRunner {
/**
* Injection setter for {@link JobExplorer}.
- *
+ *
* @param jobExplorer the {@link JobExplorer} to set
*/
public void setJobExplorer(JobExplorer jobExplorer) {
@@ -205,7 +207,7 @@ public class CommandLineJobRunner {
/**
* Injection setter for the {@link ExitCodeMapper}.
- *
+ *
* @param exitCodeMapper the exitCodeMapper to set
*/
public void setExitCodeMapper(ExitCodeMapper exitCodeMapper) {
@@ -216,8 +218,8 @@ public class CommandLineJobRunner {
* Static setter for the {@link SystemExiter} so it can be adjusted before
* dependency injection. Typically overridden by
* {@link #setSystemExiter(SystemExiter)}.
- *
- * @param systemExitor
+ *
+ * @param systemExiter
*/
public static void presetSystemExiter(SystemExiter systemExiter) {
CommandLineJobRunner.systemExiter = systemExiter;
@@ -227,7 +229,7 @@ public class CommandLineJobRunner {
* Retrieve the error message set by an instance of
* {@link CommandLineJobRunner} as it exits. Empty if the last job launched
* was successful.
- *
+ *
* @return the error message
*/
public static String getErrorMessage() {
@@ -236,8 +238,8 @@ public class CommandLineJobRunner {
/**
* Injection setter for the {@link SystemExiter}.
- *
- * @param systemExitor
+ *
+ * @param systemExiter
*/
public void setSystemExiter(SystemExiter systemExiter) {
CommandLineJobRunner.systemExiter = systemExiter;
@@ -245,7 +247,7 @@ public class CommandLineJobRunner {
/**
* Injection setter for {@link JobParametersConverter}.
- *
+ *
* @param jobParametersConverter
*/
public void setJobParametersConverter(JobParametersConverter jobParametersConverter) {
@@ -254,7 +256,7 @@ public class CommandLineJobRunner {
/**
* Delegate to the exiter to (possibly) exit the VM gracefully.
- *
+ *
* @param status
*/
public void exit(int status) {
@@ -295,7 +297,7 @@ public class CommandLineJobRunner {
.splitArrayElementsIntoProperties(parameters, "="));
Assert.isTrue(parameters == null || parameters.length == 0 || !jobParameters.isEmpty(),
"Invalid JobParameters " + Arrays.asList(parameters)
- + ". If parameters are provided they should be in the form name=value (no whitespace).");
+ + ". If parameters are provided they should be in the form name=value (no whitespace).");
if (opts.contains("-stop")) {
List jobExecutions = getRunningJobExecutions(jobIdentifier);
@@ -327,7 +329,7 @@ public class CommandLineJobRunner {
throw new JobExecutionNotFailedException("No failed or stopped execution found for job="
+ jobIdentifier);
}
- jobParameters = jobExecution.getJobInstance().getJobParameters();
+ jobParameters = jobExecution.getJobParameters();
jobName = jobExecution.getJobInstance().getJobName();
}
@@ -476,7 +478,8 @@ public class CommandLineJobRunner {
}
}
else {
- jobParameters = incrementer.getNext(lastInstances.get(0).getJobParameters());
+ List lastExecutions = jobExplorer.getJobExecutions(lastInstances.get(0));
+ jobParameters = incrementer.getNext(lastExecutions.get(0).getJobParameters());
}
return jobParameters;
}
@@ -490,7 +493,7 @@ public class CommandLineJobRunner {
* Spring context).
* Parameters can be provided in the form key=value, and will be converted
* using the injected {@link JobParametersConverter}.
- *
+ *
* @param args
*
*
-restart: (optional) if the job has failed or stopped and the most
@@ -543,7 +546,7 @@ public class CommandLineJobRunner {
String jobIdentifier = null;
for (String arg : newargs) {
- if (arg.startsWith("-")) {
+ if (VALID_OPTS.contains(arg)) {
opts.add(arg);
}
else {
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java
index c57c54492..0735e7f2e 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java
@@ -199,7 +199,7 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
JobExecution jobExecution = findExecutionById(executionId);
return PropertiesConverter.propertiesToString(jobParametersConverter.getProperties(jobExecution
- .getJobInstance().getJobParameters()));
+ .getJobParameters()));
}
/*
@@ -267,7 +267,7 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
String jobName = jobExecution.getJobInstance().getJobName();
Job job = jobRegistry.getJob(jobName);
- JobParameters parameters = jobExecution.getJobInstance().getJobParameters();
+ JobParameters parameters = jobExecution.getJobParameters();
logger.info(String.format("Attempting to resume job with name=%s and parameters=%s", jobName, parameters));
try {
@@ -349,7 +349,8 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
}
}
else {
- parameters = incrementer.getNext(lastInstances.get(0).getJobParameters());
+ List lastExecutions = jobExplorer.getJobExecutions(lastInstances.get(0));
+ parameters = incrementer.getNext(lastExecutions.get(0).getJobParameters());
}
logger.info(String.format("Attempting to launch job with name=%s and parameters=%s", jobName, parameters));
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java
index 83bf252c7..62b161537 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java
@@ -18,9 +18,13 @@ package org.springframework.batch.core.repository.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Timestamp;
import java.sql.Types;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -29,6 +33,9 @@ import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
+import org.springframework.batch.core.JobParameter;
+import org.springframework.batch.core.JobParameter.ParameterType;
+import org.springframework.batch.core.JobParameters;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.dao.OptimisticLockingFailureException;
@@ -79,6 +86,12 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
private static final String CURRENT_VERSION_JOB_EXECUTION = "SELECT VERSION FROM %PREFIX%JOB_EXECUTION WHERE JOB_EXECUTION_ID=?";
+ private static final String FIND_PARAMS_FROM_ID = "SELECT JOB_EXECUTION_ID, KEY_NAME, TYPE_CD, "
+ + "STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL, IDENTIFYING from %PREFIX%JOB_EXECUTION_PARAMS where JOB_EXECUTION_ID = ?";
+
+ private static final String CREATE_JOB_PARAMETERS = "INSERT into %PREFIX%JOB_EXECUTION_PARAMS(JOB_EXECUTION_ID, KEY_NAME, TYPE_CD, "
+ + "STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL, IDENTIFYING) values (?, ?, ?, ?, ?, ?, ?, ?)";
+
private int exitMessageLength = DEFAULT_EXIT_MESSAGE_LENGTH;
private DataFieldMaxValueIncrementer jobExecutionIncrementer;
@@ -144,6 +157,8 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
parameters,
new int[] { Types.BIGINT, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP });
+
+ insertJobParameters(jobExecution.getId(), jobExecution.getJobParameters());
}
/**
@@ -291,16 +306,95 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
}
}
+ /**
+ * Convenience method that inserts all parameters from the provided
+ * JobParameters.
+ *
+ */
+ private void insertJobParameters(Long executionId, JobParameters jobParameters) {
+
+ for (Entry entry : jobParameters.getParameters()
+ .entrySet()) {
+ JobParameter jobParameter = entry.getValue();
+ insertParameter(executionId, jobParameter.getType(), entry.getKey(),
+ jobParameter.getValue(), jobParameter.isIdentifying());
+ }
+ }
+
+ /**
+ * Convenience method that inserts an individual records into the
+ * JobParameters table.
+ */
+ private void insertParameter(Long executionId, ParameterType type, String key,
+ Object value, boolean identifying) {
+
+ Object[] args = new Object[0];
+ int[] argTypes = new int[] { Types.BIGINT, Types.VARCHAR,
+ Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.BIGINT,
+ Types.DOUBLE, Types.CHAR };
+
+ String identifyingFlag = identifying? "Y":"N";
+
+ if (type == ParameterType.STRING) {
+ args = new Object[] { executionId, key, type, value, new Timestamp(0L),
+ 0L, 0D, identifyingFlag};
+ } else if (type == ParameterType.LONG) {
+ args = new Object[] { executionId, key, type, "", new Timestamp(0L),
+ value, new Double(0), identifyingFlag};
+ } else if (type == ParameterType.DOUBLE) {
+ args = new Object[] { executionId, key, type, "", new Timestamp(0L), 0L,
+ value, identifyingFlag};
+ } else if (type == ParameterType.DATE) {
+ args = new Object[] { executionId, key, type, "", value, 0L, 0D, identifyingFlag};
+ }
+
+ getJdbcTemplate().update(getQuery(CREATE_JOB_PARAMETERS), args, argTypes);
+ }
+
+ /**
+ * @param executionId
+ * @return
+ */
+ private JobParameters getJobParameters(Long executionId) {
+ final Map map = new HashMap();
+ RowCallbackHandler handler = new RowCallbackHandler() {
+ @Override
+ public void processRow(ResultSet rs) throws SQLException {
+ ParameterType type = ParameterType.valueOf(rs.getString(3));
+ JobParameter value = null;
+
+ if (type == ParameterType.STRING) {
+ value = new JobParameter(rs.getString(4), rs.getString(8).equalsIgnoreCase("Y"));
+ } else if (type == ParameterType.LONG) {
+ value = new JobParameter(rs.getLong(6), rs.getString(8).equalsIgnoreCase("Y"));
+ } else if (type == ParameterType.DOUBLE) {
+ value = new JobParameter(rs.getDouble(7), rs.getString(8).equalsIgnoreCase("Y"));
+ } else if (type == ParameterType.DATE) {
+ value = new JobParameter(rs.getTimestamp(5), rs.getString(8).equalsIgnoreCase("Y"));
+ }
+
+ // No need to assert that value is not null because it's an enum
+ map.put(rs.getString(2), value);
+ }
+ };
+
+ getJdbcTemplate().query(getQuery(FIND_PARAMS_FROM_ID), new Object[] { executionId }, handler);
+
+ return new JobParameters(map);
+ }
+
/**
* Re-usable mapper for {@link JobExecution} instances.
*
* @author Dave Syer
*
*/
- private static class JobExecutionRowMapper implements ParameterizedRowMapper {
+ private final class JobExecutionRowMapper implements ParameterizedRowMapper {
private JobInstance jobInstance;
+ private JobParameters jobParameters;
+
public JobExecutionRowMapper() {
}
@@ -312,12 +406,15 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
public JobExecution mapRow(ResultSet rs, int rowNum) throws SQLException {
Long id = rs.getLong(1);
JobExecution jobExecution;
+ if (jobParameters == null) {
+ jobParameters = getJobParameters(id);
+ }
if (jobInstance == null) {
- jobExecution = new JobExecution(id);
+ jobExecution = new JobExecution(id, jobParameters);
}
else {
- jobExecution = new JobExecution(jobInstance, id);
+ jobExecution = new JobExecution(jobInstance, id, jobParameters);
}
jobExecution.setStartTime(rs.getTimestamp(2));
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java
index 6bd2f6f9f..874042341 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java
@@ -16,31 +16,21 @@
package org.springframework.batch.core.repository.dao;
-import java.io.UnsupportedEncodingException;
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Timestamp;
import java.sql.Types;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
+import org.springframework.batch.core.DefaultJobKeyGenerator;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
-import org.springframework.batch.core.JobParameter;
-import org.springframework.batch.core.JobParameter.ParameterType;
+import org.springframework.batch.core.JobKeyGenerator;
import org.springframework.batch.core.JobParameters;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
-import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
import org.springframework.util.Assert;
@@ -58,6 +48,7 @@ import org.springframework.util.StringUtils;
* @author Lucas Ward
* @author Dave Syer
* @author Robert Kasanicky
+ * @author Michael Minella
*/
public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
JobInstanceDao, InitializingBean {
@@ -65,9 +56,6 @@ JobInstanceDao, InitializingBean {
private static final String CREATE_JOB_INSTANCE = "INSERT into %PREFIX%JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION)"
+ " values (?, ?, ?, ?)";
- private static final String CREATE_JOB_PARAMETERS = "INSERT into %PREFIX%JOB_PARAMS(JOB_INSTANCE_ID, KEY_NAME, TYPE_CD, "
- + "STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL) values (?, ?, ?, ?, ?, ?, ?)";
-
private static final String FIND_JOBS_WITH_NAME = "SELECT JOB_INSTANCE_ID, JOB_NAME from %PREFIX%JOB_INSTANCE where JOB_NAME = ?";
private static final String FIND_JOBS_WITH_KEY = FIND_JOBS_WITH_NAME
@@ -80,15 +68,14 @@ JobInstanceDao, InitializingBean {
private static final String GET_JOB_FROM_EXECUTION_ID = "SELECT ji.JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, ji.VERSION from %PREFIX%JOB_INSTANCE ji, "
+ "%PREFIX%JOB_EXECUTION je where JOB_EXECUTION_ID = ? and ji.JOB_INSTANCE_ID = je.JOB_INSTANCE_ID";
- private static final String FIND_PARAMS_FROM_ID = "SELECT JOB_INSTANCE_ID, KEY_NAME, TYPE_CD, "
- + "STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL from %PREFIX%JOB_PARAMS where JOB_INSTANCE_ID = ?";
-
private static final String FIND_JOB_NAMES = "SELECT distinct JOB_NAME from %PREFIX%JOB_INSTANCE order by JOB_NAME";
private static final String FIND_LAST_JOBS_BY_NAME = "SELECT JOB_INSTANCE_ID, JOB_NAME from %PREFIX%JOB_INSTANCE where JOB_NAME = ? order by JOB_INSTANCE_ID desc";
private DataFieldMaxValueIncrementer jobIncrementer;
+ private JobKeyGenerator jobKeyGenerator = new DefaultJobKeyGenerator();
+
/**
* In this jdbc implementation a job id is obtained by asking the
* jobIncrementer (which is likely a sequence) for the next long value, and
@@ -110,95 +97,20 @@ JobInstanceDao, InitializingBean {
Long jobId = jobIncrementer.nextLongValue();
- JobInstance jobInstance = new JobInstance(jobId, jobParameters, jobName);
+ JobInstance jobInstance = new JobInstance(jobId, jobName);
jobInstance.incrementVersion();
Object[] parameters = new Object[] { jobId, jobName,
- createJobKey(jobParameters), jobInstance.getVersion() };
+ jobKeyGenerator.generateKey(jobParameters), jobInstance.getVersion() };
getJdbcTemplate().update(
getQuery(CREATE_JOB_INSTANCE),
parameters,
new int[] { Types.BIGINT, Types.VARCHAR, Types.VARCHAR,
Types.INTEGER });
- insertJobParameters(jobId, jobParameters);
-
return jobInstance;
}
- protected String createJobKey(JobParameters jobParameters) {
-
- Map props = jobParameters.getParameters();
- StringBuffer stringBuffer = new StringBuffer();
- List keys = new ArrayList(props.keySet());
- Collections.sort(keys);
- for (String key : keys) {
- JobParameter jobParameter = props.get(key);
- String value = jobParameter.getValue()==null ? "" : jobParameter.toString();
- stringBuffer.append(key + "=" + value + ";");
- }
-
- MessageDigest digest;
- try {
- digest = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- throw new IllegalStateException(
- "MD5 algorithm not available. Fatal (should be in the JDK).");
- }
-
- try {
- byte[] bytes = digest.digest(stringBuffer.toString().getBytes(
- "UTF-8"));
- return String.format("%032x", new BigInteger(1, bytes));
- } catch (UnsupportedEncodingException e) {
- throw new IllegalStateException(
- "UTF-8 encoding not available. Fatal (should be in the JDK).");
- }
- }
-
- /**
- * Convenience method that inserts all parameters from the provided
- * JobParameters.
- *
- */
- private void insertJobParameters(Long jobId, JobParameters jobParameters) {
-
- for (Entry entry : jobParameters.getParameters()
- .entrySet()) {
- JobParameter jobParameter = entry.getValue();
- insertParameter(jobId, jobParameter.getType(), entry.getKey(),
- jobParameter.getValue());
- }
- }
-
- /**
- * Convenience method that inserts an individual records into the
- * JobParameters table.
- */
- private void insertParameter(Long jobId, ParameterType type, String key,
- Object value) {
-
- Object[] args = new Object[0];
- int[] argTypes = new int[] { Types.BIGINT, Types.VARCHAR,
- Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.BIGINT,
- Types.DOUBLE };
-
- if (type == ParameterType.STRING) {
- args = new Object[] { jobId, key, type, value, new Timestamp(0L),
- 0L, 0D };
- } else if (type == ParameterType.LONG) {
- args = new Object[] { jobId, key, type, "", new Timestamp(0L),
- value, new Double(0) };
- } else if (type == ParameterType.DOUBLE) {
- args = new Object[] { jobId, key, type, "", new Timestamp(0L), 0L,
- value };
- } else if (type == ParameterType.DATE) {
- args = new Object[] { jobId, key, type, "", value, 0L, 0D };
- }
-
- getJdbcTemplate().update(getQuery(CREATE_JOB_PARAMETERS), args, argTypes);
- }
-
/**
* The job table is queried for any jobs that match the
* given identifier, adding them to a list via the RowMapper callback.
@@ -214,10 +126,9 @@ JobInstanceDao, InitializingBean {
Assert.notNull(jobName, "Job name must not be null.");
Assert.notNull(jobParameters, "JobParameters must not be null.");
- String jobKey = createJobKey(jobParameters);
+ String jobKey = jobKeyGenerator.generateKey(jobParameters);
- ParameterizedRowMapper rowMapper = new JobInstanceRowMapper(
- jobParameters);
+ ParameterizedRowMapper rowMapper = new JobInstanceRowMapper();
List instances;
if (StringUtils.hasLength(jobKey)) {
@@ -256,34 +167,6 @@ JobInstanceDao, InitializingBean {
}
- /**
- * @param instanceId
- * @return
- */
- private JobParameters getJobParameters(Long instanceId) {
- final Map map = new HashMap();
- RowCallbackHandler handler = new RowCallbackHandler() {
- @Override
- public void processRow(ResultSet rs) throws SQLException {
- ParameterType type = ParameterType.valueOf(rs.getString(3));
- JobParameter value = null;
- if (type == ParameterType.STRING) {
- value = new JobParameter(rs.getString(4));
- } else if (type == ParameterType.LONG) {
- value = new JobParameter(rs.getLong(6));
- } else if (type == ParameterType.DOUBLE) {
- value = new JobParameter(rs.getDouble(7));
- } else if (type == ParameterType.DATE) {
- value = new JobParameter(rs.getTimestamp(5));
- }
- // No need to assert that value is not null because it's an enum
- map.put(rs.getString(2), value);
- }
- };
- getJdbcTemplate().query(getQuery(FIND_PARAMS_FROM_ID), new Object[] { instanceId }, handler);
- return new JobParameters(map);
- }
-
/*
* (non-Javadoc)
*
@@ -385,23 +268,12 @@ JobInstanceDao, InitializingBean {
private final class JobInstanceRowMapper implements
ParameterizedRowMapper {
- private JobParameters jobParameters;
-
public JobInstanceRowMapper() {
}
- public JobInstanceRowMapper(JobParameters jobParameters) {
- this.jobParameters = jobParameters;
- }
-
@Override
public JobInstance mapRow(ResultSet rs, int rowNum) throws SQLException {
- Long id = rs.getLong(1);
- if (jobParameters == null) {
- jobParameters = getJobParameters(id);
- }
- JobInstance jobInstance = new JobInstance(rs.getLong(1),
- jobParameters, rs.getString(2));
+ JobInstance jobInstance = new JobInstance(rs.getLong(1), rs.getString(2));
// should always be at version=0 because they never get updated
jobInstance.incrementVersion();
return jobInstance;
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java
index a0e23c953..6848de662 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java
@@ -20,12 +20,14 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
+import org.springframework.batch.core.DefaultJobKeyGenerator;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
+import org.springframework.batch.core.JobKeyGenerator;
import org.springframework.batch.core.JobParameters;
import org.springframework.util.Assert;
@@ -35,7 +37,10 @@ import org.springframework.util.Assert;
public class MapJobInstanceDao implements JobInstanceDao {
// JDK6 Make a ConcurrentSkipListSet: tends to add on end
- private final Set jobInstances = new CopyOnWriteArraySet();
+ private final Map jobInstances = new ConcurrentHashMap();
+ // private final Set jobInstances = new CopyOnWriteArraySet();
+
+ private JobKeyGenerator jobKeyGenerator = new DefaultJobKeyGenerator();
private final AtomicLong currentId = new AtomicLong(0L);
@@ -48,28 +53,22 @@ public class MapJobInstanceDao implements JobInstanceDao {
Assert.state(getJobInstance(jobName, jobParameters) == null, "JobInstance must not already exist");
- JobInstance jobInstance = new JobInstance(currentId.getAndIncrement(), jobParameters, jobName);
+ JobInstance jobInstance = new JobInstance(currentId.getAndIncrement(), jobName);
jobInstance.incrementVersion();
- jobInstances.add(jobInstance);
+ jobInstances.put(jobName + jobKeyGenerator.generateKey(jobParameters), jobInstance);
return jobInstance;
}
@Override
public JobInstance getJobInstance(String jobName, JobParameters jobParameters) {
-
- for (JobInstance instance : jobInstances) {
- if (instance.getJobName().equals(jobName) && instance.getJobParameters().equals(jobParameters)) {
- return instance;
- }
- }
- return null;
-
+ return jobInstances.get(jobName + jobKeyGenerator.generateKey(jobParameters));
}
@Override
public JobInstance getJobInstance(Long instanceId) {
- for (JobInstance instance : jobInstances) {
+ for (Map.Entry instanceEntry : jobInstances.entrySet()) {
+ JobInstance instance = instanceEntry.getValue();
if (instance.getId().equals(instanceId)) {
return instance;
}
@@ -80,8 +79,8 @@ public class MapJobInstanceDao implements JobInstanceDao {
@Override
public List getJobNames() {
List result = new ArrayList();
- for (JobInstance instance : jobInstances) {
- result.add(instance.getJobName());
+ for (Map.Entry instanceEntry : jobInstances.entrySet()) {
+ result.add(instanceEntry.getValue().getJobName());
}
Collections.sort(result);
return result;
@@ -90,7 +89,8 @@ public class MapJobInstanceDao implements JobInstanceDao {
@Override
public List getJobInstances(String jobName, int start, int count) {
List result = new ArrayList();
- for (JobInstance instance : jobInstances) {
+ for (Map.Entry instanceEntry : jobInstances.entrySet()) {
+ JobInstance instance = instanceEntry.getValue();
if (instance.getJobName().equals(jobName)) {
result.add(instance);
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java
index 9518bfb6f..6cc044de3 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java
@@ -134,7 +134,7 @@ public class SimpleJobRepository implements JobRepository {
executionContext = new ExecutionContext();
}
- JobExecution jobExecution = new JobExecution(jobInstance);
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
jobExecution.setExecutionContext(executionContext);
jobExecution.setLastUpdated(new Date(System.currentTimeMillis()));
@@ -199,6 +199,7 @@ public class SimpleJobRepository implements JobRepository {
public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) {
List jobExecutions = jobExecutionDao.findJobExecutions(jobInstance);
List stepExecutions = new ArrayList(jobExecutions.size());
+
for (JobExecution jobExecution : jobExecutions) {
stepExecutionDao.addStepExecutions(jobExecution);
for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
@@ -207,6 +208,7 @@ public class SimpleJobRepository implements JobRepository {
}
}
}
+
StepExecution latest = null;
for (StepExecution stepExecution : stepExecutions) {
if (latest == null) {
@@ -216,10 +218,12 @@ public class SimpleJobRepository implements JobRepository {
latest = stepExecution;
}
}
+
if (latest != null) {
ExecutionContext executionContext = ecDao.getExecutionContext(latest);
latest.setExecutionContext(executionContext);
}
+
return latest;
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/SimpleStepBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/SimpleStepBuilder.java
index 4ad1a66ae..2b49a7f4b 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/SimpleStepBuilder.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/SimpleStepBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2011 the original author or authors.
+ * Copyright 2006-2013 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.
@@ -45,11 +45,11 @@ import org.springframework.util.Assert;
* Step builder for simple item processing (chunk oriented) steps. Items are read and cached in chunks, and then
* processed (transformed) and written (optionally either the processor or the writer can be omitted) all in the same
* transaction.
- *
+ *
* @see FaultTolerantStepBuilder for a step that handles retry and skip of failed items
- *
+ *
* @author Dave Syer
- *
+ *
* @since 2.2
*/
public class SimpleStepBuilder extends AbstractTaskletStepBuilder> {
@@ -74,16 +74,16 @@ public class SimpleStepBuilder extends AbstractTaskletStepBuilder parent) {
super(parent);
}
-
+
/**
* Create a new builder initialized with any properties in the parent. The parent is copied, so it can be re-used.
- *
+ *
* @param parent a parent helper containing common step properties
*/
protected SimpleStepBuilder(SimpleStepBuilder parent) {
@@ -97,7 +97,7 @@ public class SimpleStepBuilder extends AbstractTaskletStepBuilder faultTolerant() {
FaultTolerantStepBuilder builder = new FaultTolerantStepBuilder(this);
return builder;
@@ -105,7 +105,7 @@ public class SimpleStepBuilder extends AbstractTaskletStepBuilder extends AbstractTaskletStepBuilder extends AbstractTaskletStepBuilder extends AbstractTaskletStepBuilder extends AbstractTaskletStepBuilder extends AbstractTaskletStepBuilder extends AbstractTaskletStepBuilder readerIsTransactionalQueue() {
@@ -208,7 +208,7 @@ public class SimpleStepBuilder extends AbstractTaskletStepBuilder extends AbstractTaskletStepBuilder extends AbstractTaskletStepBuilder extends AbstractTaskletStepBuilder extends AbstractTaskletStepBuilder || listener instanceof ItemProcessListener, ?>
- || listener instanceof ItemWriteListener>) {
+ || listener instanceof ItemWriteListener>) {
itemListeners.add(listener);
}
}
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/StepBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/StepBuilder.java
index 09b524642..e0b08a461 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/StepBuilder.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/StepBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2011 the original author or authors.
+ * Copyright 2006-2013 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.
@@ -24,16 +24,16 @@ import org.springframework.batch.repeat.CompletionPolicy;
/**
* Convenient entry point for building all kinds of steps. Use this as a factory for fluent builders of any step.
- *
+ *
* @author Dave Syer
- *
+ *
* @since 2.2
*/
public class StepBuilder extends StepBuilderHelper {
/**
* Initialize a step builder for a step with the given name.
- *
+ *
* @param name the name of the step
*/
public StepBuilder(String name) {
@@ -42,7 +42,7 @@ public class StepBuilder extends StepBuilderHelper {
/**
* Build a step with a custom tasklet, not necessarily item processing.
- *
+ *
* @param tasklet a tasklet
* @return a {@link TaskletStepBuilder}
*/
@@ -53,7 +53,7 @@ public class StepBuilder extends StepBuilderHelper {
/**
* Build a step that processes items in chunks with the size provided. To extend the step to being fault tolerant,
* call the {@link SimpleStepBuilder#faultTolerant()} method on the builder.
- *
+ *
* @param chunkSize the chunk size (commit interval)
* @return a {@link SimpleStepBuilder}
*/
@@ -64,7 +64,7 @@ public class StepBuilder extends StepBuilderHelper {
/**
* Build a step that processes items in chunks with the completion policy provided. To extend the step to being
* fault tolerant, call the {@link SimpleStepBuilder#faultTolerant()} method on the builder.
- *
+ *
* @param completionPolicy the completion policy to use to control chunk processing
* @return a {@link SimpleStepBuilder}
*/
@@ -74,7 +74,7 @@ public class StepBuilder extends StepBuilderHelper {
/**
* Create a partition step builder for a remote (or local) step.
- *
+ *
* @param stepName the name of the remote or delegate step
* @param partitioner a partitioner to be used to construct new step executions
* @return a {@link PartitionStepBuilder}
@@ -85,9 +85,8 @@ public class StepBuilder extends StepBuilderHelper {
/**
* Create a partition step builder for a remote (or local) step.
- *
+ *
* @param step the step to execute in parallel
- * @param partitioner a partitioner to be used to construct new step executions
* @return a PartitionStepBuilder
*/
public PartitionStepBuilder partitioner(Step step) {
@@ -96,7 +95,7 @@ public class StepBuilder extends StepBuilderHelper {
/**
* Create a new step builder that will execute a job.
- *
+ *
* @param job a job to execute
* @return a {@link JobStepBuilder}
*/
@@ -106,7 +105,7 @@ public class StepBuilder extends StepBuilderHelper {
/**
* Create a new step builder that will execute a flow.
- *
+ *
* @param flow a flow to execute
* @return a {@link FlowStepBuilder}
*/
diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java
index c661cdd1a..8b98f9fe4 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java
@@ -354,6 +354,7 @@ public class TaskletStep extends AbstractStep {
}
chunkListener.afterChunkError(chunkContext);
}
+
if (status == TransactionSynchronization.STATUS_UNKNOWN) {
logger.error("Rolling back with transaction in unknown state");
rollback(stepExecution);
@@ -367,13 +368,13 @@ public class TaskletStep extends AbstractStep {
if (locked) {
semaphore.release();
}
+
locked = false;
}
}
@Override
public Object doInTransaction(TransactionStatus status) {
-
TransactionSynchronizationManager.registerSynchronization(this);
RepeatStatus result = RepeatStatus.CONTINUABLE;
@@ -448,7 +449,6 @@ public class TaskletStep extends AbstractStep {
stepExecution.setTerminateOnly();
throw new FatalStepExecutionException(msg, e);
}
-
}
catch (Error e) {
logger.debug("Rollback for Error: " + e.getClass().getName() + ": " + e.getMessage());
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-db2.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-db2.sql
index eb2b17167..264b52ad2 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-db2.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-db2.sql
@@ -1,19 +1,19 @@
-- Autogenerated: do not edit this file
CREATE TABLE BATCH_JOB_INSTANCE (
- JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
- JOB_NAME VARCHAR(100) NOT NULL,
+ JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY ,
+ VERSION BIGINT ,
+ JOB_NAME VARCHAR(100) NOT NULL,
JOB_KEY VARCHAR(32) NOT NULL,
constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
) ;
CREATE TABLE BATCH_JOB_EXECUTION (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
+ VERSION BIGINT ,
JOB_INSTANCE_ID BIGINT NOT NULL,
CREATE_TIME TIMESTAMP NOT NULL,
- START_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP DEFAULT NULL ,
END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
EXIT_CODE VARCHAR(100) ,
@@ -22,35 +22,36 @@ CREATE TABLE BATCH_JOB_EXECUTION (
constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
) ;
-
-CREATE TABLE BATCH_JOB_PARAMS (
- JOB_INSTANCE_ID BIGINT NOT NULL ,
+
+CREATE TABLE BATCH_JOB_EXECUTION_PARAMS (
+ JOB_EXECUTION_ID BIGINT NOT NULL ,
TYPE_CD VARCHAR(6) NOT NULL ,
- KEY_NAME VARCHAR(100) NOT NULL ,
- STRING_VAL VARCHAR(250) ,
+ KEY_NAME VARCHAR(100) NOT NULL ,
+ STRING_VAL VARCHAR(250) ,
DATE_VAL TIMESTAMP DEFAULT NULL ,
LONG_VAL BIGINT ,
DOUBLE_VAL DOUBLE PRECISION ,
- constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
- references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+ IDENTIFYING CHAR(1) NOT NULL ,
+ constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
-
+
CREATE TABLE BATCH_STEP_EXECUTION (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT NOT NULL,
+ VERSION BIGINT NOT NULL,
STEP_NAME VARCHAR(100) NOT NULL,
JOB_EXECUTION_ID BIGINT NOT NULL,
- START_TIME TIMESTAMP NOT NULL ,
- END_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP NOT NULL ,
+ END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
- COMMIT_COUNT BIGINT ,
+ COMMIT_COUNT BIGINT ,
READ_COUNT BIGINT ,
FILTER_COUNT BIGINT ,
WRITE_COUNT BIGINT ,
READ_SKIP_COUNT BIGINT ,
WRITE_SKIP_COUNT BIGINT ,
PROCESS_SKIP_COUNT BIGINT ,
- ROLLBACK_COUNT BIGINT ,
+ ROLLBACK_COUNT BIGINT ,
EXIT_CODE VARCHAR(100) ,
EXIT_MESSAGE VARCHAR(2500) ,
LAST_UPDATED TIMESTAMP,
@@ -61,7 +62,7 @@ CREATE TABLE BATCH_STEP_EXECUTION (
CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT CLOB ,
+ SERIALIZED_CONTEXT CLOB ,
constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
) ;
@@ -69,7 +70,7 @@ CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT CLOB ,
+ SERIALIZED_CONTEXT CLOB ,
constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-derby.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-derby.sql
index f52f984fe..8794edb69 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-derby.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-derby.sql
@@ -1,19 +1,19 @@
-- Autogenerated: do not edit this file
CREATE TABLE BATCH_JOB_INSTANCE (
- JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
- VERSION BIGINT ,
- JOB_NAME VARCHAR(100) NOT NULL,
+ JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
+ VERSION BIGINT ,
+ JOB_NAME VARCHAR(100) NOT NULL,
JOB_KEY VARCHAR(32) NOT NULL,
constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
) ;
CREATE TABLE BATCH_JOB_EXECUTION (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
- VERSION BIGINT ,
+ VERSION BIGINT ,
JOB_INSTANCE_ID BIGINT NOT NULL,
CREATE_TIME TIMESTAMP NOT NULL,
- START_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP DEFAULT NULL ,
END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
EXIT_CODE VARCHAR(100) ,
@@ -22,35 +22,36 @@ CREATE TABLE BATCH_JOB_EXECUTION (
constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
) ;
-
-CREATE TABLE BATCH_JOB_PARAMS (
- JOB_INSTANCE_ID BIGINT NOT NULL ,
+
+CREATE TABLE BATCH_JOB_EXECUTION_PARAMS (
+ JOB_EXECUTION_ID BIGINT NOT NULL ,
TYPE_CD VARCHAR(6) NOT NULL ,
- KEY_NAME VARCHAR(100) NOT NULL ,
- STRING_VAL VARCHAR(250) ,
+ KEY_NAME VARCHAR(100) NOT NULL ,
+ STRING_VAL VARCHAR(250) ,
DATE_VAL TIMESTAMP DEFAULT NULL ,
LONG_VAL BIGINT ,
DOUBLE_VAL DOUBLE PRECISION ,
- constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
- references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+ IDENTIFYING CHAR(1) NOT NULL ,
+ constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
-
+
CREATE TABLE BATCH_STEP_EXECUTION (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
- VERSION BIGINT NOT NULL,
+ VERSION BIGINT NOT NULL,
STEP_NAME VARCHAR(100) NOT NULL,
JOB_EXECUTION_ID BIGINT NOT NULL,
- START_TIME TIMESTAMP NOT NULL ,
- END_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP NOT NULL ,
+ END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
- COMMIT_COUNT BIGINT ,
+ COMMIT_COUNT BIGINT ,
READ_COUNT BIGINT ,
FILTER_COUNT BIGINT ,
WRITE_COUNT BIGINT ,
READ_SKIP_COUNT BIGINT ,
WRITE_SKIP_COUNT BIGINT ,
PROCESS_SKIP_COUNT BIGINT ,
- ROLLBACK_COUNT BIGINT ,
+ ROLLBACK_COUNT BIGINT ,
EXIT_CODE VARCHAR(100) ,
EXIT_MESSAGE VARCHAR(2500) ,
LAST_UPDATED TIMESTAMP,
@@ -61,7 +62,7 @@ CREATE TABLE BATCH_STEP_EXECUTION (
CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT CLOB ,
+ SERIALIZED_CONTEXT CLOB ,
constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
) ;
@@ -69,7 +70,7 @@ CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT CLOB ,
+ SERIALIZED_CONTEXT CLOB ,
constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-db2.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-db2.sql
index a45e3647c..891182071 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-db2.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-db2.sql
@@ -3,8 +3,8 @@
DROP TABLE BATCH_STEP_EXECUTION_CONTEXT ;
DROP TABLE BATCH_JOB_EXECUTION_CONTEXT ;
DROP TABLE BATCH_STEP_EXECUTION ;
+DROP TABLE BATCH_JOB_EXECUTION_PARAMS ;
DROP TABLE BATCH_JOB_EXECUTION ;
-DROP TABLE BATCH_JOB_PARAMS ;
DROP TABLE BATCH_JOB_INSTANCE ;
DROP SEQUENCE BATCH_STEP_EXECUTION_SEQ ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-derby.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-derby.sql
index 68ffb0214..d63d1c074 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-derby.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-derby.sql
@@ -3,8 +3,8 @@
DROP TABLE BATCH_STEP_EXECUTION_CONTEXT ;
DROP TABLE BATCH_JOB_EXECUTION_CONTEXT ;
DROP TABLE BATCH_STEP_EXECUTION ;
+DROP TABLE BATCH_JOB_EXECUTION_PARAMS ;
DROP TABLE BATCH_JOB_EXECUTION ;
-DROP TABLE BATCH_JOB_PARAMS ;
DROP TABLE BATCH_JOB_INSTANCE ;
DROP TABLE BATCH_STEP_EXECUTION_SEQ ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-h2.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-h2.sql
index 33be1393a..c057fa608 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-h2.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-h2.sql
@@ -3,8 +3,8 @@
DROP TABLE BATCH_STEP_EXECUTION_CONTEXT IF EXISTS;
DROP TABLE BATCH_JOB_EXECUTION_CONTEXT IF EXISTS;
DROP TABLE BATCH_STEP_EXECUTION IF EXISTS;
+DROP TABLE BATCH_JOB_EXECUTION_PARAMS IF EXISTS;
DROP TABLE BATCH_JOB_EXECUTION IF EXISTS;
-DROP TABLE BATCH_JOB_PARAMS IF EXISTS;
DROP TABLE BATCH_JOB_INSTANCE IF EXISTS;
DROP SEQUENCE BATCH_STEP_EXECUTION_SEQ IF EXISTS;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-hsqldb.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-hsqldb.sql
index 34ebe189b..53ec12ddf 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-hsqldb.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-hsqldb.sql
@@ -3,8 +3,8 @@
DROP TABLE BATCH_STEP_EXECUTION_CONTEXT IF EXISTS;
DROP TABLE BATCH_JOB_EXECUTION_CONTEXT IF EXISTS;
DROP TABLE BATCH_STEP_EXECUTION IF EXISTS;
+DROP TABLE BATCH_JOB_EXECUTION_PARAMS IF EXISTS;
DROP TABLE BATCH_JOB_EXECUTION IF EXISTS;
-DROP TABLE BATCH_JOB_PARAMS IF EXISTS;
DROP TABLE BATCH_JOB_INSTANCE IF EXISTS;
DROP TABLE BATCH_STEP_EXECUTION_SEQ IF EXISTS;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-mysql.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-mysql.sql
index ae2520194..28fe65bac 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-mysql.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-mysql.sql
@@ -3,8 +3,8 @@
DROP TABLE IF EXISTS BATCH_STEP_EXECUTION_CONTEXT ;
DROP TABLE IF EXISTS BATCH_JOB_EXECUTION_CONTEXT ;
DROP TABLE IF EXISTS BATCH_STEP_EXECUTION ;
+DROP TABLE IF EXISTS BATCH_JOB_EXECUTION_PARAMS ;
DROP TABLE IF EXISTS BATCH_JOB_EXECUTION ;
-DROP TABLE IF EXISTS BATCH_JOB_PARAMS ;
DROP TABLE IF EXISTS BATCH_JOB_INSTANCE ;
DROP TABLE IF EXISTS BATCH_STEP_EXECUTION_SEQ ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-oracle10g.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-oracle10g.sql
index a45e3647c..891182071 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-oracle10g.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-oracle10g.sql
@@ -3,8 +3,8 @@
DROP TABLE BATCH_STEP_EXECUTION_CONTEXT ;
DROP TABLE BATCH_JOB_EXECUTION_CONTEXT ;
DROP TABLE BATCH_STEP_EXECUTION ;
+DROP TABLE BATCH_JOB_EXECUTION_PARAMS ;
DROP TABLE BATCH_JOB_EXECUTION ;
-DROP TABLE BATCH_JOB_PARAMS ;
DROP TABLE BATCH_JOB_INSTANCE ;
DROP SEQUENCE BATCH_STEP_EXECUTION_SEQ ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-postgresql.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-postgresql.sql
index a45e3647c..891182071 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-postgresql.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-postgresql.sql
@@ -3,8 +3,8 @@
DROP TABLE BATCH_STEP_EXECUTION_CONTEXT ;
DROP TABLE BATCH_JOB_EXECUTION_CONTEXT ;
DROP TABLE BATCH_STEP_EXECUTION ;
+DROP TABLE BATCH_JOB_EXECUTION_PARAMS ;
DROP TABLE BATCH_JOB_EXECUTION ;
-DROP TABLE BATCH_JOB_PARAMS ;
DROP TABLE BATCH_JOB_INSTANCE ;
DROP SEQUENCE BATCH_STEP_EXECUTION_SEQ ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlf.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlf.sql
index 68ffb0214..d63d1c074 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlf.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlf.sql
@@ -3,8 +3,8 @@
DROP TABLE BATCH_STEP_EXECUTION_CONTEXT ;
DROP TABLE BATCH_JOB_EXECUTION_CONTEXT ;
DROP TABLE BATCH_STEP_EXECUTION ;
+DROP TABLE BATCH_JOB_EXECUTION_PARAMS ;
DROP TABLE BATCH_JOB_EXECUTION ;
-DROP TABLE BATCH_JOB_PARAMS ;
DROP TABLE BATCH_JOB_INSTANCE ;
DROP TABLE BATCH_STEP_EXECUTION_SEQ ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlserver.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlserver.sql
index 68ffb0214..d63d1c074 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlserver.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlserver.sql
@@ -3,8 +3,8 @@
DROP TABLE BATCH_STEP_EXECUTION_CONTEXT ;
DROP TABLE BATCH_JOB_EXECUTION_CONTEXT ;
DROP TABLE BATCH_STEP_EXECUTION ;
+DROP TABLE BATCH_JOB_EXECUTION_PARAMS ;
DROP TABLE BATCH_JOB_EXECUTION ;
-DROP TABLE BATCH_JOB_PARAMS ;
DROP TABLE BATCH_JOB_INSTANCE ;
DROP TABLE BATCH_STEP_EXECUTION_SEQ ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sybase.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sybase.sql
index 68ffb0214..d63d1c074 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sybase.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sybase.sql
@@ -3,8 +3,8 @@
DROP TABLE BATCH_STEP_EXECUTION_CONTEXT ;
DROP TABLE BATCH_JOB_EXECUTION_CONTEXT ;
DROP TABLE BATCH_STEP_EXECUTION ;
+DROP TABLE BATCH_JOB_EXECUTION_PARAMS ;
DROP TABLE BATCH_JOB_EXECUTION ;
-DROP TABLE BATCH_JOB_PARAMS ;
DROP TABLE BATCH_JOB_INSTANCE ;
DROP TABLE BATCH_STEP_EXECUTION_SEQ ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-h2.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-h2.sql
index c4a95283b..a8bf52427 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-h2.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-h2.sql
@@ -1,19 +1,19 @@
-- Autogenerated: do not edit this file
CREATE TABLE BATCH_JOB_INSTANCE (
- JOB_INSTANCE_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
- JOB_NAME VARCHAR(100) NOT NULL,
+ JOB_INSTANCE_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
+ VERSION BIGINT ,
+ JOB_NAME VARCHAR(100) NOT NULL,
JOB_KEY VARCHAR(32) NOT NULL,
constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
) ;
CREATE TABLE BATCH_JOB_EXECUTION (
JOB_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
+ VERSION BIGINT ,
JOB_INSTANCE_ID BIGINT NOT NULL,
CREATE_TIME TIMESTAMP NOT NULL,
- START_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP DEFAULT NULL ,
END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
EXIT_CODE VARCHAR(100) ,
@@ -22,35 +22,36 @@ CREATE TABLE BATCH_JOB_EXECUTION (
constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
) ;
-
-CREATE TABLE BATCH_JOB_PARAMS (
- JOB_INSTANCE_ID BIGINT NOT NULL ,
+
+CREATE TABLE BATCH_JOB_EXECUTION_PARAMS (
+ JOB_EXECUTION_ID BIGINT NOT NULL ,
TYPE_CD VARCHAR(6) NOT NULL ,
- KEY_NAME VARCHAR(100) NOT NULL ,
- STRING_VAL VARCHAR(250) ,
+ KEY_NAME VARCHAR(100) NOT NULL ,
+ STRING_VAL VARCHAR(250) ,
DATE_VAL TIMESTAMP DEFAULT NULL ,
LONG_VAL BIGINT ,
DOUBLE_VAL DOUBLE PRECISION ,
- constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
- references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+ IDENTIFYING CHAR(1) NOT NULL ,
+ constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
-
+
CREATE TABLE BATCH_STEP_EXECUTION (
STEP_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
- VERSION BIGINT NOT NULL,
+ VERSION BIGINT NOT NULL,
STEP_NAME VARCHAR(100) NOT NULL,
JOB_EXECUTION_ID BIGINT NOT NULL,
- START_TIME TIMESTAMP NOT NULL ,
- END_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP NOT NULL ,
+ END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
- COMMIT_COUNT BIGINT ,
+ COMMIT_COUNT BIGINT ,
READ_COUNT BIGINT ,
FILTER_COUNT BIGINT ,
WRITE_COUNT BIGINT ,
READ_SKIP_COUNT BIGINT ,
WRITE_SKIP_COUNT BIGINT ,
PROCESS_SKIP_COUNT BIGINT ,
- ROLLBACK_COUNT BIGINT ,
+ ROLLBACK_COUNT BIGINT ,
EXIT_CODE VARCHAR(100) ,
EXIT_MESSAGE VARCHAR(2500) ,
LAST_UPDATED TIMESTAMP,
@@ -61,7 +62,7 @@ CREATE TABLE BATCH_STEP_EXECUTION (
CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT LONGVARCHAR ,
+ SERIALIZED_CONTEXT LONGVARCHAR ,
constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
) ;
@@ -69,7 +70,7 @@ CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT LONGVARCHAR ,
+ SERIALIZED_CONTEXT LONGVARCHAR ,
constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-hsqldb.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-hsqldb.sql
index 6d4db0c23..5ac3d3544 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-hsqldb.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-hsqldb.sql
@@ -1,19 +1,19 @@
-- Autogenerated: do not edit this file
CREATE TABLE BATCH_JOB_INSTANCE (
- JOB_INSTANCE_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
- JOB_NAME VARCHAR(100) NOT NULL,
+ JOB_INSTANCE_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
+ VERSION BIGINT ,
+ JOB_NAME VARCHAR(100) NOT NULL,
JOB_KEY VARCHAR(32) NOT NULL,
constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
) ;
CREATE TABLE BATCH_JOB_EXECUTION (
JOB_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
+ VERSION BIGINT ,
JOB_INSTANCE_ID BIGINT NOT NULL,
CREATE_TIME TIMESTAMP NOT NULL,
- START_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP DEFAULT NULL ,
END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
EXIT_CODE VARCHAR(100) ,
@@ -22,35 +22,36 @@ CREATE TABLE BATCH_JOB_EXECUTION (
constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
) ;
-
-CREATE TABLE BATCH_JOB_PARAMS (
- JOB_INSTANCE_ID BIGINT NOT NULL ,
+
+CREATE TABLE BATCH_JOB_EXECUTION_PARAMS (
+ JOB_EXECUTION_ID BIGINT NOT NULL ,
TYPE_CD VARCHAR(6) NOT NULL ,
- KEY_NAME VARCHAR(100) NOT NULL ,
- STRING_VAL VARCHAR(250) ,
+ KEY_NAME VARCHAR(100) NOT NULL ,
+ STRING_VAL VARCHAR(250) ,
DATE_VAL TIMESTAMP DEFAULT NULL ,
LONG_VAL BIGINT ,
DOUBLE_VAL DOUBLE PRECISION ,
- constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
- references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+ IDENTIFYING CHAR(1) NOT NULL ,
+ constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
-
+
CREATE TABLE BATCH_STEP_EXECUTION (
STEP_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
- VERSION BIGINT NOT NULL,
+ VERSION BIGINT NOT NULL,
STEP_NAME VARCHAR(100) NOT NULL,
JOB_EXECUTION_ID BIGINT NOT NULL,
- START_TIME TIMESTAMP NOT NULL ,
- END_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP NOT NULL ,
+ END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
- COMMIT_COUNT BIGINT ,
+ COMMIT_COUNT BIGINT ,
READ_COUNT BIGINT ,
FILTER_COUNT BIGINT ,
WRITE_COUNT BIGINT ,
READ_SKIP_COUNT BIGINT ,
WRITE_SKIP_COUNT BIGINT ,
PROCESS_SKIP_COUNT BIGINT ,
- ROLLBACK_COUNT BIGINT ,
+ ROLLBACK_COUNT BIGINT ,
EXIT_CODE VARCHAR(100) ,
EXIT_MESSAGE VARCHAR(2500) ,
LAST_UPDATED TIMESTAMP,
@@ -61,7 +62,7 @@ CREATE TABLE BATCH_STEP_EXECUTION (
CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT LONGVARCHAR ,
+ SERIALIZED_CONTEXT LONGVARCHAR ,
constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
) ;
@@ -69,7 +70,7 @@ CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT LONGVARCHAR ,
+ SERIALIZED_CONTEXT LONGVARCHAR ,
constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-mysql.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-mysql.sql
index 6a9bcf71b..9d7e9009b 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-mysql.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-mysql.sql
@@ -1,19 +1,19 @@
-- Autogenerated: do not edit this file
CREATE TABLE BATCH_JOB_INSTANCE (
- JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
- JOB_NAME VARCHAR(100) NOT NULL,
+ JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY ,
+ VERSION BIGINT ,
+ JOB_NAME VARCHAR(100) NOT NULL,
JOB_KEY VARCHAR(32) NOT NULL,
constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
) ENGINE=InnoDB;
CREATE TABLE BATCH_JOB_EXECUTION (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
+ VERSION BIGINT ,
JOB_INSTANCE_ID BIGINT NOT NULL,
CREATE_TIME DATETIME NOT NULL,
- START_TIME DATETIME DEFAULT NULL ,
+ START_TIME DATETIME DEFAULT NULL ,
END_TIME DATETIME DEFAULT NULL ,
STATUS VARCHAR(10) ,
EXIT_CODE VARCHAR(100) ,
@@ -22,35 +22,36 @@ CREATE TABLE BATCH_JOB_EXECUTION (
constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
) ENGINE=InnoDB;
-
-CREATE TABLE BATCH_JOB_PARAMS (
- JOB_INSTANCE_ID BIGINT NOT NULL ,
+
+CREATE TABLE BATCH_JOB_EXECUTION_PARAMS (
+ JOB_EXECUTION_ID BIGINT NOT NULL ,
TYPE_CD VARCHAR(6) NOT NULL ,
- KEY_NAME VARCHAR(100) NOT NULL ,
- STRING_VAL VARCHAR(250) ,
+ KEY_NAME VARCHAR(100) NOT NULL ,
+ STRING_VAL VARCHAR(250) ,
DATE_VAL DATETIME DEFAULT NULL ,
LONG_VAL BIGINT ,
DOUBLE_VAL DOUBLE PRECISION ,
- constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
- references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+ IDENTIFYING CHAR(1) NOT NULL ,
+ constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ENGINE=InnoDB;
-
+
CREATE TABLE BATCH_STEP_EXECUTION (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT NOT NULL,
+ VERSION BIGINT NOT NULL,
STEP_NAME VARCHAR(100) NOT NULL,
JOB_EXECUTION_ID BIGINT NOT NULL,
- START_TIME DATETIME NOT NULL ,
- END_TIME DATETIME DEFAULT NULL ,
+ START_TIME DATETIME NOT NULL ,
+ END_TIME DATETIME DEFAULT NULL ,
STATUS VARCHAR(10) ,
- COMMIT_COUNT BIGINT ,
+ COMMIT_COUNT BIGINT ,
READ_COUNT BIGINT ,
FILTER_COUNT BIGINT ,
WRITE_COUNT BIGINT ,
READ_SKIP_COUNT BIGINT ,
WRITE_SKIP_COUNT BIGINT ,
PROCESS_SKIP_COUNT BIGINT ,
- ROLLBACK_COUNT BIGINT ,
+ ROLLBACK_COUNT BIGINT ,
EXIT_CODE VARCHAR(100) ,
EXIT_MESSAGE VARCHAR(2500) ,
LAST_UPDATED DATETIME,
@@ -61,7 +62,7 @@ CREATE TABLE BATCH_STEP_EXECUTION (
CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT TEXT ,
+ SERIALIZED_CONTEXT TEXT ,
constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
) ENGINE=InnoDB;
@@ -69,7 +70,7 @@ CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT TEXT ,
+ SERIALIZED_CONTEXT TEXT ,
constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ENGINE=InnoDB;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-oracle10g.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-oracle10g.sql
index a50f89f28..73403b90b 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-oracle10g.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-oracle10g.sql
@@ -1,19 +1,19 @@
-- Autogenerated: do not edit this file
CREATE TABLE BATCH_JOB_INSTANCE (
- JOB_INSTANCE_ID NUMBER(19,0) NOT NULL PRIMARY KEY ,
- VERSION NUMBER(19,0) ,
- JOB_NAME VARCHAR2(100) NOT NULL,
+ JOB_INSTANCE_ID NUMBER(19,0) NOT NULL PRIMARY KEY ,
+ VERSION NUMBER(19,0) ,
+ JOB_NAME VARCHAR2(100) NOT NULL,
JOB_KEY VARCHAR2(32) NOT NULL,
constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
) ;
CREATE TABLE BATCH_JOB_EXECUTION (
JOB_EXECUTION_ID NUMBER(19,0) NOT NULL PRIMARY KEY ,
- VERSION NUMBER(19,0) ,
+ VERSION NUMBER(19,0) ,
JOB_INSTANCE_ID NUMBER(19,0) NOT NULL,
CREATE_TIME TIMESTAMP NOT NULL,
- START_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP DEFAULT NULL ,
END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR2(10) ,
EXIT_CODE VARCHAR2(100) ,
@@ -22,35 +22,36 @@ CREATE TABLE BATCH_JOB_EXECUTION (
constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
) ;
-
-CREATE TABLE BATCH_JOB_PARAMS (
- JOB_INSTANCE_ID NUMBER(19,0) NOT NULL ,
+
+CREATE TABLE BATCH_JOB_EXECUTION_PARAMS (
+ JOB_EXECUTION_ID NUMBER(19,0) NOT NULL ,
TYPE_CD VARCHAR2(6) NOT NULL ,
- KEY_NAME VARCHAR2(100) NOT NULL ,
- STRING_VAL VARCHAR2(250) ,
+ KEY_NAME VARCHAR2(100) NOT NULL ,
+ STRING_VAL VARCHAR2(250) ,
DATE_VAL TIMESTAMP DEFAULT NULL ,
LONG_VAL NUMBER(19,0) ,
DOUBLE_VAL NUMBER ,
- constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
- references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+ IDENTIFYING CHAR(1) NOT NULL ,
+ constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
-
+
CREATE TABLE BATCH_STEP_EXECUTION (
STEP_EXECUTION_ID NUMBER(19,0) NOT NULL PRIMARY KEY ,
- VERSION NUMBER(19,0) NOT NULL,
+ VERSION NUMBER(19,0) NOT NULL,
STEP_NAME VARCHAR2(100) NOT NULL,
JOB_EXECUTION_ID NUMBER(19,0) NOT NULL,
- START_TIME TIMESTAMP NOT NULL ,
- END_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP NOT NULL ,
+ END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR2(10) ,
- COMMIT_COUNT NUMBER(19,0) ,
+ COMMIT_COUNT NUMBER(19,0) ,
READ_COUNT NUMBER(19,0) ,
FILTER_COUNT NUMBER(19,0) ,
WRITE_COUNT NUMBER(19,0) ,
READ_SKIP_COUNT NUMBER(19,0) ,
WRITE_SKIP_COUNT NUMBER(19,0) ,
PROCESS_SKIP_COUNT NUMBER(19,0) ,
- ROLLBACK_COUNT NUMBER(19,0) ,
+ ROLLBACK_COUNT NUMBER(19,0) ,
EXIT_CODE VARCHAR2(100) ,
EXIT_MESSAGE VARCHAR2(2500) ,
LAST_UPDATED TIMESTAMP,
@@ -61,7 +62,7 @@ CREATE TABLE BATCH_STEP_EXECUTION (
CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
STEP_EXECUTION_ID NUMBER(19,0) NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR2(2500) NOT NULL,
- SERIALIZED_CONTEXT CLOB ,
+ SERIALIZED_CONTEXT CLOB ,
constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
) ;
@@ -69,7 +70,7 @@ CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
JOB_EXECUTION_ID NUMBER(19,0) NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR2(2500) NOT NULL,
- SERIALIZED_CONTEXT CLOB ,
+ SERIALIZED_CONTEXT CLOB ,
constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-postgresql.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-postgresql.sql
index 175dc85cb..82dcb00c0 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-postgresql.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-postgresql.sql
@@ -1,19 +1,19 @@
-- Autogenerated: do not edit this file
CREATE TABLE BATCH_JOB_INSTANCE (
- JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
- JOB_NAME VARCHAR(100) NOT NULL,
+ JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY ,
+ VERSION BIGINT ,
+ JOB_NAME VARCHAR(100) NOT NULL,
JOB_KEY VARCHAR(32) NOT NULL,
constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
) ;
CREATE TABLE BATCH_JOB_EXECUTION (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
+ VERSION BIGINT ,
JOB_INSTANCE_ID BIGINT NOT NULL,
CREATE_TIME TIMESTAMP NOT NULL,
- START_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP DEFAULT NULL ,
END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
EXIT_CODE VARCHAR(100) ,
@@ -22,35 +22,35 @@ CREATE TABLE BATCH_JOB_EXECUTION (
constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
) ;
-
-CREATE TABLE BATCH_JOB_PARAMS (
- JOB_INSTANCE_ID BIGINT NOT NULL ,
+
+CREATE TABLE BATCH_JOB_EXECUTION_PARAMS (
+ JOB_EXECUTION_ID BIGINT NOT NULL ,
TYPE_CD VARCHAR(6) NOT NULL ,
- KEY_NAME VARCHAR(100) NOT NULL ,
- STRING_VAL VARCHAR(250) ,
+ KEY_NAME VARCHAR(100) NOT NULL ,
+ STRING_VAL VARCHAR(250) ,
DATE_VAL TIMESTAMP DEFAULT NULL ,
LONG_VAL BIGINT ,
DOUBLE_VAL DOUBLE PRECISION ,
- constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
- references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+ constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
-
+
CREATE TABLE BATCH_STEP_EXECUTION (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT NOT NULL,
+ VERSION BIGINT NOT NULL,
STEP_NAME VARCHAR(100) NOT NULL,
JOB_EXECUTION_ID BIGINT NOT NULL,
- START_TIME TIMESTAMP NOT NULL ,
- END_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP NOT NULL ,
+ END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
- COMMIT_COUNT BIGINT ,
+ COMMIT_COUNT BIGINT ,
READ_COUNT BIGINT ,
FILTER_COUNT BIGINT ,
WRITE_COUNT BIGINT ,
READ_SKIP_COUNT BIGINT ,
WRITE_SKIP_COUNT BIGINT ,
PROCESS_SKIP_COUNT BIGINT ,
- ROLLBACK_COUNT BIGINT ,
+ ROLLBACK_COUNT BIGINT ,
EXIT_CODE VARCHAR(100) ,
EXIT_MESSAGE VARCHAR(2500) ,
LAST_UPDATED TIMESTAMP,
@@ -61,7 +61,7 @@ CREATE TABLE BATCH_STEP_EXECUTION (
CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT TEXT ,
+ SERIALIZED_CONTEXT TEXT ,
constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
) ;
@@ -69,7 +69,7 @@ CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT TEXT ,
+ SERIALIZED_CONTEXT TEXT ,
constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlf.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlf.sql
index f52f984fe..8794edb69 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlf.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlf.sql
@@ -1,19 +1,19 @@
-- Autogenerated: do not edit this file
CREATE TABLE BATCH_JOB_INSTANCE (
- JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
- VERSION BIGINT ,
- JOB_NAME VARCHAR(100) NOT NULL,
+ JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
+ VERSION BIGINT ,
+ JOB_NAME VARCHAR(100) NOT NULL,
JOB_KEY VARCHAR(32) NOT NULL,
constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
) ;
CREATE TABLE BATCH_JOB_EXECUTION (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
- VERSION BIGINT ,
+ VERSION BIGINT ,
JOB_INSTANCE_ID BIGINT NOT NULL,
CREATE_TIME TIMESTAMP NOT NULL,
- START_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP DEFAULT NULL ,
END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
EXIT_CODE VARCHAR(100) ,
@@ -22,35 +22,36 @@ CREATE TABLE BATCH_JOB_EXECUTION (
constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
) ;
-
-CREATE TABLE BATCH_JOB_PARAMS (
- JOB_INSTANCE_ID BIGINT NOT NULL ,
+
+CREATE TABLE BATCH_JOB_EXECUTION_PARAMS (
+ JOB_EXECUTION_ID BIGINT NOT NULL ,
TYPE_CD VARCHAR(6) NOT NULL ,
- KEY_NAME VARCHAR(100) NOT NULL ,
- STRING_VAL VARCHAR(250) ,
+ KEY_NAME VARCHAR(100) NOT NULL ,
+ STRING_VAL VARCHAR(250) ,
DATE_VAL TIMESTAMP DEFAULT NULL ,
LONG_VAL BIGINT ,
DOUBLE_VAL DOUBLE PRECISION ,
- constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
- references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+ IDENTIFYING CHAR(1) NOT NULL ,
+ constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
-
+
CREATE TABLE BATCH_STEP_EXECUTION (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
- VERSION BIGINT NOT NULL,
+ VERSION BIGINT NOT NULL,
STEP_NAME VARCHAR(100) NOT NULL,
JOB_EXECUTION_ID BIGINT NOT NULL,
- START_TIME TIMESTAMP NOT NULL ,
- END_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP NOT NULL ,
+ END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
- COMMIT_COUNT BIGINT ,
+ COMMIT_COUNT BIGINT ,
READ_COUNT BIGINT ,
FILTER_COUNT BIGINT ,
WRITE_COUNT BIGINT ,
READ_SKIP_COUNT BIGINT ,
WRITE_SKIP_COUNT BIGINT ,
PROCESS_SKIP_COUNT BIGINT ,
- ROLLBACK_COUNT BIGINT ,
+ ROLLBACK_COUNT BIGINT ,
EXIT_CODE VARCHAR(100) ,
EXIT_MESSAGE VARCHAR(2500) ,
LAST_UPDATED TIMESTAMP,
@@ -61,7 +62,7 @@ CREATE TABLE BATCH_STEP_EXECUTION (
CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT CLOB ,
+ SERIALIZED_CONTEXT CLOB ,
constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
) ;
@@ -69,7 +70,7 @@ CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT CLOB ,
+ SERIALIZED_CONTEXT CLOB ,
constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlserver.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlserver.sql
index 31daa0c17..560a304bb 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlserver.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlserver.sql
@@ -1,19 +1,19 @@
-- Autogenerated: do not edit this file
CREATE TABLE BATCH_JOB_INSTANCE (
- JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
- JOB_NAME VARCHAR(100) NOT NULL,
+ JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY ,
+ VERSION BIGINT ,
+ JOB_NAME VARCHAR(100) NOT NULL,
JOB_KEY VARCHAR(32) NOT NULL,
constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
) ;
CREATE TABLE BATCH_JOB_EXECUTION (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
+ VERSION BIGINT ,
JOB_INSTANCE_ID BIGINT NOT NULL,
CREATE_TIME DATETIME NOT NULL,
- START_TIME DATETIME DEFAULT NULL ,
+ START_TIME DATETIME DEFAULT NULL ,
END_TIME DATETIME DEFAULT NULL ,
STATUS VARCHAR(10) ,
EXIT_CODE VARCHAR(100) ,
@@ -22,35 +22,36 @@ CREATE TABLE BATCH_JOB_EXECUTION (
constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
) ;
-
-CREATE TABLE BATCH_JOB_PARAMS (
- JOB_INSTANCE_ID BIGINT NOT NULL ,
+
+CREATE TABLE BATCH_JOB_EXECUTION_PARAMS (
+ JOB_EXECUTION_ID BIGINT NOT NULL ,
TYPE_CD VARCHAR(6) NOT NULL ,
- KEY_NAME VARCHAR(100) NOT NULL ,
- STRING_VAL VARCHAR(250) ,
+ KEY_NAME VARCHAR(100) NOT NULL ,
+ STRING_VAL VARCHAR(250) ,
DATE_VAL DATETIME DEFAULT NULL ,
LONG_VAL BIGINT ,
DOUBLE_VAL DOUBLE PRECISION ,
- constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
- references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+ IDENTIFYING CHAR(1) NOT NULL ,
+ constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
-
+
CREATE TABLE BATCH_STEP_EXECUTION (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT NOT NULL,
+ VERSION BIGINT NOT NULL,
STEP_NAME VARCHAR(100) NOT NULL,
JOB_EXECUTION_ID BIGINT NOT NULL,
- START_TIME DATETIME NOT NULL ,
- END_TIME DATETIME DEFAULT NULL ,
+ START_TIME DATETIME NOT NULL ,
+ END_TIME DATETIME DEFAULT NULL ,
STATUS VARCHAR(10) ,
- COMMIT_COUNT BIGINT ,
+ COMMIT_COUNT BIGINT ,
READ_COUNT BIGINT ,
FILTER_COUNT BIGINT ,
WRITE_COUNT BIGINT ,
READ_SKIP_COUNT BIGINT ,
WRITE_SKIP_COUNT BIGINT ,
PROCESS_SKIP_COUNT BIGINT ,
- ROLLBACK_COUNT BIGINT ,
+ ROLLBACK_COUNT BIGINT ,
EXIT_CODE VARCHAR(100) ,
EXIT_MESSAGE VARCHAR(2500) ,
LAST_UPDATED DATETIME,
@@ -61,7 +62,7 @@ CREATE TABLE BATCH_STEP_EXECUTION (
CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT TEXT ,
+ SERIALIZED_CONTEXT TEXT ,
constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
) ;
@@ -69,7 +70,7 @@ CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT TEXT ,
+ SERIALIZED_CONTEXT TEXT ,
constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sybase.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sybase.sql
index d84ef01a1..6f122e523 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sybase.sql
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sybase.sql
@@ -1,19 +1,19 @@
-- Autogenerated: do not edit this file
CREATE TABLE BATCH_JOB_INSTANCE (
- JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT NULL,
- JOB_NAME VARCHAR(100) NOT NULL,
+ JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY ,
+ VERSION BIGINT NULL,
+ JOB_NAME VARCHAR(100) NOT NULL,
JOB_KEY VARCHAR(32) NOT NULL,
constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
) ;
CREATE TABLE BATCH_JOB_EXECUTION (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT NULL,
+ VERSION BIGINT NULL,
JOB_INSTANCE_ID BIGINT NOT NULL,
CREATE_TIME DATETIME NOT NULL,
- START_TIME DATETIME DEFAULT NULL NULL,
+ START_TIME DATETIME DEFAULT NULL NULL,
END_TIME DATETIME DEFAULT NULL NULL,
STATUS VARCHAR(10) NULL,
EXIT_CODE VARCHAR(100) NULL,
@@ -22,35 +22,36 @@ CREATE TABLE BATCH_JOB_EXECUTION (
constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
) ;
-
-CREATE TABLE BATCH_JOB_PARAMS (
- JOB_INSTANCE_ID BIGINT NOT NULL ,
+
+CREATE TABLE BATCH_JOB_EXECUTION_PARAMS (
+ JOB_EXECUTION_ID BIGINT NOT NULL ,
TYPE_CD VARCHAR(6) NOT NULL ,
- KEY_NAME VARCHAR(100) NOT NULL ,
- STRING_VAL VARCHAR(250) NULL,
+ KEY_NAME VARCHAR(100) NOT NULL ,
+ STRING_VAL VARCHAR(250) NULL,
DATE_VAL DATETIME DEFAULT NULL NULL,
LONG_VAL BIGINT NULL,
DOUBLE_VAL DOUBLE PRECISION NULL,
- constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
- references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
+ IDENTIFYING CHAR(1) NOT NULL ,
+ constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID)
+ references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
-
+
CREATE TABLE BATCH_STEP_EXECUTION (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
- VERSION BIGINT NOT NULL,
+ VERSION BIGINT NOT NULL,
STEP_NAME VARCHAR(100) NOT NULL,
JOB_EXECUTION_ID BIGINT NOT NULL,
- START_TIME DATETIME NOT NULL ,
- END_TIME DATETIME DEFAULT NULL NULL,
+ START_TIME DATETIME NOT NULL ,
+ END_TIME DATETIME DEFAULT NULL NULL,
STATUS VARCHAR(10) NULL,
- COMMIT_COUNT BIGINT NULL,
+ COMMIT_COUNT BIGINT NULL,
READ_COUNT BIGINT NULL,
FILTER_COUNT BIGINT NULL,
WRITE_COUNT BIGINT NULL,
READ_SKIP_COUNT BIGINT NULL,
WRITE_SKIP_COUNT BIGINT NULL,
PROCESS_SKIP_COUNT BIGINT NULL,
- ROLLBACK_COUNT BIGINT NULL,
+ ROLLBACK_COUNT BIGINT NULL,
EXIT_CODE VARCHAR(100) NULL,
EXIT_MESSAGE VARCHAR(2500) NULL,
LAST_UPDATED DATETIME,
@@ -61,7 +62,7 @@ CREATE TABLE BATCH_STEP_EXECUTION (
CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT TEXT NULL,
+ SERIALIZED_CONTEXT TEXT NULL,
constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
) ;
@@ -69,7 +70,7 @@ CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT TEXT NULL,
+ SERIALIZED_CONTEXT TEXT NULL,
constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/DefaultJobKeyGeneratorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/DefaultJobKeyGeneratorTests.java
new file mode 100644
index 000000000..cdca6355b
--- /dev/null
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/DefaultJobKeyGeneratorTests.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2013-2013 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.core;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class DefaultJobKeyGeneratorTests {
+
+ private JobKeyGenerator jobKeyGenerator;
+
+ @Before
+ public void setUp() throws Exception {
+ jobKeyGenerator = new DefaultJobKeyGenerator();
+ }
+
+ @Test
+ public void testMixedParameters() {
+ JobParameters jobParameters1 = new JobParametersBuilder().addString(
+ "foo", "bar").addString("bar", "foo").toJobParameters();
+ JobParameters jobParameters2 = new JobParametersBuilder().addString(
+ "foo", "bar", true).addString("bar", "foo", true)
+ .addString("ignoreMe", "irrelivant", false).toJobParameters();
+ String key1 = jobKeyGenerator.generateKey(jobParameters1);
+ String key2 = jobKeyGenerator.generateKey(jobParameters2);
+ assertEquals(key1, key2);
+ }
+
+ @Test
+ public void testCreateJobKey() {
+ JobParameters jobParameters = new JobParametersBuilder().addString(
+ "foo", "bar").addString("bar", "foo").toJobParameters();
+ String key = jobKeyGenerator.generateKey(jobParameters);
+ assertEquals(32, key.length());
+ }
+
+ @Test
+ public void testCreateJobKeyWithNullParameter() {
+ JobParameters jobParameters1 = new JobParametersBuilder().addString(
+ "foo", "bar").addString("bar", null).toJobParameters();
+ JobParameters jobParameters2 = new JobParametersBuilder().addString(
+ "foo", "bar").addString("bar", "").toJobParameters();
+ String key1 = jobKeyGenerator.generateKey(jobParameters1);
+ String key2 = jobKeyGenerator.generateKey(jobParameters2);
+ assertEquals(key1, key2);
+ }
+
+ @Test
+ public void testCreateJobKeyOrdering() {
+ JobParameters jobParameters1 = new JobParametersBuilder().addString(
+ "foo", "bar").addString("bar", "foo").toJobParameters();
+ String key1 = jobKeyGenerator.generateKey(jobParameters1);
+ JobParameters jobParameters2 = new JobParametersBuilder().addString(
+ "bar", "foo").addString("foo", "bar").toJobParameters();
+ String key2 = jobKeyGenerator.generateKey(jobParameters2);
+ assertEquals(key1, key2);
+ }
+}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java
index e2dbefc34..76cc1c64b 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java
@@ -30,16 +30,16 @@ import org.springframework.batch.support.SerializationUtils;
/**
* @author Dave Syer
- *
+ *
*/
public class JobExecutionTests {
- private JobExecution execution = new JobExecution(new JobInstance(new Long(11), new JobParameters(), "foo"),
- new Long(12));
+ private JobExecution execution = new JobExecution(new JobInstance(new Long(11), "foo"),
+ new Long(12), new JobParameters());
@Test
public void testJobExecution() {
- assertNull(new JobExecution(new JobInstance(null, null, "foo")).getId());
+ assertNull(new JobExecution(new JobInstance(null, "foo"), null).getId());
}
/**
@@ -126,7 +126,7 @@ public class JobExecutionTests {
@Test
public void testGetJobId() {
assertEquals(11, execution.getJobId().longValue());
- execution = new JobExecution(new JobInstance(new Long(23), new JobParameters(), "testJob"), null);
+ execution = new JobExecution(new JobInstance(new Long(23), "testJob"), null, new JobParameters());
assertEquals(23, execution.getJobId().longValue());
}
@@ -136,7 +136,7 @@ public class JobExecutionTests {
*/
@Test
public void testGetJobIdForNullJob() {
- execution = new JobExecution(null, null);
+ execution = new JobExecution((JobInstance) null, (JobParameters) null);
assertEquals(null, execution.getJobId());
}
@@ -213,7 +213,7 @@ public class JobExecutionTests {
@Test
public void testToStringWithNullJob() throws Exception {
- execution = new JobExecution(new JobInstance(null, null, "foo"));
+ execution = new JobExecution(new JobInstance(null, "foo"), null);
assertTrue("JobExecution string does not contain id", execution.toString().indexOf("id=") >= 0);
assertTrue("JobExecution string does not contain job: " + execution, execution.toString().indexOf("job=") >= 0);
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java
index a1c9d504a..c3a1ac594 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java
@@ -21,18 +21,18 @@ import org.springframework.batch.support.SerializationUtils;
/**
* @author dsyer
- *
+ *
*/
public class JobInstanceTests extends TestCase {
- private JobInstance instance = new JobInstance(new Long(11), new JobParameters(), "job");
+ private JobInstance instance = new JobInstance(new Long(11), "job");
/**
* Test method for
* {@link org.springframework.batch.core.JobInstance#getJobName()}.
*/
public void testGetName() {
- instance = new JobInstance(new Long(1), new JobParameters(), "foo");
+ instance = new JobInstance(new Long(1), "foo");
assertEquals("foo", instance.getJobName());
}
@@ -42,24 +42,21 @@ public class JobInstanceTests extends TestCase {
public void testCreateWithNulls() {
try {
- new JobInstance(null, null, null);
+ new JobInstance(null, null);
fail("job instance can't exist without job specified");
}
catch (IllegalArgumentException e) {
// expected
}
- instance = new JobInstance(null, null, "testJob");
+ instance = new JobInstance(null, "testJob");
assertEquals("testJob", instance.getJobName());
- assertEquals(0, instance.getJobParameters().getParameters().size());
}
public void testSerialization() {
- instance = new JobInstance(new Long(1), new JobParametersBuilder().addDouble("doubleKey", Double.valueOf(5.1))
- .toJobParameters(), "jobName");
-
- byte[] serialized = SerializationUtils.serialize(instance);
-
- assertEquals(instance, SerializationUtils.deserialize(serialized));
+ instance = new JobInstance(new Long(1), "jobName");
+ byte[] serialized = SerializationUtils.serialize(instance);
+
+ assertEquals(instance, SerializationUtils.deserialize(serialized));
}
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParameterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParameterTests.java
index f06aadaa9..1baca9168 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParameterTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParameterTests.java
@@ -1,9 +1,11 @@
/**
- *
+ *
*/
package org.springframework.batch.core;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.util.Date;
@@ -16,84 +18,84 @@ import org.junit.Test;
public class JobParameterTests {
JobParameter jobParameter;
-
+
@Test
public void testStringParameter(){
- jobParameter = new JobParameter("test");
+ jobParameter = new JobParameter("test", true);
assertEquals("test", jobParameter.getValue());
}
-
+
@Test
public void testNullStringParameter(){
- jobParameter = new JobParameter((String)null);
+ jobParameter = new JobParameter((String)null, true);
assertEquals(null, jobParameter.getValue());
}
-
+
@Test
public void testLongParameter(){
- jobParameter = new JobParameter(1L);
+ jobParameter = new JobParameter(1L, true);
assertEquals(1L, jobParameter.getValue());
}
-
+
@Test
public void testDoubleParameter(){
- jobParameter = new JobParameter(1.1);
+ jobParameter = new JobParameter(1.1, true);
assertEquals(1.1, jobParameter.getValue());
}
-
+
@Test
public void testDateParameter(){
Date epoch = new Date(0L);
- jobParameter = new JobParameter(epoch);
+ jobParameter = new JobParameter(epoch, true);
assertEquals(new Date(0L), jobParameter.getValue());
}
-
+
@Test
public void testNullDateParameter(){
- jobParameter = new JobParameter((Date)null);
+ jobParameter = new JobParameter((Date)null, true);
assertEquals(null, jobParameter.getValue());
}
-
+
@Test
public void testDateParameterToString(){
Date epoch = new Date(0L);
- jobParameter = new JobParameter(epoch);
+ jobParameter = new JobParameter(epoch, true);
assertEquals("0", jobParameter.toString());
}
-
+
@Test
public void testEquals(){
- jobParameter = new JobParameter("test");
- JobParameter testParameter = new JobParameter("test");
+ jobParameter = new JobParameter("test", true);
+ JobParameter testParameter = new JobParameter("test", true);
assertTrue(jobParameter.equals(testParameter));
}
-
+
@Test
public void testHashcode(){
- jobParameter = new JobParameter("test");
- JobParameter testParameter = new JobParameter("test");
+ jobParameter = new JobParameter("test", true);
+ JobParameter testParameter = new JobParameter("test", true);
assertEquals(testParameter.hashCode(), jobParameter.hashCode());
}
-
+
@Test
public void testEqualsWithNull(){
- jobParameter = new JobParameter((String)null);
- JobParameter testParameter = new JobParameter((String)null);
+ jobParameter = new JobParameter((String)null, true);
+ JobParameter testParameter = new JobParameter((String)null, true);
assertTrue(jobParameter.equals(testParameter));
}
@Test
public void testEqualsWithNullAndDifferentType(){
- jobParameter = new JobParameter((String)null);
- JobParameter testParameter = new JobParameter((Date)null);
+ jobParameter = new JobParameter((String)null, true);
+ JobParameter testParameter = new JobParameter((Date)null, true);
assertFalse(jobParameter.equals(testParameter));
}
@Test
public void testHashcodeWithNull(){
- jobParameter = new JobParameter((String)null);
- JobParameter testParameter = new JobParameter((String)null);
+ jobParameter = new JobParameter((String)null, true);
+ JobParameter testParameter = new JobParameter((String)null, true);
assertEquals(testParameter.hashCode(), jobParameter.hashCode());
}
-
+
}
\ No newline at end of file
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java
index be16ee3c6..6cbecb515 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java
@@ -1,25 +1,43 @@
/**
- *
+ *
*/
package org.springframework.batch.core;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* @author Lucas Ward
*
*/
-public class JobParametersBuilderTests extends TestCase {
+public class JobParametersBuilderTests {
JobParametersBuilder parametersBuilder = new JobParametersBuilder();
-
+
Date date = new Date(System.currentTimeMillis());
-
- public void testToJobRuntimeParamters(){
+
+ @Test
+ public void testNonIdentifyingParameters() {
+ parametersBuilder.addDate("SCHEDULE_DATE", date, false);
+ parametersBuilder.addLong("LONG", new Long(1), false);
+ parametersBuilder.addString("STRING", "string value", false);
+ JobParameters parameters = parametersBuilder.toJobParameters();
+ assertEquals(date, parameters.getDate("SCHEDULE_DATE"));
+ assertEquals(1L, parameters.getLong("LONG"));
+ assertEquals("string value", parameters.getString("STRING"));
+ assertFalse(parameters.getParameters().get("SCHEDULE_DATE").isIdentifying());
+ assertFalse(parameters.getParameters().get("LONG").isIdentifying());
+ assertFalse(parameters.getParameters().get("STRING").isIdentifying());
+ }
+
+ @Test
+ public void testToJobRuntimeParamters(){
parametersBuilder.addDate("SCHEDULE_DATE", date);
parametersBuilder.addLong("LONG", new Long(1));
parametersBuilder.addString("STRING", "string value");
@@ -29,7 +47,8 @@ public class JobParametersBuilderTests extends TestCase {
assertEquals("string value", parameters.getString("STRING"));
}
- public void testNullRuntimeParamters(){
+ @Test
+ public void testNullRuntimeParamters(){
parametersBuilder.addDate("SCHEDULE_DATE", null);
parametersBuilder.addLong("LONG", null);
parametersBuilder.addString("STRING", null);
@@ -39,14 +58,16 @@ public class JobParametersBuilderTests extends TestCase {
assertEquals(null, parameters.getString("STRING"));
}
- public void testCopy(){
+ @Test
+ public void testCopy(){
parametersBuilder.addString("STRING", "string value");
parametersBuilder = new JobParametersBuilder(parametersBuilder.toJobParameters());
Iterator parameters = parametersBuilder.toJobParameters().getParameters().keySet().iterator();
assertEquals("STRING", parameters.next());
}
- public void testOrderedTypes(){
+ @Test
+ public void testOrderedTypes(){
parametersBuilder.addDate("SCHEDULE_DATE", date);
parametersBuilder.addLong("LONG", new Long(1));
parametersBuilder.addString("STRING", "string value");
@@ -56,7 +77,8 @@ public class JobParametersBuilderTests extends TestCase {
assertEquals("STRING", parameters.next());
}
- public void testOrderedStrings(){
+ @Test
+ public void testOrderedStrings(){
parametersBuilder.addString("foo", "value foo");
parametersBuilder.addString("bar", "value bar");
parametersBuilder.addString("spam", "value spam");
@@ -65,7 +87,8 @@ public class JobParametersBuilderTests extends TestCase {
assertEquals("bar", parameters.next());
assertEquals("spam", parameters.next());
}
-
+
+ @Test
public void testAddJobParameter(){
JobParameter jobParameter = new JobParameter("bar");
parametersBuilder.addParameter("foo", jobParameter);
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java
index 8addd3760..87c8f2057 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java
@@ -1,9 +1,12 @@
/**
- *
+ *
*/
package org.springframework.batch.core;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.util.Collections;
import java.util.Date;
@@ -18,7 +21,7 @@ import org.springframework.batch.support.SerializationUtils;
/**
* @author Lucas Ward
* @author Dave Syer
- *
+ *
*/
public class JobParametersTests {
@@ -36,14 +39,14 @@ public class JobParametersTests {
private JobParameters getNewParameters() {
Map parameterMap = new HashMap();
- parameterMap.put("string.key1", new JobParameter("value1"));
- parameterMap.put("string.key2", new JobParameter("value2"));
- parameterMap.put("long.key1", new JobParameter(1L));
- parameterMap.put("long.key2", new JobParameter(2L));
- parameterMap.put("double.key1", new JobParameter(1.1));
- parameterMap.put("double.key2", new JobParameter(2.2));
- parameterMap.put("date.key1", new JobParameter(date1));
- parameterMap.put("date.key2", new JobParameter(date2));
+ parameterMap.put("string.key1", new JobParameter("value1", true));
+ parameterMap.put("string.key2", new JobParameter("value2", true));
+ parameterMap.put("long.key1", new JobParameter(1L, true));
+ parameterMap.put("long.key2", new JobParameter(2L, true));
+ parameterMap.put("double.key1", new JobParameter(1.1, true));
+ parameterMap.put("double.key2", new JobParameter(2.2, true));
+ parameterMap.put("date.key1", new JobParameter(date1, true));
+ parameterMap.put("date.key2", new JobParameter(date2, true));
return new JobParameters(parameterMap);
}
@@ -57,7 +60,7 @@ public class JobParametersTests {
@Test
public void testGetNullString() {
- parameters = new JobParameters(Collections.singletonMap("string.key1", new JobParameter((String)null)));
+ parameters = new JobParameters(Collections.singletonMap("string.key1", new JobParameter((String) null, true)));
assertEquals(null, parameters.getDate("string.key1"));
}
@@ -81,13 +84,13 @@ public class JobParametersTests {
@Test
public void testGetNullDate() {
- parameters = new JobParameters(Collections.singletonMap("date.key1", new JobParameter((Date)null)));
+ parameters = new JobParameters(Collections.singletonMap("date.key1", new JobParameter((Date)null, true)));
assertEquals(null, parameters.getDate("date.key1"));
}
@Test
public void testGetEmptyLong() {
- parameters = new JobParameters(Collections.singletonMap("long1", new JobParameter((Long)null)));
+ parameters = new JobParameters(Collections.singletonMap("long1", new JobParameter((Long)null, true)));
assertEquals(0L, parameters.getLong("long1"));
}
@@ -149,15 +152,15 @@ public class JobParametersTests {
String string1 = stringBuilder.toString();
Map parameterMap = new HashMap();
- parameterMap.put("string.key2", new JobParameter("value2"));
- parameterMap.put("string.key1", new JobParameter("value1"));
- parameterMap.put("long.key2", new JobParameter(2L));
- parameterMap.put("long.key1", new JobParameter(1L));
- parameterMap.put("double.key2", new JobParameter(2.2));
- parameterMap.put("double.key1", new JobParameter(1.1));
- parameterMap.put("date.key2", new JobParameter(date2));
- parameterMap.put("date.key1", new JobParameter(date1));
-
+ parameterMap.put("string.key2", new JobParameter("value2", true));
+ parameterMap.put("string.key1", new JobParameter("value1", true));
+ parameterMap.put("long.key2", new JobParameter(2L, true));
+ parameterMap.put("long.key1", new JobParameter(1L, true));
+ parameterMap.put("double.key2", new JobParameter(2.2, true));
+ parameterMap.put("double.key1", new JobParameter(1.1, true));
+ parameterMap.put("date.key2", new JobParameter(date2, true));
+ parameterMap.put("date.key1", new JobParameter(date1, true));
+
JobParameters testProps = new JobParameters(parameterMap);
props = testProps.getParameters();
@@ -187,28 +190,28 @@ public class JobParametersTests {
JobParameters params = getNewParameters();
byte[] serialized =
- SerializationUtils.serialize(params);
+ SerializationUtils.serialize(params);
assertEquals(params, SerializationUtils.deserialize(serialized));
}
-
- @Test
- public void testLongReturns0WhenKeyDoesntExit(){
- assertEquals(0L,new JobParameters().getLong("keythatdoesntexist"));
- }
- @Test
- public void testStringReturnsNullWhenKeyDoesntExit(){
- assertNull(new JobParameters().getString("keythatdoesntexist"));
- }
+ @Test
+ public void testLongReturns0WhenKeyDoesntExit(){
+ assertEquals(0L,new JobParameters().getLong("keythatdoesntexist"));
+ }
- @Test
- public void testDoubleReturns0WhenKeyDoesntExit(){
- assertEquals(0.0,new JobParameters().getLong("keythatdoesntexist"), 0.0001);
- }
+ @Test
+ public void testStringReturnsNullWhenKeyDoesntExit(){
+ assertNull(new JobParameters().getString("keythatdoesntexist"));
+ }
- @Test
- public void testDateReturnsNullWhenKeyDoesntExit(){
- assertNull(new JobParameters().getDate("keythatdoesntexist"));
- }
+ @Test
+ public void testDoubleReturns0WhenKeyDoesntExit(){
+ assertEquals(0.0,new JobParameters().getLong("keythatdoesntexist"), 0.0001);
+ }
+
+ @Test
+ public void testDateReturnsNullWhenKeyDoesntExit(){
+ assertNull(new JobParameters().getDate("keythatdoesntexist"));
+ }
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java
index 87c294f69..043e60860 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java
@@ -34,17 +34,17 @@ import org.springframework.batch.support.SerializationUtils;
/**
* @author Dave Syer
- *
+ *
*/
public class StepExecutionTests {
private StepExecution execution = newStepExecution(new StepSupport("stepName"), new Long(23));
private StepExecution blankExecution = newStepExecution(new StepSupport("blank"), null);
-
+
private ExecutionContext foobarEc = new ExecutionContext();
-
-
+
+
@Before
public void setUp() throws Exception {
@@ -58,7 +58,7 @@ public class StepExecutionTests {
@Test
public void testStepExecutionWithNullId() {
- assertNull(new StepExecution("stepName", new JobExecution(new JobInstance(null,null,"foo"))).getId());
+ assertNull(new StepExecution("stepName", new JobExecution(new JobInstance(null,"foo"), null)).getId());
}
/**
@@ -161,7 +161,7 @@ public class StepExecutionTests {
@Test
public void testNullNameIsIllegal() throws Exception {
try {
- new StepExecution(null, new JobExecution(new JobInstance(null, null, "job")));
+ new StepExecution(null, new JobExecution(new JobInstance(null, "job"), null));
fail();
}
catch (IllegalArgumentException e) {
@@ -262,25 +262,25 @@ public class StepExecutionTests {
execution.setExecutionContext(foobarEc);
assertTrue(set.contains(execution));
}
-
+
@Test
public void testSerialization() throws Exception {
-
+
ExitStatus status = ExitStatus.NOOP;
execution.setExitStatus(status);
execution.setExecutionContext(foobarEc);
-
+
byte[] serialized = SerializationUtils.serialize(execution);
StepExecution deserialized = (StepExecution) SerializationUtils.deserialize(serialized);
-
+
assertEquals(execution, deserialized);
assertEquals(status, deserialized.getExitStatus());
assertNotNull(deserialized.getFailureExceptions());
}
-
+
@Test
public void testAddException() throws Exception{
-
+
RuntimeException exception = new RuntimeException();
assertEquals(0, execution.getFailureExceptions().size());
execution.addFailureException(exception);
@@ -302,10 +302,10 @@ public class StepExecutionTests {
private StepExecution newStepExecution(Step step, Long jobExecutionId) {
return newStepExecution(step, jobExecutionId, 4);
}
-
+
private StepExecution newStepExecution(Step step, Long jobExecutionId, long stepExecutionId) {
- JobInstance job = new JobInstance(3L, new JobParameters(), "testJob");
- StepExecution execution = new StepExecution(step.getName(), new JobExecution(job, jobExecutionId), stepExecutionId);
+ JobInstance job = new JobInstance(3L, "testJob");
+ StepExecution execution = new StepExecution(step.getName(), new JobExecution(job, jobExecutionId, new JobParameters()), stepExecutionId);
return execution;
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobStepParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobStepParserTests.java
index 53ca66e35..443b25dd6 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobStepParserTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobStepParserTests.java
@@ -44,7 +44,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class JobStepParserTests {
-
+
@Autowired
@Qualifier("job1")
private Job job1;
@@ -58,7 +58,7 @@ public class JobStepParserTests {
@Autowired
private MapJobRepositoryFactoryBean mapJobRepositoryFactoryBean;
-
+
@Before
public void setUp() {
mapJobRepositoryFactoryBean.clear();
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/converter/DefaultJobParametersConverterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/converter/DefaultJobParametersConverterTests.java
index 6d8aa1397..e37054ee6 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/converter/DefaultJobParametersConverterTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/converter/DefaultJobParametersConverterTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2008 the original author or authors.
+ * Copyright 2006-2013 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.
@@ -16,6 +16,7 @@
package org.springframework.batch.core.converter;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -34,7 +35,8 @@ import org.springframework.util.StringUtils;
/**
* @author Dave Syer
- *
+ * @author Michael Minella
+ *
*/
public class DefaultJobParametersConverterTests {
@@ -42,6 +44,66 @@ public class DefaultJobParametersConverterTests {
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
+ @Test
+ public void testGetParametersIdentifyingWithIdentifyingKey() throws Exception {
+ String jobKey = "+job.key=myKey";
+ String scheduleDate = "+schedule.date(date)=2008/01/23";
+ String vendorId = "+vendor.id(long)=33243243";
+
+ String[] args = new String[] { jobKey, scheduleDate, vendorId };
+
+ JobParameters props = factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
+ assertNotNull(props);
+ assertTrue(props.getParameters().get("job.key").isIdentifying());
+ assertTrue(props.getParameters().get("schedule.date").isIdentifying());
+ assertTrue(props.getParameters().get("vendor.id").isIdentifying());
+ }
+
+ @Test
+ public void testGetParametersIdentifyingByDefault() throws Exception {
+ String jobKey = "job.key=myKey";
+ String scheduleDate = "schedule.date(date)=2008/01/23";
+ String vendorId = "vendor.id(long)=33243243";
+
+ String[] args = new String[] { jobKey, scheduleDate, vendorId };
+
+ JobParameters props = factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
+ assertNotNull(props);
+ assertTrue(props.getParameters().get("job.key").isIdentifying());
+ assertTrue(props.getParameters().get("schedule.date").isIdentifying());
+ assertTrue(props.getParameters().get("vendor.id").isIdentifying());
+ }
+
+ @Test
+ public void testGetParametersNonIdentifying() throws Exception {
+ String jobKey = "-job.key=myKey";
+ String scheduleDate = "-schedule.date(date)=2008/01/23";
+ String vendorId = "-vendor.id(long)=33243243";
+
+ String[] args = new String[] { jobKey, scheduleDate, vendorId };
+
+ JobParameters props = factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
+ assertNotNull(props);
+ assertFalse(props.getParameters().get("job.key").isIdentifying());
+ assertFalse(props.getParameters().get("schedule.date").isIdentifying());
+ assertFalse(props.getParameters().get("vendor.id").isIdentifying());
+ }
+
+ @Test
+ public void testGetParametersMixed() throws Exception {
+ String jobKey = "+job.key=myKey";
+ String scheduleDate = "schedule.date(date)=2008/01/23";
+ String vendorId = "-vendor.id(long)=33243243";
+
+ String[] args = new String[] { jobKey, scheduleDate, vendorId };
+
+ JobParameters props = factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
+ assertNotNull(props);
+ assertTrue(props.getParameters().get("job.key").isIdentifying());
+ assertTrue(props.getParameters().get("schedule.date").isIdentifying());
+ assertFalse(props.getParameters().get("vendor.id").isIdentifying());
+ }
+
@Test
public void testGetParameters() throws Exception {
@@ -206,7 +268,7 @@ public class DefaultJobParametersConverterTests {
public void testRoundTrip() throws Exception {
String[] args = new String[] { "schedule.date(date)=2008/01/23", "job.key=myKey", "vendor.id(long)=33243243",
- "double.key(double)=1.23" };
+ "double.key(double)=1.23" };
JobParameters parameters = factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
@@ -222,7 +284,7 @@ public class DefaultJobParametersConverterTests {
public void testRoundTripWithNumberFormat() throws Exception {
String[] args = new String[] { "schedule.date(date)=2008/01/23", "job.key=myKey", "vendor.id(long)=33243243",
- "double.key(double)=1,23" };
+ "double.key(double)=1,23" };
NumberFormat format = NumberFormat.getInstance(Locale.GERMAN);
factory.setNumberFormat(format);
@@ -252,21 +314,21 @@ public class DefaultJobParametersConverterTests {
private boolean contains(String str, String searchStr) {
return str.indexOf(searchStr) != -1;
}
-
+
@Test
public void testGetPropertiesWithNullValues() throws Exception {
-
+
JobParameters parameters = new JobParametersBuilder().addDate("schedule.date", null)
.addString("job.key", null).addLong("vendor.id", null).addDouble("double.key", null)
.toJobParameters();
-
+
Properties props = factory.getProperties(parameters);
assertNotNull(props);
-
+
final String NOT_FOUND = "NOT FOUND";
- assertEquals(NOT_FOUND, props.getProperty("schedule.date", NOT_FOUND));
- assertEquals(NOT_FOUND, props.getProperty("job.key", NOT_FOUND));
- assertEquals(NOT_FOUND, props.getProperty("vendor.id", NOT_FOUND));
- assertEquals(NOT_FOUND, props.getProperty("double.key", NOT_FOUND));
+ assertEquals(NOT_FOUND, props.getProperty("schedule.date", NOT_FOUND));
+ assertEquals(NOT_FOUND, props.getProperty("job.key", NOT_FOUND));
+ assertEquals(NOT_FOUND, props.getProperty("vendor.id", NOT_FOUND));
+ assertEquals(NOT_FOUND, props.getProperty("double.key", NOT_FOUND));
}
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/SimpleJobExplorerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/SimpleJobExplorerTests.java
index 7a37409e8..69f1fed6e 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/SimpleJobExplorerTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/SimpleJobExplorerTests.java
@@ -39,9 +39,9 @@ import org.springframework.batch.core.repository.dao.StepExecutionDao;
/**
* Test {@link SimpleJobExplorer}.
- *
+ *
* @author Dave Syer
- *
+ *
*/
public class SimpleJobExplorerTests {
@@ -53,12 +53,11 @@ public class SimpleJobExplorerTests {
private StepExecutionDao stepExecutionDao;
- private JobInstance jobInstance = new JobInstance(111L,
- new JobParameters(), "job");
+ private JobInstance jobInstance = new JobInstance(111L, "job");
private ExecutionContextDao ecDao;
- private JobExecution jobExecution = new JobExecution(jobInstance, 1234L);
+ private JobExecution jobExecution = new JobExecution(jobInstance, 1234L, new JobParameters());
@Before
public void setUp() throws Exception {
@@ -98,7 +97,7 @@ public class SimpleJobExplorerTests {
expect(jobExecutionDao.getJobExecution(jobExecution.getId())).andReturn(jobExecution);
StepExecution stepExecution = jobExecution.createStepExecution("foo");
expect(stepExecutionDao.getStepExecution(jobExecution, 123L))
- .andReturn(stepExecution);
+ .andReturn(stepExecution);
expect(ecDao.getExecutionContext(stepExecution)).andReturn(null);
expectLastCall();
replay(jobExecutionDao, stepExecutionDao, ecDao);
@@ -111,7 +110,7 @@ public class SimpleJobExplorerTests {
expect(jobExecutionDao.getJobExecution(jobExecution.getId())).andReturn(jobExecution);
expectLastCall();
expect(stepExecutionDao.getStepExecution(jobExecution, 123L))
- .andReturn(null);
+ .andReturn(null);
replay(jobExecutionDao, stepExecutionDao, ecDao);
assertNull(jobExplorer.getStepExecution(jobExecution.getId(), 123L));
verify(jobExecutionDao, stepExecutionDao, ecDao);
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobLauncherIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobLauncherIntegrationTests.java
index 4410146aa..e1c255bf2 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobLauncherIntegrationTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobLauncherIntegrationTests.java
@@ -10,9 +10,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
-import org.springframework.batch.core.JobInstance;
+import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
-import org.springframework.batch.core.repository.dao.JdbcJobInstanceDao;
+import org.springframework.batch.core.repository.dao.JdbcJobExecutionDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
@@ -34,37 +34,40 @@ public class JobLauncherIntegrationTests {
public void setDataSource(DataSource dataSource) {
jdbcTemplate = new JdbcTemplate(dataSource);
}
-
+
@Test
public void testLaunchAndRelaunch() throws Exception {
-
+
int before = jdbcTemplate.queryForInt("select count(*) from BATCH_JOB_INSTANCE");
-
+
JobExecution jobExecution = launch(true,0);
- launch(false, jobExecution.getJobId());
- launch(false, jobExecution.getJobId());
+ launch(false, jobExecution.getId());
+ launch(false, jobExecution.getId());
int after = jdbcTemplate.queryForInt("select count(*) from BATCH_JOB_INSTANCE");
assertEquals(before+1, after);
}
- private JobExecution launch(boolean start, long jobInstanceID) throws Exception {
+ private JobExecution launch(boolean start, long jobExecutionId) throws Exception {
if (start) {
Calendar c = Calendar.getInstance();
JobParametersBuilder builder = new JobParametersBuilder();
builder.addDate("TIMESTAMP", c.getTime());
- return jobLauncher.run(job, builder.toJobParameters());
+ JobParameters jobParameters = builder.toJobParameters();
+
+ return jobLauncher.run(job, jobParameters);
} else {
- JdbcJobInstanceDao dao = new JdbcJobInstanceDao();
+ JdbcJobExecutionDao dao = new JdbcJobExecutionDao();
dao.setJdbcTemplate(jdbcTemplate);
- JobInstance instance = dao.getJobInstance(jobInstanceID);
- if (instance != null) {
- return jobLauncher.run(job, instance.getJobParameters());
+ JobExecution execution = dao.getJobExecution(jobExecutionId);
+
+ if (execution != null) {
+ return jobLauncher.run(job, execution.getJobParameters());
}
return null;
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java
index d53681e01..12444370b 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java
@@ -116,9 +116,9 @@ public class SimpleJobLauncherTests {
testRun();
reset(jobRepository);
expect(jobRepository.getLastJobExecution(job.getName(), jobParameters)).andReturn(
- new JobExecution(new JobInstance(1L, jobParameters, job.getName())));
+ new JobExecution(new JobInstance(1L, job.getName()), jobParameters));
expect(jobRepository.createJobExecution(job.getName(), jobParameters)).andReturn(
- new JobExecution(new JobInstance(1L, jobParameters, job.getName())));
+ new JobExecution(new JobInstance(1L, job.getName()), jobParameters));
replay(jobRepository);
jobLauncher.run(job, jobParameters);
verify(jobRepository);
@@ -147,7 +147,7 @@ public class SimpleJobLauncherTests {
try {
reset(jobRepository);
expect(jobRepository.getLastJobExecution(job.getName(), jobParameters)).andReturn(
- new JobExecution(new JobInstance(1L, jobParameters, job.getName())));
+ new JobExecution(new JobInstance(1L, job.getName()), jobParameters));
replay(jobRepository);
jobLauncher.run(job, jobParameters);
fail("Expected JobRestartException");
@@ -184,7 +184,7 @@ public class SimpleJobLauncherTests {
}
});
- JobExecution jobExecution = new JobExecution(null, null);
+ JobExecution jobExecution = new JobExecution((JobInstance) null, (JobParameters) null);
expect(jobRepository.getLastJobExecution(job.getName(), jobParameters)).andReturn(null);
expect(jobRepository.createJobExecution(job.getName(), jobParameters)).andReturn(jobExecution);
@@ -263,7 +263,7 @@ public class SimpleJobLauncherTests {
}
private void run(ExitStatus exitStatus) throws Exception {
- JobExecution jobExecution = new JobExecution(null, null);
+ JobExecution jobExecution = new JobExecution((JobInstance) null, (JobParameters) null);
expect(jobRepository.getLastJobExecution(job.getName(), jobParameters)).andReturn(null);
expect(jobRepository.createJobExecution(job.getName(), jobParameters)).andReturn(jobExecution);
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java
index f9f328054..7e2a85e38 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java
@@ -69,7 +69,7 @@ public class CommandLineJobRunnerTests {
@Before
public void setUp() throws Exception {
- JobExecution jobExecution = new JobExecution(null, new Long(1));
+ JobExecution jobExecution = new JobExecution(null, new Long(1), null);
ExitStatus exitStatus = ExitStatus.COMPLETED;
jobExecution.setExitStatus(exitStatus);
StubJobLauncher.jobExecution = jobExecution;
@@ -213,8 +213,7 @@ public class CommandLineJobRunnerTests {
@Test
public void testStop() throws Throwable {
String[] args = new String[] { jobPath, "-stop", jobName };
- JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(3L, jobParameters, jobName));
+ StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(3L, jobName));
CommandLineJobRunner.main(args);
assertEquals(0, StubSystemExiter.status);
}
@@ -222,8 +221,7 @@ public class CommandLineJobRunnerTests {
@Test
public void testStopFailed() throws Throwable {
String[] args = new String[] { jobPath, "-stop", jobName };
- JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(0L, jobParameters, jobName));
+ StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(0L, jobName));
CommandLineJobRunner.main(args);
assertEquals(1, StubSystemExiter.status);
}
@@ -231,8 +229,7 @@ public class CommandLineJobRunnerTests {
@Test
public void testStopFailedAndRestarted() throws Throwable {
String[] args = new String[] { jobPath, "-stop", jobName };
- JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(5L, jobParameters, jobName));
+ StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(5L, jobName));
CommandLineJobRunner.main(args);
assertEquals(0, StubSystemExiter.status);
}
@@ -240,8 +237,7 @@ public class CommandLineJobRunnerTests {
@Test
public void testStopRestarted() throws Throwable {
String[] args = new String[] { jobPath, "-stop", jobName };
- JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- JobInstance jobInstance = new JobInstance(3L, jobParameters, jobName);
+ JobInstance jobInstance = new JobInstance(3L, jobName);
StubJobExplorer.jobInstances = Arrays.asList(jobInstance);
CommandLineJobRunner.main(args);
assertEquals(0, StubSystemExiter.status);
@@ -250,8 +246,7 @@ public class CommandLineJobRunnerTests {
@Test
public void testAbandon() throws Throwable {
String[] args = new String[] { jobPath, "-abandon", jobName };
- JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(2L, jobParameters, jobName));
+ StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(2L, jobName));
CommandLineJobRunner.main(args);
assertEquals(0, StubSystemExiter.status);
}
@@ -259,8 +254,7 @@ public class CommandLineJobRunnerTests {
@Test
public void testAbandonRunning() throws Throwable {
String[] args = new String[] { jobPath, "-abandon", jobName };
- JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(3L, jobParameters, jobName));
+ StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(3L, jobName));
CommandLineJobRunner.main(args);
assertEquals(1, StubSystemExiter.status);
}
@@ -268,8 +262,7 @@ public class CommandLineJobRunnerTests {
@Test
public void testAbandonAbandoned() throws Throwable {
String[] args = new String[] { jobPath, "-abandon", jobName };
- JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(4L, jobParameters, jobName));
+ StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(4L, jobName));
CommandLineJobRunner.main(args);
assertEquals(1, StubSystemExiter.status);
}
@@ -278,17 +271,20 @@ public class CommandLineJobRunnerTests {
public void testRestart() throws Throwable {
String[] args = new String[] { jobPath, "-restart", jobName };
JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(0L, jobParameters, jobName));
+ JobInstance jobInstance = new JobInstance(0L, jobName);
+ StubJobExplorer.jobInstances = Arrays.asList(jobInstance);
+ StubJobExplorer.jobParameters = jobParameters;
CommandLineJobRunner.main(args);
assertEquals(0, StubSystemExiter.status);
assertEquals(jobParameters, StubJobLauncher.jobParameters);
+ StubJobExplorer.jobParameters = new JobParameters();
}
@Test
public void testRestartExecution() throws Throwable {
String[] args = new String[] { jobPath, "-restart", "11" };
JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- JobExecution jobExecution = new JobExecution(new JobInstance(0L, jobParameters, jobName), 11L);
+ JobExecution jobExecution = new JobExecution(new JobInstance(0L, jobName), 11L, jobParameters);
jobExecution.setStatus(BatchStatus.FAILED);
StubJobExplorer.jobExecution = jobExecution;
CommandLineJobRunner.main(args);
@@ -300,7 +296,7 @@ public class CommandLineJobRunnerTests {
public void testRestartExecutionNotFailed() throws Throwable {
String[] args = new String[] { jobPath, "-restart", "11" };
JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- JobExecution jobExecution = new JobExecution(new JobInstance(0L, jobParameters, jobName), 11L);
+ JobExecution jobExecution = new JobExecution(new JobInstance(0L, jobName), 11L, jobParameters);
jobExecution.setStatus(BatchStatus.COMPLETED);
StubJobExplorer.jobExecution = jobExecution;
CommandLineJobRunner.main(args);
@@ -311,8 +307,7 @@ public class CommandLineJobRunnerTests {
@Test
public void testRestartNotFailed() throws Throwable {
String[] args = new String[] { jobPath, "-restart", jobName };
- JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(123L, jobParameters, jobName));
+ StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(123L, jobName));
CommandLineJobRunner.main(args);
assertEquals(1, StubSystemExiter.status);
String errorMessage = CommandLineJobRunner.getErrorMessage();
@@ -325,7 +320,7 @@ public class CommandLineJobRunnerTests {
String[] args = new String[] { jobPath, "-next", jobName, "bar=foo" };
JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").addString("bar", "foo")
.toJobParameters();
- StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(2L, jobParameters, jobName));
+ StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(2L, jobName));
CommandLineJobRunner.main(args);
assertEquals(0, StubSystemExiter.status);
jobParameters = new JobParametersBuilder().addString("foo", "spam").addString("bar", "foo").toJobParameters();
@@ -416,6 +411,8 @@ public class CommandLineJobRunnerTests {
static JobExecution jobExecution;
+ static JobParameters jobParameters = new JobParameters();
+
@Override
public Set findRunningJobExecutions(String jobName) {
throw new UnsupportedOperationException();
@@ -454,7 +451,7 @@ public class CommandLineJobRunnerTests {
}
private JobExecution createJobExecution(JobInstance jobInstance, BatchStatus status) {
- JobExecution jobExecution = new JobExecution(jobInstance, 1L);
+ JobExecution jobExecution = new JobExecution(jobInstance, 1L, jobParameters);
jobExecution.setStatus(status);
jobExecution.setStartTime(new Date());
if (status != BatchStatus.STARTED) {
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java
index 114e87d24..1608d461d 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java
@@ -16,6 +16,7 @@
package org.springframework.batch.core.launch.support;
import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
@@ -113,7 +114,7 @@ public class SimpleJobOperatorTests {
@Override
public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException,
JobRestartException, JobInstanceAlreadyCompleteException {
- return new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 999L);
+ return new JobExecution(new JobInstance(123L, job.getName()), 999L, jobParameters);
}
});
@@ -161,9 +162,9 @@ public class SimpleJobOperatorTests {
*/
@Test
public void testStartNextInstanceSunnyDay() throws Exception {
- final JobParameters jobParameters = new JobParameters();
- jobExplorer.getJobInstances("foo", 0, 1);
- EasyMock.expectLastCall().andReturn(Collections.singletonList(new JobInstance(321L, jobParameters, "foo")));
+ JobInstance jobInstance = new JobInstance(321L, "foo");
+ expect(jobExplorer.getJobInstances("foo", 0, 1)).andReturn(Collections.singletonList(jobInstance));
+ expect(jobExplorer.getJobExecutions(jobInstance)).andReturn(Collections.singletonList(new JobExecution(jobInstance, new JobParameters())));
EasyMock.replay(jobExplorer);
Long value = jobOperator.startNextInstance("foo");
assertEquals(999, value.longValue());
@@ -202,7 +203,7 @@ public class SimpleJobOperatorTests {
jobParameters = new JobParameters();
jobExplorer.getJobExecution(111L);
EasyMock.expectLastCall()
- .andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L));
+ .andReturn(new JobExecution(new JobInstance(123L, job.getName()), 111L, jobParameters));
EasyMock.replay(jobExplorer);
Long value = jobOperator.restart(111L);
assertEquals(999, value.longValue());
@@ -213,7 +214,7 @@ public class SimpleJobOperatorTests {
public void testGetSummarySunnyDay() throws Exception {
jobParameters = new JobParameters();
jobExplorer.getJobExecution(111L);
- JobExecution jobExecution = new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L);
+ JobExecution jobExecution = new JobExecution(new JobInstance(123L, job.getName()), 111L, jobParameters);
EasyMock.expectLastCall().andReturn(jobExecution);
EasyMock.replay(jobExplorer);
String value = jobOperator.getSummary(111L);
@@ -240,7 +241,7 @@ public class SimpleJobOperatorTests {
public void testGetStepExecutionSummariesSunnyDay() throws Exception {
jobParameters = new JobParameters();
jobExplorer.getJobExecution(111L);
- JobExecution jobExecution = new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L);
+ JobExecution jobExecution = new JobExecution(new JobInstance(123L, job.getName()), 111L, jobParameters);
jobExecution.createStepExecution("step1");
jobExecution.createStepExecution("step2");
jobExecution.getStepExecutions().iterator().next().setId(21L);
@@ -270,7 +271,7 @@ public class SimpleJobOperatorTests {
public void testFindRunningExecutionsSunnyDay() throws Exception {
jobParameters = new JobParameters();
jobExplorer.findRunningJobExecutions("foo");
- JobExecution jobExecution = new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L);
+ JobExecution jobExecution = new JobExecution(new JobInstance(123L, job.getName()), 111L, jobParameters);
EasyMock.expectLastCall().andReturn(Collections.singleton(jobExecution));
EasyMock.replay(jobExplorer);
Set value = jobOperator.getRunningExecutions("foo");
@@ -298,7 +299,7 @@ public class SimpleJobOperatorTests {
final JobParameters jobParameters = new JobParameters();
jobExplorer.getJobExecution(111L);
EasyMock.expectLastCall()
- .andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L));
+ .andReturn(new JobExecution(new JobInstance(123L, job.getName()), 111L, jobParameters));
EasyMock.replay(jobExplorer);
String value = jobOperator.getParameters(111L);
assertEquals("a=b", value);
@@ -321,9 +322,8 @@ public class SimpleJobOperatorTests {
@Test
public void testGetLastInstancesSunnyDay() throws Exception {
- jobParameters = new JobParameters();
jobExplorer.getJobInstances("foo", 0, 2);
- JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
+ JobInstance jobInstance = new JobInstance(123L, job.getName());
EasyMock.expectLastCall().andReturn(Collections.singletonList(jobInstance));
EasyMock.replay(jobExplorer);
List value = jobOperator.getJobInstances("foo", 0, 2);
@@ -356,10 +356,10 @@ public class SimpleJobOperatorTests {
@Test
public void testGetExecutionsSunnyDay() throws Exception {
- JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
+ JobInstance jobInstance = new JobInstance(123L, job.getName());
jobExplorer.getJobInstance(123L);
EasyMock.expectLastCall().andReturn(jobInstance);
- JobExecution jobExecution = new JobExecution(jobInstance, 111L);
+ JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters);
jobExplorer.getJobExecutions(jobInstance);
EasyMock.expectLastCall().andReturn(Collections.singletonList(jobExecution));
EasyMock.replay(jobExplorer);
@@ -385,8 +385,8 @@ public class SimpleJobOperatorTests {
@Test
public void testStop() throws Exception{
- JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
- JobExecution jobExecution = new JobExecution(jobInstance, 111L);
+ JobInstance jobInstance = new JobInstance(123L, job.getName());
+ JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters);
jobExplorer.getJobExecution(111L);
expectLastCall().andReturn(jobExecution);
jobRepository.update(jobExecution);
@@ -400,8 +400,8 @@ public class SimpleJobOperatorTests {
@Test
public void testAbort() throws Exception {
- JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
- JobExecution jobExecution = new JobExecution(jobInstance, 111L);
+ JobInstance jobInstance = new JobInstance(123L, job.getName());
+ JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters);
jobExecution.setStatus(BatchStatus.STOPPING);
jobExplorer.getJobExecution(123L);
expectLastCall().andReturn(jobExecution);
@@ -414,8 +414,8 @@ public class SimpleJobOperatorTests {
@Test(expected = JobExecutionAlreadyRunningException.class)
public void testAbortNonStopping() throws Exception {
- JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
- JobExecution jobExecution = new JobExecution(jobInstance, 111L);
+ JobInstance jobInstance = new JobInstance(123L, job.getName());
+ JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters);
jobExecution.setStatus(BatchStatus.STARTED);
jobExplorer.getJobExecution(123L);
expectLastCall().andReturn(jobExecution);
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java
index 98aa545ce..2abc4feaa 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java
@@ -82,7 +82,7 @@ public class CompositeJobExecutionListenerTests extends TestCase {
list.add("foo");
}
});
- listener.beforeJob(new JobExecution(new JobInstance(new Long(11L), null, "testOpenJob")));
+ listener.beforeJob(new JobExecution(new JobInstance(new Long(11L), "testOpenJob"), null));
assertEquals(1, list.size());
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobParameterExecutionContextCopyListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobParameterExecutionContextCopyListenerTests.java
index 242835fb4..5d0c8f41d 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobParameterExecutionContextCopyListenerTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobParameterExecutionContextCopyListenerTests.java
@@ -28,7 +28,7 @@ import org.springframework.batch.core.StepExecution;
/**
* @author Dave Syer
- *
+ *
*/
public class JobParameterExecutionContextCopyListenerTests {
@@ -39,7 +39,7 @@ public class JobParameterExecutionContextCopyListenerTests {
@Before
public void createExecution() {
JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- stepExecution = new StepExecution("foo", new JobExecution(new JobInstance(123L, jobParameters, "job")));
+ stepExecution = new StepExecution("foo", new JobExecution(new JobInstance(123L, "job"), jobParameters));
}
@Test
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java
index 2824334f9..15d621326 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java
@@ -205,7 +205,7 @@ public class SimpleStepExecutionSplitterTests {
jobExecution.setEndTime(new Date());
jobRepository.update(jobExecution);
JobInstance jobInstance = jobExecution.getJobInstance();
- jobExecution = jobRepository.createJobExecution(jobInstance.getJobName(), jobInstance.getJobParameters());
+ jobExecution = jobRepository.createJobExecution(jobInstance.getJobName(), jobExecution.getJobParameters());
}
stepExecution = jobExecution.createStepExecution(stepExecution.getStepName());
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextDaoTests.java
index 43cfe8be9..38c7ff56e 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextDaoTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextDaoTests.java
@@ -20,7 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
public abstract class AbstractExecutionContextDaoTests extends AbstractTransactionalJUnit4SpringContextTests {
private JobInstanceDao jobInstanceDao;
-
+
private JobExecutionDao jobExecutionDao;
private StepExecutionDao stepExecutionDao;
@@ -39,7 +39,7 @@ public abstract class AbstractExecutionContextDaoTests extends AbstractTransacti
contextDao = getExecutionContextDao();
JobInstance ji = jobInstanceDao.createJobInstance("testJob", new JobParameters());
- jobExecution = new JobExecution(ji);
+ jobExecution = new JobExecution(ji, new JobParameters());
jobExecutionDao.saveJobExecution(jobExecution);
stepExecution = new StepExecution("stepName", jobExecution);
stepExecutionDao.saveStepExecution(stepExecution);
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobDaoTests.java
index 292f2ec9d..d4397ee46 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobDaoTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobDaoTests.java
@@ -42,7 +42,7 @@ import org.springframework.transaction.annotation.Transactional;
/**
* @author Dave Syer
- *
+ *
*/
public abstract class AbstractJobDaoTests {
@@ -90,7 +90,7 @@ public abstract class AbstractJobDaoTests {
// Create an execution
jobExecutionStartTime = new Date(System.currentTimeMillis());
- jobExecution = new JobExecution(jobInstance);
+ jobExecution = new JobExecution(jobInstance, jobParameters);
jobExecution.setStartTime(jobExecutionStartTime);
jobExecution.setStatus(BatchStatus.STARTED);
jobExecutionDao.saveJobExecution(jobExecution);
@@ -123,7 +123,6 @@ public abstract class AbstractJobDaoTests {
JobInstance instance = jobInstanceDao.getJobInstance(jobName, jobParameters);
assertNotNull(instance);
assertTrue(jobInstance.equals(instance));
- assertEquals(jobParameters, instance.getJobParameters());
}
@Transactional @Test
@@ -156,7 +155,6 @@ public abstract class AbstractJobDaoTests {
JobInstance instance;
instance = jobInstanceDao.getJobInstance(scheduledJob, jobParameters);
assertNotNull(instance);
- assertEquals(jobParameters, instance.getJobParameters());
instance = jobInstanceDao.getJobInstance(scheduledJob, tempProps);
assertNull(instance);
@@ -189,7 +187,7 @@ public abstract class AbstractJobDaoTests {
public void testUpdateInvalidJobExecution() {
// id is invalid
- JobExecution execution = new JobExecution(jobInstance, (long) 29432);
+ JobExecution execution = new JobExecution(jobInstance, (long) 29432, jobParameters);
execution.incrementVersion();
try {
jobExecutionDao.updateJobExecution(execution);
@@ -203,7 +201,7 @@ public abstract class AbstractJobDaoTests {
@Transactional @Test
public void testUpdateNullIdJobExection() {
- JobExecution execution = new JobExecution(jobInstance);
+ JobExecution execution = new JobExecution(jobInstance, jobParameters);
try {
jobExecutionDao.updateJobExecution(execution);
fail();
@@ -239,9 +237,6 @@ public abstract class AbstractJobDaoTests {
JobInstance instance = jobInstanceDao.getJobInstance(testDefaultJob, jobParameters);
assertNotNull(instance);
- assertEquals(jobParameters.getString("job.key"), instance.getJobParameters().getString(
- "job.key"));
-
}
@Transactional @Test
@@ -252,11 +247,6 @@ public abstract class AbstractJobDaoTests {
validateJobExecution(jobExecution, results.get(0));
}
- @Transactional @Test
- public void testFindJobsWithProperties() throws Exception {
-
- }
-
private void validateJobExecution(JobExecution lhs, JobExecution rhs) {
// equals operator only checks id
@@ -269,7 +259,7 @@ public abstract class AbstractJobDaoTests {
@Transactional @Test
public void testGetLastJobExecution() {
- JobExecution lastExecution = new JobExecution(jobInstance);
+ JobExecution lastExecution = new JobExecution(jobInstance, jobParameters);
lastExecution.setStatus(BatchStatus.STARTED);
int JUMP_INTO_FUTURE = 1000; // makes sure start time is 'greatest'
@@ -277,18 +267,20 @@ public abstract class AbstractJobDaoTests {
jobExecutionDao.saveJobExecution(lastExecution);
assertEquals(lastExecution, jobExecutionDao.getLastJobExecution(jobInstance));
+ assertNotNull(lastExecution.getJobParameters());
+ assertEquals("jobKey", lastExecution.getJobParameters().getString("job.key"));
}
-
+
/**
* Trying to create instance twice for the same job+parameters causes error
*/
@Transactional @Test
public void testCreateDuplicateInstance() {
-
+
jobParameters = new JobParameters();
-
+
jobInstanceDao.createJobInstance(jobName, jobParameters);
-
+
try {
jobInstanceDao.createJobInstance(jobName, jobParameters);
fail();
@@ -297,35 +289,35 @@ public abstract class AbstractJobDaoTests {
// expected
}
}
-
+
@Transactional @Test
public void testCreationAddsVersion() {
-
+
jobInstance = jobInstanceDao.createJobInstance("testCreationAddsVersion", new JobParameters());
-
+
assertNotNull(jobInstance.getVersion());
}
-
+
@Transactional @Test
public void testSaveAddsVersionAndId() {
-
- JobExecution jobExecution = new JobExecution(jobInstance);
-
+
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
+
assertNull(jobExecution.getId());
assertNull(jobExecution.getVersion());
-
+
jobExecutionDao.saveJobExecution(jobExecution);
-
+
assertNotNull(jobExecution.getId());
assertNotNull(jobExecution.getVersion());
}
-
+
@Transactional @Test
public void testUpdateIncrementsVersion() {
int version = jobExecution.getVersion();
-
+
jobExecutionDao.updateJobExecution(jobExecution);
-
+
assertEquals(version + 1, jobExecution.getVersion().intValue());
}
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java
index 971a6b69f..b7d84e212 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobExecutionDaoTests.java
@@ -31,6 +31,8 @@ public abstract class AbstractJobExecutionDaoTests {
protected JobExecution execution;
+ protected JobParameters jobParameters;
+
/**
* @return tested object ready for use
*/
@@ -48,8 +50,9 @@ public abstract class AbstractJobExecutionDaoTests {
@Before
public void onSetUp() throws Exception {
dao = getJobExecutionDao();
- jobInstance = getJobInstanceDao().createJobInstance("execTestJob", new JobParameters());
- execution = new JobExecution(jobInstance);
+ jobParameters = new JobParameters();
+ jobInstance = getJobInstanceDao().createJobInstance("execTestJob", jobParameters);
+ execution = new JobExecution(jobInstance, new JobParameters());
}
/**
@@ -81,7 +84,7 @@ public abstract class AbstractJobExecutionDaoTests {
List execs = new ArrayList();
for (int i = 0; i < 10; i++) {
- JobExecution exec = new JobExecution(jobInstance);
+ JobExecution exec = new JobExecution(jobInstance, jobParameters);
exec.setCreateTime(new Date(i));
execs.add(exec);
dao.saveJobExecution(exec);
@@ -146,10 +149,10 @@ public abstract class AbstractJobExecutionDaoTests {
@Transactional
@Test
public void testGetLastExecution() {
- JobExecution exec1 = new JobExecution(jobInstance);
+ JobExecution exec1 = new JobExecution(jobInstance, jobParameters);
exec1.setCreateTime(new Date(0));
- JobExecution exec2 = new JobExecution(jobInstance);
+ JobExecution exec2 = new JobExecution(jobInstance, jobParameters);
exec2.setCreateTime(new Date(1));
dao.saveJobExecution(exec1);
@@ -176,13 +179,13 @@ public abstract class AbstractJobExecutionDaoTests {
@Test
public void testFindRunningExecutions() {
- JobExecution exec = new JobExecution(jobInstance);
+ JobExecution exec = new JobExecution(jobInstance, jobParameters);
exec.setCreateTime(new Date(0));
exec.setEndTime(new Date(1L));
exec.setLastUpdated(new Date(5L));
dao.saveJobExecution(exec);
- exec = new JobExecution(jobInstance);
+ exec = new JobExecution(jobInstance, jobParameters);
exec.setLastUpdated(new Date(5L));
exec.createStepExecution("step");
dao.saveJobExecution(exec);
@@ -219,7 +222,7 @@ public abstract class AbstractJobExecutionDaoTests {
@Transactional
@Test
public void testGetExecution() {
- JobExecution exec = new JobExecution(jobInstance);
+ JobExecution exec = new JobExecution(jobInstance, jobParameters);
exec.setCreateTime(new Date(0));
exec.createStepExecution("step");
@@ -254,10 +257,10 @@ public abstract class AbstractJobExecutionDaoTests {
@Test
public void testConcurrentModificationException() {
- JobExecution exec1 = new JobExecution(jobInstance);
+ JobExecution exec1 = new JobExecution(jobInstance, jobParameters);
dao.saveJobExecution(exec1);
- JobExecution exec2 = new JobExecution(jobInstance);
+ JobExecution exec2 = new JobExecution(jobInstance, jobParameters);
exec2.setId(exec1.getId());
exec2.incrementVersion();
@@ -284,11 +287,11 @@ public abstract class AbstractJobExecutionDaoTests {
@Test
public void testSynchronizeStatusUpgrade() {
- JobExecution exec1 = new JobExecution(jobInstance);
+ JobExecution exec1 = new JobExecution(jobInstance, jobParameters);
exec1.setStatus(BatchStatus.STOPPING);
dao.saveJobExecution(exec1);
- JobExecution exec2 = new JobExecution(jobInstance);
+ JobExecution exec2 = new JobExecution(jobInstance, jobParameters);
Assert.state(exec1.getId() != null);
exec2.setId(exec1.getId());
@@ -311,11 +314,11 @@ public abstract class AbstractJobExecutionDaoTests {
@Test
public void testSynchronizeStatusDowngrade() {
- JobExecution exec1 = new JobExecution(jobInstance);
+ JobExecution exec1 = new JobExecution(jobInstance, jobParameters);
exec1.setStatus(BatchStatus.STARTED);
dao.saveJobExecution(exec1);
- JobExecution exec2 = new JobExecution(jobInstance);
+ JobExecution exec2 = new JobExecution(jobInstance, jobParameters);
Assert.state(exec1.getId() != null);
exec2.setId(exec1.getId());
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobInstanceDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobInstanceDaoTests.java
index 6250e4b1b..c48ceff0c 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobInstanceDaoTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobInstanceDaoTests.java
@@ -46,18 +46,10 @@ public abstract class AbstractJobInstanceDaoTests {
JobInstance fooInstance = dao.createJobInstance(fooJob, fooParams);
assertNotNull(fooInstance.getId());
assertEquals(fooJob, fooInstance.getJobName());
- assertEquals(fooParams, fooInstance.getJobParameters());
JobInstance retrievedInstance = dao.getJobInstance(fooJob, fooParams);
- JobParameters retrievedParams = retrievedInstance.getJobParameters();
assertEquals(fooInstance, retrievedInstance);
assertEquals(fooJob, retrievedInstance.getJobName());
- assertEquals(fooParams, retrievedParams);
-
- assertEquals(Long.MAX_VALUE, retrievedParams.getLong("longKey"));
- assertEquals(Double.MAX_VALUE, retrievedParams.getDouble("doubleKey"), 0.001);
- assertEquals("stringValue", retrievedParams.getString("stringKey"));
- assertEquals(new Date(DATE), retrievedParams.getDate("dateKey"));
}
/*
@@ -72,15 +64,10 @@ public abstract class AbstractJobInstanceDaoTests {
JobInstance fooInstance = dao.createJobInstance(fooJob, jobParameters);
assertNotNull(fooInstance.getId());
assertEquals(fooJob, fooInstance.getJobName());
- assertEquals(jobParameters, fooInstance.getJobParameters());
JobInstance retrievedInstance = dao.getJobInstance(fooJob, jobParameters);
- JobParameters retrievedParams = retrievedInstance.getJobParameters();
assertEquals(fooInstance, retrievedInstance);
assertEquals(fooJob, retrievedInstance.getJobName());
- assertEquals(jobParameters, retrievedParams);
-
- assertEquals(null, retrievedParams.getString("foo"));
}
/*
@@ -93,18 +80,10 @@ public abstract class AbstractJobInstanceDaoTests {
JobInstance fooInstance = dao.createJobInstance(fooJob, fooParams);
assertNotNull(fooInstance.getId());
assertEquals(fooJob, fooInstance.getJobName());
- assertEquals(fooParams, fooInstance.getJobParameters());
JobInstance retrievedInstance = dao.getJobInstance(fooInstance.getId());
- JobParameters retrievedParams = retrievedInstance.getJobParameters();
assertEquals(fooInstance, retrievedInstance);
assertEquals(fooJob, retrievedInstance.getJobName());
- assertEquals(fooParams, retrievedParams);
-
- assertEquals(Long.MAX_VALUE, retrievedParams.getLong("longKey"));
- assertEquals(Double.MAX_VALUE, retrievedParams.getDouble("doubleKey"), 0.001);
- assertEquals("stringValue", retrievedParams.getString("stringKey"));
- assertEquals(new Date(DATE), retrievedParams.getDate("dateKey"));
}
/*
@@ -180,7 +159,7 @@ public abstract class AbstractJobInstanceDaoTests {
JobParameters params = new JobParametersBuilder().addLong(paramKey, Long.valueOf(i)).toJobParameters();
dao.createJobInstance(multiInstanceJob, params);
}
-
+
int startIndex = 3;
int queryCount = 2;
@@ -192,9 +171,9 @@ public abstract class AbstractJobInstanceDaoTests {
JobInstance returnedInstance = jobInstances.get(i);
assertEquals(multiInstanceJob, returnedInstance.getJobName());
assertEquals(Integer.valueOf(0), returnedInstance.getVersion());
-
+
//checks the correct instances are returned and the order is descending
- assertEquals(instanceCount - startIndex - i , returnedInstance.getJobParameters().getLong(paramKey));
+ // assertEquals(instanceCount - startIndex - i , returnedInstance.getJobParameters().getLong(paramKey));
}
}
@@ -241,7 +220,7 @@ public abstract class AbstractJobInstanceDaoTests {
@Test
public void testCreationAddsVersion() {
- JobInstance jobInstance = new JobInstance((long) 1, new JobParameters(), "testVersionAndId");
+ JobInstance jobInstance = new JobInstance((long) 1, "testVersionAndId");
assertNull(jobInstance.getVersion());
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java
index 866ffe6c4..a3044acc7 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java
@@ -40,7 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
/**
* Tests for {@link StepExecutionDao} implementations.
- *
+ *
* @see #getStepExecutionDao()
*/
public abstract class AbstractStepExecutionDaoTests extends AbstractTransactionalJUnit4SpringContextTests {
@@ -139,7 +139,7 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
@Transactional
@Test
public void testGetForNotExistingJobExecution() {
- assertNull(dao.getStepExecution(new JobExecution(jobInstance, (long) 777), 11L));
+ assertNull(dao.getStepExecution(new JobExecution(jobInstance, (long) 777, new JobParameters()), 11L));
}
/**
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java
index 6bdab8cbb..1a24e99c8 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java
@@ -74,7 +74,7 @@ public class JdbcJobDaoQueryTests extends TestCase {
return 1;
}
});
- JobExecution jobExecution = new JobExecution(new JobInstance(new Long(11), new JobParameters(), "testJob"));
+ JobExecution jobExecution = new JobExecution(new JobInstance(new Long(11), "testJob"), new JobParameters());
jobExecutionDao.saveJobExecution(jobExecution);
assertEquals(1, list.size());
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDaoTests.java
index 01c5e0f53..339ba22fc 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDaoTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDaoTests.java
@@ -23,7 +23,7 @@ public class JdbcJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
private JobInstanceDao jobInstanceDao;
private JdbcTemplate jdbcTemplate;
-
+
@Autowired
public void setDataSource(DataSource dataSource) {
jdbcTemplate = new JdbcTemplate(dataSource);
@@ -36,9 +36,9 @@ public class JdbcJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
@Override
protected JobExecutionDao getJobExecutionDao() {
- JdbcTestUtils.deleteFromTables(jdbcTemplate, "BATCH_JOB_EXECUTION_CONTEXT",
- "BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", "BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS",
- "BATCH_JOB_INSTANCE");
+ JdbcTestUtils.deleteFromTables(jdbcTemplate, "BATCH_JOB_EXECUTION_CONTEXT",
+ "BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", "BATCH_JOB_EXECUTION", "BATCH_JOB_EXECUTION_PARAMS",
+ "BATCH_JOB_INSTANCE");
return jobExecutionDao;
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java
index 3630b8939..f4e7d2078 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java
@@ -12,7 +12,6 @@ import org.junit.runner.RunWith;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
-import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
@@ -41,78 +40,24 @@ public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
protected JobInstanceDao getJobInstanceDao() {
JdbcTestUtils.deleteFromTables(jdbcTemplate, "BATCH_JOB_EXECUTION_CONTEXT",
"BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION",
- "BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE");
+ "BATCH_JOB_EXECUTION", "BATCH_JOB_EXECUTION_PARAMS", "BATCH_JOB_INSTANCE");
return jobInstanceDao;
}
- @Transactional
- @Test
- public void testNullStringParameter() throws Exception {
-
- JobInstance jobInstance = dao.createJobInstance("testInstance",
- new JobParametersBuilder().addString("foo", null).toJobParameters());
-
- JobInstance retrievedInstance = dao.getJobInstance(jobInstance.getId());
- JobParameters retrievedParams = retrievedInstance.getJobParameters();
- assertEquals(null, retrievedParams.getString("foo"));
-
- }
-
@Transactional
@Test
public void testFindJobInstanceByExecution() {
+ JobParameters jobParameters = new JobParameters();
JobInstance jobInstance = dao.createJobInstance("testInstance",
- new JobParameters());
- JobExecution jobExecution = new JobExecution(jobInstance, 2L);
+ jobParameters);
+ JobExecution jobExecution = new JobExecution(jobInstance, 2L, jobParameters);
jobExecutionDao.saveJobExecution(jobExecution);
JobInstance returnedInstance = dao.getJobInstance(jobExecution);
assertEquals(jobInstance, returnedInstance);
}
- @Transactional
- @Test
- public void testCreateJobKey() {
-
- JdbcJobInstanceDao jdbcDao = (JdbcJobInstanceDao) dao;
- JobParameters jobParameters = new JobParametersBuilder().addString(
- "foo", "bar").addString("bar", "foo").toJobParameters();
- String key = jdbcDao.createJobKey(jobParameters);
- assertEquals(32, key.length());
-
- }
-
- @Transactional
- @Test
- public void testCreateJobKeyWithNullParameter() {
-
- JdbcJobInstanceDao jdbcDao = (JdbcJobInstanceDao) dao;
- JobParameters jobParameters1 = new JobParametersBuilder().addString(
- "foo", "bar").addString("bar", null).toJobParameters();
- JobParameters jobParameters2 = new JobParametersBuilder().addString(
- "foo", "bar").addString("bar", "").toJobParameters();
- String key1 = jdbcDao.createJobKey(jobParameters1);
- String key2 = jdbcDao.createJobKey(jobParameters2);
- assertEquals(key1, key2);
-
- }
-
- @Transactional
- @Test
- public void testCreateJobKeyOrdering() {
-
- JdbcJobInstanceDao jdbcDao = (JdbcJobInstanceDao) dao;
- JobParameters jobParameters1 = new JobParametersBuilder().addString(
- "foo", "bar").addString("bar", "foo").toJobParameters();
- String key1 = jdbcDao.createJobKey(jobParameters1);
- JobParameters jobParameters2 = new JobParametersBuilder().addString(
- "bar", "foo").addString("foo", "bar").toJobParameters();
- String key2 = jdbcDao.createJobKey(jobParameters2);
- assertEquals(key1, key2);
-
- }
-
@Test
public void testHexing() throws Exception {
MessageDigest digest = MessageDigest.getInstance("MD5");
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java
index e5dabff17..5a05b47c6 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java
@@ -23,7 +23,7 @@ public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
@Override
protected JobRepository getJobRepository() {
deleteFromTables("BATCH_JOB_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", "BATCH_JOB_EXECUTION",
- "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE");
+ "BATCH_JOB_EXECUTION_PARAMS", "BATCH_JOB_INSTANCE");
return (JobRepository) applicationContext.getBean("jobRepository");
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java
index 507ce01bd..21d5df1d2 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java
@@ -36,7 +36,7 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
@Test
public void testPersistentCopy() {
JobExecutionDao tested = new MapJobExecutionDao();
- JobExecution jobExecution = new JobExecution(new JobInstance((long) 1, new JobParameters(), "mapJob"));
+ JobExecution jobExecution = new JobExecution(new JobInstance((long) 1, "mapJob"), new JobParameters());
assertNull(jobExecution.getStartTime());
tested.saveJobExecution(jobExecution);
@@ -71,7 +71,7 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
@Override
public void run() {
try {
- JobExecution jobExecution = new JobExecution(new JobInstance((long) -1, new JobParameters(), "mapJob"));
+ JobExecution jobExecution = new JobExecution(new JobInstance((long) -1, "mapJob"), new JobParameters());
latch.await();
tested.saveJobExecution(jobExecution);
ids.add(jobExecution.getId());
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java
index 94ce39d5d..2e4f9b4c8 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java
@@ -14,6 +14,7 @@ import org.springframework.batch.core.job.JobSupport;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
@@ -25,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
+@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
public class SimpleJobRepositoryProxyTests {
@Autowired
@@ -37,7 +39,6 @@ public class SimpleJobRepositoryProxyTests {
@Transactional
@Test(expected=IllegalStateException.class)
- @DirtiesContext
public void testCreateAndFindWithExistingTransaction() throws Exception {
assertFalse(advice.invoked);
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
@@ -46,7 +47,6 @@ public class SimpleJobRepositoryProxyTests {
}
@Test
- @DirtiesContext
public void testCreateAndFindNoTransaction() throws Exception {
assertFalse(advice.invoked);
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryTests.java
index 899dd4c29..e59265314 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryTests.java
@@ -16,8 +16,13 @@
package org.springframework.batch.core.repository.support;
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
@@ -43,9 +48,9 @@ import org.springframework.batch.core.step.StepSupport;
* Test SimpleJobRepository. The majority of test cases are tested using
* EasyMock, however, there were some issues with using it for the stepExecutionDao when
* testing finding or creating steps, so an actual mock class had to be written.
- *
+ *
* @author Lucas Ward
- *
+ *
*/
public class SimpleJobRepositoryTests {
@@ -58,13 +63,13 @@ public class SimpleJobRepositoryTests {
Step stepConfiguration1;
Step stepConfiguration2;
-
+
JobExecutionDao jobExecutionDao;
-
+
JobInstanceDao jobInstanceDao;
StepExecutionDao stepExecutionDao;
-
+
ExecutionContextDao ecDao;
JobInstance jobInstance;
@@ -74,7 +79,7 @@ public class SimpleJobRepositoryTests {
String databaseStep2;
List steps;
-
+
JobExecution jobExecution;
@Before
@@ -103,7 +108,7 @@ public class SimpleJobRepositoryTests {
job.setSteps(stepConfigurations);
- jobInstance = new JobInstance(1L, jobParameters, job.getName());
+ jobInstance = new JobInstance(1L, job.getName());
databaseStep1 = "dbStep1";
databaseStep2 = "dbStep2";
@@ -112,14 +117,14 @@ public class SimpleJobRepositoryTests {
steps.add(databaseStep1);
steps.add(databaseStep2);
- jobExecution = new JobExecution(new JobInstance(1L, jobParameters, job.getName()), 1L);
+ jobExecution = new JobExecution(new JobInstance(1L, job.getName()), 1L, jobParameters);
}
@Test
public void testSaveOrUpdateInvalidJobExecution() {
// failure scenario - must have job ID
- JobExecution jobExecution = new JobExecution(null, null);
+ JobExecution jobExecution = new JobExecution((JobInstance) null, (JobParameters) null);
try {
jobRepository.update(jobExecution);
fail();
@@ -132,13 +137,13 @@ public class SimpleJobRepositoryTests {
@Test
public void testUpdateValidJobExecution() throws Exception {
- JobExecution jobExecution = new JobExecution(new JobInstance(1L, jobParameters, job.getName()), 1L);
+ JobExecution jobExecution = new JobExecution(new JobInstance(1L, job.getName()), 1L, jobParameters);
// new execution - call update on job dao
jobExecutionDao.updateJobExecution(jobExecution);
replay(jobExecutionDao);
jobRepository.update(jobExecution);
verify(jobExecutionDao);
-
+
assertNotNull(jobExecution.getLastUpdated());
}
@@ -156,45 +161,45 @@ public class SimpleJobRepositoryTests {
// expected
}
}
-
+
@Test
public void testSaveStepExecutionSetsLastUpdated(){
-
+
StepExecution stepExecution = new StepExecution("stepName", jobExecution);
-
- long before = System.currentTimeMillis();
-
+
+ long before = System.currentTimeMillis();
+
jobRepository.add(stepExecution);
-
+
assertNotNull(stepExecution.getLastUpdated());
-
+
long lastUpdated = stepExecution.getLastUpdated().getTime();
assertTrue(lastUpdated > (before - 1000));
}
-
+
@Test
public void testUpdateStepExecutionSetsLastUpdated(){
-
+
StepExecution stepExecution = new StepExecution("stepName", jobExecution);
stepExecution.setId(2343L);
-
- long before = System.currentTimeMillis();
-
+
+ long before = System.currentTimeMillis();
+
jobRepository.update(stepExecution);
-
+
assertNotNull(stepExecution.getLastUpdated());
-
+
long lastUpdated = stepExecution.getLastUpdated().getTime();
assertTrue(lastUpdated > (before - 1000));
}
-
+
@Test
public void testInterrupted(){
-
+
jobExecution.setStatus(BatchStatus.STOPPING);
StepExecution stepExecution = new StepExecution("stepName", jobExecution);
stepExecution.setId(323L);
-
+
jobRepository.update(stepExecution);
assertTrue(stepExecution.isTerminateOnly());
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java
index 27a1de1ac..488786ba8 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java
@@ -53,8 +53,8 @@ public class StepExecutionSimpleCompletionPolicyTests extends TestCase {
protected void setUp() throws Exception {
JobParameters jobParameters = new JobParametersBuilder().addLong("commit.interval", 2L).toJobParameters();
- jobInstance = new JobInstance(new Long(0), jobParameters, "testJob");
- JobExecution jobExecution = new JobExecution(jobInstance);
+ jobInstance = new JobInstance(new Long(0), "testJob");
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
Step step = new StepSupport("bar");
stepExecution = jobExecution.createStepExecution(step.getName());
policy.beforeStep(stepExecution);
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/ChunkContextTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/ChunkContextTests.java
index a46ac3920..8a754b999 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/ChunkContextTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/ChunkContextTests.java
@@ -30,13 +30,13 @@ import org.springframework.batch.core.JobParameters;
/**
* @author Dave Syer
- *
+ *
*/
public class ChunkContextTests {
private ChunkContext context = new ChunkContext(new StepContext(new JobExecution(new JobInstance(0L,
- new JobParameters(Collections.singletonMap("foo", new JobParameter("bar"))), "job"), 1L)
- .createStepExecution("foo")));
+ "job"), 1L, new JobParameters(Collections.singletonMap("foo", new JobParameter("bar"))))
+ .createStepExecution("foo")));
@Test
public void testGetStepContext() {
@@ -49,7 +49,7 @@ public class ChunkContextTests {
public void testIsComplete() {
assertFalse(context.isComplete());
context.setComplete();
- assertTrue(context.isComplete());
+ assertTrue(context.isComplete());
}
@Test
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java
index 0a9e523c7..8e962bb3b 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java
@@ -40,7 +40,7 @@ public class StepContextTests {
private List list = new ArrayList();
- private StepExecution stepExecution = new StepExecution("step", new JobExecution(new JobInstance(2L, null, "job"), 0L), 1L);
+ private StepExecution stepExecution = new StepExecution("step", new JobExecution(new JobInstance(2L, "job"), 0L, null), 1L);
private StepContext context = new StepContext(stepExecution);
@@ -169,8 +169,9 @@ public class StepContextTests {
@Test
public void testJobParameters() throws Exception {
JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
- JobInstance jobInstance = new JobInstance(0L, jobParameters, "foo");
- stepExecution.getJobExecution().setJobInstance(jobInstance);
+ JobInstance instance = stepExecution.getJobExecution().getJobInstance();
+ stepExecution = new StepExecution("step", new JobExecution(instance, jobParameters));
+ context = new StepContext(stepExecution);
assertEquals("bar", context.getJobParameters().get("foo"));
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java
index 37fdee424..a673a2a5e 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java
@@ -32,8 +32,8 @@ public class JobRepositorySupport implements JobRepository {
*/
@Override
public JobExecution createJobExecution(String jobName, JobParameters jobParameters) {
- JobInstance jobInstance = new JobInstance(0L, jobParameters, jobName);
- return new JobExecution(jobInstance, 11L);
+ JobInstance jobInstance = new JobInstance(0L, jobName);
+ return new JobExecution(jobInstance, 11L, jobParameters);
}
/* (non-Javadoc)
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListenerTests.java
index b4d295a67..3ab938ab7 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListenerTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListenerTests.java
@@ -34,8 +34,7 @@ public class NoWorkFoundStepExecutionListenerTests {
@Test
public void noWork() {
- StepExecution stepExecution = new StepExecution("NoProcessingStep", new JobExecution(new JobInstance(1L,
- new JobParameters(), "NoProcessingJob")));
+ StepExecution stepExecution = new StepExecution("NoProcessingStep", new JobExecution(new JobInstance(1L, "NoProcessingJob"), new JobParameters()));
stepExecution.setExitStatus(ExitStatus.COMPLETED);
stepExecution.setReadCount(0);
@@ -47,7 +46,7 @@ public class NoWorkFoundStepExecutionListenerTests {
@Test
public void workDone() {
StepExecution stepExecution = new StepExecution("NoProcessingStep", new JobExecution(new JobInstance(1L,
- new JobParameters(), "NoProcessingJob")));
+ "NoProcessingJob"), new JobParameters()));
stepExecution.setReadCount(1);
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java
index 87001db72..468e630ca 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java
@@ -39,7 +39,7 @@ public class NonAbstractStepTests {
final List events = new ArrayList();
final StepExecution execution = new StepExecution(tested.getName(), new JobExecution(new JobInstance(1L,
- new JobParameters(), "jobName")));
+ "jobName"), new JobParameters()));
/**
* Fills the events list when abstract methods are called.
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java
index 348234a0f..0e5c3e6ca 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java
@@ -54,7 +54,7 @@ public class ChunkOrientedTaskletTests {
}
});
StepContribution contribution = new StepContribution(new StepExecution("foo", new JobExecution(new JobInstance(
- 123L, new JobParameters(), "job"))));
+ 123L, "job"),new JobParameters())));
handler.execute(contribution, context);
assertEquals(1, contribution.getReadCount());
assertEquals(1, contribution.getWriteCount());
@@ -77,7 +77,7 @@ public class ChunkOrientedTaskletTests {
}
});
StepContribution contribution = new StepContribution(new StepExecution("foo", new JobExecution(new JobInstance(
- 123L, new JobParameters(), "job"))));
+ 123L, "job"), new JobParameters())));
try {
handler.execute(contribution, context);
fail("Expected RuntimeException");
@@ -108,7 +108,7 @@ public class ChunkOrientedTaskletTests {
}
});
StepContribution contribution = new StepContribution(new StepExecution("foo", new JobExecution(new JobInstance(
- 123L, new JobParameters(), "job"))));
+ 123L, "job"), new JobParameters())));
ExitStatus expected = contribution.getExitStatus();
handler.execute(contribution, context);
// The tasklet does not change the exit code
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java
index 372dd1e46..ecb09a6f7 100755
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java
@@ -24,7 +24,7 @@ public class FaultTolerantChunkProviderTests {
private FaultTolerantChunkProvider provider;
private StepContribution contribution = new StepContribution(new StepExecution("foo", new JobExecution(
- new JobInstance(123L, new JobParameters(), "job"))));
+ new JobInstance(123L, "job"), new JobParameters())));
@Test
public void testProvide() throws Exception {
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java
index d6d97e0ea..c340414d9 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java
@@ -66,8 +66,8 @@ public class FaultTolerantStepFactoryBeanNonBufferingTests {
factory.setSkipLimit(2);
factory.setIsReaderTransactionalQueue(true);
- JobInstance jobInstance = new JobInstance(new Long(1), new JobParameters(), "skipJob");
- jobExecution = new JobExecution(jobInstance);
+ JobInstance jobInstance = new JobInstance(new Long(1), "skipJob");
+ jobExecution = new JobExecution(jobInstance, new JobParameters());
}
/**
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java
index d8c163123..68c9f2acd 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java
@@ -178,11 +178,6 @@ public class FaultTolerantStepFactoryBeanRetryTests {
jobExecution);
repository.add(stepExecution);
step.execute(stepExecution);
- // System.out.println(stepExecution.getWriteCount());
- // System.out.println(stepExecution.getSkipCount());
- // System.out.println(processed.size());
- // System.out.println(processed);
- // System.out.println(written);
/*
* Each chunk tried up to RETRY_LIMIT, then the scan processes each item
* once, identfiying the skip as it goes
@@ -230,7 +225,6 @@ public class FaultTolerantStepFactoryBeanRetryTests {
jobExecution);
repository.add(stepExecution);
step.execute(stepExecution);
- // System.out.println(processed);
assertEquals(ExitStatus.COMPLETED.getExitCode(), stepExecution
.getExitStatus().getExitCode());
/*
@@ -278,10 +272,6 @@ public class FaultTolerantStepFactoryBeanRetryTests {
jobExecution);
repository.add(stepExecution);
step.execute(stepExecution);
- // System.out.println(stepExecution.getWriteCount());
- // System.out.println(processed.size());
- // System.out.println(processed);
- // System.out.println(written);
assertEquals(3, processed.size()); // Initial try only, then cached
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java
index 1bf9b97b7..904621e1f 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java
@@ -44,7 +44,7 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase {
private List list;
- private JobExecution jobExecution = new JobExecution(new JobInstance(0L, new JobParameters(), "job"));
+ private JobExecution jobExecution = new JobExecution(new JobInstance(0L, "job"), new JobParameters());
@Override
protected void setUp() throws Exception {
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java
index 545936915..1155d9a74 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java
@@ -38,7 +38,7 @@ public class SimpleChunkProcessorTests {
});
private StepContribution contribution = new StepContribution(new StepExecution("foo", new JobExecution(
- new JobInstance(123L, new JobParameters(), "job"))));
+ new JobInstance(123L, "job"), new JobParameters())));
private List list = new ArrayList();
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProviderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProviderTests.java
index 3b2aaa026..2080514de 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProviderTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProviderTests.java
@@ -19,7 +19,7 @@ public class SimpleChunkProviderTests {
private SimpleChunkProvider provider;
private StepContribution contribution = new StepContribution(new StepExecution("foo", new JobExecution(
- new JobInstance(123L, new JobParameters(), "job"))));
+ new JobInstance(123L, "job"), new JobParameters())));
@Test
public void testProvide() throws Exception {
@@ -36,7 +36,7 @@ public class SimpleChunkProviderTests {
new RepeatTemplate()) {
@Override
protected String read(StepContribution contribution, Chunk chunk) throws SkipOverflowException,
- Exception {
+ Exception {
chunk.skip(new RuntimeException("Planned"));
throw new SkipOverflowException("Overflow");
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWrapperTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWrapperTests.java
index 853a996c6..ec393d315 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWrapperTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWrapperTests.java
@@ -39,7 +39,7 @@ public class SkipWrapperTests {
}
/**
- * Test method for {@link org.springframework.batch.core.step.item.SkipWrapper#SkipWrapper(java.lang.Object, java.lang.Exception)}.
+ * Test method for {@link org.springframework.batch.core.step.item.SkipWrapper#SkipWrapper(java.lang.Object, java.lang.Throwable)}.
*/
@Test
public void testItemWrapperTException() {
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java
index 35fee14ec..41d21f285 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java
@@ -67,8 +67,8 @@ public class TaskletStepExceptionTests {
taskletStep.setJobRepository(jobRepository);
taskletStep.setTransactionManager(new ResourcelessTransactionManager());
- JobInstance jobInstance = new JobInstance(1L, new JobParameters(), "testJob");
- JobExecution jobExecution = new JobExecution(jobInstance);
+ JobInstance jobInstance = new JobInstance(1L, "testJob");
+ JobExecution jobExecution = new JobExecution(jobInstance, new JobParameters());
stepExecution = new StepExecution("testStep", jobExecution);
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractorJobParametersTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractorJobParametersTests.java
index ef25ab1ff..fde076210 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractorJobParametersTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractorJobParametersTests.java
@@ -15,7 +15,7 @@
*/
package org.springframework.batch.core.step.job;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -33,7 +33,7 @@ import org.springframework.batch.support.PropertiesConverter;
*
*/
public class DefaultJobParametersExtractorJobParametersTests {
-
+
private DefaultJobParametersExtractor extractor = new DefaultJobParametersExtractor();
@Test
@@ -43,7 +43,7 @@ public class DefaultJobParametersExtractorJobParametersTests {
JobParameters jobParameters = extractor.getJobParameters(null, stepExecution);
assertEquals("{foo=bar}", jobParameters.toString());
}
-
+
@Test
public void testGetAllJobParameters() throws Exception {
StepExecution stepExecution = getStepExecution("foo=bar,spam=bucket");
@@ -51,7 +51,7 @@ public class DefaultJobParametersExtractorJobParametersTests {
JobParameters jobParameters = extractor.getJobParameters(null, stepExecution);
assertEquals("{spam=bucket, foo=bar}", jobParameters.toString());
}
-
+
@Test
public void testGetNamedLongStringParameters() throws Exception {
StepExecution stepExecution = getStepExecution("foo=bar");
@@ -100,7 +100,7 @@ public class DefaultJobParametersExtractorJobParametersTests {
*/
private StepExecution getStepExecution(String parameters) {
JobParameters jobParameters = new DefaultJobParametersConverter().getJobParameters(PropertiesConverter.stringToProperties(parameters));
- return new StepExecution("step", new JobExecution(new JobInstance(1L, jobParameters, "job")));
+ return new StepExecution("step", new JobExecution(new JobInstance(1L, "job"), jobParameters));
}
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java
index e9a61deda..5914fb57a 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java
@@ -35,7 +35,7 @@ import org.springframework.batch.item.ExecutionContext;
/**
* @author Dave Syer
- *
+ *
*/
public class JobStepTests {
@@ -143,7 +143,7 @@ public class JobStepTests {
step.setJob(new JobSupport("child") {
@Override
public void execute(JobExecution execution) throws UnexpectedJobExecutionException {
- assertEquals(1, execution.getJobInstance().getJobParameters().getParameters().size());
+ assertEquals(1, execution.getJobParameters().getParameters().size());
execution.setStatus(BatchStatus.FAILED);
execution.setEndTime(new Date());
jobRepository.update(execution);
@@ -160,11 +160,11 @@ public class JobStepTests {
JobExecution jobExecution = stepExecution.getJobExecution();
jobExecution.setEndTime(new Date());
jobRepository.update(jobExecution);
-
+
jobExecution = jobRepository.createJobExecution("job", new JobParameters());
stepExecution = jobExecution.createStepExecution("step");
// In a restart the surrounding Job would set up the context like this...
- stepExecution.setExecutionContext(executionContext);
+ stepExecution.setExecutionContext(executionContext);
jobRepository.add(stepExecution);
step.execute(stepExecution);
assertEquals("FOO", stepExecution.getFailureExceptions().get(0).getMessage());
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java
index 7600d86a7..bcd11a66a 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java
@@ -113,7 +113,6 @@ public class AsyncChunkOrientedStepIntegrationTests {
repeatTemplate.setTaskExecutor(new SimpleAsyncTaskExecutor());
step.setStepOperations(repeatTemplate);
step.setTransactionManager(transactionManager);
-
}
@Test
@@ -134,11 +133,10 @@ public class AsyncChunkOrientedStepIntegrationTests {
jobRepository.add(stepExecution);
step.execute(stepExecution);
assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
+ dataSource.setMaxActive(2);
StepExecution lastStepExecution = jobRepository.getLastStepExecution(jobExecution.getJobInstance(), step
.getName());
assertEquals(lastStepExecution, stepExecution);
assertFalse(lastStepExecution == stepExecution);
-
}
-
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapterTests.java
index da8fbcc13..1600c2c81 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapterTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapterTests.java
@@ -25,19 +25,18 @@ import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
-import org.springframework.batch.core.step.tasklet.MethodInvokingTaskletAdapter;
/**
* @author Dave Syer
*
*/
public class StepHandlerAdapterTests {
-
+
private MethodInvokingTaskletAdapter tasklet = new MethodInvokingTaskletAdapter();
private Object result = null;
-
+
private StepExecution stepExecution = new StepExecution("systemCommandStep", new JobExecution(new JobInstance(1L,
- new JobParameters(), "systemCommandJob")));
+ "systemCommandJob"), new JobParameters()));
public ExitStatus execute() {
return ExitStatus.NOOP;
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java
index 89711b90f..dcb3e9aa1 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java
@@ -31,7 +31,7 @@ public class SystemCommandTaskletIntegrationTests {
private SystemCommandTasklet tasklet = new SystemCommandTasklet();
private StepExecution stepExecution = new StepExecution("systemCommandStep", new JobExecution(new JobInstance(1L,
- new JobParameters(), "systemCommandJob")));
+ "systemCommandJob"), new JobParameters()));
@Before
public void setUp() throws Exception {
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java
index 847fcf0bf..b0425e43e 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java
@@ -85,6 +85,8 @@ public class TaskletStepTests {
private JobInstance jobInstance;
+ private JobParameters jobParameters;
+
private ResourcelessTransactionManager transactionManager;
@SuppressWarnings("serial")
@@ -125,7 +127,8 @@ public class TaskletStepTests {
step.setStepOperations(template);
job = new JobSupport("FOO");
- jobInstance = new JobInstance(0L, new JobParameters(), job.getName());
+ jobInstance = new JobInstance(0L, job.getName());
+ jobParameters = new JobParameters();
step.setTransactionManager(transactionManager);
@@ -133,7 +136,7 @@ public class TaskletStepTests {
@Test
public void testStepExecutor() throws Exception {
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
step.execute(stepExecution);
assertEquals(1, processed.size());
@@ -143,7 +146,7 @@ public class TaskletStepTests {
@Test
public void testCommitCount_Even() throws Exception {
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
step = getStep(new String[] { "foo", "bar", "spam", "eggs" }, 2);
step.setTransactionManager(transactionManager);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
@@ -156,7 +159,7 @@ public class TaskletStepTests {
@Test
public void testCommitCount_Uneven() throws Exception {
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
step = getStep(new String[] { "foo", "bar", "spam" }, 2);
step.setTransactionManager(transactionManager);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
@@ -169,7 +172,7 @@ public class TaskletStepTests {
@Test
public void testEmptyReader() throws Exception {
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
step = getStep(new String[0]);
step.setTasklet(new TestingChunkOrientedTasklet(getReader(new String[0]), itemWriter,
@@ -190,7 +193,7 @@ public class TaskletStepTests {
@Test
public void testStepExecutionUpdates() throws Exception {
- JobExecution jobExecution = new JobExecution(jobInstance);
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
step.setStepOperations(new RepeatTemplate());
@@ -211,7 +214,7 @@ public class TaskletStepTests {
@Test
public void testStepExecutionUpdateFailure() throws Exception {
- JobExecution jobExecution = new JobExecution(jobInstance);
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
JobRepository repository = new JobRepositoryFailedUpdateStub();
@@ -230,7 +233,7 @@ public class TaskletStepTests {
new MapStepExecutionDao(), new MapExecutionContextDao());
step.setJobRepository(repository);
- JobExecution jobExecution = repository.createJobExecution(job.getName(), jobInstance.getJobParameters());
+ JobExecution jobExecution = repository.createJobExecution(job.getName(), jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
repository.add(stepExecution);
step.execute(stepExecution);
@@ -250,7 +253,7 @@ public class TaskletStepTests {
};
step.setTasklet(new TestingChunkOrientedTasklet(itemReader, itemWriter));
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
try {
@@ -276,7 +279,7 @@ public class TaskletStepTests {
};
step.setTasklet(new TestingChunkOrientedTasklet(itemReader, itemWriter));
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
try {
@@ -308,7 +311,7 @@ public class TaskletStepTests {
return ExitStatus.FAILED.addExitDescription("FOO");
}
});
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
try {
@@ -331,7 +334,7 @@ public class TaskletStepTests {
MockRestartableItemReader tasklet = new MockRestartableItemReader();
step.setTasklet(new TestingChunkOrientedTasklet(tasklet, itemWriter));
step.registerStream(tasklet);
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
step.execute(stepExecution);
@@ -342,7 +345,7 @@ public class TaskletStepTests {
@Test
public void testSuccessfulExecutionWithExecutionContext() throws Exception {
- final JobExecution jobExecution = new JobExecution(jobInstance);
+ final JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
final StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
step.setJobRepository(new JobRepositorySupport() {
@Override
@@ -359,7 +362,7 @@ public class TaskletStepTests {
@Test
public void testSuccessfulExecutionWithFailureOnSaveOfExecutionContext() throws Exception {
- final JobExecution jobExecution = new JobExecution(jobInstance);
+ final JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
final StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
step.setJobRepository(new JobRepositorySupport() {
private int counter = 0;
@@ -389,7 +392,7 @@ public class TaskletStepTests {
public void testNoSaveExecutionAttributesRestartableJob() {
MockRestartableItemReader tasklet = new MockRestartableItemReader();
step.setTasklet(new TestingChunkOrientedTasklet(tasklet, itemWriter));
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
try {
@@ -415,7 +418,7 @@ public class TaskletStepTests {
return "foo";
}
}, itemWriter));
- JobExecution jobExecution = new JobExecution(jobInstance);
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
step.execute(stepExecution);
@@ -436,7 +439,7 @@ public class TaskletStepTests {
};
step.setTasklet(new TestingChunkOrientedTasklet(reader, itemWriter));
step.registerStream(reader);
- JobExecution jobExecution = new JobExecution(jobInstance);
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
assertEquals(false, stepExecution.getExecutionContext().containsKey("foo"));
@@ -456,7 +459,7 @@ public class TaskletStepTests {
executionContext.putString("foo", "bar");
}
} });
- JobExecution jobExecution = new JobExecution(jobInstance);
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
assertEquals(false, stepExecution.getExecutionContext().containsKey("foo"));
@@ -480,7 +483,7 @@ public class TaskletStepTests {
return null;
}
});
- JobExecution jobExecution = new JobExecution(jobInstance);
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
step.execute(stepExecution);
assertEquals(2, list.size());
@@ -501,7 +504,7 @@ public class TaskletStepTests {
};
step.setStreams(new ItemStream[] { reader });
step.registerStepExecutionListener(reader);
- StepExecution stepExecution = new StepExecution(step.getName(), new JobExecution(jobInstance));
+ StepExecution stepExecution = new StepExecution(step.getName(), new JobExecution(jobInstance, jobParameters));
step.execute(stepExecution);
assertEquals(1, list.size());
}
@@ -523,7 +526,7 @@ public class TaskletStepTests {
stepTemplate.setCompletionPolicy(new SimpleCompletionPolicy(5));
step.setStepOperations(stepTemplate);
- JobExecution jobExecution = new JobExecution(jobInstance);
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
step.execute(stepExecution);
assertEquals(1, list.size());
@@ -547,7 +550,7 @@ public class TaskletStepTests {
throw new RuntimeException("FOO");
}
}, itemWriter));
- JobExecution jobExecution = new JobExecution(jobInstance);
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
step.execute(stepExecution);
assertEquals("FOO", stepExecution.getFailureExceptions().get(0).getMessage());
@@ -569,7 +572,7 @@ public class TaskletStepTests {
};
step.setTasklet(new TestingChunkOrientedTasklet(reader, itemWriter));
step.setStreams(new ItemStream[] { reader });
- JobExecution jobExecution = new JobExecution(jobInstance);
+ JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
assertEquals(false, stepExecution.getExecutionContext().containsKey("foo"));
@@ -606,7 +609,7 @@ public class TaskletStepTests {
step.setTasklet(new TestingChunkOrientedTasklet(itemReader, itemWriter));
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
stepExecution.setExecutionContext(foobarEc);
@@ -630,7 +633,7 @@ public class TaskletStepTests {
};
step.setTasklet(new TestingChunkOrientedTasklet(itemReader, itemWriter));
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
stepExecution.setExecutionContext(foobarEc);
@@ -654,7 +657,7 @@ public class TaskletStepTests {
};
step.setTasklet(new TestingChunkOrientedTasklet(itemReader, itemWriter));
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
stepExecution.setExecutionContext(foobarEc);
@@ -686,7 +689,7 @@ public class TaskletStepTests {
}
});
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
stepExecution.setExecutionContext(foobarEc);
@@ -716,7 +719,7 @@ public class TaskletStepTests {
}
});
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
stepExecution.setExecutionContext(foobarEc);
@@ -740,7 +743,7 @@ public class TaskletStepTests {
}
} });
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
step.execute(stepExecution);
@@ -768,7 +771,7 @@ public class TaskletStepTests {
step.setTasklet(new TestingChunkOrientedTasklet(itemReader, itemWriter));
step.registerStream(itemReader);
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
stepExecution.setExecutionContext(foobarEc);
@@ -801,7 +804,7 @@ public class TaskletStepTests {
step.setTasklet(new TestingChunkOrientedTasklet(reader, itemWriter));
step.registerStream(reader);
- StepExecution stepExecution = new StepExecution(step.getName(), new JobExecution(jobInstance));
+ StepExecution stepExecution = new StepExecution(step.getName(), new JobExecution(jobInstance, jobParameters));
step.execute(stepExecution);
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
@@ -820,7 +823,7 @@ public class TaskletStepTests {
template.setCompletionPolicy(new DefaultResultCompletionPolicy());
step.setStepOperations(template);
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
step.execute(stepExecution);
@@ -842,7 +845,7 @@ public class TaskletStepTests {
}
};
step.setStepExecutionListeners(new StepExecutionListener[] { listener });
- StepExecution stepExecution = new StepExecution(step.getName(), new JobExecution(jobInstance));
+ StepExecution stepExecution = new StepExecution(step.getName(), new JobExecution(jobInstance, jobParameters));
step.execute(stepExecution);
assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
@@ -859,7 +862,7 @@ public class TaskletStepTests {
}
});
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
@SuppressWarnings("serial")
@@ -883,7 +886,7 @@ public class TaskletStepTests {
return null;
}
});
- JobExecution jobExecutionContext = new JobExecution(jobInstance);
+ JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
step.execute(stepExecution);
assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/schema-prefix-hsqldb.sql b/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/schema-prefix-hsqldb.sql
index 88d8c559b..ba2a35821 100644
--- a/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/schema-prefix-hsqldb.sql
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/schema-prefix-hsqldb.sql
@@ -10,19 +10,19 @@ DROP TABLE PREFIX_JOB_EXECUTION_SEQ IF EXISTS;
DROP TABLE PREFIX_JOB_SEQ IF EXISTS;
CREATE TABLE PREFIX_JOB_INSTANCE (
- JOB_INSTANCE_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
- JOB_NAME VARCHAR(100) NOT NULL,
+ JOB_INSTANCE_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
+ VERSION BIGINT ,
+ JOB_NAME VARCHAR(100) NOT NULL,
JOB_KEY VARCHAR(32) NOT NULL,
constraint PREFIX_JOB_INST_UN unique (JOB_NAME, JOB_KEY)
) ;
CREATE TABLE PREFIX_JOB_EXECUTION (
JOB_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
- VERSION BIGINT ,
+ VERSION BIGINT ,
JOB_INSTANCE_ID BIGINT NOT NULL,
CREATE_TIME TIMESTAMP NOT NULL,
- START_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP DEFAULT NULL ,
END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
EXIT_CODE VARCHAR(20) ,
@@ -31,35 +31,36 @@ CREATE TABLE PREFIX_JOB_EXECUTION (
constraint PREFIX_JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
references PREFIX_JOB_INSTANCE(JOB_INSTANCE_ID)
) ;
-
-CREATE TABLE PREFIX_JOB_PARAMS (
- JOB_INSTANCE_ID BIGINT NOT NULL ,
+
+CREATE TABLE PREFIX_JOB_EXECUTION_PARAMS (
+ JOB_EXECUTION_ID BIGINT NOT NULL ,
TYPE_CD VARCHAR(6) NOT NULL ,
- KEY_NAME VARCHAR(100) NOT NULL ,
- STRING_VAL VARCHAR(250) ,
+ KEY_NAME VARCHAR(100) NOT NULL ,
+ STRING_VAL VARCHAR(250) ,
DATE_VAL TIMESTAMP DEFAULT NULL ,
LONG_VAL BIGINT ,
DOUBLE_VAL DOUBLE PRECISION ,
- constraint PREFIX_JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
- references PREFIX_JOB_INSTANCE(JOB_INSTANCE_ID)
+ IDENTIFYING CHAR(1) NOT NULL ,
+ constraint PREFIX_JOB_INST_PARAMS_FK foreign key (JOB_EXECUTION_ID)
+ references PREFIX_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
-
+
CREATE TABLE PREFIX_STEP_EXECUTION (
STEP_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
- VERSION BIGINT NOT NULL,
+ VERSION BIGINT NOT NULL,
STEP_NAME VARCHAR(100) NOT NULL,
JOB_EXECUTION_ID BIGINT NOT NULL,
- START_TIME TIMESTAMP NOT NULL ,
- END_TIME TIMESTAMP DEFAULT NULL ,
+ START_TIME TIMESTAMP NOT NULL ,
+ END_TIME TIMESTAMP DEFAULT NULL ,
STATUS VARCHAR(10) ,
- COMMIT_COUNT BIGINT ,
+ COMMIT_COUNT BIGINT ,
READ_COUNT BIGINT ,
FILTER_COUNT BIGINT ,
WRITE_COUNT BIGINT ,
READ_SKIP_COUNT BIGINT ,
WRITE_SKIP_COUNT BIGINT ,
PROCESS_SKIP_COUNT BIGINT ,
- ROLLBACK_COUNT BIGINT ,
+ ROLLBACK_COUNT BIGINT ,
EXIT_CODE VARCHAR(20) ,
EXIT_MESSAGE VARCHAR(2500) ,
LAST_UPDATED TIMESTAMP,
@@ -70,7 +71,7 @@ CREATE TABLE PREFIX_STEP_EXECUTION (
CREATE TABLE PREFIX_STEP_EXECUTION_CONTEXT (
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT LONGVARCHAR ,
+ SERIALIZED_CONTEXT LONGVARCHAR ,
constraint PREFIX_STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
references PREFIX_STEP_EXECUTION(STEP_EXECUTION_ID)
) ;
@@ -78,7 +79,7 @@ CREATE TABLE PREFIX_STEP_EXECUTION_CONTEXT (
CREATE TABLE PREFIX_JOB_EXECUTION_CONTEXT (
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
- SERIALIZED_CONTEXT LONGVARCHAR ,
+ SERIALIZED_CONTEXT LONGVARCHAR ,
constraint PREFIX_JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
references PREFIX_JOB_EXECUTION(JOB_EXECUTION_ID)
) ;
diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java
index 11097c01a..c24fa8f4b 100644
--- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java
+++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java
@@ -52,7 +52,7 @@ public class StagingItemReaderTests {
@BeforeTransaction
public void onSetUpBeforeTransaction() throws Exception {
StepExecution stepExecution = new StepExecution("stepName", new JobExecution(new JobInstance(jobId,
- new JobParameters(), "testJob")));
+ "testJob"), new JobParameters()));
writer.beforeStep(stepExecution);
writer.write(Arrays.asList(new String[] { "FOO", "BAR", "SPAM", "BUCKET" }));
reader.beforeStep(stepExecution);
@@ -61,7 +61,7 @@ public class StagingItemReaderTests {
@AfterTransaction
public void onTearDownAfterTransaction() throws Exception {
reader.destroy();
- jdbcTemplate.update("DELETE FROM BATCH_STAGING");
+ jdbcTemplate.update("DELETE FROM BATCH_STAGING");
}
@Transactional
diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java
index f67f2402b..1fccfce0b 100644
--- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java
+++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java
@@ -52,7 +52,7 @@ public class StagingItemWriterTests {
@Before
public void onSetUpBeforeTransaction() throws Exception {
StepExecution stepExecution = new StepExecution("stepName", new JobExecution(new JobInstance(12L,
- new JobParameters(), "testJob")));
+ "testJob"), new JobParameters()));
writer.beforeStep(stepExecution);
}
diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java b/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java
index 49d3dd0b5..2ae8555f2 100644
--- a/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java
+++ b/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java
@@ -37,9 +37,9 @@ import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.DataAccessException;
-import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.util.Assert;
/**
@@ -47,7 +47,7 @@ import org.springframework.util.Assert;
* from a database. Typical usage in test case would be to create instances
* before a transaction, save the result, and then use it to remove them after
* the transaction.
- *
+ *
* @author Dave Syer
*/
public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao implements InitializingBean {
@@ -58,7 +58,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
Long count = 0L;
- @Override
+ @Override
public JobParameters getNext(JobParameters parameters) {
return new JobParameters(Collections.singletonMap("count", new JobParameter(count++)));
}
@@ -70,7 +70,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
/**
* @see InitializingBean#afterPropertiesSet()
*/
- @Override
+ @Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(jobRepository, "JobRepository must be set");
Assert.notNull(jdbcTemplate, "DataSource must be set");
@@ -85,7 +85,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
/**
* Create a {@link JobRepositoryTestUtils} with all its mandatory
* properties.
- *
+ *
* @param jobRepository a {@link JobRepository} backed by a database
* @param dataSource a {@link DataSource}
*/
@@ -117,7 +117,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
* Use the {@link JobRepository} to create some {@link JobExecution}
* instances each with the given job name and each having step executions
* with the given step names.
- *
+ *
* @param jobName the name of the job
* @param stepNames the names of the step executions
* @param count the required number of instances of {@link JobExecution} to
@@ -143,14 +143,14 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
/**
* Use the {@link JobRepository} to create some {@link JobExecution}
* instances each with a single step execution.
- *
+ *
* @param count the required number of instances of {@link JobExecution} to
* create
* @return a collection of {@link JobExecution}
* @throws Exception if there is a problem in the {@link JobRepository}
*/
public List createJobExecutions(int count) throws JobExecutionAlreadyRunningException,
- JobRestartException, JobInstanceAlreadyCompleteException {
+ JobRestartException, JobInstanceAlreadyCompleteException {
return createJobExecutions("job", new String[] { "step" }, count);
}
@@ -158,7 +158,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
* Remove the {@link JobExecution} instances, and all associated
* {@link JobInstance} and {@link StepExecution} instances from the standard
* RDBMS locations used by Spring Batch.
- *
+ *
* @param list a list of {@link JobExecution}
* @throws DataAccessException if there is a problem
*/
@@ -167,7 +167,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
List stepExecutionIds = jdbcTemplate.query(
getQuery("select STEP_EXECUTION_ID from %PREFIX%STEP_EXECUTION where JOB_EXECUTION_ID=?"),
new ParameterizedRowMapper() {
- @Override
+ @Override
public Long mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getLong(1);
}
@@ -180,12 +180,12 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
}
jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_CONTEXT where JOB_EXECUTION_ID=?"),
jobExecution.getId());
+ jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_PARAMS where JOB_EXECUTION_ID=?"), jobExecution
+ .getId());
jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION where JOB_EXECUTION_ID=?"), jobExecution
.getId());
}
- for (JobExecution jobExecution : list) {
- jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_PARAMS where JOB_INSTANCE_ID=?"), jobExecution
- .getJobId());
+ for (JobExecution jobExecution : list) {
jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_INSTANCE where JOB_INSTANCE_ID=?"), jobExecution
.getJobId());
}
@@ -195,15 +195,15 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
* Remove all the {@link JobExecution} instances, and all associated
* {@link JobInstance} and {@link StepExecution} instances from the standard
* RDBMS locations used by Spring Batch.
- *
+ *
* @throws DataAccessException if there is a problem
*/
public void removeJobExecutions() throws DataAccessException {
jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION_CONTEXT"));
jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION"));
jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_CONTEXT"));
+ jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_PARAMS"));
jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION"));
- jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_PARAMS"));
jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_INSTANCE"));
}
diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/MetaDataInstanceFactory.java b/spring-batch-test/src/main/java/org/springframework/batch/test/MetaDataInstanceFactory.java
index 68ee1551d..de2d72f63 100644
--- a/spring-batch-test/src/main/java/org/springframework/batch/test/MetaDataInstanceFactory.java
+++ b/spring-batch-test/src/main/java/org/springframework/batch/test/MetaDataInstanceFactory.java
@@ -28,9 +28,9 @@ import org.springframework.batch.support.PropertiesConverter;
/**
* Convenience methods for creating test instances of {@link JobExecution},
* {@link JobInstance} and {@link StepExecution}.
- *
+ *
* @author Dave Syer
- *
+ *
*/
public class MetaDataInstanceFactory {
@@ -61,54 +61,28 @@ public class MetaDataInstanceFactory {
/**
* Create a {@link JobInstance} with the parameters provided.
- *
- * @param jobName the name of the job
- * @param instanceId the Id of the {@link JobInstance}
- * @param jobParameters comma or new line separated name=value pairs
- * @return a {@link JobInstance}
- */
- public static JobInstance createJobInstance(String jobName, Long instanceId, String jobParameters) {
- JobParameters params = new DefaultJobParametersConverter().getJobParameters(PropertiesConverter
- .stringToProperties(jobParameters));
- return createJobInstance(jobName, instanceId, params);
- }
-
- /**
- * Create a {@link JobInstance} with the parameters provided.
- *
- * @param jobName the name of the job
- * @param instanceId the Id of the {@link JobInstance}
- * @param jobParameters an instance of {@link JobParameters}
- * @return a {@link JobInstance}
- */
- public static JobInstance createJobInstance(String jobName, Long instanceId, JobParameters jobParameters) {
- return new JobInstance(instanceId, jobParameters, jobName);
- }
-
- /**
- * Create a {@link JobInstance} with the parameters provided.
- *
+ *
* @param jobName the name of the job
* @param instanceId the Id of the {@link JobInstance}
* @return a {@link JobInstance} with empty {@link JobParameters}
*/
public static JobInstance createJobInstance(String jobName, Long instanceId) {
- return new JobInstance(instanceId, new JobParameters(), jobName);
+ return new JobInstance(instanceId, jobName);
}
/**
* Create a {@link JobInstance} with default parameters.
- *
+ *
* @return a {@link JobInstance} with name=DEFAULT_JOB_NAME,
* id=DEFAULT_JOB_INSTANCE_ID and empty parameters
*/
public static JobInstance createJobInstance() {
- return new JobInstance(DEFAULT_JOB_INSTANCE_ID, new JobParameters(), DEFAULT_JOB_NAME);
+ return new JobInstance(DEFAULT_JOB_INSTANCE_ID, DEFAULT_JOB_NAME);
}
/**
* Create a {@link JobExecution} with default parameters.
- *
+ *
* @return a {@link JobExecution} with id=DEFAULT_JOB_EXECUTION_ID
*/
public static JobExecution createJobExecution() {
@@ -117,7 +91,7 @@ public class MetaDataInstanceFactory {
/**
* Create a {@link JobExecution} with the parameters provided.
- *
+ *
* @param executionId the id for the {@link JobExecution}
* @return a {@link JobExecution} with valid {@link JobInstance}
*/
@@ -127,7 +101,7 @@ public class MetaDataInstanceFactory {
/**
* Create a {@link JobExecution} with the parameters provided.
- *
+ *
* @param jobName the name of the job
* @param instanceId the id for the {@link JobInstance}
* @param executionId the id for the {@link JobExecution}
@@ -139,7 +113,7 @@ public class MetaDataInstanceFactory {
/**
* Create a {@link JobExecution} with the parameters provided.
- *
+ *
* @param jobName the name of the job
* @param instanceId the Id of the {@link JobInstance}
* @param executionId the id for the {@link JobExecution}
@@ -155,7 +129,7 @@ public class MetaDataInstanceFactory {
/**
* Create a {@link JobExecution} with the parameters provided.
- *
+ *
* @param jobName the name of the job
* @param instanceId the Id of the {@link JobInstance}
* @param executionId the id for the {@link JobExecution}
@@ -164,12 +138,12 @@ public class MetaDataInstanceFactory {
*/
public static JobExecution createJobExecution(String jobName, Long instanceId, Long executionId,
JobParameters jobParameters) {
- return new JobExecution(createJobInstance(jobName, instanceId, jobParameters), executionId);
+ return new JobExecution(createJobInstance(jobName, instanceId), executionId, jobParameters);
}
/**
* Create a {@link StepExecution} with default parameters.
- *
+ *
* @return a {@link StepExecution} with stepName="step" and
* id=DEFAULT_STEP_EXECUTION_ID
*/
@@ -179,7 +153,7 @@ public class MetaDataInstanceFactory {
/**
* Create a {@link StepExecution} with the parameters provided.
- *
+ *
* @param stepName the stepName for the {@link StepExecution}
* @param executionId the id for the {@link StepExecution}
* @return a {@link StepExecution} with a {@link JobExecution} having
@@ -191,7 +165,7 @@ public class MetaDataInstanceFactory {
/**
* Create a {@link StepExecution} with the parameters provided.
- *
+ *
* @param stepName the stepName for the {@link StepExecution}
* @param executionId the id for the {@link StepExecution}
* @return a {@link StepExecution} with the given {@link JobExecution}
@@ -205,7 +179,7 @@ public class MetaDataInstanceFactory {
/**
* Create a {@link JobExecution} with the parameters provided with attached
* step executions.
- *
+ *
* @param executionId the {@link JobExecution} id
* @param stepNames the names of the step executions
* @return a {@link JobExecution} with step executions as specified, each
@@ -225,10 +199,10 @@ public class MetaDataInstanceFactory {
* Create a {@link StepExecution} and all its parent entities with default
* values, but using the {@link ExecutionContext} and {@link JobParameters}
* provided.
- *
+ *
* @param jobParameters come {@link JobParameters}
* @param executionContext some {@link ExecutionContext}
- *
+ *
* @return a {@link StepExecution} with the execution context provided
*/
public static StepExecution createStepExecution(JobParameters jobParameters, ExecutionContext executionContext) {
@@ -240,7 +214,7 @@ public class MetaDataInstanceFactory {
/**
* Create a {@link StepExecution} and all its parent entities with default
* values, but using the {@link JobParameters} provided.
- *
+ *
* @param jobParameters some {@link JobParameters}
* @return a {@link StepExecution} with the job parameters provided
*/
@@ -253,7 +227,7 @@ public class MetaDataInstanceFactory {
/**
* Create a {@link StepExecution} and all its parent entities with default
* values, but using the {@link ExecutionContext} provided.
- *
+ *
* @param executionContext some {@link ExecutionContext}
* @return a {@link StepExecution} with the execution context provided
*/
diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java b/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java
index c5b87685b..a529b38d3 100755
--- a/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java
+++ b/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java
@@ -45,7 +45,7 @@ import org.springframework.batch.item.ExecutionContext;
* Utility class for executing steps outside of a {@link Job}. This is useful in
* end to end testing in order to allow for the testing of a step individually
* without running every Step in a job.
- *
+ *
*
*
launchStep(Step step): Launch the step with new parameters each
* time. (The current system time will be used)
@@ -53,12 +53,12 @@ import org.springframework.batch.item.ExecutionContext;
* specified step with the provided JobParameters. This may be useful if your
* step requires a certain parameter during runtime.
*
- *
+ *
* It should be noted that any checked exceptions encountered while running the
* Step will wrapped with RuntimeException. Any checked exception thrown will be
* due to a framework error, not the logic of the step, and thus requiring a
* throws declaration in clients of this class is unnecessary.
- *
+ *
* @author Dan Garrette
* @author Lucas Ward
* @since 2.0
@@ -82,8 +82,8 @@ public class StepRunner {
* Launch just the specified step as its own job. A unique set of
* JobParameters will automatically be generated. An IllegalStateException
* is thrown if there is no Step with the given name.
- *
- * @param stepName The name of the step to launch
+ *
+ * @param step The step to launch
* @return JobExecution
*/
public JobExecution launchStep(Step step) {
@@ -94,8 +94,8 @@ public class StepRunner {
* Launch just the specified step as its own job. A unique set of
* JobParameters will automatically be generated. An IllegalStateException
* is thrown if there is no Step with the given name.
- *
- * @param stepName The name of the step to launch
+ *
+ * @param step The step to launch
* @param jobExecutionContext An ExecutionContext whose values will be
* loaded into the Job ExecutionContext prior to launching the step.
* @return JobExecution
@@ -107,8 +107,8 @@ public class StepRunner {
/**
* Launch just the specified step as its own job. An IllegalStateException
* is thrown if there is no Step with the given name.
- *
- * @param stepName The name of the step to launch
+ *
+ * @param step The step to launch
* @param jobParameters The JobParameters to use during the launch
* @return JobExecution
*/
@@ -119,8 +119,8 @@ public class StepRunner {
/**
* Launch just the specified step as its own job. An IllegalStateException
* is thrown if there is no Step with the given name.
- *
- * @param stepName The name of the step to launch
+ *
+ * @param step The step to launch
* @param jobParameters The JobParameters to use during the launch
* @param jobExecutionContext An ExecutionContext whose values will be
* loaded into the Job ExecutionContext prior to launching the step.
@@ -143,7 +143,7 @@ public class StepRunner {
//
if (jobExecutionContext != null && !jobExecutionContext.isEmpty()) {
job.setJobExecutionListeners(new JobExecutionListener[] { new JobExecutionListenerSupport() {
- @Override
+ @Override
public void beforeJob(JobExecution jobExecution) {
ExecutionContext jobContext = jobExecution.getExecutionContext();
for (Map.Entry entry : jobExecutionContext.entrySet()) {
@@ -161,7 +161,7 @@ public class StepRunner {
/**
* Launch the given job
- *
+ *
* @param job
* @param jobParameters
*/
diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java b/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java
index 6d1e29816..701aaad24 100644
--- a/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java
+++ b/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java
@@ -39,7 +39,7 @@ import org.springframework.test.jdbc.JdbcTestUtils;
/**
* @author Dave Syer
- *
+ *
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "/simple-job-launcher-context.xml")
@@ -65,7 +65,7 @@ public class JobRepositoryTestUtilsTests {
beforeJobs = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION");
beforeSteps = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
}
-
+
@Test(expected=IllegalArgumentException.class)
public void testMandatoryProperties() throws Exception {
utils = new JobRepositoryTestUtils();
@@ -134,14 +134,14 @@ public class JobRepositoryTestUtilsTests {
public void testCreateJobExecutionsWithIncrementer() throws Exception {
utils = new JobRepositoryTestUtils(jobRepository, dataSource);
utils.setJobParametersIncrementer(new JobParametersIncrementer() {
- @Override
+ @Override
public JobParameters getNext(JobParameters parameters) {
return new JobParametersBuilder().addString("foo","bar").toJobParameters();
}
});
List list = utils.createJobExecutions(1);
assertEquals(1, list.size());
- assertEquals("bar", list.get(0).getJobInstance().getJobParameters().getString("foo"));
+ assertEquals("bar", list.get(0).getJobParameters().getString("foo"));
utils.removeJobExecutions(list);
assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
}
diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/MetaDataInstanceFactoryTests.java b/spring-batch-test/src/test/java/org/springframework/batch/test/MetaDataInstanceFactoryTests.java
index f12782c65..ac31e4dba 100644
--- a/spring-batch-test/src/test/java/org/springframework/batch/test/MetaDataInstanceFactoryTests.java
+++ b/spring-batch-test/src/test/java/org/springframework/batch/test/MetaDataInstanceFactoryTests.java
@@ -27,7 +27,7 @@ import org.springframework.batch.support.PropertiesConverter;
/**
* @author Dave Syer
- *
+ *
*/
public class MetaDataInstanceFactoryTests {
@@ -46,25 +46,6 @@ public class MetaDataInstanceFactoryTests {
private Long stepExecutionId = 11L;
- /**
- * Test method for
- * {@link MetaDataInstanceFactory#createJobInstance(String, Long, String)} .
- */
- @Test
- public void testCreateJobInstanceStringLongString() {
- assertNotNull(MetaDataInstanceFactory.createJobInstance(jobName, instanceId, jobParametersString));
- }
-
- /**
- * Test method for
- * {@link MetaDataInstanceFactory#createJobInstance(String, Long, JobParameters)}
- * .
- */
- @Test
- public void testCreateJobInstanceStringLongJobParameters() {
- assertNotNull(MetaDataInstanceFactory.createJobInstance(jobName, instanceId, jobParameters));
- }
-
/**
* Test method for
* {@link MetaDataInstanceFactory#createJobInstance(String, Long)} .