Package nexj.core.integration.io

Examples of nexj.core.integration.io.StringInput


    * Parser told to parse message: XML_Inherit_Parent_Reference
    * Parser given this message data: XML_Inherit_Child1_Referrer
    */
   public void testParsePolymorphicRootMessage()
   {
      StringInput in = new StringInput(XML_HEADER +
         "<referrer xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"ChildReferrerType\">" +
         "<name>123</name>" +
         "<child1>" +
            "<b>23</b>" +
            "<c1>31</c1>" +
View Full Code Here


    * Parses a reference to the child message with the child's child message.
    * Should fail because reference is not polymorphic.
    */
   public void testParseChild1Child_Child1Referrer()
   {
      StringInput in = new StringInput(XML_HEADER +
         "<referrer xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"ChildReferrerType\">" +
         "<name>123</name>" +
         "<child1 xsi:type=\"Child1ChildType\">" + // Not allowed--not polymorphic
            "<b>23</b>" +
            "<c1>31</c1>" +
View Full Code Here

    * Tests directly parsing to a non-polymorphic message one of its sub-messages.
    */
   public void testParseNonPolymorphicMessage()
   {
      Message msgChild1 = m_context.getMetadata().getMessage("XML_Inherit_Child1");
      StringInput in = new StringInput(XML_HEADER +
         "<child1 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"Child1ChildType\">" +
            "<b>23</b>" +
            "<c1>31</c1>" +
            "<c1c>C1Cvalue</c1c>" +
         "</child1>");

      try
      {
         m_parser.parse(in, msgChild1);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.messageTypeMismatch", ex.getErrorCode());
         assertEquals("XML_Inherit_Child1_Child", ex.getErrorArgs()[0]);
         assertEquals("XML_Inherit_Child1", ex.getErrorArgs()[1]);
         assertEquals("XML_Inherit_Child1_Child", ex.getErrorArgs()[2]);
      }

      // Parse Child1 directly, this time passing Child1 data. Specify xsi:type (unnecessary).
      in = new StringInput(XML_HEADER +
         "<child1 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"Child1Type\">" +
            "<b>23</b>" +
            "<c1>31</c1>" +
         "</child1>");

View Full Code Here

   /**
    * Parses a reference with a child message.
    */
   public void testParseChild2()
   {
      StringInput in = new StringInput(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>" +
View Full Code Here

   /**
    * Parses a reference with an unknown message.
    */
   public void testParseUnknown()
   {
      StringInput in = new StringInput(XML_HEADER +
         "<referrer xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<name>123</name>" +
         "<reference xsi:type=\"UnknownType\">" +
            "<a>Avalue</a>" +
            "<b>Bvalue</b>" +
View Full Code Here

   {
      TransferObject root;
      Message message = m_context.getMetadata().getMessage("XMLAnyTest");

      // Parse child1
      root = m_parser.parse(new StringInput(
         "<XMLAnyTest>" +
            "<anyInterfaceInheritanceElement>" +
               "<child1>" +
                  "<b>23</b>" +
                  "<c1>31</c1>" +
               "</child1>" +
            "</anyInterfaceInheritanceElement>" +
         "</XMLAnyTest>"), message);

      assertEquals("XMLAnyTest", root.getClassName());
      root = (TransferObject)root.getValue("anyInterfaceInheritanceElement");
      assertEquals("XML_Inherit_Child1", root.getClassName());
      assertEquals(Primitive.createInteger(23), root.getValue("b"));
      assertEquals(Primitive.createInteger(31), root.getValue("c1"));


      // Parse child2
      root = m_parser.parse(new StringInput(
         "<XMLAnyTest>" +
            "<anyInterfaceInheritanceElement>" +
               "<child2>" +
                  "<a>Avalue</a>" +
                  "<b>Bvalue</b>" +
               "</child2>" +
            "</anyInterfaceInheritanceElement>" +
         "</XMLAnyTest>"), message);

      assertEquals("XMLAnyTest", root.getClassName());
      root = (TransferObject)root.getValue("anyInterfaceInheritanceElement");
      assertEquals("XML_Inherit_Child2", root.getClassName());
      assertEquals("Avalue", root.getValue("a"));
      assertEquals("Bvalue", root.getValue("b"));

      // Cannot parse child3 on its own. (it has same root element name as its parent)

      // Parse parent
      root = m_parser.parse(new StringInput(
         "<XMLAnyTest>" +
            "<anyInterfaceInheritanceElement>" +
               "<parent>" +
                  "<a>Avalue</a>" +
                  "<b>11</b>" +
               "</parent>" +
            "</anyInterfaceInheritanceElement>" +
         "</XMLAnyTest>"), message);

      assertEquals("XMLAnyTest", root.getClassName());
      root = (TransferObject)root.getValue("anyInterfaceInheritanceElement");
      assertEquals("XML_Inherit_Parent", root.getClassName());
      assertEquals("Avalue", root.getValue("a"));
      assertEquals(Primitive.createInteger(11), root.getValue("b"));


      // Parse parent/child1
      root = m_parser.parse(new StringInput(
         "<XMLAnyTest>" +
            "<anyInterfaceInheritanceElement>" +
               "<parent xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"Child1Type\">" +
                  "<b>23</b>" +
                  "<c1>31</c1>" +
               "</parent>" +
            "</anyInterfaceInheritanceElement>" +
         "</XMLAnyTest>"), message);

      assertEquals("XMLAnyTest", root.getClassName());
      root = (TransferObject)root.getValue("anyInterfaceInheritanceElement");
      assertEquals("XML_Inherit_Child1", root.getClassName());
      assertEquals(Primitive.createInteger(23), root.getValue("b"));
      assertEquals(Primitive.createInteger(31), root.getValue("c1"));


      // Parse parent/child2
      root = m_parser.parse(new StringInput(
         "<XMLAnyTest>" +
            "<anyInterfaceInheritanceElement>" +
               "<parent xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"Child2Type\">" +
                  "<a>Avalue</a>" +
                  "<b>Bvalue</b>" +
               "</parent>" +
            "</anyInterfaceInheritanceElement>" +
         "</XMLAnyTest>"), message);

      assertEquals("XMLAnyTest", root.getClassName());
      root = (TransferObject)root.getValue("anyInterfaceInheritanceElement");
      assertEquals("XML_Inherit_Child2", root.getClassName());
      assertEquals("Avalue", root.getValue("a"));
      assertEquals("Bvalue", root.getValue("b"));


      // Parse parent/child3
      root = m_parser.parse(new StringInput(
         "<XMLAnyTest>" +
            "<anyInterfaceInheritanceElement>" +
               "<parent xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"Child3Type\">" +
                  "<a>Avalue</a>" +
                  "<b>Bvalue</b>" +
View Full Code Here

    * Parses a reference with a message that is not a sub-message of the
    * message specified on the reference.
    */
   public void testParseNonSubMessage()
   {
      StringInput in = new StringInput(XML_HEADER +
         "<referrer xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<name>123</name>" +
         "<reference xsi:type=\"ParentParentType\">" +
            "<a>Avalue</a>" +
            "<b>Bvalue</b>" +
         "</reference>" +
         "</referrer>");

      try
      {
         m_parser.parse(in, m_referrerMessage);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         assertEquals("err.integration.messageTypeMismatch", ex.getErrorCode());
         assertEquals("XML_Inherit_Parent_Referrer ref", ex.getErrorArgs()[0]);
         assertEquals("XML_Inherit_Parent", ex.getErrorArgs()[1]);
         assertEquals("XML_Inherit_Parent_Parent", ex.getErrorArgs()[2]);
      }

      // Parse the abstract message
      in = new StringInput(XML_HEADER +
         "<parentparent>" +
            "<a>Avalue</a>" +
            "<b>Bvalue</b>" +
         "</parentparent>");

View Full Code Here

    */
   public void testParseSOAPHeader()
   {
      Message parentMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Parent");
      Message childMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Child");
      StringInput in = new StringInput(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>" +
               "<a>test</a>" +
            "</parent>" +
         "</soap:Body>" +
         "</soap:Envelope>");
      TransferObject root = m_parser.parse(in, parentMessage);
      TransferObject headerRoot;

      assertEquals("XML_Inherit_SOAP_Header_Parent", root.getClassName());
      assertEquals("test", root.getValue("a"));
      headerRoot = (TransferObject)root.getValue("header");
      assertEquals(Primitive.createInteger(11), headerRoot.getValue("data"));


      // Parse child data using child Metadata
      in = new StringInput(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>");
      root = m_parser.parse(in, childMessage);

      assertEquals("XML_Inherit_SOAP_Header_Child", root.getClassName());
      assertEquals("test", root.getValue("a"));
      assertEquals("Bvalue", root.getValue("b"));
      headerRoot = (TransferObject)root.getValue("header");
      assertEquals(Primitive.createInteger(11), headerRoot.getValue("data"));
      assertEquals("abc", headerRoot.getValue("data2"));


      // Parse child data using parent Metadata
      in = new StringInput(XML_HEADER +
         "<soap:Envelope" +
            " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<soap:Header>" +
            "<data>13</data>" +
View Full Code Here

    */
   public void testParseSOAPHeaderReference()
   {
      Message parentMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Parent");
      Message childMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Child_Header_Ref");
      StringInput in;
      TransferObject root;
      TransferObject headerRoot, actionHeader;

      // Parse child data using child Metadata
      in = new StringInput(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>");
      root = m_parser.parse(in, childMessage);

      assertEquals("XML_Inherit_SOAP_Header_Child_Header_Ref", root.getClassName());
      assertEquals("test", root.getValue("a"));
      assertEquals("Cvalue", root.getValue("c"));
      headerRoot = (TransferObject)root.getValue("header");
      actionHeader = (TransferObject)headerRoot.getValue("action");
      assertEquals("Hamlet", actionHeader.getValue("role"));
      assertEquals(Boolean.TRUE, actionHeader.getValue("mustUnderstand"));
      assertEquals("Adieu, adieu, adieu; remember me!", actionHeader.getValue("value"));

      // Parse child data using parent Metadata
      in = new StringInput(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" +
View Full Code Here

    */
   public void testParseSOAPHeaderSameHeader()
   {
      Message parentMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Parent");
      Message childMessage = m_context.getMetadata().getMessage("XML_Inherit_SOAP_Header_Child_SameHeader");
      StringInput in;
      TransferObject root;
      TransferObject headerRoot;

      // Parse child data using child Metadata
      in = new StringInput(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>");
      root = m_parser.parse(in, childMessage);

      assertEquals("XML_Inherit_SOAP_Header_Child_SameHeader", root.getClassName());
      assertEquals("test", root.getValue("a"));
      assertEquals("Dvalue", root.getValue("d"));
      headerRoot = (TransferObject)root.getValue("header");
      assertEquals(Primitive.createInteger(11), headerRoot.getValue("data"));

      // Parse child data using parent Metadata
      in = new StringInput(XML_HEADER +
         "<soap:Envelope" +
         " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
         " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "<soap:Header>" +
            "<data>7</data>" +
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.