@Override public void onException(ConversionFormatException exception) { callback.onException(exception); } }
@Override public void onException(Exception e) { try { reportException(e); } finally { inputStreamConsumer.onException(e); } } }
@Override protected void onConversionFailed(RuntimeException e) { consumer.onException(e); }
@Override public void onException(File file, Exception e) { try { inputStreamConsumer.onException(e); } finally { tryDelete(file); } }
@Test(timeout = DEFAULT_CONVERSION_TIMEOUT, expected = ConverterAccessException.class) public void testInputStreamToInputStreamConsumerFuture() throws Exception { InputStream inputStream = spy(new FileInputStream(validFile(true))); IInputStreamConsumer inputStreamConsumer = mock(IInputStreamConsumer.class); try { getConverter() .convert(inputStream).as(validInputType()) .to(inputStreamConsumer).as(validTargetType()) .schedule().get(); fail(); } catch (ExecutionException e) { verify(inputStreamConsumer).onException(any(ConverterAccessException.class)); verifyNoMoreInteractions(inputStreamConsumer); verify(inputStream).close(); assertPostConverterState(); throw (Exception) e.getCause(); } }
@Test(timeout = DEFAULT_CONVERSION_TIMEOUT, expected = ConverterAccessException.class) public void testInputStreamToInputStreamConsumerExecute() throws Exception { InputStream inputStream = spy(new FileInputStream(validFile(true))); IInputStreamConsumer inputStreamConsumer = mock(IInputStreamConsumer.class); try { getConverter() .convert(inputStream).as(validInputType()) .to(inputStreamConsumer).as(validTargetType()) .execute(); fail(); } catch (ConverterAccessException e) { verify(inputStreamConsumer).onException(any(ConverterAccessException.class)); verifyNoMoreInteractions(inputStreamConsumer); verify(inputStream).close(); assertPostConverterState(); throw e; } }
case CONVERTER_ERROR: { Exception exception = new ConverterAccessException(asReply(message)); callback.onException(exception); return MockResult.indicating(exception); callback.onException(exception); return MockResult.indicating(exception); callback.onException(exception); return MockResult.indicating(exception); callback.onException(exception); return MockResult.indicating(exception); callback.onException(exception); return MockResult.indicating(exception);