Package nexj.core.integration.io

Examples of nexj.core.integration.io.StringInput


    * Message with root node reference to another message, using a different envelope than the referent.
    */
   public void testParseMessageWithRootRef() throws Exception
   {
      Message message = m_context.getMetadata().getMessage("SOAP12_PatientDemographics");
      TransferObject root = m_parser.parse(new StringInput(PATIENT_SOAP12), message);

      assertFalse(root.hasValue("headers"));

      TransferObject player = (TransferObject)root.getValue("player");

View Full Code Here


   /**
    * Test single aggregation.
    */
   public void testSingleAggregation() throws Exception
   {
      m_formatter.format(m_parser.parse(new StringInput(SINGLE_AGGREGATION_TEST), m_singleAggregationMessage),
            m_singleAggregationMessage, new WriterOutput(new StringWriter()));
   }
View Full Code Here

    * Test that correct exception is generated when the missing
    * piece of required data is not mapped to any field at all.
    */
   public void testParseSkippedRequiredBeginning2() throws Exception
   {
      StringInput input = new StringInput(
         "a1,a2,realdata1,a4,a5,realdata2\n" +
         ",,nextrealdata1,,,nextrealdata2\n" +
         "c1\n"  //second column is missing, unmapped, but required (because third column is required)
         );
     
View Full Code Here

      m_parser.initializeMessageTable(table);
     
      TransferObject root, record;
      List recordList;
     
      root = m_parser.parse(new StringInput(
         "a,b,c,d\n" +
         "a2,b2,c2,d2\n"
         ), table);
     
      recordList = (List)root.getValue("Data4R");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertEquals("d2", record.getValue("fourth"));


      // Try parsing a single row of data (motivated by a real-world bug)
      root = m_parser.parse(new StringInput(
         "a,b,c,d\n"
         ), table);

      assertNotNull(root);
      recordList = (List)root.getValue("Data4R");

      assertEquals(1, recordList.size());

      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));



      root = m_parser.parse(new StringInput(
         "a,b,c\n" +
         "a2,b2,c2\n"
         ), table);
     
      recordList = (List)root.getValue("Data3R");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));


      // Try parsing a single row of data (motivated by a real-world bug)
      root = m_parser.parse(new StringInput(
         "a,b,c\n"
         ), table);

      assertNotNull(root);
      recordList = (List)root.getValue("Data3R");

      assertEquals(1, recordList.size());

      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));



      try
      {
         root = m_parser.parse(new StringInput(
            "a,b\n" +
            "a2,b2\n"
            ), table);
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.csv.undetectableMessage", ex.getErrorCode());
      }
     
      try
      {
         root = m_parser.parse(new StringInput(
            "a,b,c,d,e\n" +
            "a2,b2,c2,d2,e2\n"
            ), table);
         fail();
      }
View Full Code Here

      m_parser.initializeMessageTable(table);
     
      TransferObject root, record;
      List recordList;
     
      root = m_parser.parse(new StringInput(
         "a,b,c,d\n" +
         "a2,b2,c2,d2\n"
         ), table);
     
      recordList = (List)root.getValue("Data4R");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertEquals("d2", record.getValue("fourth"));
     
     
     
      root = m_parser.parse(new StringInput(
         "a,b,c\n" +
         "a2,b2,c2\n"
         ), table);
     
      recordList = (List)root.getValue("Data3O");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
     
     
      root = m_parser.parse(new StringInput(
         "; A comment here should not ruin things.\r\n" +
         "a,b\n" +
         "; Nor should a comment here...\n" +
         "a2,b2,c2\n"
         ), table);
     
      recordList = (List)root.getValue("Data3O");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertFalse(record.hasValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
     
     
      root = m_parser.parse(new StringInput(
         "a\n" +
         "a2,b2,c2\n"
         ), table);
     
      recordList = (List)root.getValue("Data3O");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertFalse(record.hasValue("second"));
      assertFalse(record.hasValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
     
     
      try
      {
         root = m_parser.parse(new StringInput(
            "a,b,c,d,e\n" +
            "a2,b2,c2,d2,e2\n"
            ), table);
         fail();
      }
View Full Code Here

      m_parser.initializeMessageTable(table);
     
      TransferObject root, record;
      List recordList;
     
      root = m_parser.parse(new StringInput(
         "a,b,c,d\n" +
         "a2,b2,c2,d2\n"
         ), table);
     
      recordList = (List)root.getValue("Data4R");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertEquals("d2", record.getValue("fourth"));
     
     
     
      root = m_parser.parse(new StringInput(
         "a,b,c\n" +
         "a2,b2,c2\n"
         ), table);
     
      recordList = (List)root.getValue("Data2R1O");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
     
     
      root = m_parser.parse(new StringInput(
         "a,b\n" +
         "a2,b2,c2\n"
         ), table);
     
      recordList = (List)root.getValue("Data2R1O");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertFalse(record.hasValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
     

      try
      {
         root = m_parser.parse(new StringInput(
            "a\n" +
            "a2,b2,c2\n"
            ), table);
         fail();
      }
View Full Code Here

      m_parser.initializeMessageTable(table);
     
      TransferObject root, record;
      List recordList;
     
      root = m_parser.parse(new StringInput(
         "first,second,third,fourth\n" +
         "a,b,c,d\n" +
         "a2,b2,c2,d2\n"
         ), table);

      assertEquals("CSV_TableConflict_4HeaderAllRequired", root.getClassName());
      recordList = (List)root.getValue("Data4H");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertEquals("d2", record.getValue("fourth"));
     
     
     
      //Test re-ordered header
      root = m_parser.parse(new StringInput(
         "fourth,second,third,first\n" +
         "d,b,c,a\n" +
         "d2,b2,c2,a2\n"
         ), table);
     
      recordList = (List)root.getValue("Data4H");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertEquals("d2", record.getValue("fourth"));
     

      // Test header but no data.
      root = m_parser.parse(new StringInput(
         "fourth,second,third,first\n"
         ), table);

      assertNotNull(root);
      assertEquals("CSV_TableConflict_4HeaderAllRequired", root.getClassName());
      recordList = (List)root.getValue("Data4H");
      assertTrue(recordList.isEmpty());


     
      root = m_parser.parse(new StringInput(
         "a,b,c\n" +
         "a2,b2,c2\n"
         ), table);

      assertEquals("CSV_TableConflict_3Optional", root.getClassName());
      recordList = (List)root.getValue("Data3O");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
     
     
      root = m_parser.parse(new StringInput(
         "a,b\n" +
         "a2,b2,c2\n"
         ), table);

      assertEquals("CSV_TableConflict_3Optional", root.getClassName());
      recordList = (List)root.getValue("Data3O");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertFalse(record.hasValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
     
     
      root = m_parser.parse(new StringInput(
         "a\n" +
         "a2,b2,c2\n"
         ), table);

      assertEquals("CSV_TableConflict_3Optional", root.getClassName());
      recordList = (List)root.getValue("Data3O");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertFalse(record.hasValue("second"));
      assertFalse(record.hasValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
     
     
      try
      {
         root = m_parser.parse(new StringInput(
            "a,b,c,d,e\n" +
            "a2,b2,c2,d2,e2\n"
            ), table);
         fail();
      }
View Full Code Here

      m_parser.initializeMessageTable(table);
     
      TransferObject root, record;
      List recordList;
     
      root = m_parser.parse(new StringInput(
         "\nfirst,second,third,fourth\n" +
         "a,b,c,d\n" +
         "a2,b2,c2,d2\n"
         ), table);
     
      recordList = (List)root.getValue("Data4H");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertEquals("d2", record.getValue("fourth"));
     
     
      //Test re-ordered header
      root = m_parser.parse(new StringInput(
         "fourth,second,third,first\n" +
         "d,b,c,a\n" +
         "d2,b2,c2,a2\n"
         ), table);
     
      recordList = (List)root.getValue("Data4H");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertEquals("d2", record.getValue("fourth"));
     
     
     
     
      root = m_parser.parse(new StringInput(
         "\n\na,b,c\n" +
         "a2,b2,c2\n"
         ), table);
     
      recordList = (List)root.getValue("Data2R1O");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
     
     
      root = m_parser.parse(new StringInput(
         "\n\n\na,b\n" +
         "a2,b2,c2\n"
         ), table);
     
      recordList = (List)root.getValue("Data2R1O");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertFalse(record.hasValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
     
     
      root = m_parser.parse(new StringInput(
         "\n\n\n\na,b,c,d,e\n" +
         "a2,b2,c2,d2,e2\n"
         ), table);
     
      recordList = (List)root.getValue("Data5R");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));
      assertEquals("e", record.getValue("fifth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertEquals("d2", record.getValue("fourth"));
      assertEquals("e2", record.getValue("fifth"));
     
     
     
      try
      {
         root = m_parser.parse(new StringInput(
            "a,b,c,d,e,f\n" +
            "a2,b2,c2,d2,e2,f2\n"
            ), table);
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.csv.undetectableMessage", ex.getErrorCode());
      }
     
      try
      {
         root = m_parser.parse(new StringInput(
            "a\n" +
            "a2,b2,c2,d2\n"
            ), table);
         fail();
      }
View Full Code Here

      m_parser.initializeMessageTable(table);
     
      TransferObject root, record;
      List recordList;
     
      root = m_parser.parse(new StringInput(
         "\nfirst,second,third,fourth\n" +
         ";This is a comment\n" +
         "a,b,c,d\n" +
         ";So is this\n" +
         "a2,b2,c2,d2\n"
         ), table);
     
      recordList = (List)root.getValue("Data4H");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertEquals("d2", record.getValue("fourth"));
     
     
      //Test re-ordered header
      root = m_parser.parse(new StringInput(
         "fourth,second,third,first\n" +
         "d,b,c,a\n" +
         "d2,b2,c2,a2\n"
         ), table);
     
      recordList = (List)root.getValue("Data4H");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertEquals("d2", record.getValue("fourth"));
     
     
     
      //Test re-ordered, short header
      root = m_parser.parse(new StringInput(
         "second,third,first\n" +
         "b,c,a\n" +
         "b2,c2,a2\n"
         ), table);
     
      recordList = (List)root.getValue("Data4H");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertFalse(record.hasValue("fourth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertFalse(record.hasValue("fourth"));
           
     
      root = m_parser.parse(new StringInput(
         "\n\nfirst,second,third\n" +
         "\n\na,b,c\n" +
         "a2,b2,c2\n"
         ), table);
     
      recordList = (List)root.getValue("Data4H");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
     
     
      root = m_parser.parse(new StringInput(
         "\n\n\na,b\n" +
         "a2,b2,c2\n"
         ), table);
     
      recordList = (List)root.getValue("Data1R1O");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertFalse(record.hasValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertFalse(record.hasValue("third"));
     
     
      root = m_parser.parse(new StringInput(
         "\n\n\n\na,b,c,d,e\n" +
         "a2,b2,c2,d2,e2\n"
         ), table);
     
      recordList = (List)root.getValue("Data5R");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertEquals("d", record.getValue("fourth"));
      assertEquals("e", record.getValue("fifth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertEquals("d2", record.getValue("fourth"));
      assertEquals("e2", record.getValue("fifth"));
     
     
     
      try
      {
         root = m_parser.parse(new StringInput(
            "a,b,c,d,e,f\n" +
            "a2,b2,c2,d2,e2,f2\n"
            ), table);
         fail();
      }
View Full Code Here

  
   public void testParseHeaderWithMissingRequired() throws Exception
   {
      TransferObject root, record;
      List recordList;
      root = m_parser.parse(new StringInput(
         "first,second,third\n" +
         "a,b,c\n" +
         "a2,b2,c2\n"
         ), Repository.getMetadata().getMessage("CSV_TableConflict_4Header"));
     
      recordList = (List)root.getValue("Data4H");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("c", record.getValue("third"));
      assertFalse(record.hasValue("fourth"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("c2", record.getValue("third"));
      assertFalse(record.hasValue("fourth"));
     
     
      //Missing "third" column, which is marked as required.
      root = m_parser.parse(new StringInput(
         "first,second,fourth\n" +
         "a,b,d\n" +
         "a2,b2,d2\n"
         ), Repository.getMetadata().getMessage("CSV_TableConflict_4Header"));
     
      recordList = (List)root.getValue("Data4H");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("d", record.getValue("fourth"));
      assertFalse(record.hasValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("d2", record.getValue("fourth"));
      assertFalse(record.hasValue("third"));
     
     
      //"third" column is required and "fourth" column is optional, but still allow
      //as long as data doesn't violate.
      root = m_parser.parse(new StringInput(
         "first,second,fourth,third\n" +
         "a,b,d,c\n" +
         "a2,b2,d2,c2\n"
         ), Repository.getMetadata().getMessage("CSV_TableConflict_4Header"));
     
      recordList = (List)root.getValue("Data4H");
     
      assertEquals(2, recordList.size());
     
      record = (TransferObject)recordList.get(0);
      assertEquals("a", record.getValue("first"));
      assertEquals("b", record.getValue("second"));
      assertEquals("d", record.getValue("fourth"));
      assertEquals("c", record.getValue("third"));
    
      record = (TransferObject)recordList.get(1);
      assertEquals("a2", record.getValue("first"));
      assertEquals("b2", record.getValue("second"));
      assertEquals("d2", record.getValue("fourth"));
      assertEquals("c2", record.getValue("third"));
     
     
      try
      {
         root = m_parser.parse(new StringInput(
            "fourth,first,second,third\n" +
            "d,a,b,c\n" +
            "d2,a2,b2,c2\n" +
            "d3,a3\n"
            ), Repository.getMetadata().getMessage("CSV_TableConflict_4Header"));
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ((IntegrationException)ex.getCause()).getErrorCode());
         assertEquals("CSV_TableConflict_4Header Data4H second", ((IntegrationException)ex.getCause()).getErrorArgs()[0]);
      }
     
     
      try
      {
         root = m_parser.parse(new StringInput(
            "fourth,first,second,third\n" +
            "d,a,b,c\n" +
            "d2,a2,b2,c2\n" +
            "d3,a3,b3\n"
            ), Repository.getMetadata().getMessage("CSV_TableConflict_4Header"));
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ((IntegrationException)ex.getCause()).getErrorCode());
         assertEquals("CSV_TableConflict_4Header Data4H third", ((IntegrationException)ex.getCause()).getErrorArgs()[0]);
      }
     
     
      try
      {
         root = m_parser.parse(new StringInput(
            "fourth,first\n" +
            "d,a\n" +
            "d2,a2\n" +
            "d3\n"
            ), Repository.getMetadata().getMessage("CSV_TableConflict_4Header"));
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ((IntegrationException)ex.getCause()).getErrorCode());
         assertEquals("CSV_TableConflict_4Header Data4H first", ((IntegrationException)ex.getCause()).getErrorArgs()[0]);
      }
     
     
      //This final test makes sure that the parse looks ahead, past just the immediate
      //column, which may be optional, and finds that there is a subesequent required column.
      try
      {
         root = m_parser.parse(new StringInput(
            "first,fourth,second\n" +
            "a,d,b\n" +
            "a2,d2,b2\n" +
            "a3\n"
            ), Repository.getMetadata().getMessage("CSV_TableConflict_4Header"));
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.