dims 2002/11/19 19:13:44
Modified: java/src/org/apache/axis/message SOAPBody.java
SOAPHeader.java
java/test/message TestSOAPEnvelope.java
Log:
1. Fix for Bug 14574 - NullPointer on getHeaderByName call
2. Fix for Bug 14570 - NullPointer on getBodyByName call
Notes:
Added test cases for both as well.
Revision Changes Path
1.34 +3 -3 xml-axis/java/src/org/apache/axis/message/SOAPBody.java
Index: SOAPBody.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPBody.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- SOAPBody.java 18 Sep 2002 16:10:28 -0000 1.33
+++ SOAPBody.java 20 Nov 2002 03:13:42 -0000 1.34
@@ -203,13 +203,13 @@
{
if (vec.isEmpty())
return null;
-
+
+ QName qname = new QName(namespace, localPart);
Enumeration e = vec.elements();
MessageElement element;
while (e.hasMoreElements()) {
element = (MessageElement)e.nextElement();
- if (element.getNamespaceURI().equals(namespace) &&
- element.getName().equals(localPart))
+ if (element.getQName().equals(qname))
return element;
}
1.64 +2 -2 xml-axis/java/src/org/apache/axis/message/SOAPHeader.java
Index: SOAPHeader.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPHeader.java,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- SOAPHeader.java 16 Oct 2002 16:36:41 -0000 1.63
+++ SOAPHeader.java 20 Nov 2002 03:13:43 -0000 1.64
@@ -251,12 +251,12 @@
if (vec.isEmpty())
return null;
+ QName qname = new QName(namespace, localPart);
Enumeration e = vec.elements();
MessageElement element;
while (e.hasMoreElements()) {
element = (MessageElement)e.nextElement();
- if (element.getNamespaceURI().equals(namespace) &&
- element.getName().equals(localPart))
+ if (element.getQName().equals(qname))
return element;
}
1.4 +31 -0 xml-axis/java/test/message/TestSOAPEnvelope.java
Index: TestSOAPEnvelope.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/message/TestSOAPEnvelope.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestSOAPEnvelope.java 10 Jul 2002 18:28:53 -0000 1.3
+++ TestSOAPEnvelope.java 20 Nov 2002 03:13:44 -0000 1.4
@@ -63,6 +63,10 @@
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPException;
+import org.apache.axis.Message;
+import org.apache.axis.message.SOAPBodyElement;
+import org.apache.axis.message.SOAPHeaderElement;
+
/**
* Test SOAPEnvelope class.
*
@@ -126,5 +130,32 @@
assertTrue("second body added", false);
} catch (SOAPException e) {
}
+ }
+
+ // Test for bug #14570
+ public void testNullpointer() throws Exception{
+ org.apache.axis.message.SOAPEnvelope env=new
org.apache.axis.message.SOAPEnvelope();
+ SOAPBodyElement bdy=new SOAPBodyElement();
+ bdy.setName("testResponse");
+ env.addBodyElement(bdy);
+ Message msg=new Message(env);
+ SOAPBodyElement sbe =
msg.getSOAPEnvelope().getBodyByName(null,"testResponse");
+ assertTrue(sbe != null);
+ }
+
+ // Test for bug 14574
+ public void testNullpointerInHeader() throws Exception{
+ org.apache.axis.message.SOAPEnvelope env=new
org.apache.axis.message.SOAPEnvelope();
+ SOAPHeaderElement hdr=new SOAPHeaderElement(null,"testHeader");
+ env.addHeader(hdr);
+ Message msg=new Message(env);
+ SOAPHeaderElement she =
msg.getSOAPEnvelope().getHeaderByName(null,"testHeader");
+ assertTrue(she != null);
+ }
+
+ public static void main(String args[]) throws Exception {
+ TestSOAPEnvelope tester = new TestSOAPEnvelope("TestSOAPEnvelope");
+ tester.testNullpointer();
+ tester.testNullpointerInHeader();
}
}