Package org.milyn

Examples of org.milyn.Smooks.filterSource()


       
        execContext = smooks.createExecutionContext();
        execContext.getBeanContext().addBean("aBean", bean, null);
        bean.put("a", "hello");
       
        smooks.filterSource(execContext, new StreamSource(new StringReader("<a/>")), null);
        assertTrue(DOMVisitor.visited);

        DOMVisitor.visited = false;
        smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01.xml"));
View Full Code Here


   
    smooks.addVisitor(new DefaultSAXElementSerializer(), "customer");
    smooks.addVisitor(new DefaultSAXElementSerializer(), "customer/**");
    smooks.setFilterSettings(new FilterSettings().setDefaultSerializationOn(false).setFilterType(StreamFilterType.SAX));
   
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order.xml")), result);
   
    assertOK("expected_02.xml", result);       
  }

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

        execContext = smooks.createExecutionContext();
        execContext.getBeanContext().addBean("aBean", bean, null);
        bean.put("a", "goodbye");       
       
        smooks.filterSource(execContext, new StreamSource(new StringReader("<a/>")), null);
        assertFalse(DOMVisitor.visited);
    }

    public void testInvalidExpression() {
        // Just eval on an unbound variable...
View Full Code Here

    }

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

        smooks.filterSource(smooks.createExecutionContext(), new StreamSource(new StringReader("<x/>")), null);
        assertFalse(VisitBeforeDOMVisitor.visited);
        assertFalse(VisitAfterDOMVisitor.visited);
        reset();
        smooks.filterSource(smooks.createExecutionContext(), new StreamSource(new StringReader("<a/>")), null);
        assertTrue(VisitBeforeDOMVisitor.visited);
View Full Code Here

                                               setAttribute(new QName("http://ns1", "xxx", "ns1"), "${injectedVal}"), "a");

        ExecutionContext execContext = smooks.createExecutionContext();
        execContext.getBeanContext().addBean("injectedVal", "something");

        smooks.filterSource(execContext, new StringSource("<a/>"), result);

        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new StringReader("<a xmlns:ns1=\"http://ns1\" ns1:xxx=\"something\" />"), new StringReader(result.getResult()));
    }
}
View Full Code Here

   
    smooks.addVisitor(new DefaultSAXElementSerializer(), "items");
    smooks.addVisitor(new DefaultSAXElementSerializer(), "items/**");
    smooks.setFilterSettings(new FilterSettings().setDefaultSerializationOn(false).setFilterType(StreamFilterType.SAX));
   
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order.xml")), result);
   
    assertOK("expected_03.xml", result);       
  }

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

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

   
    smooks.addVisitor(new DefaultSerializationUnit(), "#document");
    smooks.addVisitor(new DefaultSerializationUnit(), "#document/**");
    smooks.setFilterSettings(new FilterSettings().setDefaultSerializationOn(false).setFilterType(StreamFilterType.DOM));
   
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order.xml")), result);
   
    assertOK("expected_01.xml", result);       
  }

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

        reset();
        smooks.filterSource(smooks.createExecutionContext(), new StreamSource(new StringReader("<a/>")), null);
        assertTrue(VisitBeforeDOMVisitor.visited);
        assertFalse(VisitAfterDOMVisitor.visited);
        reset();
        smooks.filterSource(smooks.createExecutionContext(), new StreamSource(new StringReader("<a><b/></a>")), null);
        assertTrue(VisitBeforeDOMVisitor.visited);
        assertTrue(VisitAfterDOMVisitor.visited);
        assertEquals("Hi There!", VisitAfterDOMVisitor.staticInjectedParam);
    }
View Full Code Here

        // We need to +1 this because Xerces always closes input streams/readers and there's no
        // way of turning that off
        TestInputStream inStream = new TestInputStream("<x/>".getBytes(), expectedCloseCallCount + 1);
        TestOutputStream outStream = new TestOutputStream(expectedCloseCallCount);
        execContext = smooks.createExecutionContext(profile);
        smooks.filterSource(execContext, new StreamSource(inStream), new StreamResult(outStream));

        // Test io reader/writer close...
        // We need to +1 this because Xerces always closes input streams/readers and there's no
        // way of turning that off
        TestReader reader = new TestReader("<x/>", expectedCloseCallCount + 1);
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.