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/02/22 19:28:44 UTC

svn commit: r510614 [2/2] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/ws/policy/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ rt/ws/policy/src/main/java/org/apache/cxf/ws/po...

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=510614&r1=510613&r2=510614
==============================================================================
--- 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 Thu Feb 22 10:28:42 2007
@@ -19,19 +19,22 @@
 
 package org.apache.cxf.ws.policy;
 
+import java.util.Collection;
 import java.util.Collections;
 
 import junit.framework.TestCase;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.service.model.BindingOperationInfo;
-import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.Destination;
+import org.apache.neethi.Assertion;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
 
@@ -42,8 +45,9 @@
     
     private IMocksControl control;
     private Message message;
+    private Exchange exchange;
     private BindingOperationInfo boi;
-    private EndpointInfo ei;
+    private Endpoint endpoint;
     private Bus bus;
     private PolicyEngine pe;
     private Conduit conduit;
@@ -64,12 +68,15 @@
         control.reset();
         setupMessage(true, true, true, true, true, true);
         Interceptor i = control.createMock(Interceptor.class);
-        EasyMock.expect(pe.getClientOutInterceptors(boi, ei, conduit))
+        EasyMock.expect(pe.getClientOutInterceptors(endpoint, boi, conduit))
             .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
         InterceptorChain ic = control.createMock(InterceptorChain.class);
         EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
         ic.add(i);
         EasyMock.expectLastCall();
+        Collection<Assertion> assertions = CastUtils.cast(Collections.EMPTY_LIST, Assertion.class);
+        EasyMock.expect(pe.getClientOutAssertions(endpoint, boi, conduit)).andReturn(assertions);
+        EasyMock.expect(message.put(PolicyConstants.CLIENT_OUT_ASSERTIONS, assertions)).andReturn(null);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();        
@@ -84,7 +91,7 @@
         control.reset();
         setupMessage(true, true, false, false, true, true);
         Interceptor i = control.createMock(Interceptor.class);
-        EasyMock.expect(pe.getClientInInterceptors(ei, conduit))
+        EasyMock.expect(pe.getClientInInterceptors(endpoint, conduit))
             .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
         InterceptorChain ic = control.createMock(InterceptorChain.class);
         EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
@@ -94,7 +101,7 @@
         interceptor.handleMessage(message);
         control.verify();        
     }
-    
+
     public void testClientPolicyInFaultInterceptor() {
         ClientPolicyInFaultInterceptor interceptor = new ClientPolicyInFaultInterceptor();
         interceptor.setBus(bus);
@@ -104,7 +111,7 @@
         control.reset();
         setupMessage(true, true, false, false, true, true);
         Interceptor i = control.createMock(Interceptor.class);
-        EasyMock.expect(pe.getClientInFaultInterceptors(ei, conduit))
+        EasyMock.expect(pe.getClientInFaultInterceptors(endpoint, conduit))
             .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
         InterceptorChain ic = control.createMock(InterceptorChain.class);
         EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
@@ -114,7 +121,7 @@
         interceptor.handleMessage(message);
         control.verify();        
     }
-    
+
     public void testServerPolicyInInterceptor() {
         ServerPolicyInInterceptor interceptor = new ServerPolicyInInterceptor();
         interceptor.setBus(bus);
@@ -124,7 +131,7 @@
         control.reset();
         setupMessage(false, false, false, false, true, true);
         Interceptor i = control.createMock(Interceptor.class);
-        EasyMock.expect(pe.getServerInInterceptors(ei, destination))
+        EasyMock.expect(pe.getServerInInterceptors(endpoint, destination))
             .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
         InterceptorChain ic = control.createMock(InterceptorChain.class);
         EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
@@ -144,12 +151,15 @@
         control.reset();
         setupMessage(false, false, true, true, true, true);
         Interceptor i = control.createMock(Interceptor.class);
-        EasyMock.expect(pe.getServerOutInterceptors(boi, ei, destination))
+        EasyMock.expect(pe.getServerOutInterceptors(endpoint, boi, destination))
             .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
         InterceptorChain ic = control.createMock(InterceptorChain.class);
         EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
         ic.add(i);
         EasyMock.expectLastCall();
+        Collection<Assertion> assertions = CastUtils.cast(Collections.EMPTY_LIST, Assertion.class);
+        EasyMock.expect(pe.getServerOutAssertions(endpoint, boi, destination)).andReturn(assertions);
+        EasyMock.expect(message.put(PolicyConstants.SERVER_OUT_ASSERTIONS, assertions)).andReturn(null);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();        
@@ -164,7 +174,7 @@
         control.reset();
         setupMessage(false, false, true, true, true, true);
         Interceptor i = control.createMock(Interceptor.class);
-        EasyMock.expect(pe.getServerOutFaultInterceptors(boi, ei, destination))
+        EasyMock.expect(pe.getServerOutFaultInterceptors(endpoint, boi, destination))
             .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
         InterceptorChain ic = control.createMock(InterceptorChain.class);
         EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
@@ -208,31 +218,41 @@
                       Boolean setupEngine) {
 
         message = control.createMock(Message.class);
-        
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE))
             .andReturn(setupRequestor ? Boolean.TRUE : Boolean.FALSE);
         if (setupRequestor != isClient) {
             return;
         }
+        
+        exchange = control.createMock(Exchange.class);
+        EasyMock.expect(message.getExchange()).andReturn(exchange);
+        
         if (usesOperationInfo) {
-            if (null == boi) {
+            if (null == boi && setupOperation) {
                 boi = control.createMock(BindingOperationInfo.class);
             }
-            EasyMock.expect(message.get(BindingOperationInfo.class)).andReturn(setupOperation ? boi : null);
+            EasyMock.expect(exchange.get(BindingOperationInfo.class)).andReturn(setupOperation ? boi : null);
             if (!setupOperation) {
                 return;
             }
         }
         
-        if (null == ei) {
-            ei = control.createMock(EndpointInfo.class);
+        if (null == endpoint && setupEndpoint) {
+            endpoint = control.createMock(Endpoint.class);
         }
-        EasyMock.expect(message.get(EndpointInfo.class)).andReturn(setupEndpoint ? ei : null);
+        EasyMock.expect(exchange.get(Endpoint.class)).andReturn(setupEndpoint ? endpoint : null);
         if (!setupEndpoint) {
             return;
         }
         
-        if (null == pe) {
+        /*
+        if (null == ei) {
+            ei = control.createMock(EndpointInfo.class);            
+        }
+        EasyMock.expect(endpoint.getEndpointInfo()).andReturn(ei);
+        */
+        
+        if (null == pe && setupEngine) {
             pe = control.createMock(PolicyEngine.class);
         }
         EasyMock.expect(bus.getExtension(PolicyEngine.class)).andReturn(setupEngine ? pe : null);

Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyTest.java?view=diff&rev=510614&r1=510613&r2=510614
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyTest.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyTest.java Thu Feb 22 10:28:42 2007
@@ -19,6 +19,9 @@
 
 package org.apache.cxf.ws.policy;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.xml.namespace.QName;
 
 import junit.framework.TestCase;
@@ -35,6 +38,21 @@
 public class PolicyTest extends TestCase {
  
     public void testNothing() {
+    }
+    
+    public void testContains() {
+        List<Assertion> alt1 = new ArrayList<Assertion>();
+        Assertion a11 = new PrimitiveAssertion(new QName("http://x.y.z", "a1"));
+        alt1.add(a11);
+        Assertion a12 = new PrimitiveAssertion(new QName("http://x.y.z", "a2"));
+        alt1.add(a12);
+        
+        List<Assertion> alt2 = new ArrayList<Assertion>();
+        Assertion a21 = new PrimitiveAssertion(new QName("http://x.y.z", "a1"));
+        alt2.add(a21);
+
+        assertTrue("second alternative should be contained in first alternative",
+                   PolicyUtils.contains(alt1, alt2));    
     }
     
     public void xtestMergeIdentical() {

Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java?view=diff&rev=510614&r1=510613&r2=510614
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java Thu Feb 22 10:28:42 2007
@@ -20,6 +20,7 @@
 package org.apache.cxf.ws.policy.attachment.external;
 
 import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -43,6 +44,8 @@
 import org.apache.neethi.Policy;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
 
 /**
  * 
@@ -66,9 +69,10 @@
     } 
     
     public void testBasic() {
-        assertNull(eap.getURI());
-        eap.setURI("abc.xml");
-        assertEquals("abc.xml", eap.getURI());
+        assertNull(eap.getLocation());
+        Resource uri = control.createMock(Resource.class);
+        eap.setLocation(uri);
+        assertSame(uri, eap.getLocation());
         
     }
     
@@ -142,11 +146,11 @@
         control.verify();
     }
     
-    public void testReadDocumentNotExisting() {
+    public void testReadDocumentNotExisting() throws MalformedURLException {
         URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments1.xml");
         String uri = url.toExternalForm();
         uri = uri.replaceAll("attachments1.xml", "attachments0.xml");
-        eap.setURI(uri);
+        eap.setLocation(new UrlResource(uri));
         try {
             eap.readDocument();
             fail("Expected PolicyException not thrown.");
@@ -155,23 +159,23 @@
         }
     }
     
-    public void testReadDocumentWithoutAttachmentElements() {
+    public void testReadDocumentWithoutAttachmentElements() throws MalformedURLException {
         URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments1.xml");
         String uri = url.toExternalForm();
-        eap.setURI(uri);
+        eap.setLocation(new UrlResource(uri));
         eap.readDocument(); 
         assertTrue(eap.getAttachments().isEmpty());
     }
     
-    public void testReadDocumentAttachmentElementWithoutAppliesTo() {
+    public void testReadDocumentAttachmentElementWithoutAppliesTo() throws MalformedURLException {
         URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments2.xml");
         String uri = url.toExternalForm();
-        eap.setURI(uri);
+        eap.setLocation(new UrlResource(uri));
         eap.readDocument(); 
         assertTrue(eap.getAttachments().isEmpty());
     }
     
-    public void testReadDocumentUnknownDomainExpression() {
+    public void testReadDocumentUnknownDomainExpression() throws MalformedURLException {
         Bus bus = control.createMock(Bus.class);
         eap = new ExternalAttachmentProvider(bus);
         DomainExpressionBuilderRegistry debr = control.createMock(DomainExpressionBuilderRegistry.class);
@@ -180,7 +184,7 @@
             .andThrow(new PolicyException(new Exception()));
         URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments3.xml");
         String uri = url.toExternalForm();
-        eap.setURI(uri);
+        eap.setLocation(new UrlResource(uri));
         
         control.replay();
         try {
@@ -192,7 +196,7 @@
         control.verify();
     }
     
-    public void testReadDocumentEPRDomainExpression() {
+    public void testReadDocumentEPRDomainExpression() throws MalformedURLException {
         Bus bus = control.createMock(Bus.class);
         eap = new ExternalAttachmentProvider(bus);
         DomainExpressionBuilderRegistry debr = control.createMock(DomainExpressionBuilderRegistry.class);
@@ -206,7 +210,7 @@
                 
         URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments4.xml");
         String uri = url.toExternalForm();
-        eap.setURI(uri);
+        eap.setLocation(new UrlResource(uri));
         
         control.replay();
         eap.readDocument();

Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/policy-bus.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/policy-bus.xml?view=diff&rev=510614&r1=510613&r2=510614
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/policy-bus.xml (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/policy-bus.xml Thu Feb 22 10:28:42 2007
@@ -34,10 +34,11 @@
     <bean class="org.apache.cxf.bus.spring.BusExtensionPostProcessor"/>
     <import resource="../../../../../META-INF/cxf/cxf-extension-policy.xml"/>  
     
-    <!--
+    <!-- use bean ids if you want to load multiple external attachment providers -->
+    
     <bean class="org.apache.cxf.ws.policy.attachment.external.ExternalAttachmentProvider">
-       <property name="uri" value="test-externals.xml"/>
+       <constructor-arg ref="cxf"/>
+       <property name="location" value="org/apache/cxf/ws/policy/policy-bus.xml"/>
     </bean>
-    -->
 
 </beans>

Modified: incubator/cxf/trunk/systests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/pom.xml?view=diff&rev=510614&r1=510613&r2=510614
==============================================================================
--- incubator/cxf/trunk/systests/pom.xml (original)
+++ incubator/cxf/trunk/systests/pom.xml Thu Feb 22 10:28:42 2007
@@ -138,6 +138,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-ws-policy</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-integration-jca</artifactId>
             <version>${project.version}</version>
         </dependency>

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/GreeterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/GreeterImpl.java?view=auto&rev=510614
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/GreeterImpl.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/GreeterImpl.java Thu Feb 22 10:28:42 2007
@@ -0,0 +1,131 @@
+/**
+ * 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.concurrent.Future;
+import java.util.logging.Logger;
+
+import javax.jws.WebService;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.apache.cxf.greeter_control.Greeter;
+import org.apache.cxf.greeter_control.PingMeFault;
+import org.apache.cxf.greeter_control.types.FaultDetail;
+import org.apache.cxf.greeter_control.types.GreetMeResponse;
+import org.apache.cxf.greeter_control.types.PingMeResponse;
+import org.apache.cxf.greeter_control.types.SayHiResponse;
+
+/**
+ * 
+ */
+
+@WebService(serviceName = "BasicGreeterService",
+            portName = "GreeterPort",
+            endpointInterface = "org.apache.cxf.greeter_control.Greeter",
+            targetNamespace = "http://cxf.apache.org/greeter_control")
+public class GreeterImpl implements Greeter {
+
+    private static final Logger LOG = Logger.getLogger(GreeterImpl.class.getName());
+    private long delay;
+    private String lastOnewayArg;
+    private int pingMeCount;
+     
+    public long getDelay() {
+        return delay;
+    }
+
+    public void setDelay(long d) {
+        delay = d;
+    }
+
+    public String greetMe(String arg0) {
+        LOG.fine("Executing operation greetMe with parameter: " + arg0);        
+        if (delay > 0) {
+            try {
+                Thread.sleep(delay);
+            } catch (InterruptedException ex) {
+                // ignore
+            }
+        }
+        String result = null;
+        synchronized (this) {
+            result = null == lastOnewayArg ? arg0.toUpperCase() : lastOnewayArg;
+        }
+        LOG.fine("returning: " + result);
+        return result;
+    }
+
+    public Future<?> greetMeAsync(String arg0, AsyncHandler<GreetMeResponse> arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Response<GreetMeResponse> greetMeAsync(String arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void greetMeOneWay(String arg0) {
+        synchronized (this) {
+            lastOnewayArg = arg0;
+        }
+        LOG.fine("Executing operation greetMeOneWay with parameter: " + arg0);
+    }
+
+    public void pingMe() throws PingMeFault {
+        pingMeCount++;
+        if ((pingMeCount % 2) > 0) {
+            LOG.fine("Executing operation pingMe");        
+        } else {
+            LOG.fine("Throwing PingMeFault while executiong operation pingMe");
+            FaultDetail fd = new FaultDetail();
+            fd.setMajor((short)2);
+            fd.setMinor((short)1);
+            throw new PingMeFault("Pings succeed only every other time.", fd);
+        }
+    }
+
+    public Response<PingMeResponse> pingMeAsync() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Future<?> pingMeAsync(AsyncHandler<PingMeResponse> arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String sayHi() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Response<SayHiResponse> sayHiAsync() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

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

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

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyClientServerTest.java?view=auto&rev=510614
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyClientServerTest.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyClientServerTest.java Thu Feb 22 10:28:42 2007
@@ -0,0 +1,141 @@
+/**
+ * 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 junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+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.systest.common.ClientServerSetupBase;
+import org.apache.cxf.systest.common.ClientServerTestBase;
+import org.apache.cxf.systest.common.TestServerBase;
+
+
+/**
+ * Tests the use of the WS-Policy Framework to automatically engage WS-Addressing and
+ * WS-RM in response to Policies defined for the endpoint via an external policy attachment.
+ */
+public class PolicyClientServerTest extends ClientServerTestBase {
+
+    private static final Logger LOG = Logger.getLogger(PolicyClientServerTest.class.getName());
+    private Bus bus;
+
+    public static class Server extends TestServerBase {
+    
+        protected void run()  {            
+            SpringBusFactory bf = new SpringBusFactory();
+            Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-only.xml");
+            BusFactory.setDefaultBus(bus);
+            LoggingInInterceptor in = new LoggingInInterceptor();
+            bus.getInInterceptors().add(in);
+            bus.getInFaultInterceptors().add(in);
+            LoggingOutInterceptor out = new LoggingOutInterceptor();
+            bus.getOutInterceptors().add(out);
+            bus.getOutFaultInterceptors().add(out);
+            
+            GreeterImpl implementor = new GreeterImpl();
+            String address = "http://localhost:9020/SoapContext/GreeterPort";
+            Endpoint.publish(address, implementor);
+            LOG.info("Published greeter endpoint.");
+        }
+        
+
+        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!");
+            }
+        }
+    }    
+    
+    public static Test suite() throws Exception {
+        TestSuite suite = new TestSuite(PolicyClientServerTest.class);
+        return new ClientServerSetupBase(suite) {
+            public void startServers() throws Exception {
+                assertTrue("server did not launch correctly", launchServer(Server.class));
+            }
+            
+            public void setUp() throws Exception {
+                startServers();
+                LOG.fine("Started server.");  
+            }
+        };
+    }
+    
+    public void tearDown() {
+        bus.shutdown(true);
+    }
+    
+    public void testUsingAddressing() throws Exception {
+        SpringBusFactory bf = new SpringBusFactory();
+        bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-only.xml");
+        BusFactory.setDefaultBus(bus);
+        LoggingInInterceptor in = new LoggingInInterceptor();
+        bus.getInInterceptors().add(in);
+        bus.getInFaultInterceptors().add(in);
+        LoggingOutInterceptor out = new LoggingOutInterceptor();
+        bus.getOutInterceptors().add(out);
+        bus.getOutFaultInterceptors().add(out);
+        
+        BasicGreeterService gs = new BasicGreeterService();
+        final Greeter greeter = gs.getGreeterPort();
+        LOG.fine("Created greeter client.");
+
+        // oneway
+
+        greeter.greetMeOneWay("CXF");
+
+        // two-way
+
+        assertEquals("CXF", greeter.greetMe("cxf")); 
+     
+        // exception
+
+        try {
+            greeter.pingMe();
+        } catch (PingMeFault ex) {
+            fail("First invocation should have succeeded.");
+        } 
+       
+        try {
+            greeter.pingMe();
+            fail("Expected PingMeFault not thrown.");
+        } catch (PingMeFault ex) {
+            assertEquals(2, ex.getFaultInfo().getMajor());
+            assertEquals(1, ex.getFaultInfo().getMinor());
+        } 
+    }
+}

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

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

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only-external.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only-external.xml?view=auto&rev=510614
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only-external.xml (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only-external.xml Thu Feb 22 10:28:42 2007
@@ -0,0 +1,34 @@
+<?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.
+-->
+<attachments xmlns:wsp="http://www.w3.org/2006/07/ws-policy" xmlns:wsa="http://www.w3.org/2005/08/addressing">
+    <wsp:PolicyAttachment>
+        <wsp:AppliesTo>
+            <wsa:EndpointReference>
+                <wsa:Address>http://localhost:9020/SoapContext/GreeterPort</wsa:Address>
+            </wsa:EndpointReference>
+        </wsp:AppliesTo>
+        <wsp:Policy>
+            <wsam:Addressing xmlns:wsam="http://www.w3.org/2007/01/addressing/metadata">
+                <wsp:Policy/>
+            </wsam:Addressing>
+        </wsp:Policy>
+    </wsp:PolicyAttachment>    
+</attachments>
+

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

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

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

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only.xml?view=auto&rev=510614
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only.xml (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only.xml Thu Feb 22 10:28:42 2007
@@ -0,0 +1,45 @@
+<?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:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:wsrm-mgmt="http://cxf.apache.org/ws/rm/manager"
+       xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
+       xmlns:http="http://cxf.apache.org/transports/http/configuration"
+       xsi:schemaLocation="
+http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schema/transports/http.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <!--  
+    <http:conduit id="{http://cxf.apache.org/greeter_control}GreeterPort.http-conduit">
+      <http:client DecoupledEndpoint="http://localhost:9995/decoupled_endpoint"/>
+    </http:conduit>
+    -->
+
+    <bean id="org.apache.cxf.ws.policy.PolicyEngine" class="org.apache.cxf.ws.policy.spring.InitializingPolicyEngine">
+        <property name="bus" ref="cxf"/>
+        <property name="registerInterceptors" value="true"/>
+    </bean>
+
+    <bean class="org.apache.cxf.ws.policy.attachment.external.ExternalAttachmentProvider">
+        <constructor-arg ref="cxf"/>
+        <property name="location" value="org/apache/cxf/systest/ws/policy/addr-only-external.xml"/>
+    </bean>
+
+</beans>
\ No newline at end of file

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

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

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

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl?view=diff&rev=510614&r1=510613&r2=510614
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl Thu Feb 22 10:28:42 2007
@@ -254,6 +254,11 @@
         </wsdl:port>
     </wsdl:service>
    
-    
+    <wsdl:service name="BasicGreeterService">
+        <wsdl:port binding="tns:GreeterSOAPBinding" name="GreeterPort">
+            <soap:address location="http://localhost:9020/SoapContext/GreeterPort"/>
+        </wsdl:port>
+    </wsdl:service>
+
 </wsdl:definitions>