@Test(expected = CoreException.class) public void testInsert_Broken_BinaryInput() throws Exception { PayloadStreamOutputParameter p = new PayloadStreamOutputParameter(); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(); FilterInputStream in = new FilterInputStream(new ByteArrayInputStream(new byte[0])) { @Override public int read() throws IOException { throw new IOException("Failed to read"); } @Override public int read(byte[] b) throws IOException { throw new IOException("Failed to read"); } @Override public int read(byte[] b, int off, int len) throws IOException { throw new IOException("Failed to read"); } }; p.insert(new InputStreamWithEncoding(in, null), msg); }
@Override public void insert(InputStreamWithEncoding data, InterlokMessage msg) throws InterlokException { try { String encoding = defaultIfEmpty(getContentEncoding(), data.encoding); if (isEmpty(encoding)) { copyAndClose(data.inputStream, msg.getOutputStream()); } else { copyAndClose(data.inputStream, msg.getWriter(encoding)); msg.setContentEncoding(encoding); } } catch (IOException e) { throw ExceptionHelper.wrapCoreException(e); } }
PayloadStreamOutputParameter implements DataOutputParameter<InputStreamWithEncoding> { @Override public void insert(InputStreamWithEncoding data, InterlokMessage msg) throws InterlokException { try { String encoding = defaultIfEmpty(getContentEncoding(), data.encoding); if (isEmpty(encoding)) { copyAndClose(data.inputStream, msg.getOutputStream()); } else { copyAndClose(data.inputStream, msg.getWriter(encoding)); msg.setContentEncoding(encoding); } } catch (IOException e) { throw ExceptionHelper.wrapCoreException(e); } } }
PayloadStreamOutputParameter implements DataOutputParameter<InputStreamWithEncoding> { @Override public void insert(InputStreamWithEncoding data, InterlokMessage msg) throws InterlokException { try { String encoding = defaultIfEmpty(getContentEncoding(), data.encoding); if (isEmpty(encoding)) { copyAndClose(data.inputStream, msg.getOutputStream()); } else { copyAndClose(data.inputStream, msg.getWriter(encoding)); msg.setContentEncoding(encoding); } } catch (IOException e) { throw ExceptionHelper.wrapCoreException(e); } }  }
PayloadStreamOutputParameter implements DataOutputParameter<InputStreamWithEncoding> { @Override public void insert(InputStreamWithEncoding data, InterlokMessage msg) throws InterlokException { try { String encoding = defaultIfEmpty(getContentEncoding(), data.encoding); if (isEmpty(encoding)) { copyAndClose(data.inputStream, msg.getOutputStream()); } else { copyAndClose(data.inputStream, msg.getWriter(encoding)); msg.setContentEncoding(encoding); } } catch (IOException e) { throw ExceptionHelper.wrapCoreException(e); } }  @Override void insert(InputStreamWithEncoding data, InterlokMessage msg); String getContentEncoding(); void setContentEncoding(String contentEncoding); }
PayloadStreamOutputParameter implements DataOutputParameter<InputStreamWithEncoding> { @Override public void insert(InputStreamWithEncoding data, InterlokMessage msg) throws InterlokException { try { String encoding = defaultIfEmpty(getContentEncoding(), data.encoding); if (isEmpty(encoding)) { copyAndClose(data.inputStream, msg.getOutputStream()); } else { copyAndClose(data.inputStream, msg.getWriter(encoding)); msg.setContentEncoding(encoding); } } catch (IOException e) { throw ExceptionHelper.wrapCoreException(e); } }  @Override void insert(InputStreamWithEncoding data, InterlokMessage msg); String getContentEncoding(); void setContentEncoding(String contentEncoding);  }