You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by an...@apache.org on 2007/04/11 10:33:18 UTC

svn commit: r527411 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/message/ rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/...

Author: andreasmyth
Date: Wed Apr 11 01:33:10 2007
New Revision: 527411

URL: http://svn.apache.org/viewvc?view=rev&rev=527411
Log:
[JIRA CXF-473] WS-Policification of HTTPServerPolicy
* Implementation of compatible and equals for http server policy.
* All policy interceptors to throw Fault (wrapping PolicyException) instead of PolicyException.
* System test demonstrating the use of HTTPServerPolicy assertions in wsp:Policy elements attached to different subjects (port, operation, binding,...): policies attached to operation and message subjects must - if used - be equal to effective policy for endpoint.
* HTTPDestination initialisation to take into account policies.
* Removed static method copyProperties added to MessageImpl earlier - it was never used.

Added:
    incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilderTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter.wsdl   (with props)
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java
    incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/Messages.properties
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java
    incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilderTest.java
    incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyLoggingInterceptor.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java Wed Apr 11 01:33:10 2007
@@ -150,10 +150,4 @@
             m2.setContent(c, m1.getContent(c));
         }
     }
-    
-    public static void copyProperties(Message m1, Message m2) {
-        for (String s : m1.keySet()) {
-            m2.put(s, m1.get(s));
-        }        
-    }
 }

Modified: incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java (original)
+++ incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java Wed Apr 11 01:33:10 2007
@@ -54,6 +54,7 @@
 import org.apache.cxf.transports.http.QueryHandlerRegistry;
 import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.ws.policy.PolicyEngine;
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
 import org.easymock.classextension.EasyMock;
 import org.junit.After;
@@ -324,6 +325,8 @@
         } else {
             bus = EasyMock.createMock(Bus.class);
             bus.getExtension(EndpointResolverRegistry.class);
+            EasyMock.expectLastCall().andReturn(null);
+            bus.getExtension(PolicyEngine.class);
             EasyMock.expectLastCall().andReturn(null);
             EasyMock.replay(bus);
         }

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java Wed Apr 11 01:33:10 2007
@@ -35,6 +35,7 @@
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
@@ -52,13 +53,17 @@
 import org.apache.cxf.transport.AbstractDestination;
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.ConduitInitiator;
+import org.apache.cxf.transport.http.policy.PolicyUtils;
 import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.ws.policy.Assertor;
+import org.apache.cxf.ws.policy.PolicyEngine;
 
 /**
  * Common base for HTTP Destination implementations.
  */
-public abstract class AbstractHTTPDestination extends AbstractDestination implements Configurable {
+public abstract class AbstractHTTPDestination extends AbstractDestination 
+    implements Configurable, Assertor {
     
     public static final String HTTP_REQUEST = "HTTP.REQUEST";
     public static final String HTTP_RESPONSE = "HTTP.RESPONSE";
@@ -246,7 +251,14 @@
     }
 
     private void initConfig() {
-        this.server = endpointInfo.getTraversedExtensor(new HTTPServerPolicy(), HTTPServerPolicy.class);
+        PolicyEngine engine = bus.getExtension(PolicyEngine.class);
+        // for a decoupled endpoint there is no service info
+        if (null != engine && engine.isEnabled() && null != endpointInfo.getService()) {
+            server = PolicyUtils.getServer(engine, endpointInfo, this);
+        }
+        if (null == server) {
+            server = endpointInfo.getTraversedExtensor(new HTTPServerPolicy(), HTTPServerPolicy.class);
+        }
         this.sslServer = endpointInfo.getTraversedExtensor(null, SSLServerPolicy.class);
     }
 
@@ -450,4 +462,16 @@
     public void setSslServer(SSLServerPolicy sslServer) {
         this.sslServer = sslServer;
     }
+
+    public void assertMessage(Message message) {
+        PolicyUtils.assertServerPolicy(message, server); 
+    }
+
+    public boolean canAssert(QName type) {
+        return PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME.equals(type); 
+    }
+    
+    
+    
+    
 }

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java Wed Apr 11 01:33:10 2007
@@ -73,7 +73,14 @@
             }
             JaxbAssertion<HTTPClientPolicy> other = JaxbAssertion.cast((Assertion)policyComponent);
             return PolicyUtils.equals(this.getData(), other.getData());  
-        }      
+        }
+        
+        @Override
+        protected Assertion cloneMandatory() {
+            HTTPClientPolicyAssertion a = new HTTPClientPolicyAssertion();
+            a.setData(getData());
+            return a;        
+        }
     }
     
     

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java Wed Apr 11 01:33:10 2007
@@ -25,6 +25,7 @@
 import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion;
 import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertionBuilder;
 import org.apache.neethi.Assertion;
+import org.apache.neethi.PolicyComponent;
 
 /**
  * 
@@ -46,12 +47,39 @@
             if (null == compatible) {
                 return null;
             }
-            JaxbAssertion<HTTPServerPolicy> ca = 
-                new JaxbAssertion<HTTPServerPolicy>(PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME, 
-                    a.isOptional() && b.isOptional());
+            
+            JaxbAssertion<HTTPServerPolicy> ca = buildAssertion();
+            ca.setOptional(a.isOptional() && b.isOptional());
             ca.setData(compatible);
             return ca;
         }
         return null;
+    }
+    
+    @Override
+    protected JaxbAssertion<HTTPServerPolicy> buildAssertion() {
+        return new HTTPServerPolicyAssertion();
+    }
+    
+    class HTTPServerPolicyAssertion extends JaxbAssertion<HTTPServerPolicy> {
+        HTTPServerPolicyAssertion() {
+            super(PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME, false);
+        }
+
+        @Override
+        public boolean equal(PolicyComponent policyComponent) {
+            if (!super.equal(policyComponent)) {
+                return false;
+            }
+            JaxbAssertion<HTTPServerPolicy> other = JaxbAssertion.cast((Assertion)policyComponent);
+            return PolicyUtils.equals(this.getData(), other.getData());  
+        }
+        
+        @Override
+        protected Assertion cloneMandatory() {
+            HTTPServerPolicyAssertion a = new HTTPServerPolicyAssertion();
+            a.setData(getData());
+            return a;        
+        } 
     }
 }

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/Messages.properties?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/Messages.properties (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/Messages.properties Wed Apr 11 01:33:10 2007
@@ -19,3 +19,4 @@
 #
 #
 INCOMPATIBLE_HTTPCLIENTPOLICY_ASSERTIONS = Incompatible HTTPClientPolicy assertions.
+INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS = Incompatible HTTPServerPolicy assertions.

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java Wed Apr 11 01:33:10 2007
@@ -31,6 +31,7 @@
 import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
 import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
 import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
 import org.apache.cxf.ws.policy.AssertionInfo;
@@ -63,11 +64,13 @@
 
 
     /**
-     * Returns a HTTPClientPolicy  that is compatible with the assertions included in the
-     * service, endpoint, operation and message policy subjects AND the HTTPClientPolicy configured
-     * for the conduit. 
+     * Returns a HTTPClientPolicy that is compatible with the assertions included in the
+     * service, endpoint, operation and message policy subjects AND the HTTPClientPolicy 
+     * passed as a second argument.
      * @param message the message
+     * @param confPolicy the additional policy to be compatible with
      * @return the HTTPClientPolicy for the message
+     * @throws PolicyException if no compatible HTTPClientPolicy can be determined
      */
     public static HTTPClientPolicy getClient(Message message, HTTPClientPolicy confPolicy) {
         AssertionInfoMap amap =  message.get(AssertionInfoMap.class);
@@ -96,12 +99,51 @@
     }
     
     /**
+     * Returns a HTTPServerPolicy that is compatible with the assertions included in the
+     * service, endpoint, operation and message policy subjects AND the HTTPServerPolicy 
+     * passed as a second argument.
+     * @param message the message
+     * @param confPolicy the additional policy to be compatible with
+     * @return the HTTPServerPolicy for the message
+     * @throws PolicyException if no compatible HTTPServerPolicy can be determined
+     */
+    public static HTTPServerPolicy getServer(Message message, HTTPServerPolicy confPolicy) {
+        AssertionInfoMap amap =  message.get(AssertionInfoMap.class);
+        if (null == amap) {
+            return confPolicy;
+        }
+        Collection<AssertionInfo> ais = amap.get(HTTPSERVERPOLICY_ASSERTION_QNAME);
+        if (null == ais) {
+            return confPolicy;
+        }
+        Collection<Assertion> alternative = new ArrayList<Assertion>();
+        for (AssertionInfo ai : ais) {
+            alternative.add(ai.getAssertion());
+        }
+        HTTPServerPolicy compatible = getServer(alternative);
+        if (null != compatible && null != confPolicy) {
+            if (PolicyUtils.compatible(compatible, confPolicy)) {
+                compatible = intersect(compatible, confPolicy);
+            } else {
+                LogUtils.log(LOG, Level.SEVERE, "INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS");
+                throw new PolicyException(new org.apache.cxf.common.i18n.Message(
+                    "INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS", LOG));
+            }
+        }
+        return compatible;
+    }
+  
+    /**
      * Returns a HTTPClientPolicy that is compatible with the assertions included in the
      * service and endpoint policy subjects, or null if there are no such assertions.
+     * @param pe the policy engine
+     * @param ei the endpoint info
+     * @param c the conduit
+     * @return the compatible policy
+     * @throws PolicyException if no compatible HTTPClientPolicy can be determined
      */
     public static HTTPClientPolicy getClient(PolicyEngine pe, EndpointInfo ei, Conduit c) {
         Collection<Assertion> alternative = pe.getClientEndpointPolicy(ei, c).getChosenAlternative();
-
         HTTPClientPolicy compatible = null;
         for (Assertion a : alternative) {
             if (HTTPCLIENTPOLICY_ASSERTION_QNAME.equals(a.getName())) {
@@ -119,9 +161,44 @@
             }
         }
         return compatible;
-
     }
     
+    /**
+     * Returns a HTTPServerPolicy that is compatible with the assertions included in the
+     * service and endpoint policy subjects, or null if there are no such assertions.
+     * @param pe the policy engine
+     * @param ei the endpoint info
+     * @param d the destination
+     * @return the compatible policy
+     * @throws PolicyException if no compatible HTTPServerPolicy can be determined
+     */
+    public static HTTPServerPolicy getServer(PolicyEngine pe, EndpointInfo ei, Destination d) {
+        Collection<Assertion> alternative = pe.getServerEndpointPolicy(ei, d).getChosenAlternative();
+        HTTPServerPolicy compatible = null;
+        for (Assertion a : alternative) {
+            if (HTTPSERVERPOLICY_ASSERTION_QNAME.equals(a.getName())) {
+                HTTPServerPolicy p = JaxbAssertion.cast(a, HTTPServerPolicy.class).getData();
+                if (null == compatible) {
+                    compatible = p;
+                } else {
+                    compatible = intersect(compatible, p);
+                    if (null == compatible) {
+                        LogUtils.log(LOG, Level.SEVERE, "INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS");
+                        throw new PolicyException(new org.apache.cxf.common.i18n.Message(
+                            "INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS", LOG));
+                    }
+                }
+            }
+        }
+        return compatible;
+    }
+    
+    /**
+     * Asserts all HTTPClientPolicy assertions that are compatible with the specified
+     * client policy.
+     * @param message the current message
+     * @param client the client policy
+     */
     public static void assertClientPolicy(Message message, HTTPClientPolicy client) {
        
         AssertionInfoMap aim = message.get(AssertionInfoMap.class);
@@ -151,9 +228,43 @@
     }
     
     /**
+     * Asserts all HTTPServerPolicy assertions that are equal to the specified
+     * server policy.
+     * @param message the current message
+     * @param server the server policy
+     */
+    public static void assertServerPolicy(Message message, HTTPServerPolicy server) {
+        
+        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
+        if (null == aim) {
+            return;
+        }
+        Collection<AssertionInfo> ais = aim.get(HTTPSERVERPOLICY_ASSERTION_QNAME);          
+        if (null == ais || ais.size() == 0) {
+            return;
+        }   
+ 
+        // assert all assertion(s) that are equal to the value configured for the conduit
+        
+        if (MessageUtils.isOutbound(message)) {  
+            for (AssertionInfo ai : ais) {
+                ai.setAsserted(true);
+            }
+        } else {
+            for (AssertionInfo ai : ais) {
+                HTTPServerPolicy p = (JaxbAssertion.cast(ai.getAssertion(), 
+                                                          HTTPServerPolicy.class)).getData(); 
+                if (equals(p, server)) {
+                    ai.setAsserted(true);                 
+                }
+            }
+        } 
+    }
+    
+    /**
      * Checks if two HTTPClientPolicy objects are compatible.
-     * @param p1 one policy
-     * @param p2 another policy
+     * @param p1 one client policy
+     * @param p2 another client policy
      * @return true iff policies are compatible
      */
     public static boolean compatible(HTTPClientPolicy p1, HTTPClientPolicy p2) {
@@ -198,6 +309,8 @@
             compatible &= compatible(p1.getCookie(), p2.getCookie());
         }
         
+        // REVISIT: Should compatibility require strict equality?
+        
         if (compatible) {
             compatible &= compatible(p1.getDecoupledEndpoint(), p2.getDecoupledEndpoint());
         }
@@ -237,7 +350,7 @@
  
     
     /**
-     * Returns a new HTTPClientPolicy which is compatible with the two specified policies or
+     * Returns a new HTTPClientPolicy that is compatible with the two specified policies or
      * null if no compatible policy can be determined.
      * @param p1 one policy
      * @param p2 another policy
@@ -306,9 +419,55 @@
     }
     
     /**
+     * Determines if two HTTPClientPolicy objects are equal.
+     * REVISIT: Check if this can be replaced by a generated equals method.
+     * @param p1 one client policy
+     * @param p2 another client policy
+     * @return true iff the two policies are equal
+     */
+    public static boolean equals(HTTPClientPolicy p1, HTTPClientPolicy p2) {
+        if (p1 == p2) {
+            return true;
+        }
+        boolean result = true;
+        result &= (p1.isAllowChunking() == p2.isAllowChunking())
+            && (p1.isAutoRedirect() == p2.isAutoRedirect())
+            && equals(p1.getAccept(), p2.getAccept())
+            && equals(p1.getAcceptEncoding(), p2.getAcceptEncoding())
+            && equals(p1.getAcceptLanguage(), p2.getAcceptLanguage())
+            && equals(p1.getBrowserType(), p2.getBrowserType());
+        if (!result) {
+            return false;
+        }
+      
+        result &= (p1.getCacheControl() == null 
+                ? p2.getCacheControl() == null 
+                : p1.getCacheControl().value().equals(p2.getCacheControl().value())
+                && p1.getConnection().value().equals(p2.getConnection().value()))        
+            && (p1.getConnectionTimeout() == p2.getConnectionTimeout())
+            && equals(p1.getContentType(), p2.getContentType())
+            && equals(p1.getCookie(), p2.getCookie())
+            && equals(p1.getDecoupledEndpoint(), p2.getDecoupledEndpoint())
+            && equals(p1.getHost(), p2.getHost());
+        if (!result) {
+            return false;
+        } 
+
+        result &= equals(p1.getProxyServer(), p2.getProxyServer())
+            && (p1.isSetProxyServerPort() 
+                ? p1.getProxyServerPort() == p2.getProxyServerPort()
+                : !p2.isSetProxyServerPort())
+            && p1.getProxyServerType().value().equals(p2.getProxyServerType().value())
+            && (p1.getReceiveTimeout() == p2.getReceiveTimeout())
+            && equals(p1.getReferer(), p2.getReferer());
+        
+        return result;
+    }
+    
+    /**
      * Checks if two HTTPServerPolicy objects are compatible.
-     * @param p1 one policy
-     * @param p2 another policy
+     * @param p1 one server policy
+     * @param p2 another server policy
      * @return true iff policies are compatible
      */
     public static boolean compatible(HTTPServerPolicy p1, HTTPServerPolicy p2) {
@@ -360,7 +519,7 @@
     }
     
     /**
-     * Returns a new HTTPServerPolicy which is compatible with the two specified policies or
+     * Returns a new HTTPServerPolicy that is compatible with the two specified policies or
      * null if no compatible policy can be determined.
      * @param p1 one policy
      * @param p2 another policy
@@ -409,6 +568,38 @@
         return p;
     }
     
+    /**
+     * Determines if two HTTPServerPolicy objects are equal.
+     * REVISIT: Check if this can be replaced by a generated equals method.
+     * @param p1 one server policy
+     * @param p2 another server policy
+     * @return true iff the two policies are equal
+     */
+    public static boolean equals(HTTPServerPolicy p1, HTTPServerPolicy p2) {
+        if (p1 == p2) {
+            return true;
+        }
+        boolean result = true;
+
+        result &= (p1.isHonorKeepAlive() == p2.isHonorKeepAlive())
+            && (p1.getCacheControl() == null 
+                ? p2.getCacheControl() == null 
+                : p1.getCacheControl().value().equals(p2.getCacheControl().value()))
+            && equals(p1.getContentEncoding(), p2.getContentEncoding())
+            && equals(p1.getContentLocation(), p2.getContentLocation())
+            && equals(p1.getContentType(), p2.getContentType());
+        if (!result) {
+            return false;
+        }
+        result &= (p1.getReceiveTimeout() == p2.getReceiveTimeout())
+            && equals(p1.getRedirectURL(), p2.getRedirectURL())
+            && equals(p1.getServerType(), p2.getServerType())
+            && (p1.isSuppressClientReceiveErrors() == p2.isSuppressClientReceiveErrors())
+            && (p1.isSuppressClientSendErrors() == p2.isSuppressClientSendErrors());
+        
+        return result;
+    }
+    
     private static String combine(String s1, String s2) {
         return s1 == null ? s2 : s1;
     }
@@ -443,6 +634,28 @@
         return compatible;
     }
     
+    private static HTTPServerPolicy getServer(Collection<Assertion> alternative) {      
+        HTTPServerPolicy compatible = null;
+        for (Assertion a : alternative) {
+            if (HTTPSERVERPOLICY_ASSERTION_QNAME.equals(a.getName())) {
+                HTTPServerPolicy p = JaxbAssertion.cast(a, HTTPServerPolicy.class).getData();
+                if (null == compatible) {
+                    compatible = p;
+                } else {
+                    compatible = intersect(compatible, p);
+                    if (null == compatible) {
+                        LogUtils.log(LOG, Level.SEVERE, "INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS");
+                        org.apache.cxf.common.i18n.Message m = 
+                            new org.apache.cxf.common.i18n.Message(
+                                "INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS", LOG);
+                        throw new PolicyException(m);
+                    }
+                }
+            }
+        }
+        return compatible;
+    }
+    
     public static String toString(HTTPClientPolicy p) {
         StringBuffer buf = new StringBuffer();
         buf.append(p);
@@ -452,41 +665,19 @@
         buf.append(p.getReceiveTimeout());
         buf.append("])");
         return buf.toString();
-        
     }
     
-    public static boolean equals(HTTPClientPolicy p1, HTTPClientPolicy p2) {
-        if (p1 == p2) {
-            return true;
-        }
-        boolean result = true;
-        result &= p1.isAllowChunking() == p2.isAllowChunking()
-            && p1.isAutoRedirect() == p2.isAutoRedirect()
-            && equals(p1.getAccept(), p2.getAccept())
-            && equals(p1.getAcceptEncoding(), p2.getAcceptEncoding())
-            && equals(p1.getAcceptLanguage(), p2.getAcceptLanguage())
-            && equals(p1.getBrowserType(), p2.getBrowserType());
-        if (!result) {
-            return false;
-        }
+    public static String toString(HTTPServerPolicy p) {
+        StringBuffer buf = new StringBuffer();
+        buf.append(p);
+        buf.append("[ContentType=\"");
+        buf.append(p.getContentType());
+        buf.append("\", ReceiveTimeout=");
+        buf.append(p.getReceiveTimeout());
+        buf.append("])");
+        return buf.toString();
         
-        result &= p1.getCacheControl() == null 
-                ? p2.getCacheControl() == null 
-                : p1.getCacheControl().value().equals(p2.getCacheControl().value())
-                && p1.getConnection().value().equals(p2.getConnection().value())        
-            && p1.getConnectionTimeout() == p2.getConnectionTimeout()
-            && equals(p1.getContentType(), p2.getContentType())
-            && equals(p1.getCookie(), p2.getCookie())
-            && equals(p1.getDecoupledEndpoint(), p2.getDecoupledEndpoint())
-            && equals(p1.getHost(), p2.getHost());
-        if (!result) {
-            return false;
-        }
-        result &= equals(p1.getProxyServer(), p2.getProxyServer())
-            && p1.getProxyServerPort() == p2.getProxyServerPort()
-            && p1.getProxyServerType().value().equals(p2.getProxyServerType().value())
-            && p1.getReceiveTimeout() == p2.getReceiveTimeout()
-            && equals(p1.getReferer(), p2.getReferer()); 
-        return result;
     }
+    
+    
 }

Modified: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilderTest.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilderTest.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilderTest.java Wed Apr 11 01:33:10 2007
@@ -30,6 +30,7 @@
  */
 public class HTTPClientAssertionBuilderTest extends Assert {
 
+    @Test
     public void testBuildCompatible() throws Exception {
         HTTPClientAssertionBuilder ab = new HTTPClientAssertionBuilder();
         JaxbAssertion<HTTPClientPolicy>  a = ab.buildAssertion();
@@ -53,6 +54,7 @@
         assertTrue(!a.isOptional());
     }
     
+    @Test
     public void testHTTPCLientPolicyAssertionEqual() throws Exception {
         HTTPClientAssertionBuilder ab = new HTTPClientAssertionBuilder();
         JaxbAssertion<HTTPClientPolicy>  a = ab.buildAssertion();        
@@ -66,7 +68,6 @@
         b.setData(pb);
         assertTrue(a.equal(b));
         pa.setDecoupledEndpoint("http://localhost:9999/decoupled_endpoint");
-        assertTrue(!a.equal(b));       
-    }
-    
+        assertTrue(!a.equal(b));  
+    }    
 }

Added: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilderTest.java?view=auto&rev=527411
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilderTest.java (added)
+++ incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilderTest.java Wed Apr 11 01:33:10 2007
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.transport.http.policy;
+
+import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
+import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion;
+import org.apache.neethi.Assertion;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class HTTPServerAssertionBuilderTest extends Assert {
+
+    @Test
+    public void testBuildCompatible() throws Exception {
+        HTTPServerAssertionBuilder ab = new HTTPServerAssertionBuilder();
+        JaxbAssertion<HTTPServerPolicy>  a = ab.buildAssertion();
+        HTTPServerPolicy pa = new HTTPServerPolicy();
+        a.setData(pa);
+        JaxbAssertion<HTTPServerPolicy> b = ab.buildAssertion();
+        HTTPServerPolicy pb = new HTTPServerPolicy();
+        b.setData(pb);
+        JaxbAssertion<HTTPServerPolicy> c = 
+            JaxbAssertion.cast(ab.buildCompatible(a, b), HTTPServerPolicy.class);
+        assertNotNull(c);        
+    }
+    
+    @Test
+    public void testBuildAssertion() throws Exception {
+        HTTPServerAssertionBuilder ab = new HTTPServerAssertionBuilder();
+        Assertion a = ab.buildAssertion();
+        assertTrue(a instanceof JaxbAssertion);
+        assertTrue(a instanceof HTTPServerAssertionBuilder.HTTPServerPolicyAssertion);
+        assertEquals(PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME, a.getName());
+        assertTrue(!a.isOptional());
+    }
+    
+    @Test
+    public void testHTTPServerPolicyAssertionEqual() throws Exception {
+        HTTPServerAssertionBuilder ab = new HTTPServerAssertionBuilder();
+        JaxbAssertion<HTTPServerPolicy>  a = ab.buildAssertion();        
+        assertTrue(a.equal(a));        
+        JaxbAssertion<HTTPServerPolicy> b = ab.buildAssertion();
+        assertTrue(a.equal(b));
+        HTTPServerPolicy pa = new HTTPServerPolicy();
+        a.setData(pa);
+        assertTrue(a.equal(a));
+        HTTPServerPolicy pb = new HTTPServerPolicy();
+        b.setData(pb);
+        assertTrue(a.equal(b));
+        pa.setSuppressClientSendErrors(true);
+        assertTrue(!a.equal(b));       
+    }
+    
+}

Propchange: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java Wed Apr 11 01:33:10 2007
@@ -85,6 +85,20 @@
         p = PolicyUtils.intersect(p1, p2);
         assertTrue(!p.isAllowChunking());
     }
+    
+    @Test
+    public void testEqualClientPolicies() {
+        HTTPClientPolicy p1 = new HTTPClientPolicy();
+        assertTrue(PolicyUtils.equals(p1, p1));
+        HTTPClientPolicy p2 = new HTTPClientPolicy();        
+        assertTrue(PolicyUtils.equals(p1, p2));
+        p1.setDecoupledEndpoint("http://localhost:8080/decoupled");
+        assertTrue(!PolicyUtils.equals(p1, p2));
+        p2.setDecoupledEndpoint("http://localhost:8080/decoupled");
+        assertTrue(PolicyUtils.equals(p1, p2));
+        p1.setReceiveTimeout(10000L);
+        assertTrue(!PolicyUtils.equals(p1, p2));
+    }
 
     @Test
     public void testCompatibleServerPolicies() {
@@ -104,7 +118,7 @@
         p2.setSuppressClientSendErrors(true);
         assertTrue("Policies are compatible.", PolicyUtils.compatible(p1, p2));
     }
-
+        
     @Test
     public void testIntersectServerPolicies() {
         HTTPServerPolicy p1 = new HTTPServerPolicy();
@@ -124,8 +138,32 @@
         assertTrue(p.isSuppressClientSendErrors());
     }
 
+    
+    @Test
+    public void testEqualServerPolicies() {
+        HTTPServerPolicy p1 = new HTTPServerPolicy();
+        assertTrue(PolicyUtils.equals(p1, p1));
+        HTTPServerPolicy p2 = new HTTPServerPolicy();        
+        assertTrue(PolicyUtils.equals(p1, p2));
+        p1.setContentEncoding("encoding");
+        assertTrue(!PolicyUtils.equals(p1, p2));
+        p2.setContentEncoding("encoding");
+        assertTrue(PolicyUtils.equals(p1, p2));
+        p1.setSuppressClientSendErrors(true);
+        assertTrue(!PolicyUtils.equals(p1, p2));
+    }
+    
     @Test
     public void testAssertClientPolicyNoop() {
+        testAssertPolicyNoop(true);
+    }
+    
+    @Test
+    public void testAssertServerPolicyNoop() {
+        testAssertPolicyNoop(false);
+    }
+    
+    void testAssertPolicyNoop(boolean isRequestor) {
         Message message = control.createMock(Message.class);
         EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
         control.replay();
@@ -137,7 +175,11 @@
         AssertionInfoMap aim = new AssertionInfoMap(as);
         EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
         control.replay();
-        PolicyUtils.assertClientPolicy(message, null);
+        if (isRequestor) {
+            PolicyUtils.assertClientPolicy(message, null);
+        } else {
+            PolicyUtils.assertServerPolicy(message, null);
+        }
         control.verify();
     }
 
@@ -193,6 +235,67 @@
         assertTrue(eai.isAsserted());
         assertTrue(cmai.isAsserted());
         assertTrue(outbound ? !icmai.isAsserted() : icmai.isAsserted());
+        control.verify();
+    }
+    
+    @Test
+    public void testAssertServerPolicyOutbound() {
+        testAssertServerPolicy(true);
+    }
+
+    @Test
+    public void testAssertServerPolicyInbound() {
+        testAssertServerPolicy(false);
+    }
+
+    void testAssertServerPolicy(boolean outbound) {
+        Message message = control.createMock(Message.class);
+        HTTPServerPolicy ep = new HTTPServerPolicy();
+        HTTPServerPolicy mp = new HTTPServerPolicy();
+        HTTPServerPolicy cmp = new HTTPServerPolicy(); 
+        cmp.setReceiveTimeout(60000L);
+        HTTPServerPolicy icmp = new HTTPServerPolicy();
+        icmp.setSuppressClientSendErrors(true);
+
+        JaxbAssertion<HTTPServerPolicy> ea = 
+            new JaxbAssertion<HTTPServerPolicy>(PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME, false);
+        ea.setData(ep);
+        JaxbAssertion<HTTPServerPolicy> ma = 
+            new JaxbAssertion<HTTPServerPolicy>(PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME, false);
+        ma.setData(mp);
+        JaxbAssertion<HTTPServerPolicy> cma = 
+            new JaxbAssertion<HTTPServerPolicy>(PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME, false);
+        cma.setData(cmp);
+        JaxbAssertion<HTTPServerPolicy> icma = 
+            new JaxbAssertion<HTTPServerPolicy>(PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME, false);
+        icma.setData(icmp);
+
+        AssertionInfo eai = new AssertionInfo(ea);
+        AssertionInfo mai = new AssertionInfo(ma);
+        AssertionInfo cmai = new AssertionInfo(cma);
+        AssertionInfo icmai = new AssertionInfo(icma);
+
+        AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, Assertion.class));
+        Collection<AssertionInfo> ais = new ArrayList<AssertionInfo>();
+        ais.add(eai);
+        ais.add(mai);
+        ais.add(cmai);
+        ais.add(icmai);
+        aim.put(PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME, ais);
+        EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
+        Exchange ex = control.createMock(Exchange.class);
+        EasyMock.expect(message.getExchange()).andReturn(ex);
+        EasyMock.expect(ex.getOutMessage()).andReturn(outbound ? message : null);
+        if (!outbound) {
+            EasyMock.expect(ex.getOutFaultMessage()).andReturn(null);
+        }
+
+        control.replay();
+        PolicyUtils.assertServerPolicy(message, ep);
+        assertTrue(eai.isAsserted());
+        assertTrue(mai.isAsserted());
+        assertTrue(outbound ? cmai.isAsserted() : !cmai.isAsserted());
+        assertTrue(outbound ? icmai.isAsserted() : !icmai.isAsserted());
         control.verify();
     }
 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java Wed Apr 11 01:33:10 2007
@@ -20,6 +20,7 @@
 package org.apache.cxf.ws.policy;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
@@ -42,6 +43,14 @@
     public Bus getBus() {
         return bus;
     }
+    
+    public void handleMessage(Message message) throws Fault {
+        try {
+            handle(message);
+        } catch (PolicyException ex) {
+            throw new Fault(ex);
+        }
+    }
 
     protected void getTransportAssertions(Message message) {
         Exchange ex = message.getExchange();
@@ -88,4 +97,7 @@
         }
         return bfi;
     }
+    
+    protected abstract void handle(Message message) throws PolicyException;
+
 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java Wed Apr 11 01:33:10 2007
@@ -47,7 +47,7 @@
         setPhase(Phase.RECEIVE);
     }
     
-    public void handleMessage(Message msg) {        
+    protected void handle(Message msg) {        
         if (!MessageUtils.isRequestor(msg)) {
             LOG.fine("Not a requestor.");
             return;

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java Wed Apr 11 01:33:10 2007
@@ -47,7 +47,7 @@
         setPhase(Phase.RECEIVE);
     }
     
-    public void handleMessage(Message msg) {        
+    protected void handle(Message msg) {        
         if (!MessageUtils.isRequestor(msg)) {
             LOG.fine("Not a requestor.");
             return;

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java Wed Apr 11 01:33:10 2007
@@ -48,7 +48,7 @@
         setPhase(Phase.SETUP);
     }
     
-    public void handleMessage(Message msg) {
+    protected void handle(Message msg) {
         if (!MessageUtils.isRequestor(msg)) {
             LOG.fine("Not a requestor.");
             return;
@@ -80,7 +80,7 @@
         // add the required interceptors
         
         EffectivePolicy effectivePolicy = pe.getEffectiveClientRequestPolicy(ei, boi, conduit);
-        PolicyUtils.logPolicy(LOG, Level.FINE, "Using effective policy: ", effectivePolicy.getPolicy());
+        PolicyUtils.logPolicy(LOG, Level.FINEST, "Using effective policy: ", effectivePolicy.getPolicy());
         
         List<Interceptor> interceptors = effectivePolicy.getInterceptors();
         for (Interceptor i : interceptors) {            
@@ -92,14 +92,16 @@
         
         Collection<Assertion> assertions = effectivePolicy.getChosenAlternative();
         if (null != assertions) {
-            StringBuffer buf = new StringBuffer();
-            buf.append("Chosen alternative: ");
-            String nl = System.getProperty("line.separator");
-            buf.append(nl);
-            for (Assertion a : assertions) {
-                PolicyUtils.printPolicyComponent(a, buf, 1);
+            if (LOG.isLoggable(Level.FINEST)) {
+                StringBuffer buf = new StringBuffer();
+                buf.append("Chosen alternative: ");
+                String nl = System.getProperty("line.separator");
+                buf.append(nl);
+                for (Assertion a : assertions) {
+                    PolicyUtils.printPolicyComponent(a, buf, 1);
+                }
+                LOG.finest(buf.toString());
             }
-            LOG.fine(buf.toString());
             msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
         }
     }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java Wed Apr 11 01:33:10 2007
@@ -23,7 +23,6 @@
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
@@ -49,8 +48,9 @@
      * is supported.
      *  
      * @param message
+     * @throws PolicyException if none of the alternatives is supported
      */
-    public void handleMessage(Message message) throws Fault {
+    protected void handle(Message message) {
         
         if (!MessageUtils.isRequestor(message)) {
             LOG.fine("Not a requestor.");

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java Wed Apr 11 01:33:10 2007
@@ -23,7 +23,6 @@
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
@@ -47,8 +46,9 @@
      * is supported.
      *  
      * @param message
+     * @throws PolicyException if none of the alternatives is supported
      */
-    public void handleMessage(Message message) throws Fault {
+    protected void handle(Message message) {
         Exchange exchange = message.getExchange();
         assert null != exchange;
         

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java Wed Apr 11 01:33:10 2007
@@ -43,8 +43,9 @@
      * interceptors necessary to assert the assertions are present, it is not possible
      * to predict if these interceptors actually have asserted their assertions.  
      * @param message
+     * @throws PolicyException if none of the alternatives is supported
      */
-    public void handleMessage(Message message) {
+    protected void handle(Message message) {
         
         if (MessageUtils.isPartialResponse(message)) {
             LOG.fine("Not verifying policies on outbound partial response.");

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java Wed Apr 11 01:33:10 2007
@@ -47,7 +47,7 @@
         setPhase(Phase.RECEIVE);
     }
     
-    public void handleMessage(Message msg) {        
+    protected void handle(Message msg) {        
         if (MessageUtils.isRequestor(msg)) {
             LOG.fine("Is a requestor.");
             return;
@@ -68,7 +68,7 @@
             return;
         }
         
-        Destination destination = msg.getDestination();
+        Destination destination = exchange.getDestination();
         
         // We do not know the underlying message type yet - so we pre-emptively add interceptors 
         // that can deal with any messages to this endpoint

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java Wed Apr 11 01:33:10 2007
@@ -49,7 +49,7 @@
         setPhase(Phase.SETUP);
     }
        
-    public void handleMessage(Message msg) {        
+    protected void handle(Message msg) {        
         if (MessageUtils.isRequestor(msg)) {
             LOG.fine("Is a requestor.");
             return;
@@ -76,7 +76,7 @@
             return;
         }
         
-        Destination destination = msg.getDestination();
+        Destination destination = exchange.getDestination();
         
         Exception ex = exchange.get(Exception.class);
         assert null != ex;

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java Wed Apr 11 01:33:10 2007
@@ -48,7 +48,7 @@
         setPhase(Phase.SETUP);
     }
     
-    public void handleMessage(Message msg) {        
+    protected void handle(Message msg) {        
         if (MessageUtils.isRequestor(msg)) {
             LOG.fine("Is a requestor.");
             return;
@@ -75,7 +75,7 @@
             return;
         }
         
-        Destination destination = msg.getDestination();
+        Destination destination = exchange.getDestination();
         EffectivePolicy effectivePolicy = pe.getEffectiveServerResponsePolicy(ei, boi, destination);
         
         List<Interceptor> interceptors = effectivePolicy.getInterceptors();

Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java Wed Apr 11 01:33:10 2007
@@ -358,7 +358,7 @@
             EasyMock.expect(exchange.getConduit()).andReturn(conduit);
         } else {
             destination = control.createMock(Destination.class);
-            EasyMock.expect(message.getDestination()).andReturn(destination);
+            EasyMock.expect(exchange.getDestination()).andReturn(destination);
         }
       
     }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java Wed Apr 11 01:33:10 2007
@@ -94,20 +94,17 @@
     }
          
     @Test
-    public void testUsingAddressing() throws Exception {
+    public void testUsingHTTPClientPolicies() throws Exception {
         SpringBusFactory bf = new SpringBusFactory();
         bus = bf.createBus("org/apache/cxf/systest/ws/policy/http.xml");
         BusFactory.setDefaultBus(bus);
         LoggingInInterceptor in = new LoggingInInterceptor();
         bus.getInInterceptors().add(in);
         bus.getInFaultInterceptors().add(in);
-        bus.getInInterceptors().add(new PolicyLoggingInterceptor(false));
-        bus.getInFaultInterceptors().add(new PolicyLoggingInterceptor(false));
         LoggingOutInterceptor out = new LoggingOutInterceptor();
         bus.getOutInterceptors().add(out);
         bus.getOutFaultInterceptors().add(out);
-        bus.getOutInterceptors().add(new PolicyLoggingInterceptor(true));
-        
+      
         // use a client wsdl with policies attached to endpoint, operation and message subjects
         
         URL url = HTTPClientPolicyTest.class.getResource("http_client_greeter.wsdl");

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java?view=auto&rev=527411
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java Wed Apr 11 01:33:10 2007
@@ -0,0 +1,138 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.ws.policy;
+
+import java.util.logging.Logger;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.greeter_control.BasicGreeterService;
+import org.apache.cxf.greeter_control.Greeter;
+import org.apache.cxf.greeter_control.PingMeFault;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Tests the use of the WS-Policy Framework to determine the behaviour of the HTTP client
+ * by policies including the HTTPClientPolicy assertion attached to different subjects
+ * of the contract (endpoint, operation, binding, messager).
+ * The server in this test is not policy aware.
+ * Neither client nor server do have addressing interceptors installed: there are no addressing
+ * assertions that would trigger the installation of the interceptors on the client side. The use
+ * of the DecoupledEndpoint attribute in the HTTPClientPolicy assertions is merely for illustrating
+ * the use of multiple compatible or incompatible assertions.
+ */
+public class HTTPServerPolicyTest extends AbstractBusClientServerTestBase {
+
+    private static final Logger LOG = Logger.getLogger(HTTPServerPolicyTest.class.getName());
+
+    public static class Server extends AbstractBusTestServerBase {
+   
+        protected void run()  {            
+            SpringBusFactory bf = new SpringBusFactory();
+            Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/http-server.xml");
+            
+            GreeterImpl implementor = new GreeterImpl();
+            implementor.setThrowAlways(true);
+            Endpoint.publish("http://localhost:9020/SoapContext/GreeterPort", implementor);
+
+            LOG.info("Published greeter endpoint."); 
+            
+            LoggingInInterceptor in = new LoggingInInterceptor();
+            LoggingOutInterceptor out = new LoggingOutInterceptor();
+            
+            bus.getInInterceptors().add(in);
+            bus.getOutInterceptors().add(out);
+            bus.getOutFaultInterceptors().add(out);
+        }
+        
+
+        public static void main(String[] args) {
+            try { 
+                Server s = new Server(); 
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally { 
+                System.out.println("done!");
+            }
+        }
+    }    
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", launchServer(Server.class));
+    }
+         
+    @Test
+    public void testUsingHTTPServerPolicies() throws Exception {        
+        
+        // use a plain client
+        
+        SpringBusFactory bf = new SpringBusFactory();
+        Bus bus = bf.createBus();
+        
+        BasicGreeterService gs = new BasicGreeterService();
+        final Greeter greeter = gs.getGreeterPort();
+        LoggingInInterceptor in = new LoggingInInterceptor();
+        LoggingOutInterceptor out = new LoggingOutInterceptor();
+        
+        bus.getInInterceptors().add(in);
+        bus.getOutInterceptors().add(out);
+        
+        LOG.fine("Created greeter client.");
+
+        // sayHi - this operation has message policies that are incompatible with
+        // the endpoint policies
+
+        try {
+            greeter.sayHi();
+            fail("Did not receive expected Exception.");
+        } catch (SoapFault sf) {
+            assertEquals("Server", sf.getFaultCode().getLocalPart());
+            assertEquals("None of the policy alternatives can be satisfied.", sf.getMessage());
+            // assertEquals("INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS", ex.getCode());
+        }
+        
+        // greetMe - no operation or message specific policies
+
+        assertEquals("CXF", greeter.greetMe("cxf")); 
+     
+        // pingMe - policy attached to binding operation fault should have no effect
+
+        try {
+            greeter.pingMe();
+            fail("Expected PingMeFault not thrown.");
+        } catch (PingMeFault ex) {
+            assertEquals(2, (int)ex.getFaultInfo().getMajor());
+            assertEquals(1, (int)ex.getFaultInfo().getMinor());
+        }
+
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyLoggingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyLoggingInterceptor.java?view=diff&rev=527411&r1=527410&r2=527411
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyLoggingInterceptor.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyLoggingInterceptor.java Wed Apr 11 01:33:10 2007
@@ -20,66 +20,65 @@
 package org.apache.cxf.systest.ws.policy;
 
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.logging.Logger;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
-import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.http.policy.PolicyUtils;
-import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
-import org.apache.cxf.ws.policy.AssertionInfo;
-import org.apache.cxf.ws.policy.AssertionInfoMap;
+import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
+import org.apache.cxf.ws.policy.EffectivePolicy;
+import org.apache.cxf.ws.policy.PolicyEngine;
 import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion;
+import org.apache.neethi.Assertion;
 
 public class PolicyLoggingInterceptor extends AbstractPhaseInterceptor {
 
     private static final Logger LOG = Logger.getLogger(PolicyLoggingInterceptor.class.getName());
     
     private boolean outbound;
+    private Bus bus;
     
     PolicyLoggingInterceptor(boolean o) {
         outbound = o;
-        setPhase(Phase.PRE_LOGICAL);
-        /*
+        // setPhase(Phase.PRE_LOGICAL);
         if (outbound) {
             setPhase(Phase.POST_STREAM);
-            addBefore(PolicyVerificationOutInterceptor.class.getName());
+            // addBefore(PolicyVerificationOutInterceptor.class.getName());
         } else {
-            setPhase(Phase.PRE_INVOKE);
-            addBefore(PolicyVerificationInInterceptor.class.getName());
+            setPhase(Phase.POST_INVOKE);
+            // addBefore(PolicyVerificationInInterceptor.class.getName());
         }
-        */
+    }
+    
+    public void setBus(Bus b) {
+        bus = b;
     }
     
     public void handleMessage(Message message) throws Fault {
-        StringBuffer buf = new StringBuffer();
-        String nl = System.getProperty("line.separator");
-        buf.append(outbound ? "Outbound " : "Inbound ");
-        buf.append("message for operation: " + message.getExchange().get(OperationInfo.class).getName());
-        buf.append(nl);
-        buf.append("Policies:");
-        buf.append(nl);
-        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
-        if (null != aim) {
-            for (Collection<AssertionInfo> ais : aim.values()) {
-                for (AssertionInfo ai : ais) {
-                    JaxbAssertion<HTTPClientPolicy> cp = JaxbAssertion.cast((JaxbAssertion)ai.getAssertion(),
-                                                                            HTTPClientPolicy.class);
-                    buf.append(cp);
-                    buf.append(nl);
-                    buf.append("    data: ");
-                    buf.append(PolicyUtils.toString(cp.getData()));
-                    buf.append(nl);
-                    buf.append("    asserted: ");
-                    buf.append(ai.isAsserted());
-                    buf.append(nl);
-                }
+        EndpointInfo ei = message.getExchange().get(Endpoint.class).getEndpointInfo();
+        BindingOperationInfo boi = message.getExchange().get(BindingOperationInfo.class);
+        LOG.fine("Getting effective server request policy for endpoint " + ei
+                 + " and binding operation " + boi);
+        EffectivePolicy ep = 
+            bus.getExtension(PolicyEngine.class).getEffectiveServerRequestPolicy(ei, boi);                
+        for (Iterator it = ep.getPolicy().getAlternatives(); it.hasNext();) {
+            Collection<Assertion> as = CastUtils.cast((Collection)it.next(), Assertion.class);
+            LOG.fine("Checking alternative with " + as.size() + " assertions.");
+            for (Assertion a : as) {
+                LOG.fine("Assertion: " + a.getClass().getName());
+                HTTPServerPolicy p = (JaxbAssertion.cast(a, HTTPServerPolicy.class)).getData(); 
+                LOG.fine("server policy: " + PolicyUtils.toString(p));
             }
         }
-        LOG.fine(buf.toString());
-        
+
     }
 
 }

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml?view=auto&rev=527411
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml Wed Apr 11 01:33:10 2007
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:jaxws="http://cxf.apache.org/jaxws"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">
+
+    <bean id="org.apache.cxf.ws.policy.PolicyEngine" class="org.apache.cxf.ws.policy.spring.InitializingPolicyEngine">
+        <property name="bus" ref="cxf"/>
+        <property name="enabled" value="true"/>
+    </bean>
+    
+    <jaxws:endpoint 
+        id="{http://cxf.apache.org/greeter_control}GreeterPort" 
+        abstract="true"
+        wsdlLocation="org/apache/cxf/systest/ws/policy/http_server_greeter.wsdl"/>
+        
+    <!--<jaxws:endpoint 
+        id="{http://cxf.apache.org/greeter_control}GreeterPort" 
+        abstract="true"
+        implementor="org.apache.cxf.systest.ws.policy.GreeterImpl" 
+        address="http://localhost:9020/SoapContext/GreeterPort"
+        wsdlLocation="org/apache/cxf/systest/ws/policy/http_server_greeter.wsdl"/>-->
+
+</beans>
\ No newline at end of file

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter.wsdl?view=auto&rev=527411
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter.wsdl (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter.wsdl Wed Apr 11 01:33:10 2007
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:tns="http://cxf.apache.org/greeter_control"
+    xmlns:x1="http://cxf.apache.org/greeter_control/types"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    targetNamespace="http://cxf.apache.org/greeter_control" name="HelloWorld">
+    <wsdl:types>
+        <schema targetNamespace="http://cxf.apache.org/greeter_control/types" 
+            xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+            <element name="sayHi">
+                <complexType/>
+            </element>
+            <element name="sayHiResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responseType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMe">
+                <complexType>
+                    <sequence>
+                        <element name="requestType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMeResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responseType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMeOneWay">
+                <complexType>
+                    <sequence>
+                        <element name="requestType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="pingMe">
+                <complexType/>
+            </element>
+            <element name="pingMeResponse">
+                <complexType/>
+            </element>
+            <element name="faultDetail">
+                <complexType>
+                    <sequence>
+                        <element name="minor" type="xsd:short"/>
+                        <element name="major" type="xsd:short"/>
+                    </sequence>
+                </complexType>
+            </element>
+        </schema>
+    </wsdl:types>
+
+   
+   <wsdl:message name="sayHiRequest">
+        <wsdl:part element="x1:sayHi" name="in"/>
+    </wsdl:message>
+    <wsdl:message name="sayHiResponse">
+        <wsdl:part element="x1:sayHiResponse" name="out"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeRequest">
+        <wsdl:part element="x1:greetMe" name="in"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeResponse">
+        <wsdl:part element="x1:greetMeResponse" name="out"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeOneWayRequest">
+        <wsdl:part element="x1:greetMeOneWay" name="in"/>
+    </wsdl:message>
+    <wsdl:message name="pingMeRequest">
+    <wsdl:part name="in" element="x1:pingMe"/>
+    </wsdl:message>
+    <wsdl:message name="pingMeResponse">
+        <wsdl:part name="out" element="x1:pingMeResponse"/>
+    </wsdl:message>        
+    <wsdl:message name="pingMeFault">
+        <wsdl:part name="faultDetail" element="x1:faultDetail"/>
+    </wsdl:message> 
+    
+    <wsdl:portType name="Greeter">
+        <wsdl:operation name="sayHi">
+            <!-- causes a PolicyException as it is incompatible with policy attached to port element -->
+            <wsp:Policy xmlns:wsp="http://www.w3.org/2006/07/ws-policy">
+                <http-conf:server xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
+                    ContentType="application/soap+xml"/>
+            </wsp:Policy>
+            <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+            <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+        </wsdl:operation>
+        
+        <wsdl:operation name="greetMe">
+            <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+            <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+        </wsdl:operation>
+        
+        <wsdl:operation name="greetMeOneWay">
+            <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>            
+        </wsdl:operation>
+
+        <wsdl:operation name="pingMe">
+            <wsdl:input name="pingMeRequest" message="tns:pingMeRequest"/>
+            <wsdl:output name="pingMeResponse" message="tns:pingMeResponse"/>
+            <wsdl:fault name="pingMeFault" message="tns:pingMeFault"/>            
+        </wsdl:operation> 
+    </wsdl:portType>
+
+    <wsdl:binding name="GreeterSOAPBinding" type="tns:Greeter">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+        
+        <wsdl:operation name="sayHi">
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="sayHiRequest">
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="sayHiResponse">
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+        
+        <wsdl:operation name="greetMe">            
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="greetMeRequest">
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="greetMeResponse">
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+        
+        <wsdl:operation name="greetMeOneWay">
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="greetMeOneWayRequest">
+                <soap:body use="literal"/>
+            </wsdl:input>
+        </wsdl:operation>
+
+            <wsdl:operation name="pingMe">
+            <soap:operation style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="pingMeFault">
+                <!-- although incomaptible with the policy attached to the port this does not cause a 
+                    policy exception as all server assertions are automatically asserted on the 
+                    outbound path -->
+                <wsp:Policy xmlns:wsp="http://www.w3.org/2006/07/ws-policy">
+                    <http-conf:server xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
+                        ContentType="application/soap+xml"/>
+                </wsp:Policy>
+                <soap:fault name="pingMeFault" use="literal"/>
+            </wsdl:fault>
+        </wsdl:operation>
+        
+    </wsdl:binding>
+   
+    <wsdl:service name="BasicGreeterService">
+        <wsdl:port binding="tns:GreeterSOAPBinding" name="GreeterPort">
+            <soap:address location="http://localhost:9020/SoapContext/GreeterPort"/>
+            <!-- policy to be used for all invocations on this endpoint -->
+            <wsp:Policy xmlns:wsp="http://www.w3.org/2006/07/ws-policy">
+                <http-conf:server xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
+                    ContentType="application/detergent+xml"/>
+            </wsp:Policy>
+        </wsdl:port>
+    </wsdl:service>
+
+</wsdl:definitions>
+

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Re: svn commit: r527411 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/message/ rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/...

Posted by Andrea Smyth <an...@iona.com>.
andreasmyth@apache.org wrote:

>Author: andreasmyth
>Date: Wed Apr 11 01:33:10 2007
>New Revision: 527411
>
>URL: http://svn.apache.org/viewvc?view=rev&rev=527411
>Log:
>[JIRA CXF-473] WS-Policification of HTTPServerPolicy
>* Implementation of compatible and equals for http server policy.
>* All policy interceptors to throw Fault (wrapping PolicyException) instead of PolicyException.
>* System test demonstrating the use of HTTPServerPolicy assertions in wsp:Policy elements attached to different subjects (port, operation, binding,...): policies attached to operation and message subjects must - if used - be equal to effective policy for endpoint.
>  
>
That should read of course: Assertions built from 
{http://cxf.apache.org/transports/http/configuration}server elements, 
which appear in alternatives of policies attached to operation and 
message subjects must be equal to the assertion in the selected 
alternative of the effective policy for the endpoint (if there is such 
an assertion).

Andrea.

>* HTTPDestination initialisation to take into account policies.
>* Removed static method copyProperties added to MessageImpl earlier - it was never used.
>  
>


Re: svn commit: r527411 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/message/ rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/...

Posted by Andrea Smyth <an...@iona.com>.
andreasmyth@apache.org wrote:

>Author: andreasmyth
>Date: Wed Apr 11 01:33:10 2007
>New Revision: 527411
>
>URL: http://svn.apache.org/viewvc?view=rev&rev=527411
>Log:
>[JIRA CXF-473] WS-Policification of HTTPServerPolicy
>* Implementation of compatible and equals for http server policy.
>* All policy interceptors to throw Fault (wrapping PolicyException) instead of PolicyException.
>* System test demonstrating the use of HTTPServerPolicy assertions in wsp:Policy elements attached to different subjects (port, operation, binding,...): policies attached to operation and message subjects must - if used - be equal to effective policy for endpoint.
>  
>
That should read of course: Assertions built from 
{http://cxf.apache.org/transports/http/configuration}server elements, 
which appear in alternatives of policies attached to operation and 
message subjects must be equal to the assertion in the selected 
alternative of the effective policy for the endpoint (if there is such 
an assertion).

Andrea.

>* HTTPDestination initialisation to take into account policies.
>* Removed static method copyProperties added to MessageImpl earlier - it was never used.
>  
>