Package org.milyn.container

Examples of org.milyn.container.ExecutionContext


        Smooks smooks = new Smooks(getClass().getResourceAsStream("config-06.xml"));
        StringResult result = new StringResult();

        smooks.setFilterSettings(filterSettings);

        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


*/
public class BeanMapExpressionEvaluatorTest extends TestCase {

    public void test() throws IOException, SAXException {
        Smooks smooks;
        ExecutionContext execContext;
        Map<String, Object> bean = new HashMap<String, Object>();

        DOMVisitor.visited = false;
        smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01.xml"));
       
        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"));

        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);
    }
View Full Code Here

        StringResult result = new StringResult();

        smooks.setFilterSettings(filterSettings);
        smooks.addVisitor(new SetElementData().setAttribute(new QName("xxx"), "${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 xxx=\"something\" />"), new StringReader(result.getResult()));
View Full Code Here

        smooks.setFilterSettings(filterSettings);
        smooks.addVisitor(new SetElementData().setAttribute(new QName("http://www.w3.org/2000/xmlns/", "ns1", "xmlns"), "http://ns1").
                                               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

        test_close_io("sax-close", 1);
    }

    public void test_close_io(String profile, int expectedCloseCallCount) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-close-filter-io.xml"));
        ExecutionContext execContext;

        // Test io stream close....
        // 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);
View Full Code Here

  @Test ( groups = "unit" )
    public void test_before_full_extended_config() throws ParserConfigurationException, SAXException, IOException   {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-beforeVisit-full-extended-config.xml"));

    ExecutionContext executionContext = smooks.createExecutionContext();

    JavaResult result = new JavaResult();

    smooks.filterSource(executionContext, new StreamSource(getClass().getResourceAsStream("test.xml")), result);
View Full Code Here

        }
    }

    @SuppressWarnings("unchecked")
  private void test_appContextTime(Smooks smooks) throws IOException, SAXException, InterruptedException {
        ExecutionContext execContext = smooks.createExecutionContext();
        BeanContext beanContext = execContext.getBeanContext();

        smooks.filterSource(execContext, new StringSource("<doc/>"), null);
        List orders11 = (List) beanContext.getBean("orders1");
        List orders12 = (List) beanContext.getBean("orders2");
View Full Code Here

    @SuppressWarnings("unchecked")
  public void test_ResultsetRowSelector_01() throws IOException, SAXException, InterruptedException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config.xml"));

        try {
            ExecutionContext execContext = smooks.createExecutionContext();
            BeanContext beanContext = execContext.getBeanContext();

            smooks.filterSource(execContext, new StringSource("<doc/>"), null);
            Map<String, Object> myOrder = (Map<String, Object>) beanContext.getBean("myOrder");

            assertEquals("{ORDERNUMBER=2, CUSTOMERNUMBER=2, PRODUCTCODE=456}", myOrder.toString());
View Full Code Here

    @SuppressWarnings("unchecked")
  public void test_ResultsetRowSelector_02() throws IOException, SAXException, InterruptedException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-failed-select-01.xml"));

        try {
            ExecutionContext execContext = smooks.createExecutionContext();
            BeanContext beanContext = execContext.getBeanContext();

            smooks.filterSource(execContext, new StringSource("<doc/>"), null);
            Map<String, Object> myOrder = (Map<String, Object>) beanContext.getBean("myOrder");

            assertEquals(null, myOrder);
View Full Code Here

    public void test_ResultsetRowSelector_03() throws IOException, SAXException, InterruptedException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-failed-select-02.xml"));

        try {
            ExecutionContext execContext = smooks.createExecutionContext();
            BeanContext beanContext = execContext.getBeanContext();
            BeanIdStore beanIdStore =  execContext.getContext().getBeanIdStore();

            BeanId requiredOrderNumId = beanIdStore.register("requiredOrderNum");

            beanContext.addBean(requiredOrderNumId, 9999, null);
            try {
View Full Code Here

TOP

Related Classes of org.milyn.container.ExecutionContext

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.