Examples of Smooks


Examples of org.milyn.Smooks

        Expression expression = PipelineFactory.newMvelExpression( "children" );
        expression.setReceiver( splitter );

        // Instantiate Smooks with the config...
        Smooks smooks = new Smooks( getClass().getResourceAsStream( "smooks-config.xml" ) );

        Transformer transformer = PipelineFactory.newSmooksFromSourceTransformer( smooks,
                                                                                  "root" );
        transformer.setReceiver( expression );
View Full Code Here

Examples of org.milyn.Smooks

        assertTrue(profiles.get(1).isMember("profileA"));
        assertTrue(!profiles.get(1).isMember("profile1")); // not expanded
    }

    public void test_profile_expansion() throws IOException, SAXException {
        Smooks smooks = new Smooks();

        smooks.addConfigurations("testconfig2.cdrl", getClass().getResourceAsStream("testconfig2.cdrl"));
        assertProfilesOK(smooks);
    }
View Full Code Here

Examples of org.milyn.Smooks

        smooks.addConfigurations("testconfig2.cdrl", getClass().getResourceAsStream("testconfig2.cdrl"));
        assertProfilesOK(smooks);
    }

    public void test_import_filesys() throws IOException, SAXException, URISyntaxException {
        Smooks smooks = new Smooks("src/test/java/org/milyn/cdr/testconfig3.cdrl");
        Iterator<SmooksResourceConfigurationList> listIt = smooks.getApplicationContext().getStore().getSmooksResourceConfigurationLists();
        SmooksResourceConfigurationList list = null;

        while(listIt.hasNext()) {
            list = listIt.next();
        }
View Full Code Here

Examples of org.milyn.Smooks

* @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"));
View Full Code Here

Examples of org.milyn.Smooks

        assertResourceConfigOK(list);
    }

    public void test_import_classpath() throws IOException, SAXException, URISyntaxException {
        Smooks smooks = new Smooks("/org/milyn/cdr/testconfig3.cdrl");
        Iterator<SmooksResourceConfigurationList> listIt = smooks.getApplicationContext().getStore().getSmooksResourceConfigurationLists();
        SmooksResourceConfigurationList list = null;

        while(listIt.hasNext()) {
            list = listIt.next();
        }
View Full Code Here

Examples of org.milyn.Smooks

        source = new JavaSource(beans);
        assertEquals(pojo, source.getBeans().get("abcd"));       
    }

    public void test_streamingOff_01() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-eventstream-off.xml"));
        StringResult result = new StringResult();

        smooks.filterSource(new JavaSource(new MyBean1()), result);
        assertEquals("<nullsource-document />", result.getResult());
    }
View Full Code Here

Examples of org.milyn.Smooks

        smooks.filterSource(new JavaSource(new MyBean1()), result);
        assertEquals("<nullsource-document />", result.getResult());
    }

    public void test_streamingOff_02() throws IOException, SAXException {
        Smooks smooks = new Smooks();
        JavaSource javaSource = new JavaSource(new MyBean1());
        StringResult result = new StringResult();

        // Turn streaming off via the JavaSource...
        javaSource.setEventStreamRequired(false);

        smooks.filterSource(javaSource, result);
        assertEquals("<nullsource-document />", result.getResult());
    }
View Full Code Here

Examples of org.milyn.Smooks

        smooks.filterSource(javaSource, result);
        assertEquals("<nullsource-document />", result.getResult());
    }

    public void test_streamingOn_01() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-eventstream-on.xml"));
        StringResult result = new StringResult();

        smooks.filterSource(new JavaSource(new MyBean1()));
        assertNotSame("<nullsource-document></nullsource-document>", result.getResult());
    }
View Full Code Here

Examples of org.milyn.Smooks

* @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a>
*/
public class ExpandableContentDeliveryUnitTest extends TestCase {

    public void test() throws IOException, SAXException {
        Smooks smooks = new Smooks();

        smooks.addConfigurations("expansion-config.xml", getClass().getResourceAsStream("expansion-config.xml"));
        ExecutionContext context = smooks.createExecutionContext();

        DOMContentDeliveryConfig config = (DOMContentDeliveryConfig) context.getDeliveryConfig();
        ContentHandlerConfigMapTable<DOMVisitBefore> assemblyVisitBefores = config.getAssemblyVisitBefores();
        ContentHandlerConfigMapTable<DOMVisitAfter> assemblyVisitAfters = config.getAssemblyVisitAfters();
        ContentHandlerConfigMapTable<DOMVisitBefore> processingVisitBefores = config.getProcessingVisitBefores();
View Full Code Here

Examples of org.milyn.Smooks

        smooks.filterSource(new JavaSource(new MyBean1()));
        assertNotSame("<nullsource-document></nullsource-document>", result.getResult());
    }

    public void test_streamingOn_02() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-eventstream-on.xml"));
        JavaSource javaSource = new JavaSource(new MyBean1());

        // Explicitly configure it on... should cause an erros because it is explicitly
        // configured 'on' in the config...
        javaSource.setEventStreamRequired(false);

        try {
            smooks.filterSource(javaSource);
        } catch(SmooksException e) {
            assertEquals("Invalid Smooks configuration.  Feature '" + JavaSource.FEATURE_GENERATE_EVENT_STREAM + "' is explicitly configured 'on' in the Smooks configuration, while the supplied JavaSource has explicitly configured event streaming to be off (through a call to JavaSource.setEventStreamRequired).", e.getCause().getMessage());
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.