Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 47621 invoked from network); 20 Mar 2007 10:41:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Mar 2007 10:41:24 -0000 Received: (qmail 31355 invoked by uid 500); 20 Mar 2007 10:41:32 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 31239 invoked by uid 500); 20 Mar 2007 10:41:32 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 31228 invoked by uid 99); 20 Mar 2007 10:41:31 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Mar 2007 03:41:31 -0700 X-ASF-Spam-Status: No, hits=-98.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Mar 2007 03:41:21 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 6D3C81A9838; Tue, 20 Mar 2007 03:41:01 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r520348 - in /incubator/cxf/trunk: rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/ rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/ rt/ws/rm/ rt/ws/rm/src/main/... Date: Tue, 20 Mar 2007 10:40:58 -0000 To: cxf-commits@incubator.apache.org From: andreasmyth@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070320104101.6D3C81A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: andreasmyth Date: Tue Mar 20 03:40:54 2007 New Revision: 520348 URL: http://svn.apache.org/viewvc?view=rev&rev=520348 Log: [JIRA CXF-384] * RM interceptors to assert the RMAssertions. * Added system tests demonstrating how the policy framework uses attachments of RMAssertions and an Addressing assertions to automatically engage addressing and RM interceptors. * Renamed the PolicyClientServerTest to AddressingPolicyClientServerTest and changed it to use non-anonymous ReplyTo. * ServerPolicyOutFaultInterceptor to obtain BindingFaultInfo from the wrapped operation if it cannot be obtained from the operation itself. Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingPolicyClientServerTest.java - copied, changed from r518568, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyClientServerTest.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyClientServerTest.java (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMWsdlPolicyClientServerTest.java (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/ReliableGreeterImpl.java (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-external.xml - copied unchanged from r518568, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only-external.xml incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr.xml - copied, changed from r518568, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only.xml incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm-external.xml (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm.xml (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/InMessageRecorder.java - copied, changed from r518568, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/InMessageRecorder.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java - copied, changed from r518568, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/MessageFlow.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageRecorder.java (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java - copied, changed from r518568, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/OutMessageRecorder.java Removed: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyClientServerTest.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only-external.xml incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only.xml incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/InMessageRecorder.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/MessageFlow.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/OutMessageRecorder.java Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/OutPolicyInfo.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.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/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java incubator/cxf/trunk/rt/ws/rm/pom.xml incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/OutPolicyInfo.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/OutPolicyInfo.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/OutPolicyInfo.java (original) +++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/OutPolicyInfo.java Tue Mar 20 03:40:54 2007 @@ -43,13 +43,19 @@ /** * */ -public class OutPolicyInfo { +public class OutPolicyInfo { private static final ResourceBundle BUNDLE = BundleUtils.getBundle(OutPolicyInfo.class); protected Policy policy; protected Collection chosenAlternative; protected List interceptors; + + public void initialise(EndpointPolicyInfo epi, PolicyEngine engine) { + policy = epi.getPolicy(); + chosenAlternative = epi.getChosenAlternative(); + initialiseInterceptors(engine); + } void initialise(Endpoint e, BindingOperationInfo boi, Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java (original) +++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java Tue Mar 20 03:40:54 2007 @@ -53,7 +53,7 @@ * */ public class PolicyEngine implements BusExtension { - + private Bus bus; private PolicyRegistry registry; private Collection policyProviders; @@ -349,7 +349,7 @@ return true; } - OutPolicyInfo getClientRequestPolicyInfo(Endpoint e, BindingOperationInfo boi, Conduit c) { + public OutPolicyInfo getClientRequestPolicyInfo(Endpoint e, BindingOperationInfo boi, Conduit c) { BindingOperation bo = new BindingOperation(e, boi); OutPolicyInfo opi = clientRequestInfo.get(bo); if (null == opi) { @@ -364,7 +364,12 @@ return opi; } - OutPolicyInfo getServerRequestPolicyInfo(Endpoint e, BindingOperationInfo boi) { + public void setClientRequestPolicyInfo(Endpoint e, BindingOperationInfo boi, OutPolicyInfo opi) { + BindingOperation bo = new BindingOperation(e, boi); + clientRequestInfo.put(bo, opi); + } + + public OutPolicyInfo getServerRequestPolicyInfo(Endpoint e, BindingOperationInfo boi) { BindingOperation bo = new BindingOperation(e, boi); OutPolicyInfo opi = serverRequestInfo.get(bo); if (null == opi) { @@ -375,7 +380,12 @@ return opi; } - OutPolicyInfo getClientResponsePolicyInfo(Endpoint e, BindingOperationInfo boi) { + public void setServerRequestPolicyInfo(Endpoint e, BindingOperationInfo boi, OutPolicyInfo opi) { + BindingOperation bo = new BindingOperation(e, boi); + serverRequestInfo.put(bo, opi); + } + + public OutPolicyInfo getClientResponsePolicyInfo(Endpoint e, BindingOperationInfo boi) { BindingOperation bo = new BindingOperation(e, boi); OutPolicyInfo opi = clientResponseInfo.get(bo); if (null == opi) { @@ -386,7 +396,12 @@ return opi; } - OutPolicyInfo getClientFaultPolicyInfo(Endpoint e, BindingFaultInfo bfi) { + public void setClientResponsePolicyInfo(Endpoint e, BindingOperationInfo boi, OutPolicyInfo opi) { + BindingOperation bo = new BindingOperation(e, boi); + clientResponseInfo.put(bo, opi); + } + + public OutPolicyInfo getClientFaultPolicyInfo(Endpoint e, BindingFaultInfo bfi) { BindingFault bf = new BindingFault(e, bfi); OutPolicyInfo opi = clientFaultInfo.get(bf); if (null == opi) { @@ -397,7 +412,12 @@ return opi; } - EndpointPolicyInfo getEndpointPolicyInfo(Endpoint e, Conduit conduit) { + public void setClientFaultPolicyInfo(Endpoint e, BindingFaultInfo bfi, OutPolicyInfo opi) { + BindingFault bf = new BindingFault(e, bfi); + clientFaultInfo.put(bf, opi); + } + + public EndpointPolicyInfo getEndpointPolicyInfo(Endpoint e, Conduit conduit) { EndpointPolicyInfo epi = endpointInfo.get(e); if (null != epi) { return epi; @@ -405,8 +425,8 @@ Assertor assertor = conduit instanceof Assertor ? (Assertor)conduit : null; return createEndpointPolicyInfo(e, false, assertor); } - - EndpointPolicyInfo getEndpointPolicyInfo(Endpoint e, Destination destination) { + + public EndpointPolicyInfo getEndpointPolicyInfo(Endpoint e, Destination destination) { EndpointPolicyInfo epi = endpointInfo.get(e); if (null != epi) { return epi; @@ -423,7 +443,12 @@ return epi; } - OutPolicyInfo getServerResponsePolicyInfo(Endpoint e, BindingOperationInfo boi, + public void setEndpointPolicyInfo(Endpoint e, EndpointPolicyInfo epi) { + endpointInfo.put(e, epi); + } + + + public OutPolicyInfo getServerResponsePolicyInfo(Endpoint e, BindingOperationInfo boi, Destination d) { BindingOperation bo = new BindingOperation(e, boi); OutPolicyInfo opi = serverResponseInfo.get(bo); @@ -439,7 +464,12 @@ return opi; } - OutPolicyInfo getServerFaultPolicyInfo(Endpoint e, BindingFaultInfo bfi, + public void setServerResponsePolicyInfo(Endpoint e, BindingOperationInfo boi, OutPolicyInfo opi) { + BindingOperation bo = new BindingOperation(e, boi); + serverResponseInfo.put(bo, opi); + } + + public OutPolicyInfo getServerFaultPolicyInfo(Endpoint e, BindingFaultInfo bfi, Destination d) { BindingFault bf = new BindingFault(e, bfi); OutPolicyInfo opi = serverFaultInfo.get(bf); @@ -455,6 +485,11 @@ return opi; } + public void setServerFaultPolicyInfo(Endpoint e, BindingFaultInfo bfi, OutPolicyInfo opi) { + BindingFault bf = new BindingFault(e, bfi); + serverFaultInfo.put(bf, opi); + } + /** * Class used as key in the client request policy and server response policy maps. @@ -467,6 +502,20 @@ endpoint = e; boi = b; } + + @Override + public int hashCode() { + return boi.hashCode(); + } + + @Override + public boolean equals(Object obj) { + BindingOperation other = (BindingOperation)obj; + return boi.equals(other.boi) && endpoint.equals(other.endpoint); + } + + + } /** @@ -474,11 +523,22 @@ */ class BindingFault { Endpoint endpoint; - BindingFaultInfo boi; + BindingFaultInfo bfi; BindingFault(Endpoint e, BindingFaultInfo b) { endpoint = e; - boi = b; + bfi = b; + } + + @Override + public int hashCode() { + return bfi.hashCode(); + } + + @Override + public boolean equals(Object obj) { + BindingFault other = (BindingFault)obj; + return bfi.equals(other.bfi) && endpoint.equals(other.endpoint); } } Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java (original) +++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java Tue Mar 20 03:40:54 2007 @@ -21,6 +21,8 @@ import java.util.Collection; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.cxf.helpers.CastUtils; import org.apache.cxf.message.Message; @@ -99,13 +101,25 @@ return true; } + public static void logPolicy(Logger log, Level level, String msg, PolicyComponent pc) { + if (null == pc) { + log.log(level, msg); + return; + } + StringBuffer buf = new StringBuffer(); + buf.append(msg); + nl(buf); + printPolicyComponent(pc, buf, 0); + log.log(level, buf.toString()); + } + public static void printPolicyComponent(PolicyComponent pc) { StringBuffer buf = new StringBuffer(); printPolicyComponent(pc, buf, 0); System.out.println(buf.toString()); } - private static void printPolicyComponent(PolicyComponent pc, StringBuffer buf, int level) { + public static void printPolicyComponent(PolicyComponent pc, StringBuffer buf, int level) { indent(buf, level); buf.append("type: "); buf.append(typeToString(pc.getType())); 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=520348&r1=520347&r2=520348 ============================================================================== --- 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 Tue Mar 20 03:40:54 2007 @@ -101,16 +101,30 @@ } BindingFaultInfo getBindingFaultInfo(Message msg, Exception ex, BindingOperationInfo boi) { - BindingFaultInfo bfi = msg.get(BindingFaultInfo.class); + BindingFaultInfo bfi = msg.get(BindingFaultInfo.class); if (null == bfi) { + Throwable cause = ex.getCause(); + if (null == cause) { + return null; + } for (BindingFaultInfo b : boi.getFaults()) { Class faultClass = b.getFaultInfo().getProperty(Class.class.getName(), Class.class); - if (faultClass.isAssignableFrom(ex.getClass())) { + if (faultClass.isAssignableFrom(cause.getClass())) { bfi = b; msg.put(BindingFaultInfo.class, bfi); break; } - } + } + if (null == bfi && null != boi.getWrappedOperation()) { + for (BindingFaultInfo b : boi.getWrappedOperation().getFaults()) { + Class faultClass = b.getFaultInfo().getProperty(Class.class.getName(), Class.class); + if (faultClass.isAssignableFrom(cause.getClass())) { + bfi = b; + msg.put(BindingFaultInfo.class, bfi); + break; + } + } + } } return bfi; } Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java (original) +++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java Tue Mar 20 03:40:54 2007 @@ -120,7 +120,6 @@ public Policy getEffectivePolicy(BindingMessageInfo bmi) { ServiceInfo si = bmi.getBindingOperation().getBinding().getService(); DescriptionInfo di = si.getDescription(); - Policy p = getElementPolicy(bmi, false, di); MessageInfo mi = bmi.getMessageInfo(); p = p.merge(getElementPolicy(mi, true, di)); @@ -157,7 +156,7 @@ Policy elementPolicy = new Policy(); - if (null == ex) { + if (null == ex || null == di) { return elementPolicy; } @@ -237,6 +236,9 @@ private Extensible getMessageTypeInfo(QName name, DescriptionInfo di) { + if (null == di) { + return null; + } Definition def = (Definition)di.getProperty(WSDLServiceBuilder.WSDL_DEFINITION); if (null == def) { return null; Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java (original) +++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java Tue Mar 20 03:40:54 2007 @@ -571,13 +571,23 @@ public void testKeys() { engine = new PolicyEngine(); Endpoint endpoint = control.createMock(Endpoint.class); - BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); - PolicyEngine.BindingOperation bo = engine.new BindingOperation(endpoint, boi); + BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); + BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class); + OutPolicyInfo opi = control.createMock(OutPolicyInfo.class); + control.replay(); + + PolicyEngine.BindingOperation bo = engine.new BindingOperation(endpoint, boi); assertNotNull(bo); + PolicyEngine.BindingOperation bo2 = engine.new BindingOperation(endpoint, boi); + assertEquals(bo, bo2); + assertEquals(bo.hashCode(), bo2.hashCode()); - BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class); + engine.setClientRequestPolicyInfo(endpoint, boi, opi); + assertSame(opi, engine.getClientRequestPolicyInfo(endpoint, boi, null)); + PolicyEngine.BindingFault bf = engine.new BindingFault(endpoint, bfi); - assertNotNull(bf); + assertNotNull(bf); + control.verify(); } private void doTestGetInterceptors(boolean isServer, boolean fault) throws NoSuchMethodException { 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=520348&r1=520347&r2=520348 ============================================================================== --- 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 Tue Mar 20 03:40:54 2007 @@ -254,7 +254,7 @@ public void testServerPolicyOutFaultInterceptorGetBindingFaultInfo() { ServerPolicyOutFaultInterceptor interceptor = new ServerPolicyOutFaultInterceptor(); message = control.createMock(Message.class); - Exception ex = new UnsupportedOperationException(); + Exception ex = new UnsupportedOperationException(new RuntimeException()); boi = control.createMock(BindingOperationInfo.class); EasyMock.expect(message.get(BindingFaultInfo.class)).andReturn(null); BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class); Modified: incubator/cxf/trunk/rt/ws/rm/pom.xml URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/pom.xml?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/rt/ws/rm/pom.xml (original) +++ incubator/cxf/trunk/rt/ws/rm/pom.xml Tue Mar 20 03:40:54 2007 @@ -58,6 +58,11 @@ org.apache.cxf + cxf-rt-ws-policy + ${project.version} + + + org.apache.cxf cxf-common-utilities ${project.version} Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java (original) +++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java Tue Mar 20 03:40:54 2007 @@ -19,6 +19,7 @@ package org.apache.cxf.ws.rm; +import java.util.Collection; import java.util.logging.Level; import java.util.logging.Logger; @@ -28,6 +29,8 @@ import org.apache.cxf.message.Message; import org.apache.cxf.phase.Phase; import org.apache.cxf.phase.PhaseInterceptor; +import org.apache.cxf.ws.policy.AssertionInfo; +import org.apache.cxf.ws.policy.AssertionInfoMap; /** * Interceptor responsible for implementing exchange of RM protocol messages, @@ -90,6 +93,28 @@ } public void postHandleMessage(Message msg) throws Fault { + } + + /** + * Asserts all RMAssertion assertions for the current message, regardless their attributes + * (if there is more thsn one we have ensured that they are all supported by considering + * e.g. the minimum acknowledgment interval). + * @param message the current message + */ + void assertReliability(Message message) { + AssertionInfoMap aim = message.get(AssertionInfoMap.class); + if (null == aim) { + return; + + } + Collection ais = aim.get(RMConstants.getRMAssertionQName()); + if (null == ais || ais.size() == 0) { + return; + } + + for (AssertionInfo ai : ais) { + ai.setAsserted(true); + } } // rm logic Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java (original) +++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java Tue Mar 20 03:40:54 2007 @@ -19,6 +19,7 @@ package org.apache.cxf.ws.rm; +import java.util.Collection; import java.util.List; import javax.wsdl.extensions.ExtensibilityElement; @@ -43,6 +44,9 @@ import org.apache.cxf.service.model.UnwrappedOperationInfo; import org.apache.cxf.transport.Conduit; import org.apache.cxf.ws.addressing.Names; +import org.apache.cxf.ws.policy.EndpointPolicyInfo; +import org.apache.cxf.ws.policy.OutPolicyInfo; +import org.apache.cxf.ws.policy.PolicyEngine; public class RMEndpoint { @@ -187,6 +191,7 @@ replyTo = r; createService(); createEndpoint(); + setPolicies(); } void createService() { @@ -231,6 +236,41 @@ endpoint = new WrappedEndpoint(applicationEndpoint, ei, service); service.setEndpoint(endpoint); } + + void setPolicies() { + + // if addressing was enabled on the application endpoint by means + // of the UsingAddressing element extensor, use this for the + // RM endpoint also + + Object ua = getUsingAddressing(applicationEndpoint.getEndpointInfo()); + if (null != ua) { + endpoint.getEndpointInfo().addExtensor(ua); + } + + // use same WS-policies as for application endpoint + + PolicyEngine engine = manager.getBus().getExtension(PolicyEngine.class); + + EndpointPolicyInfo epi = engine.getEndpointPolicyInfo(applicationEndpoint, conduit); + OutPolicyInfo opi = new OutPolicyInfo(); + opi.initialise(epi, engine); + + engine.setEndpointPolicyInfo(endpoint, epi); + + BindingInfo bi = endpoint.getEndpointInfo().getBinding(); + Collection bois = bi.getOperations(); + + for (BindingOperationInfo boi : bois) { + engine.setServerRequestPolicyInfo(endpoint, boi, opi); + engine.setServerResponsePolicyInfo(endpoint, boi, opi); + + engine.setClientRequestPolicyInfo(endpoint, boi, opi); + engine.setClientResponsePolicyInfo(endpoint, boi, opi); + } + + // TODO: FaultPolicy (SequenceFault) + } void buildInterfaceInfo(ServiceInfo si) { InterfaceInfo ii = new InterfaceInfo(si, INTERFACE_NAME); @@ -241,6 +281,8 @@ buildCreateSequenceOperationInfo(ii); buildTerminateSequenceOperationInfo(ii); buildSequenceAckOperationInfo(ii); + + // TODO: FaultInfo (SequenceFault) } void buildCreateSequenceOperationInfo(InterfaceInfo ii) { @@ -415,6 +457,8 @@ si.addBinding(bi); } + + // TODO: BindingFaultInfo (SequenceFault) } Object getUsingAddressing(EndpointInfo endpointInfo) { Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java (original) +++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java Tue Mar 20 03:40:54 2007 @@ -83,7 +83,10 @@ boolean isServer = RMContextUtils.isServerSide(message); LOG.fine("isServerSide: " + isServer); + boolean isApplicationMessage = RMContextUtils.isAplicationMessage(action); + LOG.fine("isApplicationMessage: " + isApplicationMessage); + /* if (RMConstants.getCreateSequenceAction().equals(action) && !isServer) { LOG.fine("Processing inbound CreateSequence on client side."); RMEndpoint rme = getManager().getReliableEndpoint(message); @@ -103,21 +106,31 @@ processAcknowledgments(rmps); return; } + */ // for application AND out of band messages - Destination destination = getManager().getDestination(message); - - if (null != rmps) { - + if (isApplicationMessage) { + Destination destination = getManager().getDestination(message); + if (null != rmps) { + processAcknowledgments(rmps); + processAcknowledgmentRequests(rmps); + processSequence(destination, message); + processDeliveryAssurance(rmps); + } + } else if (RMConstants.getSequenceAckAction().equals(action)) { processAcknowledgments(rmps); - - processAcknowledgmentRequests(rmps); - - processSequence(destination, message); - - processDeliveryAssurance(rmps); + } else if (RMConstants.getCreateSequenceAction().equals(action) && !isServer) { + LOG.fine("Processing inbound CreateSequence on client side."); + RMEndpoint rme = getManager().getReliableEndpoint(message); + Servant servant = rme.getServant(); + CreateSequenceResponseType csr = servant.createSequence(message); + Proxy proxy = rme.getProxy(); + proxy.createSequenceResponse(csr); + return; } + + assertReliability(message); } void processAcknowledgments(RMProperties rmps) throws SequenceFault { Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java (original) +++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java Tue Mar 20 03:40:54 2007 @@ -155,6 +155,8 @@ || RMConstants.getTerminateSequenceAction().equals(action)) { maps.setReplyTo(RMUtils.createNoneReference()); } + + assertReliability(message); } void addAcknowledgements(Destination destination, Copied: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingPolicyClientServerTest.java (from r518568, 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/AddressingPolicyClientServerTest.java?view=diff&rev=520348&p1=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyClientServerTest.java&r1=518568&p2=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingPolicyClientServerTest.java&r2=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyClientServerTest.java (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingPolicyClientServerTest.java Tue Mar 20 03:40:54 2007 @@ -41,15 +41,15 @@ * 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 AbstractBusClientServerTestBase { +public class AddressingPolicyClientServerTest extends AbstractBusClientServerTestBase { - private static final Logger LOG = Logger.getLogger(PolicyClientServerTest.class.getName()); + private static final Logger LOG = Logger.getLogger(AddressingPolicyClientServerTest.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/addr-only.xml"); + Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr.xml"); BusFactory.setDefaultBus(bus); LoggingInInterceptor in = new LoggingInInterceptor(); bus.getInInterceptors().add(in); @@ -61,7 +61,7 @@ GreeterImpl implementor = new GreeterImpl(); String address = "http://localhost:9020/SoapContext/GreeterPort"; Endpoint.publish(address, implementor); - LOG.info("Published greeter endpoint."); + LOG.info("Published greeter endpoint."); } @@ -86,7 +86,7 @@ @Test public void testUsingAddressing() throws Exception { SpringBusFactory bf = new SpringBusFactory(); - bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-only.xml"); + bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr.xml"); BusFactory.setDefaultBus(bus); LoggingInInterceptor in = new LoggingInInterceptor(); bus.getInInterceptors().add(in); Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyClientServerTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyClientServerTest.java?view=auto&rev=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyClientServerTest.java (added) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyClientServerTest.java Tue Mar 20 03:40:54 2007 @@ -0,0 +1,167 @@ +/** + * 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.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.ws.util.InMessageRecorder; +import org.apache.cxf.systest.ws.util.MessageFlow; +import org.apache.cxf.systest.ws.util.MessageRecorder; +import org.apache.cxf.systest.ws.util.OutMessageRecorder; +import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; +import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.apache.cxf.ws.rm.RMConstants; + +import org.junit.BeforeClass; +import org.junit.Test; + + +/** + * 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 RMPolicyClientServerTest extends AbstractBusClientServerTestBase { + + private static final Logger LOG = Logger.getLogger(RMPolicyClientServerTest.class.getName()); + private static final String GREETMEONEWAY_ACTION = null; + private static final String GREETME_ACTION = null; + private static final String GREETME_RESPONSE_ACTION = null; + private static final String PINGME_ACTION = null; + private static final String PINGME_RESPONSE_ACTION = null; + + public static class Server extends AbstractBusTestServerBase { + + protected void run() { + SpringBusFactory bf = new SpringBusFactory(); + Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/rm.xml"); + BusFactory.setDefaultBus(bus); + LoggingInInterceptor in = new LoggingInInterceptor(); + bus.getInInterceptors().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!"); + } + } + } + + @BeforeClass + public static void startServers() throws Exception { + assertTrue("server did not launch correctly", launchServer(Server.class)); + } + + @Test + public void testUsingRM() throws Exception { + SpringBusFactory bf = new SpringBusFactory(); + bus = bf.createBus("org/apache/cxf/systest/ws/policy/rm.xml"); + BusFactory.setDefaultBus(bus); + OutMessageRecorder outRecorder = new OutMessageRecorder(); + bus.getOutInterceptors().add(outRecorder); + InMessageRecorder inRecorder = new InMessageRecorder(); + bus.getInInterceptors().add(inRecorder); + + 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, (int)ex.getFaultInfo().getMajor()); + assertEquals(1, (int)ex.getFaultInfo().getMinor()); + } + + MessageRecorder mr = new MessageRecorder(outRecorder, inRecorder); + mr.awaitMessages(5, 9, 5000); + + MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages()); + + + mf.verifyMessages(5, true); + String[] expectedActions = new String[] {RMConstants.getCreateSequenceAction(), + GREETMEONEWAY_ACTION, + GREETME_ACTION, + PINGME_ACTION, + PINGME_ACTION}; + mf.verifyActions(expectedActions, true); + mf.verifyMessageNumbers(new String[] {null, "1", "2", "3", "4"}, true); + mf.verifyLastMessage(new boolean[] {false, false, false, false, false}, true); + mf.verifyAcknowledgements(new boolean[] {false, false, false, true, true}, true); + + mf.verifyMessages(9, false); + mf.verifyPartialResponses(5); + mf.purgePartialResponses(); + + expectedActions = new String[] { + RMConstants.getCreateSequenceResponseAction(), + GREETME_RESPONSE_ACTION, + PINGME_RESPONSE_ACTION, + PINGME_RESPONSE_ACTION + }; + mf.verifyActions(expectedActions, false); + mf.verifyMessageNumbers(new String[] {null, "1", "2", "3"}, false); + mf.verifyLastMessage(new boolean[] {false, false, false, false}, false); + mf.verifyAcknowledgements(new boolean[] {false, true, true, true}, false); + + } +} Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyClientServerTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyClientServerTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMWsdlPolicyClientServerTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMWsdlPolicyClientServerTest.java?view=auto&rev=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMWsdlPolicyClientServerTest.java (added) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMWsdlPolicyClientServerTest.java Tue Mar 20 03:40:54 2007 @@ -0,0 +1,167 @@ +/** + * 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.BusFactory; +import org.apache.cxf.bus.spring.SpringBusFactory; +import org.apache.cxf.greeter_control.Greeter; +import org.apache.cxf.greeter_control.PingMeFault; +import org.apache.cxf.greeter_control.ReliableGreeterService; +import org.apache.cxf.interceptor.LoggingInInterceptor; +import org.apache.cxf.interceptor.LoggingOutInterceptor; +import org.apache.cxf.systest.ws.util.InMessageRecorder; +import org.apache.cxf.systest.ws.util.MessageFlow; +import org.apache.cxf.systest.ws.util.MessageRecorder; +import org.apache.cxf.systest.ws.util.OutMessageRecorder; +import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; +import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.apache.cxf.ws.rm.RMConstants; + +import org.junit.BeforeClass; +import org.junit.Test; + + +/** + * 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 RMWsdlPolicyClientServerTest extends AbstractBusClientServerTestBase { + + private static final Logger LOG = Logger.getLogger(RMWsdlPolicyClientServerTest.class.getName()); + private static final String GREETMEONEWAY_ACTION = null; + private static final String GREETME_ACTION = null; + private static final String GREETME_RESPONSE_ACTION = null; + private static final String PINGME_ACTION = null; + private static final String PINGME_RESPONSE_ACTION = null; + + public static class Server extends AbstractBusTestServerBase { + + protected void run() { + SpringBusFactory bf = new SpringBusFactory(); + Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/rmwsdl.xml"); + BusFactory.setDefaultBus(bus); + LoggingInInterceptor in = new LoggingInInterceptor(); + bus.getInInterceptors().add(in); + LoggingOutInterceptor out = new LoggingOutInterceptor(); + bus.getOutInterceptors().add(out); + bus.getOutFaultInterceptors().add(out); + + ReliableGreeterImpl implementor = new ReliableGreeterImpl(); + 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!"); + } + } + } + + @BeforeClass + public static void startServers() throws Exception { + assertTrue("server did not launch correctly", launchServer(Server.class)); + } + + @Test + public void testUsingRM() throws Exception { + SpringBusFactory bf = new SpringBusFactory(); + bus = bf.createBus("org/apache/cxf/systest/ws/policy/rmwsdl.xml"); + BusFactory.setDefaultBus(bus); + OutMessageRecorder outRecorder = new OutMessageRecorder(); + bus.getOutInterceptors().add(outRecorder); + InMessageRecorder inRecorder = new InMessageRecorder(); + bus.getInInterceptors().add(inRecorder); + + ReliableGreeterService gs = new ReliableGreeterService(); + 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, (int)ex.getFaultInfo().getMajor()); + assertEquals(1, (int)ex.getFaultInfo().getMinor()); + } + + MessageRecorder mr = new MessageRecorder(outRecorder, inRecorder); + mr.awaitMessages(5, 9, 5000); + + MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages()); + + + mf.verifyMessages(5, true); + String[] expectedActions = new String[] {RMConstants.getCreateSequenceAction(), + GREETMEONEWAY_ACTION, + GREETME_ACTION, + PINGME_ACTION, + PINGME_ACTION}; + mf.verifyActions(expectedActions, true); + mf.verifyMessageNumbers(new String[] {null, "1", "2", "3", "4"}, true); + mf.verifyLastMessage(new boolean[] {false, false, false, false, false}, true); + mf.verifyAcknowledgements(new boolean[] {false, false, false, true, true}, true); + + mf.verifyMessages(9, false); + mf.verifyPartialResponses(5); + mf.purgePartialResponses(); + + expectedActions = new String[] { + RMConstants.getCreateSequenceResponseAction(), + GREETME_RESPONSE_ACTION, + PINGME_RESPONSE_ACTION, + PINGME_RESPONSE_ACTION + }; + mf.verifyActions(expectedActions, false); + mf.verifyMessageNumbers(new String[] {null, "1", "2", "3"}, false); + mf.verifyLastMessage(new boolean[] {false, false, false, false}, false); + mf.verifyAcknowledgements(new boolean[] {false, true, true, true}, false); + + } +} Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMWsdlPolicyClientServerTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMWsdlPolicyClientServerTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/ReliableGreeterImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/ReliableGreeterImpl.java?view=auto&rev=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/ReliableGreeterImpl.java (added) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/ReliableGreeterImpl.java Tue Mar 20 03:40:54 2007 @@ -0,0 +1,35 @@ +/** + * 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 javax.jws.WebService; + +import org.apache.cxf.greeter_control.AbstractGreeterImpl; + +/** + * + */ + +@WebService(serviceName = "ReliableGreeterService", + portName = "GreeterPort", + endpointInterface = "org.apache.cxf.greeter_control.Greeter", + targetNamespace = "http://cxf.apache.org/greeter_control") +public class ReliableGreeterImpl extends AbstractGreeterImpl { +} Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/ReliableGreeterImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/ReliableGreeterImpl.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Copied: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr.xml (from r518568, 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.xml?view=diff&rev=520348&p1=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only.xml&r1=518568&p2=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr.xml&r2=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-only.xml (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr.xml Tue Mar 20 03:40:54 2007 @@ -18,19 +18,15 @@ under the License. --> - @@ -39,7 +35,34 @@ - + + + + + Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm-external.xml URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm-external.xml?view=auto&rev=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm-external.xml (added) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm-external.xml Tue Mar 20 03:40:54 2007 @@ -0,0 +1,37 @@ + + + + + + + http://localhost:9020/SoapContext/GreeterPort + + + + + + + + + ` + + + + Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm-external.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm-external.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm-external.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm.xml URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm.xml?view=auto&rev=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm.xml (added) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm.xml Tue Mar 20 03:40:54 2007 @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rm.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml?view=auto&rev=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml (added) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml Tue Mar 20 03:40:54 2007 @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + \ No newline at end of file Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java Tue Mar 20 03:40:54 2007 @@ -34,6 +34,8 @@ import org.apache.cxf.greeter_control.Control; import org.apache.cxf.greeter_control.types.StartGreeterResponse; import org.apache.cxf.greeter_control.types.StopGreeterResponse; +import org.apache.cxf.systest.ws.util.InMessageRecorder; +import org.apache.cxf.systest.ws.util.OutMessageRecorder; import org.apache.cxf.ws.rm.RMManager; Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java Tue Mar 20 03:40:54 2007 @@ -59,7 +59,7 @@ bus.getOutFaultInterceptors().add(out); GreeterImpl implementor = new GreeterImpl(); - implementor.setDelay(8000); + implementor.setDelay(5000); String address = "http://localhost:9020/SoapContext/GreeterPort"; Endpoint.publish(address, implementor); LOG.info("Published greeter endpoint."); Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java?view=diff&rev=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java Tue Mar 20 03:40:54 2007 @@ -36,6 +36,10 @@ import org.apache.cxf.greeter_control.Greeter; import org.apache.cxf.greeter_control.GreeterService; import org.apache.cxf.interceptor.Interceptor; +import org.apache.cxf.systest.ws.util.InMessageRecorder; +import org.apache.cxf.systest.ws.util.MessageFlow; +import org.apache.cxf.systest.ws.util.MessageRecorder; +import org.apache.cxf.systest.ws.util.OutMessageRecorder; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; import org.apache.cxf.transport.http.HTTPConduit; import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; @@ -879,28 +883,8 @@ } private void awaitMessages(int nExpectedOut, int nExpectedIn, int timeout) { - int waited = 0; - int nOut = 0; - int nIn = 0; - while (waited <= timeout) { - synchronized (outRecorder) { - nOut = outRecorder.getOutboundMessages().size(); - } - synchronized (inRecorder) { - nIn = inRecorder.getInboundMessages().size(); - } - if (nIn >= nExpectedIn && nOut >= nExpectedOut) { - return; - } - try { - Thread.sleep(100); - } catch (InterruptedException ex) { - // ignore - } - waited += 100; - } - assertEquals("Did not receive expected number of inbound messages", nExpectedIn, nIn); - assertEquals("Did not send expected number of outbound messages", nExpectedOut, nOut); + MessageRecorder mr = new MessageRecorder(outRecorder, inRecorder); + mr.awaitMessages(nExpectedOut, nExpectedIn, timeout); } private void removeRMInterceptors(List interceptors) { Copied: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/InMessageRecorder.java (from r518568, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/InMessageRecorder.java) URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/InMessageRecorder.java?view=diff&rev=520348&p1=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/InMessageRecorder.java&r1=518568&p2=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/InMessageRecorder.java&r2=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/InMessageRecorder.java (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/InMessageRecorder.java Tue Mar 20 03:40:54 2007 @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.cxf.systest.ws.rm; +package org.apache.cxf.systest.ws.util; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -65,7 +65,7 @@ } } - protected List getInboundMessages() { + public List getInboundMessages() { return inbound; } } Copied: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java (from r518568, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/MessageFlow.java) URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java?view=diff&rev=520348&p1=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/MessageFlow.java&r1=518568&p2=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java&r2=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/MessageFlow.java (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java Tue Mar 20 03:40:54 2007 @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.cxf.systest.ws.rm; +package org.apache.cxf.systest.ws.util; import java.io.ByteArrayInputStream; import java.util.ArrayList; Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageRecorder.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageRecorder.java?view=auto&rev=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageRecorder.java (added) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageRecorder.java Tue Mar 20 03:40:54 2007 @@ -0,0 +1,58 @@ +/** + * 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.util; + +import junit.framework.Assert; + +public class MessageRecorder extends Assert { + + private OutMessageRecorder outRecorder; + private InMessageRecorder inRecorder; + + public MessageRecorder(OutMessageRecorder or, InMessageRecorder ir) { + inRecorder = ir; + outRecorder = or; + } + + public void awaitMessages(int nExpectedOut, int nExpectedIn, int timeout) { + int waited = 0; + int nOut = 0; + int nIn = 0; + while (waited <= timeout) { + synchronized (outRecorder) { + nOut = outRecorder.getOutboundMessages().size(); + } + synchronized (inRecorder) { + nIn = inRecorder.getInboundMessages().size(); + } + if (nIn >= nExpectedIn && nOut >= nExpectedOut) { + return; + } + try { + Thread.sleep(100); + } catch (InterruptedException ex) { + // ignore + } + waited += 100; + } + assertEquals("Did not receive expected number of inbound messages", nExpectedIn, nIn); + assertEquals("Did not send expected number of outbound messages", nExpectedOut, nOut); + } +} Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageRecorder.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/MessageRecorder.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Copied: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java (from r518568, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/OutMessageRecorder.java) URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java?view=diff&rev=520348&p1=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/OutMessageRecorder.java&r1=518568&p2=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java&r2=520348 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/OutMessageRecorder.java (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java Tue Mar 20 03:40:54 2007 @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.cxf.systest.ws.rm; +package org.apache.cxf.systest.ws.util; import java.io.ByteArrayOutputStream; import java.io.OutputStream; @@ -67,7 +67,7 @@ } - protected List getOutboundMessages() { + public List getOutboundMessages() { return outbound; } 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=520348&r1=520347&r2=520348 ============================================================================== --- incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl (original) +++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl Tue Mar 20 03:40:54 2007 @@ -254,6 +254,20 @@ + + + + + + + + + + + + + +