Package org.milyn

Examples of org.milyn.Smooks


                "        </order-item>",
                XmlUtil.serialize(ModelCatcher.elements.get(1), true)));
    }

    public void test_sax_02() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("node-model-02.xml"));

        smooks.setFilterSettings(FilterSettings.DEFAULT_SAX);

        ExecutionContext executionContext = smooks.createExecutionContext();
        smooks.filterSource(executionContext, new StreamSource(getClass().getResourceAsStream("order-message.xml")), null);

        DOMModel nodeModel = DOMModel.getModel(executionContext);

        assertTrue(
                StreamUtils.compareCharStreams(
View Full Code Here


    }
   
    @Test
    public void multipleNamedExportTypes() throws Exception
    {
        Smooks smooks = new Smooks("/org/milyn/payload/exports-named.xml");
        smooks.createExecutionContext();

        Exports exports = Exports.getExports(smooks.getApplicationContext());
        Collection<Export> exportTypes = exports.getExports();
        assertEquals(2, exportTypes.size());
    }
View Full Code Here

    }

    @Test
    public void programmaticConfiguration()
    {
        Smooks smooks = new Smooks();
        smooks.createExecutionContext();
        smooks.setExports(new Exports(StringResult.class));

        Exports exports = Exports.getExports(smooks.getApplicationContext());

        assertTrue(exports.getResultTypes().contains(StringResult.class));
        assertEquals(1, exports.getResultTypes().size());
    }
View Full Code Here

                "        </order-item>",
                XmlUtil.serialize(ModelCatcher.elements.get(3), true)));
    }

    public void test_sax_03() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("node-model-02.xml"));

        smooks.setFilterSettings(FilterSettings.DEFAULT_SAX);

        ExecutionContext executionContext = smooks.createExecutionContext();
        smooks.filterSource(executionContext, new StreamSource(getClass().getResourceAsStream("order-message-with-ns.xml")), null);

        DOMModel nodeModel = DOMModel.getModel(executionContext);

        assertTrue(
                StreamUtils.compareCharStreams(
View Full Code Here

    }

    @Test
    public void getResultsFromApplicationContext()
    {
        Smooks smooks = new Smooks();
        smooks.createExecutionContext();
        Exports exports =  new Exports(StringResult.class);
        smooks.setExports(exports);
        Result[] results = exports.createResults();
        assertEquals(1, results.length);
        assertEquals(StringResult.class, results[0].getClass());
    }
View Full Code Here

                "<ordi:product xmlns:ordi=\"http://ordi\">222</ordi:product>",
                XmlUtil.serialize(nodeModel.getModels().get("product"), true)));
    }

    public void test_dom() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("node-model-01.xml"));
        ExecutionContext executionContext = smooks.createExecutionContext();

        smooks.filterSource(executionContext, new StreamSource(getClass().getResourceAsStream("order-message.xml")));

        DOMModel nodeModel = DOMModel.getModel(executionContext);

        assertTrue(
                StreamUtils.compareCharStreams(
View Full Code Here

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

    public void test() {
        Smooks smooks = new Smooks();
        ExecutionContext context;

        ParameterAccessor.setParameter(Filter.STREAM_FILTER_TYPE, "DOM", smooks);

        context = smooks.createExecutionContext();
        context.setAttribute("object-x", "Hi there!");

        String result = SmooksUtil.filterAndSerialize(context, new ByteArrayInputStream(("<context-object key='object-x' xmlns=\"" + Namespace.SMOOKS_URI + "\" />").getBytes()), smooks);
        assertEquals("Hi there!", result);
    }
View Full Code Here

*/
public class DefaultSerializationTest extends TestCase {


    public void test_default_writing_off_no_serializers() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("DefaultWritingOff_No_Serializers_Test.xml"));

        StringSource stringSource = new StringSource("<a>aa<b>bbb<c />bbb</b>aaa</a>");
        StringResult stringResult = new StringResult();

        smooks.filterSource(smooks.createExecutionContext(), stringSource, stringResult);

        // The "default.serialization.on" global param is set to "false" in the config, so
        // nothing should get writen to the result because there are no configured
        // serialization Visitors.
        assertEquals("", stringResult.getResult());
View Full Code Here

        assertTrue(SimpleDOMVisitor.visited);
    }

    public void test_default_writing_off_one_serializer() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("DefaultWritingOff_One_Serializer_Test.xml"));

        StringSource stringSource = new StringSource("<a>aa<b>bbb<c />bbb</b>aaa</a>");
        StringResult stringResult = new StringResult();

        smooks.filterSource(smooks.createExecutionContext(), stringSource, stringResult);

        // The "default.serialization.on" global param is set to "false" in the config.
        // There's just a single result writing visitor configured on the "b" element...
        assertEquals("<b>bbbbbb</b>", stringResult.getResult());
View Full Code Here

    private Smooks smooks;

    @Before
    public void setup()
    {
        smooks = new Smooks();
        smooks.addConfiguration(new SmooksResourceConfiguration( "org.xml.sax.driver", MockReader.class.getName()));
    }
View Full Code Here

TOP

Related Classes of org.milyn.Smooks

Copyright © 2018 www.massapicom. 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.