protected IConverter getConverter() { return getConverterTestDelegate().getConverter(); }
@Test(timeout = DEFAULT_CONVERSION_TIMEOUT, expected = ConverterAccessException.class) public void testFileToFileExecute() throws Exception { IFileConsumer fileConsumer = mock(IFileConsumer.class); File target = makeTarget(false); try { getConverter() .convert(validFile(true)).as(validInputType()) .to(target, fileConsumer).as(validTargetType()) .execute(); fail(); } catch (ConverterAccessException e) { verify(fileConsumer).onException(eq(target), any(ConverterAccessException.class)); verifyNoMoreInteractions(fileConsumer); assertFalse(target.exists()); assertPostConverterState(); throw e; } }
@Test(timeout = DEFAULT_CONVERSION_TIMEOUT, expected = ConverterAccessException.class) public void testFileToFileFuture() throws Exception { IFileConsumer fileConsumer = mock(IFileConsumer.class); File target = makeTarget(false); try { getConverter() .convert(validFile(true)).as(validInputType()) .to(target, fileConsumer).as(validTargetType()) .schedule().get(); fail(); } catch (ExecutionException e) { verify(fileConsumer).onException(eq(target), any(ConverterAccessException.class)); verifyNoMoreInteractions(fileConsumer); assertFalse(target.exists()); assertPostConverterState(); throw (Exception) e.getCause(); } }
@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; } }