@Test
public void testX13StreamAsContentHandlerError() throws Exception {

	
	CloseObservableOutputStream target = new CloseObservableOutputStream() {
		@Override
		public void write(byte[] arg0, int arg1, int arg2) {
			throw new RuntimeException("fakeFailure 1");
		}
		@Override
		public void write(byte[] b) throws IOException {
			throw new RuntimeException("fakeFailure 2");
		}
		
	};
	try (MessageOutputStream stream = new MessageOutputStream(null, target, (IForwardTarget)null)) {
		ContentHandler handler = stream.asContentHandler();

		try {
			InputSource inputSource = new InputSource(new StringReader(testString)); 
			XmlUtils.parseXml(inputSource, handler);
			fail("exception should be thrown");
		} catch (Exception e) {
			assertThat(e.getMessage(),StringContains.containsString("fakeFailure"));
		}
	}
	assertTrue(target.isCloseCalled());
	
}