cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1130068 - /cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/RetransmissionQueueTest.java
Date Wed, 01 Jun 2011 09:17:32 GMT
Author: ay
Date: Wed Jun  1 09:17:27 2011
New Revision: 1130068

URL: http://svn.apache.org/viewvc?rev=1130068&view=rev
Log:
[CXF-3563] WS-RM RetransmissionQueueTest to correctly simulate the testing condition

Modified:
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/RetransmissionQueueTest.java

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/RetransmissionQueueTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/RetransmissionQueueTest.java?rev=1130068&r1=1130067&r2=1130068&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/RetransmissionQueueTest.java
(original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/RetransmissionQueueTest.java
Wed Jun  1 09:17:27 2011
@@ -18,7 +18,7 @@
  */
 package org.apache.cxf.systest.ws.rm;
 
-import java.io.IOException;
+import java.io.OutputStream;
 import java.util.logging.Logger;
 
 import javax.xml.ws.Endpoint;
@@ -32,6 +32,7 @@ import org.apache.cxf.greeter_control.Gr
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.interceptor.MessageSenderInterceptor;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -113,22 +114,30 @@ public class RetransmissionQueueTest ext
         
         bus.getOutFaultInterceptors().add(out);
         
+        bus.getExtension(RMManager.class).getRMAssertion().getBaseRetransmissionInterval()
+        .setMilliseconds(new Long(5000));
+        
         GreeterService gs = new GreeterService();
         final Greeter greeter = gs.getGreeterPort();
         updateAddressPort(greeter, DecoupledClientServerTest.PORT);
         LOG.fine("Created greeter client.");
        
         ConnectionHelper.setKeepAliveConnection(greeter, true);
+        RMManager manager = bus.getExtension(RMManager.class);
         
         try {
             greeter.greetMeOneWay("oneway");            
         } catch (Exception e) {
-            fail("fault thrown after queued for retransmission");
+            // no exception shall be thrown when the message is queued for retransmission
+            fail("fault thrown after queued for retransmission: " + e);
         }
         
+        // the message shall be in the queue
+        assertFalse("RetransmissionQueue empty", manager.getRetransmissionQueue().isEmpty());
+        
         tes.setWorking(true);
 
-        long wait = 3000;
+        long wait = 10000;
         while (wait > 0) {
             long start = System.currentTimeMillis();
             try {
@@ -138,14 +147,14 @@ public class RetransmissionQueueTest ext
             }
             wait -= System.currentTimeMillis() - start;
         }
-        
-        RMManager manager = bus.getExtension(RMManager.class);
-        boolean empty = manager.getRetransmissionQueue().isEmpty();
-        
-        assertTrue("RetransmissionQueue not cleared", empty);
+
+        // the message shall no longer be in the queue
+        assertTrue("RetransmissionQueue not empty", manager.getRetransmissionQueue().isEmpty());
     }
 
-    
+    /*
+     * an interceptor to trigger an error occuring at the sending phase.
+     */
     static class TransmissionErrorSimulator extends AbstractPhaseInterceptor<Message>
{
         private boolean working;
         
@@ -153,7 +162,8 @@ public class RetransmissionQueueTest ext
          * @param phase
          */
         public TransmissionErrorSimulator() {
-            super(Phase.WRITE);
+            super(Phase.PREPARE_SEND);
+            addAfter(MessageSenderInterceptor.class.getName());
         }
 
         /* (non-Javadoc)
@@ -169,10 +179,14 @@ public class RetransmissionQueueTest ext
                 // spare the message
             } else if (!working) {
                 // triggers a simulated error
-                throw new Fault(new IOException("simulated transmission error"));
+                try {
+                    message.getContent(OutputStream.class).close();
+                } catch (Exception e) {
+                    //
+                }
             }
         }
-
+        
         /**
          * @return the working
          */



Mime
View raw message