@Test(expectedExceptions = SystemException.class) public void testCompressShouldThrowSystemExceptionWhenSAXExceptionIsCatched() throws ParserConfigurationException, SAXException { given(saxParserFactory.newSAXParser()).willThrow(new SAXException()); underTest.compress(inputStream); }
@Override public ByteArrayOutputStream compress(final InputStream inputStream) { InputStream source = inputStream; try { ByteArrayOutputStream fis = outputStreamFactory.createByteArrayOutputStream(); SAXDocumentSerializer saxDocumentSerializer = documentSerializerFactory.createSAXDocumentSerializer(); saxDocumentSerializer.setOutputStream(fis); SAXParserFactory saxParserFactory = saxParserCreator.createSAXParserFactory(); saxParserFactory.setNamespaceAware(true); SAXParser saxParser = saxParserFactory.newSAXParser(); saxParser.parse(source, saxDocumentSerializer); return fis; } catch (Exception e) { throw new SystemException("Could not perform fastinfoset compression!", e); } }
FastInfosetCompressionService implements CompressionService { @Override public ByteArrayOutputStream compress(final InputStream inputStream) { InputStream source = inputStream; try { ByteArrayOutputStream fis = outputStreamFactory.createByteArrayOutputStream(); SAXDocumentSerializer saxDocumentSerializer = documentSerializerFactory.createSAXDocumentSerializer(); saxDocumentSerializer.setOutputStream(fis); SAXParserFactory saxParserFactory = saxParserCreator.createSAXParserFactory(); saxParserFactory.setNamespaceAware(true); SAXParser saxParser = saxParserFactory.newSAXParser(); saxParser.parse(source, saxDocumentSerializer); return fis; } catch (Exception e) { throw new SystemException("Could not perform fastinfoset compression!", e); } } }
FastInfosetCompressionService implements CompressionService { @Override public ByteArrayOutputStream compress(final InputStream inputStream) { InputStream source = inputStream; try { ByteArrayOutputStream fis = outputStreamFactory.createByteArrayOutputStream(); SAXDocumentSerializer saxDocumentSerializer = documentSerializerFactory.createSAXDocumentSerializer(); saxDocumentSerializer.setOutputStream(fis); SAXParserFactory saxParserFactory = saxParserCreator.createSAXParserFactory(); saxParserFactory.setNamespaceAware(true); SAXParser saxParser = saxParserFactory.newSAXParser(); saxParser.parse(source, saxDocumentSerializer); return fis; } catch (Exception e) { throw new SystemException("Could not perform fastinfoset compression!", e); } }  }
FastInfosetCompressionService implements CompressionService { @Override public ByteArrayOutputStream compress(final InputStream inputStream) { InputStream source = inputStream; try { ByteArrayOutputStream fis = outputStreamFactory.createByteArrayOutputStream(); SAXDocumentSerializer saxDocumentSerializer = documentSerializerFactory.createSAXDocumentSerializer(); saxDocumentSerializer.setOutputStream(fis); SAXParserFactory saxParserFactory = saxParserCreator.createSAXParserFactory(); saxParserFactory.setNamespaceAware(true); SAXParser saxParser = saxParserFactory.newSAXParser(); saxParser.parse(source, saxDocumentSerializer); return fis; } catch (Exception e) { throw new SystemException("Could not perform fastinfoset compression!", e); } }  @Override ByteArrayOutputStream compress(final InputStream inputStream); @Override ByteArrayOutputStream decompress(final InputStream inputStream); }
FastInfosetCompressionService implements CompressionService { @Override public ByteArrayOutputStream compress(final InputStream inputStream) { InputStream source = inputStream; try { ByteArrayOutputStream fis = outputStreamFactory.createByteArrayOutputStream(); SAXDocumentSerializer saxDocumentSerializer = documentSerializerFactory.createSAXDocumentSerializer(); saxDocumentSerializer.setOutputStream(fis); SAXParserFactory saxParserFactory = saxParserCreator.createSAXParserFactory(); saxParserFactory.setNamespaceAware(true); SAXParser saxParser = saxParserFactory.newSAXParser(); saxParser.parse(source, saxDocumentSerializer); return fis; } catch (Exception e) { throw new SystemException("Could not perform fastinfoset compression!", e); } }  @Override ByteArrayOutputStream compress(final InputStream inputStream); @Override ByteArrayOutputStream decompress(final InputStream inputStream);  }