axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-axis/java/test/message TestMessageElement.java
Date Sun, 02 Mar 2003 18:59:39 GMT
dims        2003/03/02 10:59:39

  Modified:    java/src/org/apache/axis/message MessageElement.java
               java/test/message TestMessageElement.java
  Log:
  Fix for Bug 16977 - MessageElement.getNamespaceURI() results in a NullPointer if element
has an href that does not successfuly resolve
  
  Revision  Changes    Path
  1.147     +2 -2      xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.146
  retrieving revision 1.147
  diff -u -r1.146 -r1.147
  --- MessageElement.java	2 Mar 2003 06:36:19 -0000	1.146
  +++ MessageElement.java	2 Mar 2003 18:59:38 -0000	1.147
  @@ -478,7 +478,7 @@
           if ((namespaceURI == null) || (namespaceURI.equals("")))
               return null;
   
  -        if (href != null) {
  +        if (href != null && getRealElement() != null) {
               return getRealElement().getPrefix(namespaceURI);
           }
   
  @@ -498,7 +498,7 @@
           if (prefix == null)
               prefix = "";
   
  -        if (href != null) {
  +        if (href != null && getRealElement() != null) {
               return getRealElement().getNamespaceURI(prefix);
           }
   
  
  
  
  1.10      +17 -0     xml-axis/java/test/message/TestMessageElement.java
  
  Index: TestMessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/message/TestMessageElement.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestMessageElement.java	11 Dec 2002 22:40:17 -0000	1.9
  +++ TestMessageElement.java	2 Mar 2003 18:59:39 -0000	1.10
  @@ -57,6 +57,8 @@
   
   import junit.framework.TestCase;
   import org.apache.axis.Message;
  +import org.apache.axis.MessageContext;
  +import org.apache.axis.client.AxisClient;
   import org.apache.axis.encoding.DeserializationContext;
   import org.apache.axis.encoding.DeserializationContextImpl;
   import org.apache.axis.message.EnvelopeBuilder;
  @@ -69,6 +71,7 @@
   import javax.xml.soap.Name;
   import javax.xml.soap.SOAPElement;
   import java.util.Iterator;
  +import java.io.StringReader;
   
   /**
    * Test MessageElement class.
  @@ -196,6 +199,20 @@
           assertEquals(s1, s2);
       }
       
  +    public void testMessageElementNullOngetNamespaceURI() throws Exception{
  +        String data="<anElement xmlns:ns1=\"aNamespace\" href=\"unknownProtocol://data\"/>";
  +        data="<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><SOAP-ENV:Body>"+
  +             data+"</SOAP-ENV:Body></SOAP-ENV:Envelope>";
  +        MessageContext ctx=new MessageContext(new AxisClient());
  +        DeserializationContext dser = new DeserializationContextImpl(
  +                                           new org.xml.sax.InputSource(new StringReader(data)),
  +                                           ctx,
  +                                           Message.REQUEST);
  +        dser.parse();
  +		MessageElement elem=dser.getEnvelope().getBodyByName("","anElement");
  +        assertEquals("aNamespace",elem.getNamespaceURI("ns1"));
  +        assertEquals("ns1",elem.getPrefix("aNamespace"));
  +    }    
       public static void main(String[] args) throws Exception {
           TestMessageElement tester = new TestMessageElement("TestMessageElement");
           tester.testQNameAttrTest();
  
  
  

Mime
View raw message