Package org.milyn

Examples of org.milyn.Smooks.createExecutionContext()


        SAXVisitAfterAndChildrenVisitor.reset();
    }

    public void test_selection() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-02.xml"));
        ExecutionContext execContext = smooks.createExecutionContext();
        String input = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-01.xml")));

        smooks.filterSource(execContext, new StreamSource(new ByteArrayInputStream(input.getBytes())), null);
        assertEquals("h", SAXVisitor01.element.getName().getLocalPart());
        assertEquals("y", SAXVisitor01.element.getName().getPrefix());
View Full Code Here


        test_contextual("smooks-config-03.02.xml");
    }

    public void test_contextual(String config) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream(config));
        ExecutionContext execContext = smooks.createExecutionContext();
        String input = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-01.xml")));

        smooks.filterSource(execContext, new StreamSource(new ByteArrayInputStream(input.getBytes())), null);
        assertEquals("h", SAXVisitor01.element.getName().getLocalPart());
        assertEquals("y", SAXVisitor01.element.getName().getPrefix());
View Full Code Here

        assertEquals(1, SAXVisitor03.childText.size());
    }

    public void test_$document() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-04.xml"));
        ExecutionContext execContext = smooks.createExecutionContext();
        String input = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-01.xml")));

        smooks.filterSource(execContext, new StreamSource(new ByteArrayInputStream(input.getBytes())), null);
        assertEquals("xx", SAXVisitor01.element.getName().getLocalPart());
        assertEquals("xx", SAXVisitor02.element.getName().getLocalPart());
View Full Code Here

    }

    public void test_visitBeforeOnly() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-05.xml"));

        smooks.filterSource(smooks.createExecutionContext(), new StreamSource(new StringReader("<a/>")), null);
        assertTrue(SAXVisitBeforeVisitor.visited);
        assertEquals("Hi There!", SAXVisitBeforeVisitor.staticInjectedParam);
    }

    public void test_visitBeforeAndChildren() throws IOException, SAXException {
View Full Code Here

    }

    public void test_visitBeforeAndChildren() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-05.xml"));

        smooks.filterSource(smooks.createExecutionContext(), new StreamSource(new StringReader("<b/>")), null);
        assertTrue(SAXVisitBeforeAndChildrenVisitor.visited);
        assertFalse(SAXVisitBeforeAndChildrenVisitor.onChildText);
        assertFalse(SAXVisitBeforeAndChildrenVisitor.onChildElement);
        SAXVisitBeforeAndChildrenVisitor.reset();
View Full Code Here

        assertTrue(SAXVisitBeforeAndChildrenVisitor.visited);
        assertFalse(SAXVisitBeforeAndChildrenVisitor.onChildText);
        assertFalse(SAXVisitBeforeAndChildrenVisitor.onChildElement);
        SAXVisitBeforeAndChildrenVisitor.reset();

        smooks.filterSource(smooks.createExecutionContext(), new StreamSource(new StringReader("<b>text</b>")), null);
        assertTrue(SAXVisitBeforeAndChildrenVisitor.visited);
        assertTrue(SAXVisitBeforeAndChildrenVisitor.onChildText);
        assertFalse(SAXVisitBeforeAndChildrenVisitor.onChildElement);
        SAXVisitBeforeAndChildrenVisitor.reset();
View Full Code Here

        assertTrue(SAXVisitBeforeAndChildrenVisitor.visited);
        assertTrue(SAXVisitBeforeAndChildrenVisitor.onChildText);
        assertFalse(SAXVisitBeforeAndChildrenVisitor.onChildElement);
        SAXVisitBeforeAndChildrenVisitor.reset();

        smooks.filterSource(smooks.createExecutionContext(), new StreamSource(new StringReader("<b><x/></b>")), null);
        assertTrue(SAXVisitBeforeAndChildrenVisitor.visited);
        assertFalse(SAXVisitBeforeAndChildrenVisitor.onChildText);
        assertTrue(SAXVisitBeforeAndChildrenVisitor.onChildElement);
        SAXVisitBeforeAndChildrenVisitor.reset();
View Full Code Here

        assertTrue(SAXVisitBeforeAndChildrenVisitor.visited);
        assertFalse(SAXVisitBeforeAndChildrenVisitor.onChildText);
        assertTrue(SAXVisitBeforeAndChildrenVisitor.onChildElement);
        SAXVisitBeforeAndChildrenVisitor.reset();

        smooks.filterSource(smooks.createExecutionContext(), new StreamSource(new StringReader("<b>text<x/></b>")), null);
        assertTrue(SAXVisitBeforeAndChildrenVisitor.visited);
        assertTrue(SAXVisitBeforeAndChildrenVisitor.onChildText);
        assertTrue(SAXVisitBeforeAndChildrenVisitor.onChildElement);
        SAXVisitBeforeAndChildrenVisitor.reset();
    }
View Full Code Here

    }

    public void test_visitAfterOnly() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-05.xml"));

        smooks.filterSource(smooks.createExecutionContext(), new StreamSource(new StringReader("<c/>")), null);
        assertTrue(SAXVisitAfterVisitor.visited);
    }

    public void test_visitAfterAndChildren() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-05.xml"));
View Full Code Here

        config = new SmooksResourceConfiguration("org.xml.sax.driver", "type:Order-List AND from:Acme", JSONReader.class.getName());
    SmooksUtil.registerResource(config, smooks);
    SmooksUtil.registerProfileSet(DefaultProfileSet.create("Order-List-Acme-AcmePartner1", new String[] {"type:Order-List", "from:Acme", "to:AcmePartner1"}), smooks);

    ExecutionContext context = smooks.createExecutionContext("Order-List-Acme-AcmePartner1");
    String result = SmooksUtil.filterAndSerialize(context,  getClass().getResourceAsStream("/test/"+ testNumber +"/input-message.jsn"), smooks);

        if(logger.isDebugEnabled()) {
          logger.debug("Result: " + result);
        }
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.