* @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a>
*/
public class XMLReadWriteTest extends TestCase {
public void test() throws IOException, SAXException {
XMLBinding xmlBinding = new XMLBinding().add("smooks-config.xml");
xmlBinding.intiailize();
Order order = xmlBinding.fromXML(new StringSource(Main.orderXMLMessage), Order.class);
assertNotNull(order);
assertNotNull(order.getHeader());
assertNotNull(order.getOrderItems());
assertEquals(2, order.getOrderItems().size());
assertEquals(1163616328000L, order.getHeader().getDate().getTime());
assertEquals("Joe", order.getHeader().getCustomerName());
assertEquals(new Long(123123), order.getHeader().getCustomerNumber());
OrderItem orderItem = order.getOrderItems().get(0);
assertEquals(8.90d, orderItem.getPrice());
assertEquals(111, orderItem.getProductId());
assertEquals(new Integer(2), orderItem.getQuantity());
orderItem = order.getOrderItems().get(1);
assertEquals(5.20d, orderItem.getPrice());
assertEquals(222, orderItem.getProductId());
assertEquals(new Integer(7), orderItem.getQuantity());
StringWriter orderWriter = new StringWriter();
xmlBinding.toXML(order, orderWriter);
XMLUnit.setIgnoreWhitespace(true);
XMLAssert.assertXMLEqual(Main.orderXMLMessage, orderWriter.toString());
}