BATCH-1780: Updated use of StepListenerFailedException

* Removed second constructor
* Updated code to log exception from the listener method more clearly
* Updated logging to report application error
This commit is contained in:
Michael Minella
2012-10-12 15:22:00 -05:00
parent 19bf011305
commit b33b2e3e97
5 changed files with 36 additions and 49 deletions

View File

@@ -28,7 +28,7 @@ import org.springframework.batch.core.StepExecution;
/**
* @author Dave Syer
*
*
*/
public class MulticasterBatchListenerTests {
@@ -276,7 +276,7 @@ public class MulticasterBatchListenerTests {
catch (StepListenerFailedException e) {
// expected
String message = e.getCause().getMessage();
assertEquals("Wrong message: " + message, "foo", message);
assertEquals("Wrong message: " + message, "listener error", message);
}
assertEquals(1, count);
}
@@ -369,7 +369,7 @@ public class MulticasterBatchListenerTests {
catch (StepListenerFailedException e) {
// expected
String message = e.getCause().getMessage();
assertEquals("Wrong message: " + message, "foo", message);
assertEquals("Wrong message: " + message, "listener error", message);
}
assertEquals(1, count);
}
@@ -508,7 +508,7 @@ public class MulticasterBatchListenerTests {
/**
* @author Dave Syer
*
*
*/
private final class CountingStepListenerSupport extends StepListenerSupport<Integer, String> {
@Override
@@ -522,7 +522,7 @@ public class MulticasterBatchListenerTests {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.listener.StepListenerSupport#afterChunk
* ()
@@ -538,7 +538,7 @@ public class MulticasterBatchListenerTests {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.listener.StepListenerSupport#afterRead
* (java.lang.Object)
@@ -554,7 +554,7 @@ public class MulticasterBatchListenerTests {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.listener.StepListenerSupport#afterStep
* (org.springframework.batch.core.StepExecution)
@@ -570,7 +570,7 @@ public class MulticasterBatchListenerTests {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.listener.StepListenerSupport#beforeChunk
* ()
@@ -586,7 +586,7 @@ public class MulticasterBatchListenerTests {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.listener.StepListenerSupport#beforeRead
* ()
@@ -602,7 +602,7 @@ public class MulticasterBatchListenerTests {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.listener.StepListenerSupport#beforeStep
* (org.springframework.batch.core.StepExecution)
@@ -618,7 +618,7 @@ public class MulticasterBatchListenerTests {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.listener.StepListenerSupport#afterWrite
* (java.util.List)
@@ -634,7 +634,7 @@ public class MulticasterBatchListenerTests {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.listener.StepListenerSupport#beforeWrite
* (java.util.List)
@@ -650,7 +650,7 @@ public class MulticasterBatchListenerTests {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.listener.StepListenerSupport#onWriteError
* (java.lang.Exception, java.util.List)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2012 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.
@@ -23,6 +23,7 @@ import org.junit.Test;
/**
* @author Dave Syer
* @author Michael Minella
*
*/
public class StepListenerFailedExceptionTests {
@@ -32,11 +33,4 @@ public class StepListenerFailedExceptionTests {
Exception exception = new StepListenerFailedException("foo", new IllegalStateException("bar"));
assertEquals("foo", exception.getMessage().substring(0, 3));
}
@Test
public void testExceptionStringThrowableThrowable() throws Exception {
Exception exception = new StepListenerFailedException("foo", new IllegalStateException(), new RuntimeException("bar"));
assertEquals("foo", exception.getMessage().substring(0, 3));
}
}