Assert.assertEquals(25, xmlSecEvents.size());
}
@Test
public void testInputStreamToInputStreamAPI() throws Exception {
TransformIdentity transformIdentity = new TransformIdentity();
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Transformer transformer = new Transformer() {
@Override
public void setOutputStream(OutputStream outputStream) throws XMLSecurityException {
}
@Override
public void setTransformer(Transformer transformer) throws XMLSecurityException {
}
@Override
public void setProperties(Map<String, Object> properties) throws XMLSecurityException {
}
@Override
public XMLSecurityConstants.TransformMethod getPreferredTransformMethod(XMLSecurityConstants.TransformMethod forInput) {
return XMLSecurityConstants.TransformMethod.InputStream;
}
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
Assert.fail("unexpected call to transform(XMLSecEvent");
}
@Override
public void transform(InputStream inputStream) throws XMLStreamException {
try {
XMLSecurityUtils.copy(inputStream, byteArrayOutputStream);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
public void doFinal() throws XMLStreamException {
}
};
transformIdentity.setTransformer(transformer);
transformIdentity.transform(this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/base64.xml"));
transformIdentity.doFinal();
Assert.assertEquals(831, byteArrayOutputStream.size());
}