Package nexj.core.integration.io

Examples of nexj.core.integration.io.WriterOutput


      recordList.add(record4);
      root.setValue("record", recordList);

      //Format it
      StringWriter writer = new StringWriter();
      m_formatter.format(root, Repository.getMetadata().getMessage("Fixed_OneFieldWithPrefixAlignRight"), new WriterOutput(writer));

      assertEquals("<<         John" +
         "<<             " +
         "<<            X" +
         "<<Joe Blow Frat",
View Full Code Here


      recordList.add(record4);
      root.setValue("record", recordList);

      //Format it
      StringWriter writer = new StringWriter();
      m_formatter.format(root, Repository.getMetadata().getMessage("Fixed_OneFieldWithPrefixAndSuffix"), new WriterOutput(writer));

      assertEquals("<<John >>>" +
         "<<#Jane>>>" +
         "<<X    >>>" +
         "<<     >>>",
View Full Code Here

      recordList.add(record2);
      root.setValue("records", recordList);

      //Format it
      StringWriter writer = new StringWriter();
      m_formatter.format(root, Repository.getMetadata().getMessage("Fixed_TwoFieldsDerived"), new WriterOutput(writer));

      assertEquals("Apple     Apple*****" +
         "Pear      Pear******",
         writer.toString());
   }
View Full Code Here

      recordList.add(record3);
      root.setValue("record", recordList);

      //Format it
      StringWriter writer = new StringWriter();
      m_formatter.format(root, Repository.getMetadata().getMessage("Fixed_Timestamps"), new WriterOutput(writer));

      assertEquals(
         //record 1
         "2010-03-03 23:30:00.123000000 " // width=30
         "20100303183000.123-0500       " // width=30 format="yyyyMMddHHmmss.SSSZ"
View Full Code Here

      root.setValue("record", recordList);

      //Format it
      StringWriter writer = new StringWriter();
      m_formatter.format(root, Repository.getMetadata().getMessage(sMessageName), new WriterOutput(writer));

      assertEquals(
         "John______|2010-03-03 23:30:00.123000000" +
         "#Jane_____|2011-03-13 23:31:11.123000000" +
         "X_________|2012-03-24 00:42:42.421000000",
         writer.toString());

      // force a failure on field 2
      try
      {
         recordList.add(record4);
         m_formatter.format(root, Repository.getMetadata().getMessage(sMessageName), new WriterOutput(writer));
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ex.getErrorCode());
         assertEquals(sMessageName + " record field_2", ex.getErrorArgs()[0]);
      }

      // force a failure on field 1
      try
      {
         recordList.remove(record4);
         recordList.add(record5);
         m_formatter.format(root, Repository.getMetadata().getMessage(sMessageName), new WriterOutput(writer));
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ex.getErrorCode());
         assertEquals(sMessageName + " record field_1", ex.getErrorArgs()[0]);
View Full Code Here

      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
View Full Code Here

      message.setValue("player", player);
      message.setValue("headers", headers);

      StringWriter writer = new StringWriter();

      m_formatter.format(message, m_patientHeadersSOAP, new WriterOutput(writer));
      assertEquals(PATIENT_SOAP_HEADERS, writer.toString());

      // Format the second SOAP message (has reference to entire header block)
      TransferObject header;

      message = new TransferObject(3);
      headers = new TransferObject(2);

      message.setValue("description", "Test");
      message.setValue("data", Binary.parse("000001"));
      message.setValue("headers", headers);

      header = new TransferObject(2);
      header.setValue("mustUnderstand", Boolean.TRUE);
      header.setValue("Expires", Primitive.createLong(3000L));
      headers.setValue("context", header);

      header = new TransferObject(1);
      header.setValue("value", "abc123");
      headers.setValue("action", header);

      writer = new StringWriter();
      m_formatter.format(message, m_SOAPMessage2, new WriterOutput(writer));
      assertEquals(SOAP_MESSAGE2, writer.toString());
   }
View Full Code Here

       */

      // Required element not in TransferObject
      try
      {
         m_formatter.format(message, m_patient, new WriterOutput(writer));
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         IntegrationException inner = (IntegrationException)ex.getCause();

         assertEquals("err.integration.minPartCount", inner.getErrorCode());
      }


      // Required element null in TransferObject
      player.setValue("lastName", null);
      writer = new StringWriter();

      try
      {
         m_formatter.format(message, m_patient, new WriterOutput(writer));
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         IntegrationException inner = (IntegrationException)ex.getCause();

         assertEquals("err.integration.minPartCount", inner.getErrorCode());
      }


      // Required element present in TransferObject
      player.setValue("lastName", "Test");
      writer = new StringWriter();
      m_formatter.format(message, 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());


      // Required element present, Optional element ""
      player.setValue("firstName", "");
      writer = new StringWriter();
      m_formatter.format(message, 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></firstName><lastName>Test</lastName><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>", writer.toString());

      // Required element present, Optional element null
      player.setValue("firstName", null);
      writer = new StringWriter();
      m_formatter.format(message, 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><lastName>Test</lastName><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>", writer.toString());


      // Required element present, Optional element not present
      player.removeValue("firstName");
      writer = new StringWriter();
      m_formatter.format(message, 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><lastName>Test</lastName><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>", writer.toString());


      /*
       * Tests of formatting an element marked nillable.
       */

      player.removeValue("lastName");
      player.setValue("firstName", "My1");
      player.removeValue("title");

      // NILLABLE: Optional Nillable element not present
      writer = new StringWriter();
      m_formatter.format(message, m_patientNillable, 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><title xsi:nil=\"1\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/><telcom xsi:nil=\"1\"/><telcom2 xsi:nil=\"1\"/></player></a:Patient>", writer.toString());


      // NILLABLE: Optional Nillable element set to null
      player.setValue("title", null);
      writer = new StringWriter();
      m_formatter.format(message, m_patientNillable, 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><title xsi:nil=\"1\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/><telcom xsi:nil=\"1\"/><telcom2 xsi:nil=\"1\"/></player></a:Patient>", writer.toString());


      // NILLABLE: Optional Nillable element set
      player.setValue("title", "Count");
      writer = new StringWriter();
      m_formatter.format(message, m_patientNillable, 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><title>Count</title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/><telcom xsi:nil=\"1\"/><telcom2 xsi:nil=\"1\"/></player></a:Patient>", writer.toString());
      player.removeValue("Count");


      // NILLABLE: Composite messages, one with nil mapped, the other one nillable.
      telcom = new TransferObject(2);
      telcom.setValue("useCode", "HOME");
      telcom.setValue("address", "adr1");
      player.setValue("telcom", telcom);
      telcom2 = new TransferObject(2);
      telcom2.setValue("useCode", "WORK");
      telcom2.setValue("address", "adr2");
      player.setValue("telcom2", telcom2);
      telcom3 = new TransferObject(2);
      telcom3.setValue("useCode", "CELL");
      telcom3.setValue("address", "adr3");
      player.setValue("telcom3", telcom3);
      writer = new StringWriter();
      m_formatter.format(message, m_patientNillable, 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><title>Count</title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/>" +
         "<telcom useCode=\"HOME\">adr1</telcom>" +
         "<telcom2 useCode=\"WORK\">adr2</telcom2>" +
         "<telcom3 useCode=\"CELL\">adr3</telcom3>" +
         "</player></a:Patient>", writer.toString());


      // NILLABLE: Composite messages, one with nil mapped, the other one nillable. Values null.
      telcom.setValue("address", null);
      telcom2.setValue("address", null);
      telcom3.setValue("address", null);
      writer = new StringWriter();
      m_formatter.format(message, m_patientNillable, 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><title>Count</title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/>" +
         "<telcom useCode=\"HOME\" xsi:nil=\"1\"/>" +
         "<telcom2 useCode=\"WORK\" xsi:nil=\"1\"/>" +
         "<telcom3 useCode=\"CELL\"/>" +
         "</player></a:Patient>", writer.toString());


      // NILLABLE: Composite messages, values not present
      telcom.removeValue("address");
      telcom2.removeValue("address");
      telcom3.removeValue("address");
      writer = new StringWriter();
      m_formatter.format(message, m_patientNillable, 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><title>Count</title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/>" +
         "<telcom useCode=\"HOME\" xsi:nil=\"1\"/>" +
         "<telcom2 useCode=\"WORK\" xsi:nil=\"1\"/>" +
         "<telcom3 useCode=\"CELL\"/>" +
         "</player></a:Patient>", writer.toString());


      // NILLABLE: Null composite message forces nil attribute
      player.setValue("telcom", null);
      player.setValue("telcom2", null);
      player.setValue("telcom3", null);
      writer = new StringWriter();
      m_formatter.format(message, m_patientNillable, 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><title>Count</title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
         "<id type=\"OHIP\" b:id=\"111222333\"/>" +
         "<telcom xsi:nil=\"1\"/>" +
         "<telcom2 xsi:nil=\"1\"/>" +
         "<telcom3/>" +
         "</player></a:Patient>", writer.toString());


      // NILLABLE: Composite messages dropped when not present
      player.removeValue("telcom");
      player.removeValue("telcom2");
      player.removeValue("telcom3");
      writer = new StringWriter();
      m_formatter.format(message, m_patientNillable, 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><title>Count</title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
View Full Code Here


      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);

View Full Code Here

    * Tests format string support in the XML format adapter.
    */
   public void testFormatXMLWithFormatString()
   {
      StringWriter outWriter = new StringWriter();
      WriterOutput out = new WriterOutput(outWriter);
      TransferObject tobj = new TransferObject("XML_FormatString", 11);
      Timestamp ts1 = Timestamp.valueOf("2010-03-03 18:30:00.123");
      List col1 = new ArrayList(4);
      BigDecimal dec = new BigDecimal("3.14159265358979323846264");

View Full Code Here

TOP

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

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.