Search in sources :

Example 11 with Canonicalizer20010315_ExclOmitCommentsTransformer

use of org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_ExclOmitCommentsTransformer in project santuario-java by apache.

the class EmptyNamespaceTest method doStAXTest.

@org.junit.Test
public void doStAXTest() throws Exception {
    org.apache.xml.security.Init.init();
    org.apache.xml.security.stax.config.Init.init(null, EmptyNamespaceTest.class);
    List<String> inclusiveNamespaces = Arrays.asList("SOAP-ENV ec ec1 ns0 ns1 ns11 ns2 ns4 ns9".split(" "));
    Canonicalizer20010315_Excl transformer = new Canonicalizer20010315_ExclOmitCommentsTransformer();
    Map<String, Object> properties = new HashMap<>();
    properties.put(Canonicalizer20010315_Excl.INCLUSIVE_NAMESPACES_PREFIX_LIST, inclusiveNamespaces);
    transformer.setProperties(properties);
    try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        InputStream stream = new ByteArrayInputStream(message.getBytes(java.nio.charset.StandardCharsets.UTF_8))) {
        transformer.setOutputStream(outputStream);
        transformer.transform(stream);
        transformer.doFinal();
        String result = outputStream.toString();
        Assert.assertEquals(message, result);
    }
}
Also used : Canonicalizer20010315_Excl(org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_Excl) HashMap(java.util.HashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) Canonicalizer20010315_ExclOmitCommentsTransformer(org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_ExclOmitCommentsTransformer) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

HashMap (java.util.HashMap)11 Canonicalizer20010315_ExclOmitCommentsTransformer (org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_ExclOmitCommentsTransformer)11 ArrayList (java.util.ArrayList)10 QName (javax.xml.namespace.QName)10 List (java.util.List)4 Map (java.util.Map)4 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Canonicalizer20010315_Excl (org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_Excl)1