Skip to content

Commit 800079b

Browse files
author
Taichi Yamakawa
committed
Test ControllableParallelExecutionHandler rethrows an exception occurred at createReader
1 parent 24ae1d6 commit 800079b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/test/java/lerna/nablarch/batch/parallelizable/handler/ControllableParallelExecutionHandlerTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,31 @@ public Result handle(String s, ExecutionContext executionContext) {
324324
assertThat(handledCount.get(), is(0));
325325
}
326326

327+
@Test
328+
public void createReaderで例外が発生したら親ハンドラにその例外がリスローされる() {
329+
final int parallelism = 5;
330+
final ControllableParallelExecutionHandler handler = new ControllableParallelExecutionHandler();
331+
handler.setParallelism(parallelism);
332+
handler.setConnectionFactory(connectionName -> new TestTransactionManagerConnectionBase());
333+
handler.setTransactionFactory(connectionName -> new TestTransactionBase());
334+
335+
final IllegalStateException expectedException =
336+
new IllegalStateException("Could not create a DataReader.");
337+
338+
final ExecutionContext context = new ExecutionContext();
339+
context.addHandler(handler);
340+
context.addHandler(new TestControllableParallelExecutorBase() {
341+
@Override
342+
public DataReader<String> createReader(ExecutionContext executionContext) {
343+
throw expectedException;
344+
}
345+
});
346+
347+
final IllegalStateException thrownException =
348+
assertThrows(IllegalStateException.class, () -> context.handleNext("input"));
349+
assertThat(thrownException, is(expectedException));
350+
}
351+
327352
@Test
328353
public void executionId毎にcommitIntervalを迎えたときと終了時に1度コミットされる() {
329354
int numberOfData = 100;

0 commit comments

Comments
 (0)