* @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a>
*/
public class NestedExecutionVisitorTest extends TestCase {
public void test() throws IOException, SAXException {
Smooks smooks = new Smooks(getClass().getResourceAsStream("config-01.xml"));
StringResult result = new StringResult();
JavaResult beans = new JavaResult();
final List<String> orderItems = new ArrayList<String>();
smooks.getApplicationContext().addBeanContextLifecycleObserver(new BeanContextLifecycleObserver() {
public void onBeanLifecycleEvent(BeanContextLifecycleEvent event) {
if(event.getLifecycle() == BeanLifecycle.REMOVE && event.getBeanId().getName().equals("orderItem")) {
orderItems.add((String) event.getBean());
}
}
});
smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order-message.xml")), result, beans);
XMLUnit.setIgnoreWhitespace(true);
XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("order-message.xml")), new StringReader(result.toString()));
assertEquals("header", beans.getBean("header"));