Skip to end of metadata
Go to start of metadata

Unit testing with Smooks is simple:

public class MyMessageTransformTest
{
    @Test
    public void test_transform() throws IOException, SAXException
    {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config.xml"));
        Source source = new StreamSource(getClass().getResourceAsStream("input-message.xml" ) );
        StringResult result = new StringResult();

        smooks.filter(source, result);

        //    compare the expected xml with the transformation result.
        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("expected.xml")), new StringReader(result.getResult()));
    }
}

The test case above uses xmlunit.

The following maven dependency was used for xmlunit in the above test:

<dependency>
    <groupId>xmlunit</groupId>
    <artifactId>xmlunit</artifactId>
    <version>1.1</version>
</dependency>
  • No labels