BATCH-2233: Moved JsrTestUtils to a location that is actually published with the release

This commit is contained in:
Michael Minella
2014-05-15 14:54:26 -05:00
parent 513e47fc9b
commit 39bb979a51
15 changed files with 249 additions and 139 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2014 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.
@@ -26,13 +26,9 @@ import java.util.Properties;
import java.util.concurrent.TimeoutException;
/**
* Provides testing utilities to execute JSR-352 jobs and block until they are complete (since all JSR-352 based jobs
* are executed asynchronously).
*
* @author Michael Minella
* @since 3.0
* @author mminella
*/
public class JsrTestUtils {
public abstract class AbstractJsrTestCase {
private static JobOperator operator;
@@ -40,21 +36,19 @@ public class JsrTestUtils {
operator = BatchRuntime.getJobOperator();
}
private JsrTestUtils() {}
/**
* Executes a job and waits for it's status to be any of {@link BatchStatus#STOPPED},
* {@link BatchStatus#COMPLETED}, or {@link BatchStatus#FAILED}. If the job does not
* reach one of those statuses within the given timeout, a {@link TimeoutException} is
* Executes a job and waits for it's status to be any of {@link javax.batch.runtime.BatchStatus#STOPPED},
* {@link javax.batch.runtime.BatchStatus#COMPLETED}, or {@link javax.batch.runtime.BatchStatus#FAILED}. If the job does not
* reach one of those statuses within the given timeout, a {@link java.util.concurrent.TimeoutException} is
* thrown.
*
* @param jobName
* @param properties
* @param timeout
* @return the {@link JobExecution} for the final state of the job
* @throws TimeoutException if the timeout occurs
* @return the {@link javax.batch.runtime.JobExecution} for the final state of the job
* @throws java.util.concurrent.TimeoutException if the timeout occurs
*/
public static JobExecution runJob(String jobName, Properties properties, long timeout) throws TimeoutException{
public static JobExecution runJob(String jobName, Properties properties, long timeout) throws TimeoutException {
long executionId = operator.start(jobName, properties);
JobExecution execution = operator.getJobExecution(executionId);
@@ -79,14 +73,14 @@ public class JsrTestUtils {
/**
* Restarts a job and waits for it's status to be any of {@link BatchStatus#STOPPED},
* {@link BatchStatus#COMPLETED}, or {@link BatchStatus#FAILED}. If the job does not
* reach one of those statuses within the given timeout, a {@link TimeoutException} is
* reach one of those statuses within the given timeout, a {@link java.util.concurrent.TimeoutException} is
* thrown.
*
* @param executionId
* @param properties
* @param timeout
* @return the {@link JobExecution} for the final state of the job
* @throws TimeoutException if the timeout occurs
* @throws java.util.concurrent.TimeoutException if the timeout occurs
*/
public static JobExecution restartJob(long executionId, Properties properties, long timeout) throws TimeoutException {
long restartId = operator.restart(executionId, properties);
@@ -122,4 +116,5 @@ public class JsrTestUtils {
return null;
}
}

View File

@@ -16,8 +16,7 @@
package org.springframework.batch.core.jsr.configuration.xml;
import org.junit.Test;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.jsr.JsrTestUtils;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import javax.batch.api.BatchProperty;
import javax.batch.api.chunk.ItemProcessor;
@@ -28,13 +27,12 @@ import javax.batch.runtime.JobExecution;
import javax.batch.runtime.Metric;
import javax.batch.runtime.StepExecution;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import static org.junit.Assert.assertEquals;
public class ExceptionHandlingParsingTests {
public class ExceptionHandlingParsingTests extends AbstractJsrTestCase {
@Test
public void testSkippable() throws Exception {
@@ -42,32 +40,32 @@ public class ExceptionHandlingParsingTests {
Properties jobParameters = new Properties();
jobParameters.setProperty("run", "1");
JobExecution execution1 = JsrTestUtils.runJob("ExceptionHandlingParsingTests-context", jobParameters, 10000l);
JobExecution execution1 = runJob("ExceptionHandlingParsingTests-context", jobParameters, 10000l);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(execution1.getExecutionId());
assertEquals(BatchStatus.FAILED, execution1.getBatchStatus());
assertEquals(1, stepExecutions.size());
assertEquals(1, JsrTestUtils.getMetric(stepExecutions.get(0), Metric.MetricType.PROCESS_SKIP_COUNT).getValue());
assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.PROCESS_SKIP_COUNT).getValue());
jobParameters = new Properties();
jobParameters.setProperty("run", "2");
JobExecution execution2 = JsrTestUtils.restartJob(execution1.getExecutionId(), jobParameters, 10000l);
JobExecution execution2 = restartJob(execution1.getExecutionId(), jobParameters, 10000l);
stepExecutions = jobOperator.getStepExecutions(execution2.getExecutionId());
assertEquals(BatchStatus.FAILED, execution2.getBatchStatus());
assertEquals(2, stepExecutions.size());
jobParameters = new Properties();
jobParameters.setProperty("run", "3");
JobExecution execution3 = JsrTestUtils.restartJob(execution2.getExecutionId(), jobParameters, 10000l);
JobExecution execution3 = restartJob(execution2.getExecutionId(), jobParameters, 10000l);
stepExecutions = jobOperator.getStepExecutions(execution3.getExecutionId());
assertEquals(BatchStatus.COMPLETED, execution3.getBatchStatus());
assertEquals(2, stepExecutions.size());
assertEquals(0, JsrTestUtils.getMetric(stepExecutions.get(1), Metric.MetricType.ROLLBACK_COUNT).getValue());
assertEquals(0, getMetric(stepExecutions.get(1), Metric.MetricType.ROLLBACK_COUNT).getValue());
jobParameters = new Properties();
jobParameters.setProperty("run", "4");
JobExecution execution4 = JsrTestUtils.runJob("ExceptionHandlingParsingTests-context", jobParameters, 10000l);
JobExecution execution4 = runJob("ExceptionHandlingParsingTests-context", jobParameters, 10000l);
stepExecutions = jobOperator.getStepExecutions(execution4.getExecutionId());
assertEquals(BatchStatus.COMPLETED, execution4.getBatchStatus());
assertEquals(3, stepExecutions.size());

View File

@@ -15,13 +15,9 @@
*/
package org.springframework.batch.core.jsr.configuration.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.springframework.batch.core.jsr.JsrTestUtils.restartJob;
import static org.springframework.batch.core.jsr.JsrTestUtils.runJob;
import java.util.List;
import java.util.Properties;
import org.junit.Test;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import javax.batch.api.AbstractBatchlet;
import javax.batch.operations.JobOperator;
@@ -30,9 +26,11 @@ import javax.batch.runtime.JobExecution;
import javax.batch.runtime.StepExecution;
import javax.batch.runtime.context.StepContext;
import javax.inject.Inject;
import java.util.List;
import java.util.Properties;
import org.junit.Test;
import org.springframework.batch.core.ExitStatus;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* <p>
@@ -42,7 +40,7 @@ import org.springframework.batch.core.ExitStatus;
* @author Chris Schaefer
* @since 3.0
*/
public class FlowParserTests {
public class FlowParserTests extends AbstractJsrTestCase {
@Test
public void testDuplicateTransitionPatternsAllowed() throws Exception {
JobExecution stoppedExecution = runJob("FlowParserTests-context", new Properties(), 10000L);

View File

@@ -16,7 +16,7 @@
package org.springframework.batch.core.jsr.configuration.xml;
import org.junit.Test;
import org.springframework.batch.core.jsr.JsrTestUtils;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;
@@ -35,46 +35,46 @@ import java.util.Properties;
import static org.junit.Assert.assertEquals;
public class ItemSkipParsingTests {
public class ItemSkipParsingTests extends AbstractJsrTestCase {
@Test
public void test() throws Exception {
javax.batch.runtime.JobExecution execution = JsrTestUtils.runJob("ItemSkipParsingTests-context", new Properties(), 10000l);
javax.batch.runtime.JobExecution execution = runJob("ItemSkipParsingTests-context", new Properties(), 10000l);
JobOperator jobOperator = BatchRuntime.getJobOperator();
assertEquals(BatchStatus.FAILED, execution.getBatchStatus());
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId());
assertEquals(1, JsrTestUtils.getMetric(stepExecutions.get(0), Metric.MetricType.READ_SKIP_COUNT).getValue());
assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.READ_SKIP_COUNT).getValue());
assertEquals(1, TestSkipListener.readSkips);
assertEquals(0, TestSkipListener.processSkips);
assertEquals(0, TestSkipListener.writeSkips);
// Process skip and fail
execution = JsrTestUtils.restartJob(execution.getExecutionId(), new Properties(), 10000l);
execution = restartJob(execution.getExecutionId(), new Properties(), 10000l);
assertEquals(BatchStatus.FAILED, execution.getBatchStatus());
stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId());
assertEquals(1, JsrTestUtils.getMetric(stepExecutions.get(0), Metric.MetricType.PROCESS_SKIP_COUNT).getValue());
assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.PROCESS_SKIP_COUNT).getValue());
assertEquals(0, TestSkipListener.readSkips);
assertEquals(1, TestSkipListener.processSkips);
assertEquals(0, TestSkipListener.writeSkips);
// Write skip and fail
execution = JsrTestUtils.restartJob(execution.getExecutionId(), new Properties(), 10000l);
execution = restartJob(execution.getExecutionId(), new Properties(), 10000l);
assertEquals(BatchStatus.FAILED, execution.getBatchStatus());
stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId());
assertEquals(1, JsrTestUtils.getMetric(stepExecutions.get(0), Metric.MetricType.WRITE_SKIP_COUNT).getValue());
assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.WRITE_SKIP_COUNT).getValue());
assertEquals(0, TestSkipListener.readSkips);
assertEquals(0, TestSkipListener.processSkips);
assertEquals(1, TestSkipListener.writeSkips);
// Complete
execution = JsrTestUtils.restartJob(execution.getExecutionId(), new Properties(), 10000l);
execution = restartJob(execution.getExecutionId(), new Properties(), 10000l);
assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus());
stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId());
assertEquals(0, JsrTestUtils.getMetric(stepExecutions.get(0), Metric.MetricType.WRITE_SKIP_COUNT).getValue());
assertEquals(0, getMetric(stepExecutions.get(0), Metric.MetricType.WRITE_SKIP_COUNT).getValue());
assertEquals(0, TestSkipListener.readSkips);
assertEquals(0, TestSkipListener.processSkips);
assertEquals(0, TestSkipListener.writeSkips);

View File

@@ -15,9 +15,12 @@
*/
package org.springframework.batch.core.jsr.configuration.xml;
import java.io.Serializable;
import java.util.List;
import java.util.Properties;
import org.junit.Test;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import javax.batch.api.BatchProperty;
import javax.batch.api.Batchlet;
@@ -31,13 +34,9 @@ import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.context.JobContext;
import javax.inject.Inject;
import org.junit.Test;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.jsr.JsrTestUtils;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import java.io.Serializable;
import java.util.List;
import java.util.Properties;
import static junit.framework.Assert.assertEquals;
@@ -49,7 +48,7 @@ import static junit.framework.Assert.assertEquals;
* @author Chris Schaefer
* @since 3.0
*/
public class JobPropertyTests {
public class JobPropertyTests extends AbstractJsrTestCase {
@Test
public void testJobPropertyConfiguration() throws Exception {
Properties jobParameters = new Properties();
@@ -57,7 +56,7 @@ public class JobPropertyTests {
jobParameters.setProperty("deciderName", "stepDecider");
jobParameters.setProperty("deciderNumber", "1");
JobExecution jobExecution = JsrTestUtils.runJob("jsrJobPropertyTestsContext", jobParameters, 5000L);
JobExecution jobExecution = runJob("jsrJobPropertyTestsContext", jobParameters, 5000L);
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}

View File

@@ -15,13 +15,10 @@
*/
package org.springframework.batch.core.jsr.configuration.xml;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.springframework.batch.core.jsr.JsrTestUtils;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.DefaultDocumentLoader;
import org.springframework.beans.factory.xml.DelegatingEntityResolver;
@@ -35,6 +32,9 @@ import org.xml.sax.InputSource;
import javax.batch.api.Batchlet;
import javax.batch.runtime.JobExecution;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
@@ -47,7 +47,7 @@ import static junit.framework.Assert.assertTrue;
*
* @author Chris Schaefer
*/
public class JsrBeanDefinitionDocumentReaderTests {
public class JsrBeanDefinitionDocumentReaderTests extends AbstractJsrTestCase {
private static final String JOB_PARAMETERS_BEAN_DEFINITION_NAME = "jsr_jobParameters";
private Log logger = LogFactory.getLog(getClass());
@@ -173,7 +173,7 @@ public class JsrBeanDefinitionDocumentReaderTests {
@Test
public void testArtifactUniqueness() throws Exception {
JobExecution jobExecution = JsrTestUtils.runJob("jsrUniqueInstanceTests", new Properties(), 10000L);
JobExecution jobExecution = runJob("jsrUniqueInstanceTests", new Properties(), 10000L);
String exitStatus = jobExecution.getExitStatus();
assertTrue("Exit status must contain listener3", exitStatus.contains("listener3"));
@@ -234,7 +234,7 @@ public class JsrBeanDefinitionDocumentReaderTests {
@Test
public void testSpringArtifactUniqueness() throws Exception {
JobExecution jobExecution = JsrTestUtils.runJob("jsrSpringInstanceTests", new Properties(), 10000L);
JobExecution jobExecution = runJob("jsrSpringInstanceTests", new Properties(), 10000L);
String exitStatus = jobExecution.getExitStatus();
assertTrue("Exit status must contain listener1", exitStatus.contains("listener1"));

View File

@@ -15,23 +15,11 @@
*/
package org.springframework.batch.core.jsr.configuration.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.springframework.batch.core.jsr.JsrTestUtils.runJob;
import java.util.List;
import javax.batch.api.AbstractBatchlet;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.StepExecution;
import javax.batch.runtime.context.JobContext;
import javax.inject.Inject;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
@@ -39,7 +27,18 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
public class JsrSplitParsingTests {
import javax.batch.api.AbstractBatchlet;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.StepExecution;
import javax.batch.runtime.context.JobContext;
import javax.inject.Inject;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class JsrSplitParsingTests extends AbstractJsrTestCase {
@Rule
public ExpectedException expectedException = ExpectedException.none();

View File

@@ -15,20 +15,10 @@
*/
package org.springframework.batch.core.jsr.configuration.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.springframework.batch.core.jsr.JsrTestUtils.runJob;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import org.springframework.util.Assert;
import javax.batch.api.BatchProperty;
import javax.batch.api.Batchlet;
@@ -41,12 +31,21 @@ import javax.batch.runtime.JobExecution;
import javax.batch.runtime.context.JobContext;
import javax.batch.runtime.context.StepContext;
import javax.inject.Inject;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.Before;
import org.junit.Test;
import org.springframework.util.Assert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class PartitionParserTests {
public class PartitionParserTests extends AbstractJsrTestCase {
private Pattern caPattern = Pattern.compile("ca");
private Pattern asPattern = Pattern.compile("AS");
private static final long TIMEOUT = 10000L;

View File

@@ -15,15 +15,15 @@
*/
package org.springframework.batch.core.jsr.configuration.xml;
import static org.junit.Assert.assertEquals;
import static org.springframework.batch.core.jsr.JsrTestUtils.runJob;
import org.junit.Test;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class ThreadLocalClassloaderBeanPostProcessorTests {
public class ThreadLocalClassloaderBeanPostProcessorTests extends AbstractJsrTestCase {
@Test
public void test() throws Exception {

View File

@@ -15,26 +15,26 @@
*/
package org.springframework.batch.core.jsr.job.flow.support.state;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import javax.batch.api.AbstractBatchlet;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import org.junit.Test;
import org.springframework.batch.core.jsr.JsrTestUtils;
import static org.junit.Assert.assertEquals;
/**
* Tests for the JSR-352 version of {@link JsrEndState}
*
* @author Michael Minella
*/
public class JsrEndStateTests {
public class JsrEndStateTests extends AbstractJsrTestCase {
@Test
public void test() throws Exception {
JobExecution jobExecution = JsrTestUtils.runJob("jobWithEndTransition", null, 10000L);
JobExecution jobExecution = runJob("jobWithEndTransition", null, 10000L);
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
assertEquals("SUCCESS", jobExecution.getExitStatus());

View File

@@ -28,6 +28,7 @@ import org.springframework.batch.core.converter.JobParametersConverter;
import org.springframework.batch.core.converter.JobParametersConverterSupport;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.explore.support.SimpleJobExplorer;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import org.springframework.batch.core.jsr.JsrJobParametersConverter;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.JobRepositorySupport;
@@ -60,10 +61,8 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.springframework.batch.core.jsr.JsrTestUtils.restartJob;
import static org.springframework.batch.core.jsr.JsrTestUtils.runJob;
public class JsrJobOperatorTests {
public class JsrJobOperatorTests extends AbstractJsrTestCase {
private JobOperator jsrJobOperator;
@Mock

View File

@@ -15,14 +15,20 @@
*/
package org.springframework.batch.core.jsr.partition;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.Serializable;
import java.util.Collection;
import java.util.Properties;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import org.springframework.batch.core.jsr.configuration.support.BatchPropertyContext;
import org.springframework.batch.core.jsr.step.batchlet.BatchletSupport;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
import org.springframework.batch.core.step.JobRepositorySupport;
import org.springframework.batch.core.step.StepSupport;
import javax.batch.api.BatchProperty;
import javax.batch.api.partition.PartitionAnalyzer;
@@ -33,23 +39,16 @@ import javax.batch.api.partition.PartitionPlanImpl;
import javax.batch.api.partition.PartitionReducer;
import javax.batch.runtime.BatchStatus;
import javax.inject.Inject;
import java.io.Serializable;
import java.util.Collection;
import java.util.Properties;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.jsr.JsrTestUtils;
import org.springframework.batch.core.jsr.configuration.support.BatchPropertyContext;
import org.springframework.batch.core.jsr.step.batchlet.BatchletSupport;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
import org.springframework.batch.core.step.JobRepositorySupport;
import org.springframework.batch.core.step.StepSupport;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class JsrPartitionHandlerTests {
public class JsrPartitionHandlerTests extends AbstractJsrTestCase {
private JsrPartitionHandler handler;
private JobRepository repository = new JobRepositorySupport();
@@ -222,7 +221,7 @@ public class JsrPartitionHandlerTests {
@Test
public void testRestartNoOverride() throws Exception {
javax.batch.runtime.JobExecution execution1 = JsrTestUtils.runJob("jsrPartitionHandlerRestartWithOverrideJob", null, 1000000L);
javax.batch.runtime.JobExecution execution1 = runJob("jsrPartitionHandlerRestartWithOverrideJob", null, 1000000L);
assertEquals(BatchStatus.FAILED, execution1.getBatchStatus());
assertEquals(1, MyPartitionReducer.beginCount);
assertEquals(0, MyPartitionReducer.beforeCount);
@@ -233,7 +232,7 @@ public class JsrPartitionHandlerTests {
MyPartitionReducer.reset();
CountingPartitionCollector.reset();
javax.batch.runtime.JobExecution execution2 = JsrTestUtils.restartJob(execution1.getExecutionId(), null, 1000000L);
javax.batch.runtime.JobExecution execution2 = restartJob(execution1.getExecutionId(), null, 1000000L);
assertEquals(BatchStatus.COMPLETED, execution2.getBatchStatus());
assertEquals(1, MyPartitionReducer.beginCount);
assertEquals(1, MyPartitionReducer.beforeCount);
@@ -248,7 +247,7 @@ public class JsrPartitionHandlerTests {
Properties jobParameters = new Properties();
jobParameters.put("mapper.override", "true");
javax.batch.runtime.JobExecution execution1 = JsrTestUtils.runJob("jsrPartitionHandlerRestartWithOverrideJob", jobParameters, 1000000L);
javax.batch.runtime.JobExecution execution1 = runJob("jsrPartitionHandlerRestartWithOverrideJob", jobParameters, 1000000L);
assertEquals(BatchStatus.FAILED, execution1.getBatchStatus());
assertEquals(1, MyPartitionReducer.beginCount);
assertEquals(0, MyPartitionReducer.beforeCount);
@@ -259,7 +258,7 @@ public class JsrPartitionHandlerTests {
MyPartitionReducer.reset();
CountingPartitionCollector.reset();
javax.batch.runtime.JobExecution execution2 = JsrTestUtils.restartJob(execution1.getExecutionId(), jobParameters, 1000000L);
javax.batch.runtime.JobExecution execution2 = restartJob(execution1.getExecutionId(), jobParameters, 1000000L);
assertEquals(BatchStatus.COMPLETED, execution2.getBatchStatus());
assertEquals(1, MyPartitionReducer.beginCount);
assertEquals(1, MyPartitionReducer.beforeCount);

View File

@@ -15,22 +15,10 @@
*/
package org.springframework.batch.core.jsr.step;
import static org.junit.Assert.assertEquals;
import static org.springframework.batch.core.jsr.JsrTestUtils.restartJob;
import static org.springframework.batch.core.jsr.JsrTestUtils.runJob;
import java.util.List;
import java.util.Properties;
import javax.batch.api.Decider;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.StepExecution;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
import org.springframework.beans.factory.access.BeanFactoryLocator;
import org.springframework.beans.factory.access.BeanFactoryReference;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
@@ -38,7 +26,17 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
import org.springframework.util.Assert;
public class DecisionStepTests {
import javax.batch.api.Decider;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.StepExecution;
import java.util.List;
import java.util.Properties;
import static org.junit.Assert.assertEquals;
public class DecisionStepTests extends AbstractJsrTestCase {
private static ApplicationContext baseContext;