* Update copyright year
* Move addition of state transition for elements with a next transition to be last * Move restartable check into run method on restart to avoid NPE in factory bean due to null JobExecution. * Add tests Transition shuffle fixes TCK test testInvokeJobWithUncaughtExceptionFailAndRestart, NPE fix contributes to other tests but does not fix completely.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -16,13 +16,18 @@
|
||||
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 javax.batch.api.AbstractBatchlet;
|
||||
import javax.batch.operations.JobOperator;
|
||||
import javax.batch.runtime.BatchRuntime;
|
||||
import javax.batch.runtime.JobExecution;
|
||||
import javax.batch.runtime.StepExecution;
|
||||
import javax.batch.runtime.context.StepContext;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -38,7 +43,6 @@ import org.springframework.batch.core.ExitStatus;
|
||||
* @since 3.0
|
||||
*/
|
||||
public class FlowParserTests {
|
||||
|
||||
@Test
|
||||
public void testDuplicateTransitionPatternsAllowed() throws Exception {
|
||||
JobExecution stoppedExecution = runJob("FlowParserTests-context", new Properties(), 10000l);
|
||||
@@ -48,6 +52,18 @@ public class FlowParserTests {
|
||||
assertEquals(ExitStatus.COMPLETED.getExitCode(), endedExecution.getExitStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWildcardAddedLastWhenUsedWithNextAttrAndNoTransitionElements() throws Exception {
|
||||
JobExecution jobExecution = runJob("FlowParserTestsWildcardAndNextAttrJob", new Properties(), 1000l);
|
||||
assertEquals(ExitStatus.FAILED.getExitCode(), jobExecution.getExitStatus());
|
||||
|
||||
JobOperator jobOperator = BatchRuntime.getJobOperator();
|
||||
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(jobExecution.getExecutionId());
|
||||
assertEquals(1, stepExecutions.size());
|
||||
StepExecution failedStep = stepExecutions.get(0);
|
||||
assertTrue("step1".equals(failedStep.getStepName()));
|
||||
}
|
||||
|
||||
public static class TestBatchlet extends AbstractBatchlet {
|
||||
private static int CNT;
|
||||
|
||||
@@ -66,4 +82,11 @@ public class FlowParserTests {
|
||||
return exitCode;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FailingTestBatchlet extends AbstractBatchlet {
|
||||
@Override
|
||||
public String process() throws Exception {
|
||||
throw new RuntimeException("blah");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.batch.api.AbstractBatchlet;
|
||||
import javax.batch.api.Batchlet;
|
||||
import javax.batch.operations.JobExecutionIsRunningException;
|
||||
import javax.batch.operations.JobOperator;
|
||||
@@ -424,6 +425,14 @@ public class JsrJobOperatorTests {
|
||||
assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus());
|
||||
}
|
||||
|
||||
@Test(expected = JobRestartException.class)
|
||||
public void testNonRestartableJob() throws Exception {
|
||||
javax.batch.runtime.JobExecution jobExecutionStart = runJob("jsrJobOperatorTestNonRestartableJob", new Properties(), TIMEOUT);
|
||||
assertEquals(BatchStatus.FAILED, jobExecutionStart.getBatchStatus());
|
||||
|
||||
restartJob(jobExecutionStart.getExecutionId(), null, TIMEOUT);
|
||||
}
|
||||
|
||||
@Test(expected = JobRestartException.class)
|
||||
public void testRestartAbandoned() throws Exception {
|
||||
jsrJobOperator = BatchRuntime.getJobOperator();
|
||||
@@ -534,4 +543,11 @@ public class JsrJobOperatorTests {
|
||||
stopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FailingBatchlet extends AbstractBatchlet {
|
||||
@Override
|
||||
public String process() throws Exception {
|
||||
throw new RuntimeException("blah");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user