Changed the exception being thrown in the ChunkListenerAdatper from BatchRuntimeExcpetion to UncheckedTransactionException so it will be unwrapped by TaskletStep

This commit is contained in:
Michael Minella
2014-01-02 14:50:59 -06:00
parent c46a134539
commit 681c1dccd9
4 changed files with 56 additions and 24 deletions

View File

@@ -1,3 +1,18 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.jsr;
import static org.mockito.Mockito.doThrow;
@@ -12,6 +27,7 @@ import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.UncheckedTransactionException;
public class ChunkListenerAdapterTests {
@@ -39,7 +55,7 @@ public class ChunkListenerAdapterTests {
verify(delegate).beforeChunk();
}
@Test(expected=BatchRuntimeException.class)
@Test(expected=UncheckedTransactionException.class)
public void testBeforeChunkException() throws Exception {
doThrow(new Exception("This is expected")).when(delegate).beforeChunk();
adapter.beforeChunk(null);
@@ -52,7 +68,7 @@ public class ChunkListenerAdapterTests {
verify(delegate).afterChunk();
}
@Test(expected=BatchRuntimeException.class)
@Test(expected=UncheckedTransactionException.class)
public void testAfterChunkException() throws Exception {
doThrow(new Exception("This is expected")).when(delegate).afterChunk();
adapter.afterChunk(null);
@@ -63,7 +79,7 @@ public class ChunkListenerAdapterTests {
adapter.afterChunkError(null);
}
@Test(expected=BatchRuntimeException.class)
@Test(expected=UncheckedTransactionException.class)
public void testAfterChunkErrorException() throws Exception {
doThrow(new Exception("This is expected")).when(delegate).afterChunk();
adapter.afterChunk(null);