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/08/26 16:43:19 UTC

svn commit: r689097 - in /cxf/branches/2.1.x-fixes: ./ api/src/main/java/org/apache/cxf/service/model/ api/src/main/java/org/apache/cxf/ws/policy/ api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/ api/src/main/java/org/apache/cxf/ws/policy/...

Author: dkulp
Date: Tue Aug 26 07:43:17 2008
New Revision: 689097

URL: http://svn.apache.org/viewvc?rev=689097&view=rev
Log:
Output better error message when policy isn't asserted (port from 2.2 line)

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/service/model/AbstractPropertiesHolder.java
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java
    cxf/branches/2.1.x-fixes/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/DOMUtils.java
    cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
    cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistryImpl.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
    cxf/branches/2.1.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusClientServerTestBase.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 26 07:43:17 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687363,687387,687463,687543,687722,687798,687814,687817
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Aug 26 07:43:17 2008
@@ -1 +1 @@
-/cxf/trunk:1-686342,686344-686363,686764,686820,687096,687363,687387,687463,687543,687722,687798,687814,687817
+/cxf/trunk:1-686342,686344-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/service/model/AbstractPropertiesHolder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/service/model/AbstractPropertiesHolder.java?rev=689097&r1=689096&r2=689097&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/service/model/AbstractPropertiesHolder.java (original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/service/model/AbstractPropertiesHolder.java Tue Aug 26 07:43:17 2008
@@ -62,7 +62,17 @@
         }
     }
     
-    
+    public boolean containsExtensor(Object el) {
+        Object exts[] = extensors.get();
+        if (exts != null) {
+            for (Object o : exts) {
+                if (o == el) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
     public void addExtensor(Object el) {
         Object exts[] = extensors.get();
         Object exts2[];

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties?rev=689097&r1=689096&r2=689097&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties (original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties Tue Aug 26 07:43:17 2008
@@ -18,5 +18,5 @@
 #    under the License.
 #
 #
-NO_ALTERNATIVE_EXC = None of the policy alternatives can be satisfied.
+NO_ALTERNATIVE_EXC = These policy alternatives can not be satisfied: {0}
 NOT_ASSERTED_EXC = Assertion of type {0} could not be asserted.
\ No newline at end of file

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=689097&r1=689096&r2=689097&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 Aug 26 07:43:17 2008
@@ -74,27 +74,32 @@
 
     }
     
-    public boolean supportsAlternative(Collection<PolicyAssertion> alternative) {
+    public boolean supportsAlternative(Collection<PolicyAssertion> alternative,
+                                       List<QName> errors) {
+        boolean pass = true;
         for (PolicyAssertion a : alternative) {          
             if (!a.isAsserted(this)) {
-                return false;
+                errors.add(a.getName());
+                pass = false;
             }
         }
-        return true;
+        return pass;
     }
     
     public void checkEffectivePolicy(Policy policy) {
+        List<QName> errors = new ArrayList<QName>();
         Iterator alternatives = policy.getAlternatives();
         while (alternatives.hasNext()) {      
             List<PolicyAssertion> alternative = CastUtils.cast((List)alternatives.next(), 
                                                                PolicyAssertion.class);
-            if (supportsAlternative(alternative)) {
+            if (supportsAlternative(alternative, errors)) {
                 return;
             }
         }
-        throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE));
+        throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE, errors));
     }
-        
+
+    
     public void check() {
         for (Collection<AssertionInfo> ais : values()) {
             for (AssertionInfo ai : ais) {

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java?rev=689097&r1=689096&r2=689097&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java (original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java Tue Aug 26 07:43:17 2008
@@ -35,6 +35,13 @@
 public interface PolicyInterceptorProviderRegistry 
     extends Registry<QName, PolicyInterceptorProvider> {
     
+    /**
+     * Register the builder for all qnames from the provider
+     * getAssertionTypes call.
+     * @param provider the provider to register 
+     */
+    void register(PolicyInterceptorProvider provider);
+    
     List<Interceptor> getInterceptors(Collection<PolicyAssertion> alterative, boolean out, boolean fault);
 
 }

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java?rev=689097&r1=689096&r2=689097&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java (original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java Tue Aug 26 07:43:17 2008
@@ -36,6 +36,13 @@
     protected Bus bus;
     private Collection<QName> knownElements = new ArrayList<QName>();
     
+    public PrimitiveAssertionBuilder() {
+        knownElements = new ArrayList<QName>();
+    }
+    public PrimitiveAssertionBuilder(Collection<QName> els) {
+        knownElements = els;
+    }
+    
     public void setBus(Bus b) {
         bus = b;
     }

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java?rev=689097&r1=689096&r2=689097&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java (original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java Tue Aug 26 07:43:17 2008
@@ -19,6 +19,10 @@
 
 package org.apache.cxf.ws.policy.builder.xml;
 
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
 import org.w3c.dom.Element;
 
 import org.apache.cxf.ws.policy.PolicyAssertion;
@@ -26,6 +30,14 @@
 
 public class XMLPrimitiveAssertionBuilder extends PrimitiveAssertionBuilder {
  
+    public XMLPrimitiveAssertionBuilder() {
+        super();
+    }
+    public XMLPrimitiveAssertionBuilder(Collection<QName> els) {
+        super(els);
+    }
+    
+    
     public PolicyAssertion build(Element element) {
         return new XmlPrimitiveAssertion(element, getPolicyConstants());
     }

Modified: cxf/branches/2.1.x-fixes/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java?rev=689097&r1=689096&r2=689097&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java (original)
+++ cxf/branches/2.1.x-fixes/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java Tue Aug 26 07:43:17 2008
@@ -97,8 +97,8 @@
         alt2.add(c);
                 
         control.replay();
-        assertTrue(!aim.supportsAlternative(alt1));
-        assertTrue(aim.supportsAlternative(alt2));
+        assertTrue(!aim.supportsAlternative(alt1, new ArrayList<QName>()));
+        assertTrue(aim.supportsAlternative(alt2, new ArrayList<QName>()));
         control.verify();     
     }  
     

Modified: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/DOMUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/DOMUtils.java?rev=689097&r1=689096&r2=689097&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/DOMUtils.java (original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/DOMUtils.java Tue Aug 26 07:43:17 2008
@@ -235,6 +235,17 @@
         }
         return (Element) n;
     }
+    public static Element getNextElement(Element el) {
+        Node nd = el.getNextSibling();
+        while (nd != null) {
+            if (nd.getNodeType() == Node.ELEMENT_NODE) {
+                return (Element)nd;
+            }
+            nd = nd.getNextSibling();
+        }
+        return null;
+    }
+    
     public static Element getFirstChildWithName(Element parent, QName q) { 
         String ns = q.getNamespaceURI();
         String lp = q.getLocalPart();

Modified: cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?rev=689097&r1=689096&r2=689097&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java (original)
+++ cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java Tue Aug 26 07:43:17 2008
@@ -109,7 +109,9 @@
     private void copyExtensors(AbstractPropertiesHolder info, List<?> extList) {
         if (info != null) {
             for (ExtensibilityElement ext : cast(extList, ExtensibilityElement.class)) {
-                info.addExtensor(ext);
+                if (!info.containsExtensor(ext)) {
+                    info.addExtensor(ext);
+                }
             }
         }
     }

Modified: cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistryImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistryImpl.java?rev=689097&r1=689096&r2=689097&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistryImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistryImpl.java Tue Aug 26 07:43:17 2008
@@ -49,6 +49,12 @@
         super(interceptors.createMap());
     }    
 
+    public void register(PolicyInterceptorProvider provider) {
+        for (QName qn : provider.getAssertionTypes()) {
+            super.register(qn, provider);
+        }
+    }
+
     public Class<?> getRegistrationType() {
         return PolicyInterceptorProviderRegistry.class;
     }

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=689097&r1=689096&r2=689097&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 Aug 26 07:43:17 2008
@@ -76,7 +76,9 @@
         
         Node res = invoke(address, "http://schemas.xmlsoap.org/soap/http", "nonmtom.xml");
         
-        assertValid("//faultstring[text()='None of the policy alternatives can be satisfied.']", res);
+        assertValid("//faultstring[text()='These policy alternatives can not be satisfied: "
+                    + "[{http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization}"
+                    + "OptimizedMimeSerialization]']", res);
     }
     
     @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=689097&r1=689096&r2=689097&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 Aug 26 07:43:17 2008
@@ -119,7 +119,9 @@
         } catch (WebServiceException wse) {
             SoapFault sf = (SoapFault)wse.getCause();
             assertEquals("Server", sf.getFaultCode().getLocalPart());
-            assertEquals("None of the policy alternatives can be satisfied.", sf.getMessage());
+            assertEquals("These policy alternatives can not be satisfied: "
+                         + "[{http://cxf.apache.org/transports/http/configuration}server]",
+                         sf.getMessage());
             // assertEquals("INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS", ex.getCode());
         }
         

Modified: cxf/branches/2.1.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusClientServerTestBase.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusClientServerTestBase.java?rev=689097&r1=689096&r2=689097&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusClientServerTestBase.java (original)
+++ cxf/branches/2.1.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusClientServerTestBase.java Tue Aug 26 07:43:17 2008
@@ -60,17 +60,18 @@
         BusFactory.setDefaultBus(bus);
     }
     
-    public static void createStaticBus(String config) throws Exception {
+    public static Bus createStaticBus(String config) throws Exception {
         defaultConfigFileName = config;
-        createStaticBus();
+        return createStaticBus();
     }
-    public static void createStaticBus() throws Exception {
+    public static Bus createStaticBus() throws Exception {
         if (defaultConfigFileName != null) {
             System.setProperty("cxf.config.file", defaultConfigFileName);
         }
         BusFactory bf = BusFactory.newInstance();
         staticBus = bf.createBus();
-        BusFactory.setDefaultBus(staticBus);  
+        BusFactory.setDefaultBus(staticBus);
+        return staticBus;
     }
     
     @After