Package org.milyn.payload

Examples of org.milyn.payload.StringSource


    public void test_2(StreamFilterType filterType) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("route-to-stream-02.cdrl"));

        smooks.setFilterSettings(new FilterSettings(filterType));
        smooks.filterSource(new StringSource("<a><c x='cx' /><d><e x='ex' /></d></a>"), null);
        assertEquals("<mybean>cx</mybean><mybean>ex</mybean>", new String(MockOutStreamResource.outputStream.toByteArray()));
    }
View Full Code Here


    private void test(StreamFilterType filterType) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("config_01.xml"));
        JavaResult result = new JavaResult();

        smooks.setFilterSettings(new FilterSettings(filterType));
        smooks.filterSource(new StringSource("<root><a><b>1</b></a></root>"), result);
        assertNotNull(result.getBean("root"));
        assertNull(result.getBean("a"));
        assertNull(result.getBean("b"));
    }
View Full Code Here

  public void test_decoder_defined() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("config_01.xml"));
    JavaResult javaResult = new JavaResult();
   
    smooks.filterSource(new StringSource("<price>123'456,00</price>"), javaResult);
   
    OrderItem orderItem = (OrderItem) javaResult.getBean("orderItem");   
    assertEquals(123456.00D, orderItem.getPrice());

    BigDecimal baseBigD = (BigDecimal) javaResult.getBean("price");
View Full Code Here

  public void test_decoder_undefined() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("config_02.xml"));
    JavaResult javaResult = new JavaResult();
   
    smooks.filterSource(new StringSource("<price>123'456,00</price>"), javaResult);
   
    OrderItem orderItem = (OrderItem) javaResult.getBean("orderItem");   
    assertEquals(123456.00D, orderItem.getPrice());
  }
View Full Code Here

        Smooks smooks = new Smooks("/org/milyn/templating/freemarker/test-configs-ext-05.cdrl");

        smooks.setFilterSettings(new FilterSettings(filterType));

        StringResult result = new StringResult();
        smooks.filterSource(new StringSource("<a><b><c>cvalue1</c><c>cvalue2</c><c>cvalue3</c></b></a>"), result);
        assertEquals("'cvalue1''cvalue2''cvalue3'", result.toString());
    }
View Full Code Here

    public void test_nodeModel_3(StreamFilterType filterType) throws IOException, SAXException {
        Smooks smooks = new Smooks("/org/milyn/templating/freemarker/test-configs-ext-07.cdrl");

        smooks.setFilterSettings(new FilterSettings(filterType));
        StringResult result = new StringResult();
        smooks.filterSource(new StringSource("<a><b javabind='javaval'><c>cvalue1</c><c>cvalue2</c><c>cvalue3</c></b></a>"), result);
        assertEquals("'cvalue1''cvalue2''cvalue3' javaVal=javaval", result.toString());
    }
View Full Code Here

    public void test_outputTo_Stream() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("test-configs-ext-outputToOutStream.cdrl"));
        ExecutionContext context = smooks.createExecutionContext();

        MockOutStreamResource.outputStream = new ByteArrayOutputStream();
        smooks.filterSource(context, new StringSource("<a/>"), null);

        assertEquals("data to outstream", MockOutStreamResource.outputStream.toString());
    }
View Full Code Here

    public void test_PTIME() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("test-configs-ext-PTIME.cdrl"));
        StringResult result = new StringResult();

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

        // should be able to convert the result to a Long instance...
        new Long(result.toString());
    }
View Full Code Here

    public void test_PUUID() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("test-configs-ext-PUUID.cdrl"));
        StringResult result = new StringResult();

        smooks.filterSource(new StringSource("<doc/>"), result);
        assertTrue(result.toString().length() > 10);
    }
View Full Code Here

    }

    private void test_ftl(Smooks smooks, ExecutionContext context, String input, String expected) throws IOException, SAXException {
        StringResult result = new StringResult();

        smooks.filterSource(context, new StringSource(input), result);

        XMLUnit.setIgnoreWhitespace(true);
        XMLAssert.assertXMLEqual(expected, result.getResult());
    }
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.