Package nexj.core.integration.io

Examples of nexj.core.integration.io.WriterOutput


    * Formats a reference with a child message.
    */
   public void testFormatChild2()
   {
      StringWriter writer = new StringWriter();
      WriterOutput out = new WriterOutput(writer);
      TransferObject root = new TransferObject("XML_Inherit_Parent_Referrer", 2);
      TransferObject polyRoot = new TransferObject(2);

      polyRoot.setClassName("XML_Inherit_Child2");
      polyRoot.setValue("a", "Avalue");
View Full Code Here


    * Formats a reference with an unknown message.
    */
   public void testFormatUnknown()
   {
      StringWriter writer = new StringWriter();
      WriterOutput out = new WriterOutput(writer);
      TransferObject root = new TransferObject("XML_Inherit_Parent_Referrer", 2);
      TransferObject polyRoot = new TransferObject(2);

      polyRoot.setClassName("XML_Inherit_Unknown");
      polyRoot.setValue("a", "Avalue");
View Full Code Here

   {
      Message message = m_context.getMetadata().getMessage("XMLAnyTest");
      TransferObject root = new TransferObject("XMLAnyTest", 1);
      TransferObject any = new TransferObject(2);
      StringWriter writer;
      WriterOutput out;

      root.setValue("anyInterfaceInheritanceElement", any);

      // Format child1
      any.setClassName("XML_Inherit_Child1");
      any.setValue("b", Primitive.createInteger(23));
      any.setValue("c1", Primitive.createInteger(31));

      writer = new StringWriter();
      out = new WriterOutput(writer);
      m_formatter.format(root, message, out);

      assertEquals(XML_HEADER +
         "<XMLAnyTest xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" +
         " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<anyInterfaceInheritanceElement>" +
               "<child1>" +
                  "<b>23</b>" +
                  "<c1>31</c1>" +
               "</child1>" +
            "</anyInterfaceInheritanceElement>" +
         "</XMLAnyTest>", writer.toString());

      // Format child2
      any.removeAllValues();
      any.setClassName("XML_Inherit_Child2");
      any.setValue("a", "Avalue");
      any.setValue("b", "Bvalue");

      writer = new StringWriter();
      out = new WriterOutput(writer);
      m_formatter.format(root, message, out);

      assertEquals(XML_HEADER +
         "<XMLAnyTest xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" +
         " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<anyInterfaceInheritanceElement>" +
               "<child2>" +
                  "<a>Avalue</a>" +
                  "<b>Bvalue</b>" +
               "</child2>" +
            "</anyInterfaceInheritanceElement>" +
         "</XMLAnyTest>", writer.toString());

      // Format parent
      any.removeAllValues();
      any.setClassName("XML_Inherit_Parent");
      any.setValue("a", "Avalue");
      any.setValue("b", Primitive.createInteger(11));

      writer = new StringWriter();
      out = new WriterOutput(writer);
      m_formatter.format(root, message, out);

      assertEquals(XML_HEADER +
         "<XMLAnyTest xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" +
         " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<anyInterfaceInheritanceElement>" +
               "<parent>" +
                  "<a>Avalue</a>" +
                  "<b>11</b>" +
               "</parent>" +
            "</anyInterfaceInheritanceElement>" +
         "</XMLAnyTest>", writer.toString());

      // Format parent/child3
      any.removeAllValues();
      any.setClassName("XML_Inherit_Child3");
      any.setValue("a", "Avalue");
      any.setValue("b", "Bvalue");

      writer = new StringWriter();
      out = new WriterOutput(writer);
      m_formatter.format(root, message, out);

      assertEquals(XML_HEADER +
         "<XMLAnyTest xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" +
         " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
View Full Code Here

    * message specified on the reference.
    */
   public void testFormatNonSubMessage()
   {
      StringWriter writer = new StringWriter();
      WriterOutput out = new WriterOutput(writer);
      TransferObject root = new TransferObject("XML_Inherit_Parent_Referrer", 2);
      TransferObject polyRoot = new TransferObject(2);

      polyRoot.setClassName("XML_Inherit_Parent_Parent");
      polyRoot.setValue("a", "Avalue");
      polyRoot.setValue("b", Primitive.createInteger(17));

      root.setValue("name", "123");
      root.setValue("ref", polyRoot);

      try
      {
         m_formatter.format(root, m_referrerMessage, out);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         IntegrationException cause = (IntegrationException)ex.getCause();

         assertEquals("err.integration.messageTypeMismatch", cause.getErrorCode());
         assertEquals("XML_Inherit_Parent_Referrer ref", cause.getErrorArgs()[0]);
         assertEquals("XML_Inherit_Parent", cause.getErrorArgs()[1]);
         assertEquals("XML_Inherit_Parent_Parent", cause.getErrorArgs()[2]);
      }


      // Format the pure message
      Message msgParent = m_context.getMetadata().getMessage("XML_Inherit_Parent");

      root = polyRoot;
      writer = new StringWriter();
      out = new WriterOutput(writer);

      try
      {
         m_formatter.format(root, msgParent, out);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         IntegrationException cause = (IntegrationException)ex.getCause();

         assertEquals("err.integration.messageTypeMismatch", cause.getErrorCode());
         assertEquals("XML_Inherit_Parent", cause.getErrorArgs()[0]);
         assertEquals("XML_Inherit_Parent", cause.getErrorArgs()[1]);
         assertEquals("XML_Inherit_Parent_Parent", cause.getErrorArgs()[2]);
      }

      // Format the abstract message
      msgParent = m_context.getMetadata().getMessage("XML_Inherit_Parent_Parent");
      writer = new StringWriter();
      out = new WriterOutput(writer);

      try
      {
         m_formatter.format(root, msgParent, out);
         fail("Expected IntegrationException");
View Full Code Here

   public void testFormatSOAPHeader()
   {
      Message parentMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Parent");
      Message childMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Child");
      StringWriter writer = new StringWriter();
      WriterOutput out = new WriterOutput(writer);
      TransferObject root = new TransferObject("XML_Inherit_SOAP_Header_Parent", 3);
      TransferObject headerRoot = new TransferObject(2);

      headerRoot.setValue("data", Primitive.createInteger(11));

      root.setValue("a", "test");
      root.setValue("header", headerRoot);
      m_formatter.format(root, parentMessage, out);

      assertEquals(XML_HEADER +
         "<soap:Envelope" +
            " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<soap:Header>" +
            "<data>11</data>" +
         "</soap:Header>" +
         "<soap:Body>" +
            "<parent " +
               "xmlns:wscoor=\"http://docs.oasis-open.org/ws-tx/wscoor/2006/06\" " +
               "xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">" +
               "<a>test</a>" +
            "</parent>" +
         "</soap:Body>" +
         "</soap:Envelope>", writer.toString());


      // Format child TO using child Message metadata
      root.setClassName("XML_Inherit_SOAP_Header_Child");
      headerRoot.setValue("data2", "abc");
      root.setValue("b", "Bvalue");

      writer = new StringWriter();
      out = new WriterOutput(writer);
      m_formatter.format(root, childMessage, out);

      assertEquals(XML_HEADER +
         "<soap:Envelope" +
            " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<soap:Header>" +
            "<data>11</data>" +
            "<data2>abc</data2>" +
         "</soap:Header>" +
         "<soap:Body>" +
            "<child>" +
               "<a>test</a>" +
               "<b>Bvalue</b>" +
            "</child>" +
         "</soap:Body>" +
         "</soap:Envelope>", writer.toString());


      // Format child TO using parent Message metadata
      root.setClassName("XML_Inherit_SOAP_Header_Child");
      headerRoot.setValue("data2", "abc");
      root.setValue("b", "Bvalue");

      writer = new StringWriter();
      out = new WriterOutput(writer);
      m_formatter.format(root, parentMessage, out);

      assertEquals(XML_HEADER +
         "<soap:Envelope" +
            " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
View Full Code Here

   public void testFormatSOAPHeaderReference()
   {
      Message parentMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Parent");
      Message childMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Child_Header_Ref");
      StringWriter writer = new StringWriter();
      WriterOutput out = new WriterOutput(writer);
      TransferObject root = new TransferObject("XML_Inherit_SOAP_Header_Parent", 3);
      TransferObject headerRoot = new TransferObject(2);
      TransferObject actionHeader = new TransferObject(3);

      actionHeader.setValue("role", "Hamlet");
      actionHeader.setValue("mustUnderstand", Boolean.TRUE);
      actionHeader.setValue("value", "Adieu, adieu, adieu; remember me!");
      headerRoot.setValue("action", actionHeader);
      root.setValue("a", "test");
      root.setValue("header", headerRoot);


      // Format child TO using child Message metadata
      root.setClassName("XML_Inherit_SOAP_Header_Child_Header_Ref");
      headerRoot.setValue("data", "abc")// should not appear
      root.setValue("c", "Cvalue");

      writer = new StringWriter();
      out = new WriterOutput(writer);
      m_formatter.format(root, childMessage, out);

      assertEquals(XML_HEADER +
         "<soap:Envelope" +
            " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<soap:Header>" +
            "<wsa:Action" +
               " xmlns:wscoor=\"http://docs.oasis-open.org/ws-tx/wscoor/2006/06\"" +
               " xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"" +
               " soap:role=\"Hamlet\" soap:mustUnderstand=\"1\">" +
               "Adieu, adieu, adieu; remember me!" +
            "</wsa:Action>" +
         "</soap:Header>" +
         "<soap:Body>" +
            "<child2" +
               " xmlns:wscoor=\"http://docs.oasis-open.org/ws-tx/wscoor/2006/06\"" +
               " xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"" +
               ">" +
               "<a>test</a>" +
               "<c>Cvalue</c>" +
            "</child2>" +
         "</soap:Body>" +
         "</soap:Envelope>", writer.toString());


      // Format child TO using parent Message metadata
      writer = new StringWriter();
      out = new WriterOutput(writer);
      m_formatter.format(root, parentMessage, out);

      assertEquals(XML_HEADER +
         "<soap:Envelope" +
            " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
View Full Code Here

   public void testFormatSOAPHeaderSameHeader()
   {
      Message parentMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Parent");
      Message childMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Child_SameHeader");
      StringWriter writer = new StringWriter();
      WriterOutput out = new WriterOutput(writer);
      TransferObject root = new TransferObject("XML_Inherit_SOAP_Header_Child_SameHeader", 3);
      TransferObject headerRoot = new TransferObject(1);

      headerRoot.setValue("data", Primitive.createInteger(11));
      root.setValue("a", "test");
      root.setValue("header", headerRoot);
      root.setValue("d", "Dvalue");

      // Format child TO using child Message metadata
      writer = new StringWriter();
      out = new WriterOutput(writer);
      m_formatter.format(root, childMessage, out);

      assertEquals(XML_HEADER +
         "<soap:Envelope" +
            " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<soap:Header>" +
            "<data>11</data>" +
         "</soap:Header>" +
         "<soap:Body>" +
            "<child3>" +
               "<a>test</a>" +
               "<d>Dvalue</d>" +
            "</child3>" +
         "</soap:Body>" +
         "</soap:Envelope>", writer.toString());


      // Format child TO using parent Message metadata
      writer = new StringWriter();
      out = new WriterOutput(writer);
      m_formatter.format(root, parentMessage, out);

      assertEquals(XML_HEADER +
         "<soap:Envelope" +
            " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
View Full Code Here

    * Test formatting messages and sub-messages with value parts.
    */
   public void testFormatValueParts() throws Exception
   {
      StringWriter writer = new StringWriter();
      WriterOutput out = new WriterOutput(writer);
      TransferObject root = new TransferObject("XML_Inherit_Parent_Referrer", 2);
      TransferObject ref = new TransferObject(3);
      TransferObject anyMsg = new TransferObject(2);

      // Parent - hex value part
      ref.setClassName("XML_Inherit_Parent");
      ref.setValue("a", "Avalue");
      ref.setValue("b", Primitive.createInteger(17));
      ref.setValue("value", Binary.fromBase64("MTIz"));

      root.setValue("name", "123");
      root.setValue("ref", ref);
      m_formatter.format(root, m_referrerMessage, out);

      assertEquals(XML_HEADER +
         "<referrer xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<name>123</name>" +
         "<reference>" +
            "<a>Avalue</a>" +
            "<b>17</b>" +
            "313233" +
         "</reference>" +
         "</referrer>", writer.toString());

      // Child2 - base64 value part
      writer = new StringWriter();
      out = new WriterOutput(writer);
      ref.setClassName("XML_Inherit_Child2");
      ref.setValue("value", Binary.parse("313233"));
      ref.setValue("b", "Bvalue");
      m_formatter.format(root, m_referrerMessage, out);

      assertEquals(XML_HEADER +
         "<referrer xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<name>123</name>" +
         "<reference xsi:type=\"Child2Type\">" +
            "<a>Avalue</a>" +
            "<b>Bvalue</b>" +
            "MTIz" +
         "</reference>" +
         "</referrer>", writer.toString());

      // Child4 - xsd:anyType value part (with interface)
      writer = new StringWriter();
      out = new WriterOutput(writer);
      ref.setClassName("XML_Inherit_Child4");
      ref.setValue("value", anyMsg);
      ref.setValue("b", "Bvalue");
      anyMsg.setClassName("XML_InternationalPrice");
      anyMsg.setValue("currency", "CNY");
      anyMsg.setValue("price", new BigDecimal("8.00"));
      m_formatter.format(root, m_referrerMessage, out);

      assertEquals(XML_HEADER +
         "<referrer xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<name>123</name>" +
         "<reference xsi:type=\"Child4Type\">" +
            "<a>Avalue</a>" +
            "<b>Bvalue</b>" +
            "<internationalPrice currency=\"CNY\">8.00</internationalPrice>" +
         "</reference>" +
         "</referrer>", writer.toString());

      // Child4Child - xsd:anyType value part (without interface)
      writer = new StringWriter();
      out = new WriterOutput(writer);
      ref.setClassName("XML_Inherit_Child4_Child");
      ref.removeValue("a");
      ref.removeValue("b");
      ref.setValue("value", "<a>Avalue</a><b>Bvalue</b><internationalPrice currency=\"CNY\">8.00</internationalPrice>");
      m_formatter.format(root, m_referrerMessage, out);
View Full Code Here

    */
   public void testFormatSchemaInherited()
   {
      Message msg1 = m_context.getMetadata().getMessage("XML_Inherit_Schema1");
      StringWriter writer;
      WriterOutput out;
      TransferObject root;

      // Format sub-message
      root = new TransferObject("XML_Inherit_Schema2", 2);
      root.setValue("a", "aValue");
      root.setValue("b", "bValue");
      out = new WriterOutput(writer = new StringWriter());
      m_formatter.format(root, msg1, out);

      assertEquals(XML_HEADER +
         "<is1:schema1" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
            " xmlns:is1=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:inherit:schema1 http://www.nexjsystems.com/ns/test/inherit/schema1.xsd\"" +
            " xsi:type=\"is1:Schema2Type\">" +
            "<a>aValue</a>" +
            "<b>bValue</b>" +
         "</is1:schema1>", writer.toString());

      // Format sub-sub-message
      root = new TransferObject("XML_Inherit_Schema3", 3);
      root.setValue("a", "aValue");
      root.setValue("b", "bValue");
      root.setValue("cReal", "cValue");
      out = new WriterOutput(writer = new StringWriter());
      m_formatter.format(root, msg1, out);

      assertEquals(XML_HEADER +
         "<is1:schema1" +
            " xmlns:is3=\"urn:com.nexjsystems:ns:test:inherit:schema3\"" +
View Full Code Here

    * Formats a reference with the parent message.
    */
   public void testFormatParent()
   {
      StringWriter writer = new StringWriter();
      WriterOutput out = new WriterOutput(writer);
      TransferObject root = new TransferObject("XML_Inherit_Parent_Referrer", 2);
      TransferObject polyRoot = new TransferObject(2);

      polyRoot.setClassName("XML_Inherit_Parent");
      polyRoot.setValue("a", "Avalue");
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.