@@ -296,6 +296,59 @@ public int getAsInt() {
296296
297297 }
298298
299+ @ Test
300+ public void createReaderがnullを返す場合はデータ0件として処理する () {
301+ final int parallelism = 5 ;
302+ final ControllableParallelExecutionHandler handler = new ControllableParallelExecutionHandler ();
303+ handler .setParallelism (parallelism );
304+ handler .setConnectionFactory (connectionName -> new TestTransactionManagerConnectionBase ());
305+ handler .setTransactionFactory (connectionName -> new TestTransactionBase ());
306+
307+ final AtomicInteger handledCount = new AtomicInteger (0 );
308+ final ExecutionContext context = new ExecutionContext ();
309+ context .addHandler (handler );
310+ context .addHandler (new TestControllableParallelExecutorBase () {
311+ @ Override
312+ public DataReader <String > createReader (ExecutionContext executionContext ) {
313+ return null ;
314+ }
315+ @ Override
316+ public Result handle (String s , ExecutionContext executionContext ) {
317+ handledCount .incrementAndGet ();
318+ return new Result .Success ();
319+ }
320+ });
321+
322+ final Result result = context .handleNext ("input" );
323+ assertThat (result .isSuccess (), is (true ));
324+ assertThat (handledCount .get (), is (0 ));
325+ }
326+
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+
299352 @ Test
300353 public void executionId毎にcommitIntervalを迎えたときと終了時に1度コミットされる () {
301354 int numberOfData = 100 ;
0 commit comments