Search in sources :

Example 1 with ResourceTransformer

use of org.apache.cxf.ws.transfer.validationtransformation.ResourceTransformer in project cxf by apache.

the class XSLTResourceTransformerTest method transformTest.

@Test
public void transformTest() throws XMLStreamException {
    ResourceTransformer transformer = new XSLTResourceTransformer(new StreamSource(getClass().getResourceAsStream("/xml/xsltresourcetransformer/stylesheet.xsl")));
    Representation representation = loadRepresentation(getClass().getResourceAsStream("/xml/xsltresourcetransformer/representation.xml"));
    transformer.transform(representation, null);
    Element representationEl = (Element) representation.getAny();
    Assert.assertEquals("Expected root element with name \"person\".", "person", representationEl.getLocalName());
    Assert.assertTrue("Expected one element \"firstname\".", representationEl.getElementsByTagName("firstname").getLength() == 1);
    Assert.assertTrue("Expected one element \"lastname\".", representationEl.getElementsByTagName("lastname").getLength() == 1);
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) Element(org.w3c.dom.Element) XSLTResourceTransformer(org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer) Representation(org.apache.cxf.ws.transfer.Representation) XSLTResourceTransformer(org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer) ResourceTransformer(org.apache.cxf.ws.transfer.validationtransformation.ResourceTransformer) Test(org.junit.Test)

Aggregations

StreamSource (javax.xml.transform.stream.StreamSource)1 Representation (org.apache.cxf.ws.transfer.Representation)1 ResourceTransformer (org.apache.cxf.ws.transfer.validationtransformation.ResourceTransformer)1 XSLTResourceTransformer (org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer)1 Test (org.junit.Test)1 Element (org.w3c.dom.Element)1