Package nexj.core.integration.io

Examples of nexj.core.integration.io.WriterOutput


      tobj = new TransferObject(1);
      root.setValue("assistant2", tobj);
      tobj.setValue("card", tobj = new TransferObject(1));
      tobj.setValue("fullName", "Sir Arthur Conan Doyle");

      m_formatter.format(root, message, new WriterOutput(m_writer));
      assertEquals("BEGIN:VCARD\r\n" +
            "VERSION:2.1\r\n" +
            "FN:Sherlock Holmes\r\n" +
            "ORG:NexJ Systems Inc.;R&D\r\n" +
            "TEL;TYPE=VOICE:555-1234\r\n" +
            "X-NexJ-Collection;p1=1,1,2,3,5,8;p2=0;p3=4,9,16;p4=123\\;456\\:789:abc,def,g\\,hi\r\n" +
            "Home.TEL:555-0000\r\n" +
            "Home.NOTE:Evenings and weekends only.\r\n" +
            "BEGIN:VCARD_CONTAINED\r\n" +
            "VERSION:2.1\r\n" +
            "N:Watson,,,Dr.\r\n" +
            "END:VCARD_CONTAINED\r\n" +
            "BEGIN:VCARD\r\n" +
            "VERSION:2.1\r\n" +
            "FN:Moriarty\r\n" +
            "END:VCARD\r\n" +
            "TEL;TYPE=VOICE:This is a really long\r\n" +
            " line....12345678941234567895123456789612345678971234567 89\r\n" +
            "TEL;TYPE=PIZZA:(416) 967-1111\r\n" +
            "ADR;TYPE=WORK;ENCODING=QUOTED-PRINTABLE:;;4101 Yonge Street=0D=0AUnit 501;N=\r\n" +
            "orth York;ON;111111;Canada\r\n" +
            "LOGO;TYPE=PNG;ENCODING=BASE64:MTIzQUJD\r\n" +
            "\r\n" +
            "X-NexJ-IntlName;CHARSET=ISO-8859-1;ENCODING=QUOTED-PRINTABLE:Pr=E6tor\r\n" +
            "AGENT;NUM=1:BEGIN:VCARD\r\n" +
            "VERSION:2.1\r\n" +
            "FN:Dr. John H. Watson\r\n" +
            "END:VCARD\r\n" +
            "AGENT;NUM=2:BEGIN:VCARD\r\n" +
            "VERSION:2.1\r\n" +
            "FN:Sir Arthur Conan Doyle\r\n" +
            "END:VCARD\r\n" +
            "END:vCard\r\n",
            m_writer.toString());

      try
      {
         companyInfo.add("extra");
         m_writer = new StringWriter();
         m_formatter.format(root, message, new WriterOutput(m_writer));
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.maxPartCount", ex.getErrorCode());
         assertEquals("VCard_v21 company", ex.getErrorArgs()[0]);
      }
      finally
      {
         companyInfo.remove(2);
      }

      try
      {
         p2List.add(Primitive.createInteger(42));
         p2List.add(Primitive.createInteger(21));
         m_writer = new StringWriter();
         m_formatter.format(root, message, new WriterOutput(m_writer));
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.maxPartCount", ex.getErrorCode());
         assertEquals("VCard_v21 collection p2", ex.getErrorArgs()[0]);
      }
      finally
      {
         p2List.remove(2);
         p2List.remove(1);
      }

      try
      {
         root.removeValue("fullName");
         m_writer = new StringWriter();
         m_formatter.format(root, message, new WriterOutput(m_writer));
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ex.getErrorCode());
         assertEquals("VCard_v21 fullName", ex.getErrorArgs()[0]);
      }
      finally
      {
         root.setValue("fullName", "Sherlock Holmes");
      }

      try
      {
         valList.remove(2);
         m_writer = new StringWriter();
         m_formatter.format(root, message, new WriterOutput(m_writer));
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ex.getErrorCode());
         assertEquals("VCard_v21 collection value", ex.getErrorArgs()[0]);
      }
      finally
      {
         valList.add("ghi");
      }

      try
      {
         tobj = (TransferObject)root.getValue("collection");
         tobj.removeValue("value");
         m_writer = new StringWriter();
         m_formatter.format(root, message, new WriterOutput(m_writer));
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ex.getErrorCode());
         assertEquals("VCard_v21 collection value", ex.getErrorArgs()[0]);
      }
      finally
      {
         tobj.setValue("value", valList);
      }

      try
      {
         tobj = (TransferObject)root.getValue("collection");
         tobj.removeValue("p1");
         m_writer = new StringWriter();
         m_formatter.format(root, message, new WriterOutput(m_writer));
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.minPartCount", ex.getErrorCode());
View Full Code Here


      tobj.setValue("name", "Pr\u00E6tor");

      root.setValue("assistant1", "BEGIN:VCARD\r\nFN:Joe Friday\r\n" +
            "TEL:+1-919-555-7878\r\nTITLE:Area Administrator, Assistant\r\nEND:VCARD\r\n");

      m_formatter.format(root, message, new WriterOutput(m_writer));
      assertEquals("BEGIN:VCARD\r\n" +
            "VERSION:3.0\r\n" +
            "FN:Sherlock Holmes\r\n" +
            "ORG:NexJ Systems Inc.;R&D\r\n" +
            "TEL;TYPE=VOICE:This is a really long line....1234567894123456789512345678\r\n" +
            " 9612345678971234567 89\r\n" +
            "TEL;TYPE=PIZZA:(416) 967-1111\r\n" +
            "LOGO;TYPE=PNG;ENCODING=BASE64:MTIzQUJDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n" +
               " AAAAA\r\n" +
            "\r\n" +
            "X-NexJ-IntlName;CHARSET=ISO-8859-1;ENCODING=B:UHLmdG9y\r\n" +
            "\r\n" +
            "AGENT:BEGIN\\:VCARD\\nFN\\:Joe Friday\\nTEL\\:+1-919-555-7878\\nTITLE\\:Area Adm\r\n" +
               " inistrator\\, Assistant\\nEND\\:VCARD\\n\r\n" +
            "END:vCard\r\n",
            m_writer.toString());

      try
      {
         companyInfo.add("extra");
         m_writer = new StringWriter();
         m_formatter.format(root, message, new WriterOutput(m_writer));
         fail();
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.maxPartCount", ex.getErrorCode());
View Full Code Here

      pat.setValue("player", pl);
      Format format = m_metadata.getFormat("XML");
      Message msg = m_metadata.getMessage("XML_PatientDemographics");
      Writer writer = new StringWriter();

      ((MessageFormatter)format.getFormatter().getInstance(m_context)).format(pat, msg, new WriterOutput(writer));
     
      TransferObject patCompare = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new StringInput(writer.toString()), msg);
      TransferObject plCompare = (TransferObject)patCompare.getValue("player");
      List idsCompare = (List)plCompare.getValue("id");
View Full Code Here

      row.setValue("name", "row1");
      row.setValue("value", "abcdef");

      Format format = m_metadata.getFormat("XML");
      Writer writer = new StringWriter();
      ((MessageFormatter)format.getFormatter().getInstance(m_context)).format(table, tableMessage, new WriterOutput(writer));

      table = ((MessageParser)format.getParser().getInstance(m_context)).parse(new StringInput(writer.toString()), tableMessage);
      rows = (List)table.getValue("Row");
      row = (TransferObject)rows.get(0);
      assertEquals(row.getValue("value"), "abcdef");
     
      Message recursiveMessage = (Message)messageRegistry.get("recursiveElement");
     
      TransferObject recursiveElement = new TransferObject();
      TransferObject recursiveElement2 = new TransferObject();
      recursiveElement.setValue("recursiveElement2", recursiveElement2);
      recursiveElement2.setValue("recursiveElement", new TransferObject());

      ((MessageFormatter)format.getFormatter().getInstance(m_context))
         .format(recursiveElement, recursiveMessage, new WriterOutput(new StringWriter()));
   }
View Full Code Here

      row.setValue("isConfirmedBySourceOwner", Boolean.FALSE);

      Format format = m_metadata.getFormat("XML");
     
      writer = new StringWriter();
      ((MessageFormatter)format.getFormatter().getInstance(m_context)).format(table, tableMessage, new WriterOutput(writer));
     
      table = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new StringInput(writer.toString()), tableMessage);
      row = (TransferObject)table.getValue("a_b");
      assertEquals(row.getValue("isConfirmedBySourceOwner"), Boolean.FALSE);
View Full Code Here

      Message csvMessage = m_metadata.getMessage("CSVTestSuiteResult");
      MessageFormatter formatter = (MessageFormatter)csvMessage.getFormat().getFormatter().getInstance(m_context);
      TransferObject root, test, testData, result;
      List testList;
      StringWriter writer;
      WriterOutput out;

      root = new TransferObject("XMLTestSuiteResult");
      testList = new ArrayList(2);
      root.setValue("tests", testList);
      test = new TransferObject();
      testList.add(test);
      test.setValue("date", Primitive.toTimestamp("2009-12-07T08:00:00"));
      test.setValue("status", "ERROR");
      testData = new TransferObject("XMLTestResult", 3);
      test.setValue("data", testData);
      testData.setValue("seed", "12345");
      testData.setValue("a", "aValue");
      testData.setValue("b", "bValue");

      test = new TransferObject();
      testList.add(test);
      test.setValue("date", Primitive.toTimestamp("2009-08-17T00:00:00"));
      test.setValue("status", "PASS");
      testData = new TransferObject("XMLTestResult", 3);
      test.setValue("data", testData);
      testData.setValue("b", "bValue2");

      Instance instance = (Instance)serviceClass.invoke("invoke", new Object[]{"TestTransform", root, null, "PRE-", Boolean.TRUE});

      assertEquals(Boolean.TRUE, instance.invoke("done"));
      result = (TransferObject)instance.invoke("result");

      assertEquals("CSVTestSuiteResult", result.getClassName());
      testList = (List)result.getValue("rows");
      assertEquals(2, testList.size());

      writer = new StringWriter();
      out = new WriterOutput(writer);
      formatter.format(result, csvMessage, out);

      assertEquals("date,status,result\n" +
         "2009-12-07 08:00:00.000000000,PRE-ERROR-POST,\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n" +
            "<XMLTestResult seed=\\\"12345\\\"><a>aValue</a><b>bValue</b></XMLTestResult>\"\n" +
         "2009-08-17 00:00:00.000000000,PRE-PASS-POST,\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n" +
            "<XMLTestResult><b>bValue2</b></XMLTestResult>\"\n",
         writer.toString());

      // Try using a message that is referred to by a message with no format
      TransferObject outer = new TransferObject(1);

      outer.setValue("xml", root);
      result = m_tf.transform(outer, m_metadata.getTransformation("TestSuiteResult"));

      assertEquals("MultiFormatReferrer", result.getClassName());
      assertFalse(result.hasValue("xml"));
      result = (TransferObject)result.getValue("csv");
      assertEquals("CSVTestSuiteResult", result.getClassName());
      testList = (List)result.getValue("rows");
      assertEquals(2, testList.size());

      writer = new StringWriter();
      out = new WriterOutput(writer);
      formatter.format(result, csvMessage, out);

      assertEquals("date,status,result\n" +
         "2009-12-07 08:00:00.000000000,PREFIXERRORAFFIX,\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n" +
            "<XMLTestResult seed=\\\"12345\\\"><a>aValue</a><b>bValue</b></XMLTestResult>\"\n" +
View Full Code Here

      /*
       * Test that the XML formats with the same namespace qualifications as described
       * in the XML schema.
       */
      StringWriter writer;
      WriterOutput out;
      TransferObject root, ref;
      Format format = m_context.getMetadata().getFormat("XML");
      MessageFormatter formatter = (MessageFormatter)format.getFormatter().getInstance(m_context);

      root = new TransferObject("XML_Inherit_Schema_Reference", 1);
      ref = new TransferObject("XML_Inherit_Schema1", 2);
      root.setValue("s1", ref);
      ref.setValue("a", "aValue");
      ref.setValue("x", "xValue");
      out = new WriterOutput(writer = new StringWriter());
      formatter.format(root, msg, out);

      assertEquals(
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<is1:references" +
View Full Code Here

    * Formatter gets TO for: XML_Inherit_Child1_Referrer
    */
   public void testFormatPolymorphicRootMessage()
   {
      StringWriter writer = new StringWriter();
      WriterOutput out = new WriterOutput(writer);
      TransferObject root = new TransferObject("XML_Inherit_Child1_Referrer", 3);
      TransferObject polyRoot = new TransferObject(2);

      polyRoot.setClassName("XML_Inherit_Child1");
      polyRoot.setValue("b", Primitive.createInteger(23));
View Full Code Here

    * Should fail because reference is not polymorphic.
    */
   public void testFormatChild1Child_Child1Referrer()
   {
      StringWriter writer = new StringWriter();
      WriterOutput out = new WriterOutput(writer);
      TransferObject root = new TransferObject("XML_Inherit_Child1_Referrer", 3);
      TransferObject polyRoot = new TransferObject(3);

      polyRoot.setClassName("XML_Inherit_Child1_Child");
      polyRoot.setValue("b", Primitive.createInteger(23));
View Full Code Here

    */
   public void testFormatNonPolymorphicMessage()
   {
      Message msgChild1 = m_context.getMetadata().getMessage("XML_Inherit_Child1");
      StringWriter writer = new StringWriter();
      WriterOutput out = new WriterOutput(writer);
      TransferObject root = new TransferObject(3);

      root.setClassName("XML_Inherit_Child1_Child");
      root.setValue("b", Primitive.createInteger(23));
      root.setValue("c1", Primitive.createInteger(31));
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.