[riftsaw-commits] riftsaw SVN: r930 - branches/RiftSaw-2.1.x/runtime/engine/src/test/java and 4 other directories.

riftsaw-commits at lists.jboss.org riftsaw-commits at lists.jboss.org
Wed Sep 1 06:19:23 EDT 2010


Author: objectiser
Date: 2010-09-01 06:19:22 -0400 (Wed, 01 Sep 2010)
New Revision: 930

Added:
   branches/RiftSaw-2.1.x/runtime/engine/src/test/java/riftsaw277/
   branches/RiftSaw-2.1.x/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java
   trunk/runtime/engine/src/test/java/riftsaw277/
   trunk/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java
Modified:
   branches/RiftSaw-2.1.x/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
   trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
Log:
RIFTSAW-277 - protected against null pointer, so now no fault is returned, and ODE handles this case by internally throwing a failure.

Modified: branches/RiftSaw-2.1.x/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
===================================================================
--- branches/RiftSaw-2.1.x/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java	2010-09-01 06:42:40 UTC (rev 929)
+++ branches/RiftSaw-2.1.x/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java	2010-09-01 10:19:22 UTC (rev 930)
@@ -538,7 +538,7 @@
         SOAPHeader.class);
   }
 
-  public Fault parseSoapFault(
+  public static Fault parseSoapFault(
       Element odeMessage,
       SOAPMessage soapMessage,
       javax.wsdl.Operation operation)
@@ -574,7 +574,7 @@
     return fdef;
   }
 
-  public Fault parseSoapFault(
+  public static Fault parseSoapFault(
 	      Element odeMessage,
 	      SOAPFault flt,
 	      javax.wsdl.Operation operation)
@@ -602,12 +602,17 @@
     return fault;
   }
 
-  private Fault inferFault(Operation operation, SOAPFault flt) {
+  private static Fault inferFault(Operation operation, SOAPFault flt) {
     if (!flt.hasDetail())
       return null;
     // The detail is a dummy <detail> node containing the interesting fault element
     Element element = DOMUtils.getFirstChildElement(flt.getDetail());
-    QName elName = new QName(element.getNamespaceURI(), element.getLocalName());
+    
+    if (element == null) {
+    	return(null);
+    }
+    
+    QName elName=new QName(element.getNamespaceURI(), element.getLocalName());
     return WsdlUtils.inferFault(operation, elName);
   }
 }

Added: branches/RiftSaw-2.1.x/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java
===================================================================
--- branches/RiftSaw-2.1.x/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java	                        (rev 0)
+++ branches/RiftSaw-2.1.x/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java	2010-09-01 10:19:22 UTC (rev 930)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package riftsaw277;
+
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.soa.bpel.runtime.ws.SOAPMessageAdapter;
+
+import junit.framework.TestCase;
+
+/**
+ * https://jira.jboss.org/jira/browse/RIFTSAW-277
+ */
+public class Riftsaw277TestCase extends TestCase {
+
+	public Riftsaw277TestCase() {
+	}
+	
+	public void testSOAPFaultWithNoDetails() {
+		try {
+			org.w3c.dom.Document doc = javax.xml.parsers.DocumentBuilderFactory.
+				newInstance().newDocumentBuilder().newDocument();
+
+			org.w3c.dom.Element odeMessage=doc.createElement("message");
+			
+			doc.appendChild(odeMessage);
+			
+			String str="<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"+
+				"<soap:Body><soap:Fault><faultcode>soap:Client</faultcode>"+
+				"<faultstring>Server did not recognize the value of HTTP Header SOAPAction: .</faultstring>"+
+				"<detail/></soap:Fault></soap:Body></soap:Envelope>";
+
+			java.io.InputStream is=new java.io.ByteArrayInputStream(str.getBytes());
+			
+			SOAPMessage soapMessage=javax.xml.soap.MessageFactory.newInstance().createMessage(null,
+								is);
+			
+			is.close();
+			
+			javax.wsdl.factory.WSDLFactory fact=
+				javax.wsdl.factory.WSDLFactory.newInstance();
+			javax.wsdl.Definition defn=fact.newDefinition();
+			javax.wsdl.Operation operation=defn.createOperation();
+		    
+		    javax.wsdl.Fault fault=SOAPMessageAdapter.parseSoapFault(odeMessage,
+		    				soapMessage, operation);
+
+		    if (fault != null) {
+		    	fail("No fault should be returned");
+		    }
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to run test: "+e);
+		}
+	}
+}

Modified: trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java	2010-09-01 06:42:40 UTC (rev 929)
+++ trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java	2010-09-01 10:19:22 UTC (rev 930)
@@ -538,7 +538,7 @@
         SOAPHeader.class);
   }
 
-  public Fault parseSoapFault(
+  public static Fault parseSoapFault(
       Element odeMessage,
       SOAPMessage soapMessage,
       javax.wsdl.Operation operation)
@@ -574,7 +574,7 @@
     return fdef;
   }
 
-  public Fault parseSoapFault(
+  public static Fault parseSoapFault(
 	      Element odeMessage,
 	      SOAPFault flt,
 	      javax.wsdl.Operation operation)
@@ -602,12 +602,17 @@
     return fault;
   }
 
-  private Fault inferFault(Operation operation, SOAPFault flt) {
+  private static Fault inferFault(Operation operation, SOAPFault flt) {
     if (!flt.hasDetail())
       return null;
     // The detail is a dummy <detail> node containing the interesting fault element
     Element element = DOMUtils.getFirstChildElement(flt.getDetail());
-    QName elName = new QName(element.getNamespaceURI(), element.getLocalName());
+    
+    if (element == null) {
+    	return(null);
+    }
+    
+    QName elName=new QName(element.getNamespaceURI(), element.getLocalName());
     return WsdlUtils.inferFault(operation, elName);
   }
 }

Added: trunk/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java
===================================================================
--- trunk/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java	                        (rev 0)
+++ trunk/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java	2010-09-01 10:19:22 UTC (rev 930)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package riftsaw277;
+
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.soa.bpel.runtime.ws.SOAPMessageAdapter;
+
+import junit.framework.TestCase;
+
+/**
+ * https://jira.jboss.org/jira/browse/RIFTSAW-277
+ */
+public class Riftsaw277TestCase extends TestCase {
+
+	public Riftsaw277TestCase() {
+	}
+	
+	public void testSOAPFaultWithNoDetails() {
+		try {
+			org.w3c.dom.Document doc = javax.xml.parsers.DocumentBuilderFactory.
+				newInstance().newDocumentBuilder().newDocument();
+
+			org.w3c.dom.Element odeMessage=doc.createElement("message");
+			
+			doc.appendChild(odeMessage);
+			
+			String str="<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"+
+				"<soap:Body><soap:Fault><faultcode>soap:Client</faultcode>"+
+				"<faultstring>Server did not recognize the value of HTTP Header SOAPAction: .</faultstring>"+
+				"<detail/></soap:Fault></soap:Body></soap:Envelope>";
+
+			java.io.InputStream is=new java.io.ByteArrayInputStream(str.getBytes());
+			
+			SOAPMessage soapMessage=javax.xml.soap.MessageFactory.newInstance().createMessage(null,
+								is);
+			
+			is.close();
+			
+			javax.wsdl.factory.WSDLFactory fact=
+				javax.wsdl.factory.WSDLFactory.newInstance();
+			javax.wsdl.Definition defn=fact.newDefinition();
+			javax.wsdl.Operation operation=defn.createOperation();
+		    
+		    javax.wsdl.Fault fault=SOAPMessageAdapter.parseSoapFault(odeMessage,
+		    				soapMessage, operation);
+
+		    if (fault != null) {
+		    	fail("No fault should be returned");
+		    }
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to run test: "+e);
+		}
+	}
+}



More information about the riftsaw-commits mailing list