Package nexj.core.integration.io

Examples of nexj.core.integration.io.StringInput


      m_singleAggregationMessage = metadata.getMessage("SingleAggregation");
   }

   public void testParseInputMessage() throws Exception
   {
      TransferObject tobj = m_parser.parse(new StringInput(PATIENT), m_patient);
      TransferObject player = (TransferObject)tobj.getValue("player");

      assertEquals("My1", player.getValue("firstName"));
      assertEquals("Test", player.getValue("lastName"));

      TransferObject id = (TransferObject)((List)player.getValue("id")).get(0);

      assertEquals("XML_PatientDemographics", tobj.getClassName());
      assertEquals("OHIP", id.getValue("type"));
      assertEquals("111222333", id.getValue("id"));

      StringWriter writer = new StringWriter();

      m_formatter.format(tobj, m_patient, new WriterOutput(writer));

      assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><lastName>Test</lastName><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>", writer.toString());

      writer = new StringWriter();
      tobj.setClassName(null);
      m_formatter.format(tobj, m_patientSOAP, new WriterOutput(writer));
      assertEquals(PATIENT_SOAP, writer.toString());


      tobj = m_parser.parse(new StringInput(PATIENT_BLANK_FIRST_NAME), m_patient);
      player = (TransferObject)tobj.getValue("player");

      assertNull(player.getValue("firstName"));
      assertEquals("Test", player.getValue("lastName"));


      tobj = m_parser.parse(new StringInput(PATIENT_EMPTY_FIRST_NAME), m_patient);
      player = (TransferObject)tobj.getValue("player");

      assertNull(player.getValue("firstName"));
      assertEquals("Test", player.getValue("lastName"));


      tobj = m_parser.parse(new StringInput(PATIENT_NO_FIRST_NAME), m_patient);
      player = (TransferObject)tobj.getValue("player");

      assertFalse(player.hasValue("firstName"));
      assertEquals("Test", player.getValue("lastName"));


      tobj = m_parser.parse(new StringInput(PATIENT_SOAP), m_patientSOAP);
      writer = new StringWriter();
      m_formatter.format(tobj, m_patientSOAP, new WriterOutput(writer));
      assertEquals(PATIENT_SOAP, writer.toString());

      Reader reader = null;

      try
      {
         reader = new InputStreamReader(URLUtil.openResource(XMLMessageParserTest.class, "XDS_SubmitObjectsRequest.xml"), XMLUtil.ENCODING);
         tobj = m_parser.parse(new ReaderInput(reader), m_xds);
      }
      finally
      {
         IOUtil.close(reader);
      }

      assertEquals("XDS_SubmitObjects", tobj.getClassName());
      assertEquals("0123 456 789 KT^^^&OHIP&ISO", ((TransferObject)((List)((TransferObject)
         ((TransferObject)tobj.getValue("LeafRegistryObjectList")).getValue("ExtrinsicObject"))
         .getValue("ExternalIdentifier")).get(0)).getValue("value"));

      try
      {
         m_parser.parse(new StringInput(SOAP_FAULT), m_patientSOAP);
         fail("Expected SOAPFaultException");
      }
      catch (SOAPFaultException e)
      {
         assertEquals("123", e.getFaultCode());
         assertEquals("This is a minor SOAP fault", e.getFaultString());
         assertEquals("not-me", e.getFaultActor());
      }

      // Try parsing a message that is mapped to SOAP Fault
      tobj = m_parser.parse(new StringInput(SOAP_FAULT), m_faultMessage);
      assertEquals(m_faultMessage.getName(), tobj.getClassName());
      assertEquals("123", tobj.getValue("code"));
      assertEquals("This is a minor SOAP fault", tobj.getValue("msg"));
      assertEquals("not-me", tobj.getValue("actor"));
      assertEquals("<a>    <b>   </b>  </a>", tobj.getValue("detail"));

      m_parser.parse(new StringInput(POLYMORPHIC_COLLECTION_TEST), m_polymorphicCollectionMessage);
   }
View Full Code Here


      table.addMessage(m_patient);
      table.addMessage(m_xds);

      m_parser.initializeMessageTable(table);

      TransferObject tobj = m_parser.parse(new StringInput(PATIENT), table);
      TransferObject player = (TransferObject)tobj.getValue("player");

      assertEquals("My1", player.getValue("firstName"));
      assertEquals("Test", player.getValue("lastName"));

      TransferObject id = (TransferObject)((List)player.getValue("id")).get(0);

      assertEquals("XML_PatientDemographics", tobj.getClassName());
      assertEquals("OHIP", id.getValue("type"));
      assertEquals("111222333", id.getValue("id"));

      table = new MessageTable();
      table.addMessage(m_patientSOAP);

      m_parser.initializeMessageTable(table);

      tobj = m_parser.parse(new StringInput(PATIENT_SOAP), table);
      player = (TransferObject)tobj.getValue("player");

      assertEquals("My1", player.getValue("firstName"));
      assertEquals("Test", player.getValue("lastName"));

      id = (TransferObject)((List)player.getValue("id")).get(0);

      assertEquals("SOAP_PatientDemographics", tobj.getClassName());
      assertEquals("OHIP", id.getValue("type"));
      assertEquals("111222333", id.getValue("id"));

      try
      {
         m_parser.parse(new StringInput(SOAP_FAULT), table);
         fail("Expected SOAPFaultException");
      }
      catch (SOAPFaultException e)
      {
         assertEquals("123", e.getFaultCode());
         assertEquals("This is a minor SOAP fault", e.getFaultString());
         assertEquals("not-me", e.getFaultActor());
      }

      // Try parsing a message that is mapped to SOAP Fault
      table.addMessage(m_faultMessage);
      m_parser.initializeMessageTable(table);
      tobj = m_parser.parse(new StringInput(SOAP_FAULT), table);
      assertEquals(m_faultMessage.getName(), tobj.getClassName());
      assertEquals("123", tobj.getValue("code"));
      assertEquals("This is a minor SOAP fault", tobj.getValue("msg"));
      assertEquals("not-me", tobj.getValue("actor"));
      assertEquals("<a>    <b>   </b>  </a>", tobj.getValue("detail"));
View Full Code Here

   /**
    * Sanity check for parsing a message that contains SOAP headers.
    */
   public void testParseSOAPHeaders() throws Exception
   {
      TransferObject message = m_parser.parse(new StringInput(PATIENT_SOAP_HEADERS), m_patientHeadersSOAP);

      verifyPatientSOAPMessage(message);

      // Parse the second SOAP message (has reference to entire header block)
      message = m_parser.parse(new StringInput(SOAP_MESSAGE2), m_SOAPMessage2);
      verifySOAPMessage2(message);

      // Parse data with headers to a message with no headers
      TransferObject tobj = m_parser.parse(new StringInput(PATIENT_SOAP_HEADERS), m_patientSOAP);
      TransferObject player = (TransferObject)tobj.getValue("player");

      assertEquals("My1", (String)player.getValue("firstName"));
      assertEquals("Test", (String)player.getValue("lastName"));
      assertEquals("\u4e2d\u6587", (String)player.getValue("title"));

      assertEquals(1, tobj.getValueCount());

      // Parse data with headers to a message where header message part is primitive
      message = m_parser.parse(new StringInput(SOAP_MESSAGE2), m_SOAPPrimitiveHeader);
      assertEquals("SOAP_PrimitiveHeader", message.getClassName());
      assertEquals("Test", message.getValue("description"));
      assertEquals(Binary.parse("000001"), message.getValue("data"));
      assertEquals(2, message.getValueCount());
   }
View Full Code Here

      table.addMessage(m_patientHeadersSOAP);
      table.addMessage(m_SOAPMessage2);

      m_parser.initializeMessageTable(table);
      message = m_parser.parse(new StringInput(PATIENT_SOAP_HEADERS), table);
      verifyPatientSOAPMessage(message);

      // Parse with data corresponding to the second message
      message = m_parser.parse(new StringInput(SOAP_MESSAGE2), table);
      verifySOAPMessage2(message);

      // Ensure determination of correct message, even if prologue is very long
      int nDataCount = 10000;
      String sLongStart = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
View Full Code Here

         "<player><firstName>My1</firstName><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";

      try
      {
         message = m_parser.parse(new StringInput(sMessage), m_patient);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ex.getErrorCode());
      }


      // Required part present but empty
      sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><lastName/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";

      try
      {
         message = m_parser.parse(new StringInput(sMessage), m_patient);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ex.getErrorCode());
      }


      // Required part present
      sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><lastName>Test</lastName><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";
      message = m_parser.parse(new StringInput(sMessage), m_patient);
      player = (TransferObject)message.getValue("player");
      assertEquals("Test", player.getValue("lastName"));
      assertFalse(player.hasValue("title"));


      // Required part present with nil (part is NOT nillable)
      sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><lastName xsi:nil=\"true\">Test</lastName><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";

      try
      {
         message = m_parser.parse(new StringInput(sMessage), m_patient);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.xml.messageSyntax", ex.getErrorCode());
      }


      // Required part empty with nil (part is NOT nillable)
      sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><lastName xsi:nil=\"true\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";

      try
      {
         message = m_parser.parse(new StringInput(sMessage), m_patient);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.xml.messageSyntax", ex.getErrorCode());
      }


      /*
       * Tests of parsing a nillable element.
       */

      // NILLABLE: Optional part empty with nil
      sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><title xsi:nil=\"true\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";
      message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
      player = (TransferObject)message.getValue("player");
      assertNull(player.getValue("title"));


      // NILLABLE: Optional part has text contents with nil
      sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><title xsi:nil=\"true\">Test</title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";

      try
      {
         message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.xml.nilElementNotEmpty", ex.getErrorCode());
      }


      // NILLABLE: Optional part has element contents with nil
      sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><title xsi:nil=\"true\"><efg/></title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";

      try
      {
         message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.xml.nilElementNotEmpty", ex.getErrorCode());
      }


      // NILLABLE: Attributes allowed when nil
      sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><title xsi:nil=\"true\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/>" +
         "<telcom useCode=\"T1\" xsi:nil=\"true\"/><telcom2 useCode=\"T2\" xsi:nil=\"true\"/>" +
         "</player></a:Patient>";
      message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
      player = (TransferObject)message.getValue("player");
      assertNull(player.getValue("title"));
      telcom = (TransferObject)player.getValue("telcom");
      assertNull(telcom.getValue("address"));
      assertEquals("T1", telcom.getValue("useCode"));
      assertEquals(Boolean.TRUE, telcom.getValue("isNil"));

      telcom = (TransferObject)player.getValue("telcom2");
      assertNull(telcom.getValue("address"));
      assertEquals("T2", telcom.getValue("useCode"));


      // NILLABLE: Composite part has attribute and is empty (not nil)
      sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><title>Test</title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/>" +
         "<telcom useCode=\"T1\"/><telcom2 useCode=\"T2\"/>" +
         "</player></a:Patient>";
      message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
      player = (TransferObject)message.getValue("player");
      assertEquals("Test", player.getValue("title"));
      telcom = (TransferObject)player.getValue("telcom");
      assertNull(telcom.getValue("address"));
      assertEquals("T1", telcom.getValue("useCode"));
      assertFalse(telcom.hasValue("isNil"));

      telcom = (TransferObject)player.getValue("telcom2");
      assertNull(telcom.getValue("address"));
      assertEquals("T2", telcom.getValue("useCode"));


      // NILLABLE: Composite message part nil, but has text content
      sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><title xsi:nil=\"true\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/>" +
         "<telcom2 useCode=\"T2\" xsi:nil=\"true\">addr2</telcom2>" +
         "</player></a:Patient>";

      try
      {
         message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
         fail("IntegrationException Expected");
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.xml.nilElementNotEmpty", ex.getErrorCode());
      }


      // NILLABLE: Composite message part nil, but has element content
      sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
         "xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
         "<player><firstName>My1</firstName><title xsi:nil=\"true\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/>" +
         "<telcom2 useCode=\"T2\" xsi:nil=\"true\"><sub/></telcom2>" +
         "</player></a:Patient>";

      try
      {
         message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
         fail("IntegrationException Expected");
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.xml.nilElementNotEmpty", ex.getErrorCode());
View Full Code Here

    */
   public void testParseCompositeMessagePartNil() throws Exception
   {
      TransferObject message, cpart;

      message = m_parser.parse(new StringInput(
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<t:outer xmlns:t=\"http://www.nexj.com/schema/test/one\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<a>t1</a><b>t2</b>" +
         "</t:outer>"
         ), m_nillableSubMessage);
      assertEquals("t1", message.getValue("a"));
      assertEquals("t2", message.getValue("b"));
      assertFalse(message.hasValue("c"));


      message = m_parser.parse(new StringInput(
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<t:outer xmlns:t=\"http://www.nexj.com/schema/test/one\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<a>t1</a><b>t2</b><c z=\"a1\" xsi:nil=\"true\"/>" +
         "</t:outer>"
         ), m_nillableSubMessage);
      assertEquals("t1", message.getValue("a"));
      assertEquals("t2", message.getValue("b"));
      assertEquals("a1", ((TransferObject)message.getValue("c")).getValue("z"));



      message = m_parser.parse(new StringInput(
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<t:outer xmlns:t=\"http://www.nexj.com/schema/test/one\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<a>t1</a><b xsi:nil=\"true\"/><c z=\"a1\" xsi:nil=\"true\"/>" +
         "</t:outer>"
         ), m_nillableSubMessage);
      assertEquals("t1", message.getValue("a"));
      assertNull(message.getValue("b"));
      assertEquals("a1", ((TransferObject)message.getValue("c")).getValue("z"));



      message = m_parser.parse(new StringInput(
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<soap12:Envelope xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:x" +
         "si=\"http://www.w3.org/2001/XMLSchema-instance\"><soap12:Body><ns2:A xmlns:ns2=\"urn:hl7-org:v3\"><ns2:B xsi:nil=\"1\"/></ns2:A>" +
         "</soap12:Body></soap12:Envelope>"), m_nillableRefSubMessage);
      assertNull(message.getValue("B"));



      message = new TransferObject("XML_NillableRefSubMessage2");

      StringWriter outWriter = new StringWriter();
      Output out = new WriterOutput(outWriter);

      m_formatter.format(message, m_nillableRefSubMessage2, out);
      message = m_parser.parse(new StringInput(outWriter.toString()), m_nillableRefSubMessage2);



      message = m_parser.parse(new StringInput(
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<t:outer xmlns:t=\"http://www.nexj.com/schema/test/one\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<a>t1</a><b>t2</b><c z=\"a1\"><x>x1</x></c>" +
         "</t:outer>"
         ), m_nillableSubMessage);
      assertEquals("t1", message.getValue("a"));
      assertEquals("t2", message.getValue("b"));
      assertTrue(message.hasValue("c"));
      cpart = (TransferObject)message.getValue("c");
      assertEquals("x1", cpart.getValue("x"));
      assertEquals("a1", cpart.getValue("z"));


      try
      {
         message = m_parser.parse(new StringInput(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<t:outer xmlns:t=\"http://www.nexj.com/schema/test/one\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>t1</a><b>t2</b><c z=\"a1\"/>" +
            "</t:outer>"
            ), m_nillableSubMessage);
         fail("IntegrationException expected");
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ex.getErrorCode());
         assertEquals("XML_NillableSubMessage c x", ex.getErrorArgs()[0]);
      }


      try
      {
         message = m_parser.parse(new StringInput(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<t:outer xmlns:t=\"http://www.nexj.com/schema/test/one\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>t1</a><b>t2</b><c/>" +
            "</t:outer>"
            ), m_nillableSubMessage);
View Full Code Here

   public void testValuePartGetsAllCharacterContent() throws Exception
   {
      Message message = m_context.getMetadata().getMessage("XML_ValuePart");
      TransferObject tobj;

      tobj = m_parser.parse(new StringInput(
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<outer attr=\"tst\">" +
         "<a>123</a>" +
         "Part1" +
         "<a>456</a>" +
View Full Code Here

   public void testEmptyValuePart()
   {
      Message message = m_context.getMetadata().getMessage("XML_ValuePart");
      TransferObject tobj;

      tobj = m_parser.parse(new StringInput(
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<outer attr=\"tst\">" +
         "</outer>"), message);

      assertEquals("tst", tobj.getValue("attr"));
View Full Code Here

   {
      Message message = m_context.getMetadata().getMessage("XML_ValuePartReq");

      try
      {
         m_parser.parse(new StringInput(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<outer attr=\"tst\">" +
            "</outer>"), message);
         fail("Expected IntegrationException");
      }
View Full Code Here

         "<formatDecimal>3.14159265358979324</formatDecimal>" +
         "</format>",
         sOutput
      );

      tobj = m_parser.parse(new StringInput(sOutput), m_formatStringMessage);

      assertEquals(ts1, tobj.getValue("normalDT"));
      assertEquals(ts1, tobj.getValue("formatDT"));
      assertEquals(Timestamp.valueOf("2010-03-03 00:00:00.000"), tobj.getValue("formatLocaleDT"));
      assertEquals(Boolean.TRUE, tobj.getValue("normalBool"));
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.