Package nexj.core.util

Examples of nexj.core.util.XMLParserException


         m_parser.parse(in, msg2);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         XMLParserException cause = (XMLParserException)ex.getCause();

         assertEquals("err.xml.parser", cause.getErrorCode());
      }

      // Valid sub-message (parsed through inheritance)
      in = new StringInput(
         "<ns:schema1 xsi:type=\"ns:Schema2Type\"" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>2Hi</a>" +
            "<b>2there!</b>" +
         "</ns:schema1>");

      root = m_parser.parse(in, msg1);
      assertEquals("XML_Inherit_Schema2", root.getClassName());
      assertEquals("2Hi", root.getValue("a"));
      assertEquals("2there!", root.getValue("b"));

      // Invalid sub-message (parsed through inheritance)
      in = new StringInput(
         "<ns:schema1 xsi:type=\"ns:Schema2Type\"" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>Hi</a>" +
            "<b>there!</b>" +
            "<c>bye</c>" +
         "</ns:schema1>");

      try
      {
         m_parser.parse(in, msg1);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         XMLParserException cause = (XMLParserException)ex.getCause();

         assertEquals("err.xml.parser", cause.getErrorCode());
      }

      // Valid sub-sub-message in different schema (direct)
      in = new StringInput(
         "<ns3:schema3" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:ns3=\"urn:com.nexjsystems:ns:test:inherit:schema3\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>3Hi</a>" +
            "<b>3there!</b>" +
            "<cReal>bye</cReal>" +
         "</ns3:schema3>");

      root = m_parser.parse(in, msg3);
      assertEquals("XML_Inherit_Schema3", root.getClassName());
      assertEquals("3Hi", root.getValue("a"));
      assertEquals("3there!", root.getValue("b"));
      assertEquals("bye", root.getValue("cReal"));

      // Invalid sub-sub-message in different schema (direct)
      in = new StringInput(
         "<ns3:schema3" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:ns3=\"urn:com.nexjsystems:ns:test:inherit:schema3\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>3Hi</a>" +
            "<b>3there!</b>" +
            "<cReal>bye</cReal>" +
            "<x>bad</x>" +
         "</ns3:schema3>");

      try
      {
         m_parser.parse(in, msg3);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         XMLParserException cause = (XMLParserException)ex.getCause();

         assertEquals("err.xml.parser", cause.getErrorCode());
      }

      // Valid sub-sub-message in different schema (inheritance)
      in = new StringInput(
         "<ns:schema1 xsi:type=\"ns3:Schema3Type\"" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:ns3=\"urn:com.nexjsystems:ns:test:inherit:schema3\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>4Hi</a>" +
            "<b>4there!</b>" +
            "<cReal>2bye</cReal>" +
         "</ns:schema1>");

      root = m_parser.parse(in, msg1);
      assertEquals("XML_Inherit_Schema3", root.getClassName());
      assertEquals("4Hi", root.getValue("a"));
      assertEquals("4there!", root.getValue("b"));
      assertEquals("2bye", root.getValue("cReal"));

      // Invalid sub-sub-message in different schema (inheritance)
      in = new StringInput(
         "<ns:schema1 xsi:type=\"ns3:Schema3Type\"" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:ns3=\"urn:com.nexjsystems:ns:test:inherit:schema3\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>4Hi</a>" +
            "<b>4there!</b>" +
            "<cReal>2bye</cReal>" +
            "<x>bad</x>" +
         "</ns:schema1>");

      try
      {
         m_parser.parse(in, msg1);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         XMLParserException cause = (XMLParserException)ex.getCause();

         assertEquals("err.xml.parser", cause.getErrorCode());
      }
   }
View Full Code Here

TOP

Related Classes of nexj.core.util.XMLParserException

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.