Refactored AbstractJsrTestCase to expose JobOperator instance

This commit is contained in:
Michael Minella
2015-02-19 13:06:51 -06:00
parent 15e7c3bc1e
commit 4839102ed5
2 changed files with 11 additions and 9 deletions

View File

@@ -15,22 +15,23 @@
*/
package org.springframework.batch.core.jsr;
import java.util.Date;
import java.util.Properties;
import java.util.concurrent.TimeoutException;
import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.Metric;
import javax.batch.runtime.StepExecution;
import java.util.Date;
import java.util.Properties;
import java.util.concurrent.TimeoutException;
/**
* @author mminella
*/
public abstract class AbstractJsrTestCase {
private static JobOperator operator;
protected static JobOperator operator;
static {
operator = BatchRuntime.getJobOperator();
@@ -49,6 +50,7 @@ public abstract class AbstractJsrTestCase {
* @throws java.util.concurrent.TimeoutException if the timeout occurs
*/
public static JobExecution runJob(String jobName, Properties properties, long timeout) throws TimeoutException {
System.out.println("Operator = " + operator);
long executionId = operator.start(jobName, properties);
JobExecution execution = operator.getJobExecution(executionId);

View File

@@ -15,15 +15,15 @@
*/
package org.springframework.batch.core.jsr.job.flow.support.state;
import org.junit.Test;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import static org.junit.Assert.assertEquals;
import javax.batch.api.AbstractBatchlet;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
/**
* Tests for the JSR-352 version of {@link JsrEndState}
@@ -38,7 +38,7 @@ public class JsrEndStateTests extends AbstractJsrTestCase {
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
assertEquals("SUCCESS", jobExecution.getExitStatus());
assertEquals(1, BatchRuntime.getJobOperator().getStepExecutions(jobExecution.getExecutionId()).size());
assertEquals(1, operator.getStepExecutions(jobExecution.getExecutionId()).size());
}
public static class EndStateBatchlet extends AbstractBatchlet {