Package nexj.core.integration.io

Examples of nexj.core.integration.io.StringInput


      String sRecPrefix = "<(<";
      String sRecSuffix = ">)>";

      TransferObject record;
      TransferObject root = m_parser.parse(new StringInput(
         sRecPrefix +
         "__r1--f1__" +       // field 1, string
         "1234567890" +       // field 2, integer
         "1357135.79" +       // field 3, double
         "false" + "     " // field 4, boolean, blank padded
View Full Code Here


   public void testParseTimestamps() throws Exception
   {
      String sMessageName = "Fixed_Timestamps";

      TransferObject record;
      TransferObject root = m_parser.parse(new StringInput(
         "2010-03-19 15:26:37.000000000" + " " + // width=30
         "20110319102639.000-0500" + "       " + // format="yyyyMMddHHmmss.SSSZ" width=30
         "            " + "20120319112643.000" + // alignment="right" format="yyyyMMddHHmmss.SSS" width=30
         "((        20130319112637.000))" +      // alignment="right" format="yyyyMMddHHmmss.SSS" prefix="((" suffix="))" width="30"
         "[[[[__02014.March.19 AD 11:26:37 AM____"   // format="yyyyy.MMMMM.dd GGG hh:mm:ss aaa" padding="_" prefix="[[[[" width="35"
View Full Code Here

      String s = writer.toString();

      logger.info("size of formatted string is (" + s.length() + ") chars");

      // Parse the formatted string
      TransferObject parseRoot = m_parser.parse(new StringInput(s), msg);

      // Test it
      assertEquals(sMessageName, parseRoot.getClassName());

      List parseRecList = (List)parseRoot.getValue("record");
View Full Code Here

      String sEmptyF1 = "__________";     // all padding chars
      String sR2F2 = "|2012-03-19 15:26:43.000000000";
      String sEmptyF2 = "|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";

      TransferObject record;
      TransferObject root = m_parser.parse(new StringInput(
         sR1F1 + sR1F2 +      // record 1
         sEmptyF1 + sR2F2 +   // record 2
         sEmptyF1 + sEmptyF2  // record 3
      ), Repository.getMetadata().getMessage(sMessageName));
View Full Code Here

      String sEmptyF1 = "__________";     // all padding chars
      String sR2F2 = "|2012-03-19 15:26:43.000000000";
      String sEmptyF2 = "|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";

      TransferObject record;
      TransferObject root = m_parser.parse(new StringInput(
         sR1F1 + sR1F2 +       // record 1
         sR1F1 + sR2F2         // record 2
      ), Repository.getMetadata().getMessage(sMessageName));

      assertEquals(sMessageName, root.getClassName());

      List recordList = (List)root.getValue("record");

      assertEquals(2, recordList.size());

      record = (TransferObject)recordList.get(0);
      assertEquals(sR1F1, record.getValue("field_1"));
      assertEquals(Primitive.toTimestamp(new Long(1269012397000L)), record.getValue("field_2"));

      record = (TransferObject)recordList.get(1);
      assertEquals(sR1F1, record.getValue("field_1"));
      assertEquals(Primitive.toTimestamp(new Long(1332170803000L)), record.getValue("field_2"));

      //
      // Try some failure cases
      //
      try
      {
         m_parser.parse(new StringInput(
            sR1F1 + sR1F2 +       // record 1
            sEmptyF1 + sR2F2 +    // record 2, fails requiredness on field_1
            sEmptyF1 + sEmptyF2 + // record 3
            sR1F1 + sR2F2         // record 4
         ), Repository.getMetadata().getMessage(sMessageName));
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.parse.noDataForRequiredPart", ex.getErrorCode());
         assertEquals(sMessageName + " record field_1", ex.getErrorArgs()[0]);
         assertEquals(2, ((Integer)(ex.getErrorArgs()[1])).intValue());    // record 2 fails
      }

      try
      {
         m_parser.parse(new StringInput(
            sR1F1 + sR1F2 +    // record 1
            sR1F1 + sR2F2 +    // record 2
            sR1F1 + sEmptyF2 + // record 3, fails requiredness on field_2
            sR1F1 + sR2F2      // record 4
         ), Repository.getMetadata().getMessage(sMessageName));
View Full Code Here

    * Also tests that CSV input can be parsed if the input does not end in a newline.
    */
   public void testParseSimpleTable() throws Exception
   {
      TransferObject record;
      TransferObject root = m_parser.parse(new StringInput(
         ";\n" +
         "firstName,familyName,age,Phone1_location,Phone1_number,location,number,balance\n" +
         "John,Doe,42,,,,,108\n" +
         ";Jane,Doe,67,,,,,\n" +
         "Jane,Doe,,,,,,\n" +
View Full Code Here

    * can still be parsed.
    */
   public void testParseSimpleTableNoEscapeOrQuote() throws Exception
   {
      TransferObject record;
      TransferObject root = m_parser.parse(new StringInput(
         ";\n" +
         "firstName,familyName,age,Phone1_location,Phone1_number,location,number,balance\n" +
         "John,Doe,42,,,,,108\n" +
         ";Jane,Doe,67,,,,,\n" +
         "Jane,Doe,,,,,,\n" +
View Full Code Here


   public void testParseSimpleTableWithCrazyNewlines() throws Exception
   {
      TransferObject record;
      TransferObject root = m_parser.parse(new StringInput(
         "firstName,familyName,age,Phone1_location,Phone1_number,location,number,balance\n\n\n\n\n" //multiple newline
         "John,Doe,42,,,,,108\r\n" +
         "Jane,Doe,37,,,,,\n\r" //crazy newline!
         "Jack,Lin,26,,,,,\r" +
         ",,,,,,,\n"
View Full Code Here

  
  
   public void testParseSingleRow() throws Exception
   {
      TransferObject record;
      TransferObject root = m_parser.parse(new StringInput(
         "firstName,familyName,age,Phone1_location,Phone1_number,location,number,balance\n" +
         "John,Doe,42,,,,,108\n"        
         ), m_simple_message);
     
     
View Full Code Here

    * (This was a real-world bug--it used to return a null transfer object)
    */
   public void testParseHeaderButNoData() throws Exception
   {
      List recordList;
      TransferObject root = m_parser.parse(new StringInput(
         "firstName,familyName,age,Phone1_location,Phone1_number,location,number,balance\n"
         ), m_simple_message);

      assertNotNull(root);
      recordList = (List)root.getValue("Row");
View Full Code Here

TOP

Related Classes of nexj.core.integration.io.StringInput

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.