Package org.milyn.payload

Examples of org.milyn.payload.StringSource



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


    }

    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.
View Full Code Here

     
      smooks.setReaderConfig(new GenericReaderConfigurator(PooledSAXParser.class));
      smooks.setFilterSettings(FilterSettings.newSAXSettings().setReaderPoolSize(1));
     
      PooledSAXParser.numSetHandlerCalls = 0;
      smooks.filterSource(new StringSource("<x/>"));
      smooks.filterSource(new StringSource("<x/>"));
      smooks.filterSource(new StringSource("<x/>"));     
      assertEquals(3, PooledSAXParser.numSetHandlerCalls);
    }
View Full Code Here

     
      smooks.setReaderConfig(new GenericReaderConfigurator(UnpooledSAXParser.class));
      smooks.setFilterSettings(FilterSettings.newSAXSettings().setReaderPoolSize(0));
     
      UnpooledSAXParser.numSetHandlerCalls = 0;
      smooks.filterSource(new StringSource("<x/>"));
      smooks.filterSource(new StringSource("<x/>"));
      smooks.filterSource(new StringSource("<x/>"));     
      assertEquals(3, UnpooledSAXParser.numSetHandlerCalls);
    }
View Full Code Here

                assertEquals("&tomfennelly", element.getTextContent());
            }
        }, "element");

        StringResult serializedRes = new StringResult();
        smooks.filterSource(new StringSource("<element attrib=\"&amp;tomfennelly\">&amp;tomfennelly</element>"), serializedRes);

        assertEquals("<element attrib=\"&amp;tomfennelly\">&amp;tomfennelly</element>", serializedRes.getResult());
    }
View Full Code Here

        Smooks smooks = new Smooks();

        smooks.addVisitor(new MockSAX(), "element");

        StringResult serializedRes = new StringResult();
        smooks.filterSource(new StringSource("<element attrib=\"&amp;tomfennelly\">&amp;tomfennelly</element>"), serializedRes);

        assertEquals("<element attrib=\"&amp;tomfennelly\">&amp;tomfennelly</element>", serializedRes.getResult());
    }
View Full Code Here

    @Override
    protected void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        MockContextFactory.setAsInitial();

        source = new StringSource("<root><a /><b /></root>");

        InitialContext context = new InitialContext();
        context.bind("java:/mockDS", dataSource);
        context.bind("java:/mockTransaction", transaction);
View Full Code Here

    public void test_normal() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("normal-ds-lifecycle.xml"));

        // Cleanup should get called twice.  Once for the visitAfter event and once for the
        // executeExecutionLifecycleCleanup event...
        smooks.filterSource(new StringSource("<a></a>"));
        assertEquals(2, MockDatasource.cleanupCallCount);
        assertTrue(MockDatasource.committed);
    }
View Full Code Here

    public void test_exception() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("exception-ds-lifecycle.xml"));

        try {
            smooks.filterSource(new StringSource("<a><b/><c/></a>"));
            fail("Expected exception...");
        } catch(SmooksException e) {
            // Expected
        }
View Full Code Here

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

        try {
            smooks.filterSource(smooks.createExecutionContext(), new StringSource("<a/>"), null);
            fail("Expected SAXWriterAccessException");
        } catch(SmooksException e) {
            assertEquals("Illegal access to the element writer for element 'a' by SAX visitor 'org.milyn.delivery.sax.SAXVisitorWriter02'.  Writer already acquired by SAX visitor 'org.milyn.delivery.sax.SAXVisitorWriter01'.  See SAXElement javadocs (http://milyn.codehaus.org/Smooks).  Change Smooks visitor resource configuration.", e.getCause().getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of org.milyn.payload.StringSource

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.