@Test
public void testX12StreamAsWriterError() throws Exception {

	
	CloseObservableOutputStream target = new CloseObservableOutputStream() {
		@Override
		public synchronized void write(byte[] arg0, int arg1, int arg2) {
			throw new RuntimeException("fakeFailure");
		}
		
	};
	
	try (MessageOutputStream stream = new MessageOutputStream(null, target, (IForwardTarget)null)) {
	
		try {
			try (Writer writer = stream.asWriter()) {
				writer.write(testString);
			}
			fail("exception should be thrown");
		} catch (Exception e) {
			assertThat(e.getMessage(),StringContains.containsString("fakeFailure"));
		}
		
	}
	assertTrue(target.isCloseCalled());
}