Author: gdaniels
Date: Tue Mar 27 21:03:05 2007
New Revision: 523158

URL: http://svn.apache.org/viewvc?view=rev&rev=523158
Log:
* Fix DOOM version of OMText.getTextAsQName() to match LLOM's

* UnsupportedOperationException isn't always the right thing.  Return null in a 
couple of places instead.  Adjust tests accordingly.

Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11FaultCodeImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPFaultCodeTest.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?view=diff&rev=523158&r1=523157&r2=523158
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
 Tue Mar 27 21:03:05 2007
@@ -33,7 +33,6 @@
 import org.apache.axiom.om.util.ElementHelper;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
@@ -937,26 +936,32 @@
     }
 
     public QName getTextAsQName() {
-        String childText = "";
+        String childText = getTrimmedText();
+        if (childText != null) {
+            return resolveQName(childText);
+        }
+        return null;
+    }
+
+    public String getTrimmedText() {
+        String childText = null;
         OMNode child = this.getFirstOMChild();
         OMText textNode;
 
         while (child != null) {
             if (child.getType() == OMNode.TEXT_NODE) {
                 textNode = (OMText) child;
-                if (textNode.getText() != null
-                        && !"".equals(textNode.getText())) {
-                    String namespaceURI = 
textNode.getTextAsQName().getNamespaceURI();
-                    if (namespaceURI != null && !"".equals(namespaceURI)) {
-                        return textNode.getTextAsQName();
-                    }
-                    childText += textNode.getText();
+                String textValue = textNode.getText();
+                if (textValue != null &&
+                        !"".equals(textValue.trim())) {
+                    if (childText == null) childText = "";
+                    childText += textValue.trim();
                 }
             }
             child = child.getNextOMSibling();
         }
 
-        return new QName(childText);
+        return childText;
     }
 
     /**

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11FaultCodeImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11FaultCodeImpl.java?view=diff&rev=523158&r1=523157&r2=523158
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11FaultCodeImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11FaultCodeImpl.java
 Tue Mar 27 21:03:05 2007
@@ -100,10 +100,12 @@
     }
 
     public SOAPFaultValue getValue() {
-        throw new UnsupportedOperationException("getValue() not supported for 
SOAP 1.1 faults");
+        return null;
+//        throw new UnsupportedOperationException("getValue() not supported 
for SOAP 1.1 faults");
     }
 
     public SOAPFaultSubCode getSubCode() {
-        throw new UnsupportedOperationException("getSubCode() not supported 
for SOAP 1.1 faults");
+        return null;
+//        throw new UnsupportedOperationException("getSubCode() not supported 
for SOAP 1.1 faults");
     }
 }

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPFaultCodeTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPFaultCodeTest.java?view=diff&rev=523158&r1=523157&r2=523158
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPFaultCodeTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPFaultCodeTest.java
 Tue Mar 27 21:03:05 2007
@@ -45,12 +45,7 @@
 //    }
 
     public void testSOAP11GetValue() {
-        try {
-            soap11FaultCode.getValue();
-        } catch (UnsupportedOperationException e) {
-            return;
-        }
-        fail("Unsupported getValue operation was allowed on SOAP 1.1 
FaultCode");
+        assertNull(soap11FaultCode.getValue());
 //        assertTrue(
 //                "SOAP 1.1 Fault Code Test :- After creating soapfaultcode, 
it has a value",
 //                soap11FaultCode.getValue() == null);
@@ -137,12 +132,7 @@
 
     //SOAP 1.1 Fault Code Test (With Parser)
     public void testSOAP11GetValueWithParser() {
-        try {
-            soap11FaultCodeWithParser.getValue();
-        } catch (UnsupportedOperationException e) {
-            return;
-        }
-        fail("Unsupported getValue operation was allowed on SOAP 1.1 
FaultCode");
+        assertNull(soap11FaultCodeWithParser.getValue());
     }
 
     //SOAP 1.2 Fault Code Test (With Parser)



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to