RESOLVE: BATCH-1333: CHanged "fatal" semantics to mean "not-skippable".

This commit is contained in:
dsyer
2009-07-10 14:08:51 +00:00
parent d5223ee3de
commit e7ff4037c7
3 changed files with 66 additions and 42 deletions

View File

@@ -164,13 +164,13 @@ public class FaultTolerantExceptionClassesTests implements ApplicationContextAwa
@Test
public void testRetryableFatal() throws Exception {
// User wants all exceptions to be retried, but only some are skippable
// FatalRuntimeException is not skippable, but is a subclass of another
// skippable
// FatalRuntimeException is not skippable because it is fatal, but is a
// subclass of another skippable
writer.setExceptionType(FatalRuntimeException.class);
StepExecution stepExecution = launchStep("retryable");
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
// TODO BATCH-1333: assertEquals("[1, 2, 3, 1, 2, 3, 1, 2, 3]",
// writer.getWritten().toString());
// BATCH-1333:
assertEquals("[1, 2, 3, 1, 2, 3]", writer.getWritten().toString());
assertEquals("[]", writer.getCommitted().toString());
}
@@ -198,9 +198,10 @@ public class FaultTolerantExceptionClassesTests implements ApplicationContextAwa
writer.setExceptionType(FatalException.class);
StepExecution stepExecution = launchStep("retryable");
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
// TODO BATCH-1333: assertEquals("[1, 2, 3, 1, 2, 3, 1, 2, 3]",
// writer.getWritten().toString());
// BATCH-1333:
assertEquals("[1, 2, 3, 1, 2, 3]", writer.getWritten().toString());
assertEquals("[]", writer.getCommitted().toString());
assertEquals(0, stepExecution.getWriteSkipCount());
}
@Test
@@ -259,11 +260,11 @@ public class FaultTolerantExceptionClassesTests implements ApplicationContextAwa
writer.setExceptionType(FatalRuntimeException.class);
StepExecution stepExecution = launchStep("noRollbackSkippable");
assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
// BATCH-1332:
assertEquals("[1, 2, 3, 1, 2, 3, 4]", writer.getWritten().toString());
// BATCH-1332:
// TODO BATCH-1334:
// Skipped but also committed (because it was marked as no-rollback)
assertEquals("[1, 2, 3, 4]", writer.getCommitted().toString());
// TODO BATCH-1334:
// Not skipped but also committed (because it was marked as no-rollback)
assertEquals(1, stepExecution.getWriteSkipCount());
}
@@ -279,16 +280,17 @@ public class FaultTolerantExceptionClassesTests implements ApplicationContextAwa
@Test
public void testNoRollbackFatalNoRollbackException() throws Exception {
// User has asked for no rollback on a fatal exception. What should the
// outcome be?
// outcome be? As per BATCH-1333 it is interpreted as not skippable, but
// retryable if requested. Here it was not requested to be retried, but
// it was marked as no-rollback. As per BATCH-1334 this has to be ignored
// so that the failed item can be isolated.
writer.setExceptionType(FatalRuntimeException.class);
StepExecution stepExecution = launchStep("noRollbackFatal");
assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
// TODO BATCH-1331: assertEquals(BatchStatus.FAILED,
// stepExecution.getStatus());
// TODO BATCH-1331: assertEquals("[1, 2, 3]",
// writer.getWritten().toString());
// TODO BATCH-1331: assertEquals("[1, 2, 3]",
// writer.getCommitted().toString());
// BATCH-1331:
assertEquals("[1, 2, 3, 1, 2, 3, 4]", writer.getWritten().toString());
// BATCH-1331:
assertEquals("[1, 2, 3, 4]", writer.getCommitted().toString());
}
@Test

View File

@@ -279,8 +279,9 @@ public class FaultTolerantStepFactoryBeanTests {
}
/**
* Fatal exception should cause immediate termination regardless of other
* skip settings (note the fatal exception is also classified as rollback).
* Fatal exception should cause immediate termination provided the exception
* is not skippable (note the fatal exception is also classified as
* rollback).
*/
@Test
public void testFatalException() throws Exception {
@@ -296,7 +297,8 @@ public class FaultTolerantStepFactoryBeanTests {
Step step = (Step) factory.getObject();
step.execute(stepExecution);
assertTrue(stepExecution.getFailureExceptions().get(0).getMessage().equals("Ouch!"));
String message = stepExecution.getFailureExceptions().get(0).getCause().getMessage();
assertTrue("Wrong message: " + message, message.equals("Ouch!"));
assertStepExecutionsAreEqual(stepExecution, repository.getLastStepExecution(jobExecution.getJobInstance(), step
.getName()));
}