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 2006/11/08 19:43:29 UTC

svn commit: r472581 - in /incubator/cxf/trunk: rt/ws/rm/src/main/resources/META-INF/cxf/ systests/src/test/java/org/apache/cxf/systest/common/ systests/src/test/java/org/apache/cxf/systest/ws/rm/

Author: andreasmyth
Date: Wed Nov  8 10:43:28 2006
New Revision: 472581

URL: http://svn.apache.org/viewvc?view=rev&rev=472581
Log:
[JIRA CXF-140] Added test for deferred acknowledgements.

Added:
    incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-property-editors.xml   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous-deferred.xml   (with props)
Modified:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/common/ClientServerSetupBase.java
    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
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous.xml

Added: incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-property-editors.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-property-editors.xml?view=auto&rev=472581
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-property-editors.xml (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-property-editors.xml Wed Nov  8 10:43:28 2006
@@ -0,0 +1,49 @@
+<?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"
+       xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+   
+    <bean id="org.apache.cxf.ws.rm.customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
+        <property name="propertyEditorRegistrars">
+            <list>
+                <bean class="org.apache.cxf.configuration.spring.JaxbPropertyEditorRegistrar">
+                    <property name="packageName" value="org.apache.cxf.ws.rm.manager"/>
+                    <property name="propertyClassNames">
+                        <list>
+                            <value>SourcePolicyType</value>
+                            <value>DestinationPolicyType</value>
+                            <value>DeliveryAssuranceType</value>
+                        </list>
+                    </property>
+                </bean>
+                <bean class="org.apache.cxf.configuration.spring.JaxbPropertyEditorRegistrar">
+                    <property name="packageName" value="org.apache.cxf.ws.rm.policy"/>
+                    <property name="propertyClassNames">
+                        <list>
+                            <value>RMAssertion</value>
+                        </list>
+                    </property>
+                </bean>
+           </list>
+        </property>
+    </bean>
+</beans>
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-property-editors.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-property-editors.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-property-editors.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/common/ClientServerSetupBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/common/ClientServerSetupBase.java?view=diff&rev=472581&r1=472580&r2=472581
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/common/ClientServerSetupBase.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/common/ClientServerSetupBase.java Wed Nov  8 10:43:28 2006
@@ -46,8 +46,10 @@
     
     public void tearDown() throws Exception {
         super.tearDown();
-        bus.shutdown(true);
-        bus = null;
+        if (null != bus) {
+            bus.shutdown(true);
+            bus = null;
+        }
         if (configFileName != null) {
             System.clearProperty("cxf.config.file");
         }

Modified: 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/rm/InMessageRecorder.java?view=diff&rev=472581&r1=472580&r2=472581
==============================================================================
--- 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/rm/InMessageRecorder.java Wed Nov  8 10:43:28 2006
@@ -23,6 +23,8 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Fault;
@@ -32,6 +34,7 @@
 
 public class InMessageRecorder extends AbstractPhaseInterceptor<Message> {
 
+    private static final Logger LOG = Logger.getLogger(InMessageRecorder.class.getName());
     private List<byte[]> inbound;
 
     public InMessageRecorder() {
@@ -52,6 +55,9 @@
             is.close();
             bos.close();
             inbound.add(bos.toByteArray());
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("inbound: " + bos.toString());
+            }
             ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
             message.setContent(InputStream.class, bis);
         } catch (Exception ex) {

Modified: 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/rm/MessageFlow.java?view=diff&rev=472581&r1=472580&r2=472581
==============================================================================
--- 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/rm/MessageFlow.java Wed Nov  8 10:43:28 2006
@@ -43,8 +43,7 @@
     private List<byte[]> outStreams;
     private List<Document> outboundMessages;
     private List<Document> inboundMessages;
-    
-    
+      
     public MessageFlow(List<byte[]> out, List<byte[]> in) throws Exception {
         inStreams = in;
         outStreams = out;

Modified: 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/rm/OutMessageRecorder.java?view=diff&rev=472581&r1=472580&r2=472581
==============================================================================
--- 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/rm/OutMessageRecorder.java Wed Nov  8 10:43:28 2006
@@ -26,6 +26,8 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 
 import org.apache.cxf.interceptor.Fault;
@@ -40,6 +42,7 @@
  */
 public class OutMessageRecorder extends AbstractPhaseInterceptor {
     
+    private static final Logger LOG = Logger.getLogger(OutMessageRecorder.class.getName());
     private List<byte[]> outbound;
     private Set<String> before = Collections.singleton(StaxOutInterceptor.class.getName());
 
@@ -85,6 +88,9 @@
             bos.close();
             original.close();
             outbound.add(bos.toByteArray());
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("outbound: " + bos.toString());
+            }
         }
 
         @Override

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=472581&r1=472580&r2=472581
==============================================================================
--- 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 Wed Nov  8 10:43:28 2006
@@ -47,6 +47,7 @@
     //private static final String GREETME_ACTION = APP_NAMESPACE + "/types/Greeter/greetMe";
     //private static final String GREETME_RESPONSE_ACTION = GREETME_ACTION + "Response";
 
+    private Bus controlBus;
     private Control control;
     private Bus greeterBus;
     private Greeter greeter;
@@ -54,6 +55,7 @@
     private InMessageRecorder inRecorder;
 
     private boolean doTestOnewayAnonymousAcks = true;
+    private boolean doTestOnewayDeferredAnonymousAcks = true;
 
     public static void main(String[] args) {
         junit.textui.TestRunner.run(SequenceTest.class);
@@ -68,29 +70,42 @@
             
             public void setUp() throws Exception {
                 startServers();
-                LOG.fine("Started server");
+                LOG.fine("Started server.");
 
+                /*
                 SpringBusFactory bf = new SpringBusFactory();
                 Bus bus = bf.createBus();
                 bf.setDefaultBus(bus);
                 setBus(bus);
-                LOG.fine("Created client bus");
+                LOG.fine("Initialised client bus."); 
+                */               
             }
         };
     }
 
     public void setUp() throws Exception {
-        super.setUp();
-        ControlService service = new ControlService(); 
-        LOG.fine("Created ControlService");
+        SpringBusFactory bf = new SpringBusFactory();
+        controlBus = bf.createBus();
+        bf.setDefaultBus(controlBus);
+        LOG.fine("Initialised control bus.");
+        controlBus = new SpringBusFactory().getDefaultBus();
+
+        ControlService service = new ControlService();
+        LOG.fine("Created ControlService.");
         control = service.getControlPort();
-        LOG.fine("Created Control");
+        LOG.fine("Created Control.");
     }
     
     public void tearDown() {
         if (null != greeter) {
-            assertTrue("Failed to stop greeter", control.stopGreeter());
+            assertTrue("Failed to stop greeter.", control.stopGreeter());            
             greeterBus.shutdown(true);
+            LOG.fine("Shutdown greeter bus.");
+            greeterBus = null;
+        }
+        if (null != control) {               
+            controlBus.shutdown(true);
+            LOG.fine("Shutdown control bus.");
         }
     }
 
@@ -125,6 +140,43 @@
         mf.verifyMessageNumbers(new String[] {null, null, null, null}, false);
         mf.verifyAcknowledgements(new boolean[] {false, true, true, true}, false);
     }
+    
+    public void testOnewayDeferredAnonymousAcks() throws Exception {
+        if (!doTestOnewayDeferredAnonymousAcks) {
+            return;
+        }
+        setupGreeter("org/apache/cxf/systest/ws/rm/anonymous-deferred.xml");
+
+        greeter.greetMeOneWay("once");
+        greeter.greetMeOneWay("twice");
+
+        try {
+            Thread.sleep(3 * 1000);
+        } catch (InterruptedException ex) {
+            // ignore
+        }
+
+        greeter.greetMeOneWay("thrice");
+
+        MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages());
+                
+        // three application messages plus createSequence
+        mf.verifyMessages(4, true);
+        String[] expectedActions = new String[] {RMConstants.getCreateSequenceAction(), null,
+                                                 null, null};
+        mf.verifyActions(expectedActions, true);
+        mf.verifyMessageNumbers(new String[] {null, "1", "2", "3"}, true);
+
+        // createSequenceResponse message plus 3 partial responses, only the
+        // last one should include a sequence acknowledgment
+
+        mf.verifyMessages(4, false);
+        expectedActions = 
+            new String[] {RMConstants.getCreateSequenceResponseAction(), null, null, null};
+        mf.verifyActions(expectedActions, false);
+        mf.verifyMessageNumbers(new String[] {null, null, null, null}, false);
+        mf.verifyAcknowledgements(new boolean[] {false, false, false, true}, false);
+    }
 
     // --- test utilities ---
 
@@ -133,6 +185,7 @@
         SpringBusFactory bf = new SpringBusFactory();
         greeterBus = bf.createBus(cfgResource);
         bf.setDefaultBus(greeterBus);
+        LOG.fine("Initialised greeter bus.");
 
         outRecorder = new OutMessageRecorder();
         greeterBus.getOutInterceptors().add(new JaxwsInterceptorRemover());
@@ -144,6 +197,7 @@
         
         GreeterService service = new GreeterService();
         greeter = service.getGreeterPort();
+        LOG.fine("Created greeter client.");
  
         
         

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous-deferred.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous-deferred.xml?view=auto&rev=472581
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous-deferred.xml (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous-deferred.xml Wed Nov  8 10:43:28 2006
@@ -0,0 +1,93 @@
+<?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"
+       xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+    
+    <bean id="org.apache.cxf.ws.rm.RMManager" class="org.apache.cxf.ws.rm.RMManager">
+        <property name="bus" ref="cxf"/>  
+        <property name="destinationPolicy">
+            <value>
+                <wsrm-mgmt:destinationPolicy>
+                    <wsrm-mgmt:acksPolicy intraMessageThreshold="0"/>                    
+                </wsrm-mgmt:destinationPolicy>
+            </value>
+        </property>
+        
+        <property name="RMAssertion">
+            <value>
+                <wsrm-policy:RMAssertion>         
+                    <wsrm-policy:BaseRetransmissionInterval Milliseconds="10000"/>           
+                    <wsrm-policy:AcknowledgementInterval Milliseconds="2000"/>                                                        
+                </wsrm-policy:RMAssertion>
+            </value>
+        </property>   
+    </bean>   
+
+    <bean id="mapAggregator" class="org.apache.cxf.ws.addressing.MAPAggregator"/>
+    <bean id="mapCodec" class="org.apache.cxf.ws.addressing.soap.MAPCodec"/>
+    <bean id="rmLogicalOut" class="org.apache.cxf.ws.rm.RMOutInterceptor">
+        <property name="bus" ref="cxf"/>
+    </bean>
+    <bean id="rmLogicalIn" class="org.apache.cxf.ws.rm.RMInInterceptor">
+        <property name="bus" ref="cxf"/>
+    </bean>
+    <bean id="rmCodec" class="org.apache.cxf.ws.rm.soap.RMSoapInterceptor"/>
+
+    <!-- We are adding the interceptors to the bus as we will have only one endpoint/service/bus. -->
+
+    <bean id="cxf" class="org.apache.cxf.bus.spring.SpringBusImpl">
+        <property name="inInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+                <ref bean="rmLogicalIn"/>
+                <ref bean="rmCodec"/>
+            </list>
+        </property>
+        <property name="inFaultInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+                <ref bean="rmLogicalIn"/>
+                <ref bean="rmCodec"/>
+            </list>
+        </property>
+        <property name="outInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+                <ref bean="rmLogicalOut"/>
+                <ref bean="rmCodec"/>
+            </list>
+        </property>
+        <property name="outFaultInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+                <ref bean="rmLogicalOut"/>
+                <ref bean="rmCodec"/>
+            </list>
+        </property>
+    </bean>
+</beans>
\ No newline at end of file

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous-deferred.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous-deferred.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous-deferred.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous.xml?view=diff&rev=472581&r1=472580&r2=472581
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous.xml (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/anonymous.xml Wed Nov  8 10:43:28 2006
@@ -22,22 +22,7 @@
        xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
        xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-    
-    <!--
-    <bean name="{http://apache.org/hello_world_soap_http}SoapPort.http-conduit" abstract="true">
-        <property name="client">
-            <value>
-                <http-conf:client DecoupledEndpoint="http://localhost:9999/decoupled_endpoint"/>
-            </value>
-        </property>
-    </bean>
-    -->
-
-    <!--
-    <bean id="logOutgoing" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
-    -->
-    <bean id="logOutgoing" class="org.apache.cxf.systest.ws.rm.OutMessageRecorder"/>
-    <bean id="logIncoming" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+  
     <bean id="mapAggregator" class="org.apache.cxf.ws.addressing.MAPAggregator"/>
     <bean id="mapCodec" class="org.apache.cxf.ws.addressing.soap.MAPCodec"/>
     <bean id="rmLogicalOut" class="org.apache.cxf.ws.rm.RMOutInterceptor">
@@ -53,9 +38,6 @@
     <bean id="cxf" class="org.apache.cxf.bus.spring.SpringBusImpl">
         <property name="inInterceptors">
             <list>
-                <ref bean="logIncoming"/>
-                <!--
-                -->
                 <ref bean="mapAggregator"/>
                 <ref bean="mapCodec"/>
                 <ref bean="rmLogicalIn"/>
@@ -64,9 +46,6 @@
         </property>
         <property name="inFaultInterceptors">
             <list>
-                <ref bean="logIncoming"/>
-                <!--
-                -->
                 <ref bean="mapAggregator"/>
                 <ref bean="mapCodec"/>
                 <ref bean="rmLogicalIn"/>
@@ -75,9 +54,6 @@
         </property>
         <property name="outInterceptors">
             <list>
-                <!--
-                <ref bean="logOutgoing"/>
-                -->
                 <ref bean="mapAggregator"/>
                 <ref bean="mapCodec"/>
                 <ref bean="rmLogicalOut"/>
@@ -86,9 +62,6 @@
         </property>
         <property name="outFaultInterceptors">
             <list>
-                <!--
-                <ref bean="logOutgoing"/>
-                -->
                 <ref bean="mapAggregator"/>
                 <ref bean="mapCodec"/>
                 <ref bean="rmLogicalOut"/>