You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/09/02 18:30:25 UTC

svn commit: r691307 - in /cxf/branches/2.1.x-fixes: ./ api/src/main/java/org/apache/cxf/ws/policy/ systests/src/test/java/org/apache/cxf/systest/mtom/ systests/src/test/java/org/apache/cxf/systest/ws/policy/

Author: dkulp
Date: Tue Sep  2 09:30:24 2008
New Revision: 691307

URL: http://svn.apache.org/viewvc?rev=691307&view=rev
Log:
Allow for better policy error messages

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep  2 09:30:24 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Sep  2 09:30:24 2008
@@ -1 +1 @@
-/cxf/trunk:1-686342,686344-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,690638
+/cxf/trunk:1-686342,686344-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690638

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java?rev=691307&r1=691306&r2=691307&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java (original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java Tue Sep  2 09:30:24 2008
@@ -27,6 +27,7 @@
     
     private boolean asserted;
     private final PolicyAssertion assertion;
+    private String errorMessage;
     
     public AssertionInfo(PolicyAssertion a) {
         assertion = a;
@@ -37,6 +38,14 @@
     public void setAsserted(boolean a) {
         asserted = a;
     }
+    public void setNotAsserted(String message) {
+        asserted = false;
+        errorMessage = message;
+    }
+    public String getErrorMessage() {
+        return errorMessage;
+    }
+    
     public PolicyAssertion getAssertion() {
         return assertion;
     }

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java?rev=691307&r1=691306&r2=691307&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java (original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java Tue Sep  2 09:30:24 2008
@@ -96,7 +96,22 @@
                 return;
             }
         }
-        throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE, errors));
+        StringBuilder error = new StringBuilder("\n");
+        for (QName name : errors) {
+            Collection<AssertionInfo> ais = getAssertionInfo(name);
+            for (AssertionInfo ai : ais) {
+                if (!ai.isAsserted()) {
+                    error.append("\n      ");
+                    error.append(name.toString());
+                    if (ai.getErrorMessage() != null) {
+                        error.append(": ").append(ai.getErrorMessage());
+                    }
+                }
+            }
+        }
+        
+        
+        throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE, error.toString()));
     }
 
     

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java?rev=691307&r1=691306&r2=691307&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java Tue Sep  2 09:30:24 2008
@@ -28,6 +28,7 @@
 
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
@@ -76,9 +77,11 @@
         
         Node res = invoke(address, "http://schemas.xmlsoap.org/soap/http", "nonmtom.xml");
         
-        assertValid("//faultstring[text()='These policy alternatives can not be satisfied: "
-                    + "[{http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization}"
-                    + "OptimizedMimeSerialization]']", res);
+        NodeList list = assertValid("//faultstring", res);
+        String text = list.item(0).getTextContent();
+        assertTrue(text.contains("These policy alternatives can not be satisfied: "));
+        assertTrue(text.contains("{http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization}"
+                    + "OptimizedMimeSerialization"));
     }
     
     @Test

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java?rev=691307&r1=691306&r2=691307&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java Tue Sep  2 09:30:24 2008
@@ -119,9 +119,10 @@
         } catch (WebServiceException wse) {
             SoapFault sf = (SoapFault)wse.getCause();
             assertEquals("Server", sf.getFaultCode().getLocalPart());
-            assertEquals("These policy alternatives can not be satisfied: "
-                         + "[{http://cxf.apache.org/transports/http/configuration}server]",
-                         sf.getMessage());
+            
+            String text = sf.getMessage();
+            assertTrue(text.contains("{http://cxf.apache.org/transports/http/configuration}server"));
+            
             // assertEquals("INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS", ex.getCode());
         }