Package org.milyn.payload

Examples of org.milyn.payload.StringResult


        ExecutionContext context = smooks.createExecutionContext();
        test_ftl(smooks, context, input, expected);
    }

    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


    }
   
    @Test
    public void convertStringResultToStreamSource() throws Exception
    {
        StringResult stringResult = createStringResult("Bajja");
       
        StreamSource streamSource = typeConverter.convertTo(StreamSource.class, stringResult);
       
        BufferedReader reader = new BufferedReader(streamSource.getReader());
        assertEquals("Bajja", reader.readLine());
View Full Code Here

   
    private StringResult createStringResult(final String string)
    {
        StringWriter stringWriter = new StringWriter();
        stringWriter.write(string);
        StringResult stringResult = new StringResult();
        stringResult.setWriter(stringWriter);
        return stringResult;
    }
View Full Code Here

    public void test_07() throws SmooksException, IOException, SAXException {
        Smooks smooks = new Smooks();

        smooks.setReaderConfig(new CSVRecordParserConfigurator("firstname,lastname,gender,age,country"));

        StringResult result = new StringResult();
        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("input-message-01.csv")), result);

        assertEquals(
                "<csv-set><csv-record number=\"1\"><firstname>Tom</firstname><lastname>Fennelly</lastname><gender>Male</gender><age>4</age><country>Ireland</country></csv-record><csv-record number=\"2\"><firstname>Mike</firstname><lastname>Fennelly</lastname><gender>Male</gender><age>2</age><country>Ireland</country></csv-record></csv-set>",
                result.getResult());
    }
View Full Code Here

        smooks.setReaderConfig(new CSVRecordParserConfigurator("firstname,lastname,gender,age,country")
                .setSeparatorChar('|').setQuoteChar('\'').setSkipLineCount(1).setRootElementName("customers")
                .setRecordElementName("customer"));

        StringResult result = new StringResult();
        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("input-message-03.csv")), result);

        assertEquals(
                "<customers><customer number=\"1\"><firstname>Tom</firstname><lastname>Fennelly</lastname><gender>Male</gender><age>4</age><country>Ireland</country></customer><customer number=\"2\"><firstname>Mike</firstname><lastname>Fennelly</lastname><gender>Male</gender><age>2</age><country>Ireland</country></customer></customers>",
                result.getResult());
    }
View Full Code Here

    }

    public void test_17_wildcard() throws SmooksException, IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-13-wildcard.xml"));
        StringResult result = new StringResult();

        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("input-message-13.csv")), result);

        assertEquals(
                "<main-set><record number=\"1\"><field_0>Tom</field_0><field_1>Fennelly</field_1><field_2>Male</field_2><field_3>A</field_3><field_4>B</field_4><field_5>C</field_5><field_6>4</field_6><field_7>IR</field_7><field_8>Ireland</field_8><field_9>2</field_9><field_10>3</field_10></record><record number=\"2\"><field_0>Mike</field_0><field_1>Fennelly</field_1><field_2>Male</field_2><field_3>D</field_3><field_4>F</field_4><field_5>G</field_5><field_6>2</field_6><field_7>IR</field_7><field_8>Ireland</field_8><field_9>4</field_9></record></main-set>",
                result.toString());
    }
View Full Code Here

    public void test_null_field_values() throws SmooksException, IOException, SAXException {
        Smooks smooks = new Smooks();

        smooks.setReaderConfig(new CSVRecordParserConfigurator("firstname,lastname,gender,age,country"));

        StringResult result = new StringResult();
        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("input-message-null-field-values.csv")), result);

        assertEquals(
                "<csv-set><csv-record number=\"1\"><firstname>Tom</firstname><lastname>Fennelly</lastname><gender>Male</gender><age>4</age><country>Ireland</country></csv-record><csv-record number=\"2\"><firstname>Mike</firstname><lastname>Fennelly</lastname><gender>Male</gender><age>2</age><country>Ireland</country></csv-record><csv-record number=\"3\"><firstname>Joel</firstname><lastname>Pearson</lastname><gender>Male</gender><age></age><country>Australia</country></csv-record></csv-set>",
                result.getResult());
    }
View Full Code Here

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

        try {
            StringResult result = new StringResult();
            smooks.filterSource(new StreamSource(getClass().getResourceAsStream("input-message-01.csv")), result);
            assertEquals("<csv-set>\n" +
                    "\t<csv-record number=\"1\">\n" +
                    "\t\t<firstname>Tom</firstname>\n" +
                    "\t\t<lastname>Fennelly</lastname>\n" +
                    "\t\t<gender>Male</gender>\n" +
                    "\t\t<age>4</age>\n" +
                    "\t\t<country>Ireland</country>\n" +
                    "\t</csv-record>\n" +
                    "\t<csv-record number=\"2\">\n" +
                    "\t\t<firstname>Mike</firstname>\n" +
                    "\t\t<lastname>Fennelly</lastname>\n" +
                    "\t\t<gender>Male</gender>\n" +
                    "\t\t<age>2</age>\n" +
                    "\t\t<country>Ireland</country>\n" +
                    "\t</csv-record>\n" +
                    "</csv-set>", result.getResult());
        } finally {
            smooks.close();
        }
    }
View Full Code Here

*/
public class Xsd14Test extends TestCase {

  public void test_no_newlines() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("default-config.xml"));
    StringResult result = new StringResult();
   
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("edi-input-01.txt")), result);

        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("expected.xml")), new StringReader(result.toString()));
  }
View Full Code Here

        XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("expected.xml")), new StringReader(result.toString()));
  }

  public void test_with_newlines() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("newlines-config.xml"));
    StringResult result;
   
    // Doesn't actually contain newlines... but that shouldn't matter...
    result = new StringResult();
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("edi-input-01.txt")), result);
        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("expected.xml")), new StringReader(result.toString()));

    // Contains newlines... should be ignored...
        result = new StringResult();
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("edi-input-02.txt")), result);
        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("expected.xml")), new StringReader(result.toString()));
  }
View Full Code Here

TOP

Related Classes of org.milyn.payload.StringResult

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.