* the java package containing the test class using this {@link org.switchyard.test.TestMixIn}.
* @param xmlResPath The XML classpath resource used to bind to the {@code javaType}. This path can be relative to
* the java package containing the test class using this {@link org.switchyard.test.TestMixIn}.
*/
public void testJavaXMLReadWrite(Class<?> javaType, String bindingConfigResPath, String xmlResPath) {
Transformer xml2JavaTransformer = newTransformer(bindingConfigResPath, SmooksTransformType.XML2JAVA);
Transformer java2xmlTransformer = newTransformer(bindingConfigResPath, SmooksTransformType.JAVA2XML);
String xml = getTestKit().readResourceString(xmlResPath);
// XML to Java...
Object javaObject = xml2JavaTransformer.transform(xml);
Assert.assertNotNull("XML to Java transformation failed. null object returned.", javaObject);
Assert.assertTrue("XML to Java transformation failed. Wrong type returned. Expected '" + javaType.getName() + "' but got '" + javaObject.getClass().getName() + "'.", javaType.isInstance(javaObject));
if (_dumpResultsToSysout) {
System.out.println("------------XML to Java Result:\n" + javaObject);
System.out.println("-------------------------------");
}
// Java to XML...
String xmlResult = (String) java2xmlTransformer.transform(javaObject);
Assert.assertNotNull("Java to XML transformation failed. null object returned.", javaObject);
if (_dumpResultsToSysout) {
System.out.println("------------Java to XML Result:\n" + xmlResult);
System.out.println("-------------------------------");
}