Author: dkulp
Date: Wed Jun 6 18:32:40 2012
New Revision: 1347035
URL: http://svn.apache.org/viewvc?rev=1347035&view=rev
Log:
Merged revisions 1345416 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1345416 | dkulp | 2012-06-01 21:54:19 -0400 (Fri, 01 Jun 2012) | 2 lines
Shorten the wait times on fast computers
........
Modified:
cxf/branches/2.5.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckBase.java
Modified:
cxf/branches/2.5.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckBase.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckBase.java?rev=1347035&r1=1347034&r2=1347035&view=diff
==============================================================================
---
cxf/branches/2.5.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckBase.java
(original)
+++
cxf/branches/2.5.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckBase.java
Wed Jun 6 18:32:40 2012
@@ -38,6 +38,7 @@ import org.apache.cxf.test.TestUtilities
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
import org.apache.cxf.ws.rm.RMManager;
+import org.apache.cxf.ws.rm.RetransmissionQueue;
import org.junit.After;
import org.junit.AfterClass;
@@ -133,16 +134,16 @@ public abstract class ServiceInvocationA
// the message is acked and the invocation takes place
greeter.greetMeOneWay("one");
- Thread.sleep(6000L);
- assertTrue("RetransmissionQueue must be empty",
manager.getRetransmissionQueue().isEmpty());
+ waitForEmpty(manager.getRetransmissionQueue());
control.setFaultLocation(location);
// the invocation fails but the message is acked because the delivery
succeeds
greeter.greetMeOneWay("two");
- Thread.sleep(6000L);
- assertTrue("RetransmissionQueue must be empty",
manager.getRetransmissionQueue().isEmpty());
+ waitForEmpty(manager.getRetransmissionQueue());
}
+
+
@Test
public void testRobustInvocationHandling() throws Exception {
@@ -160,25 +161,50 @@ public abstract class ServiceInvocationA
// the message is acked and the invocation takes place
greeter.greetMeOneWay("one");
- Thread.sleep(6000L);
- assertTrue("RetransmissionQueue must be empty",
manager.getRetransmissionQueue().isEmpty());
+ waitForEmpty(manager.getRetransmissionQueue());
control.setFaultLocation(location);
// the invocation fails but the message is acked because the delivery
succeeds
greeter.greetMeOneWay("two");
- Thread.sleep(6000L);
- assertFalse("RetransmissionQueue must not be empty",
manager.getRetransmissionQueue().isEmpty());
-
+ waitForNotEmpty(manager.getRetransmissionQueue());
+
location.setPhase(null);
control.setFaultLocation(location);
// the retransmission succeeds and the invocation succeeds, the
message is acked
- Thread.sleep(6000L);
- assertTrue("RetransmissionQueue must be empty",
manager.getRetransmissionQueue().isEmpty());
+ waitForEmpty(manager.getRetransmissionQueue());
}
+ private void waitForNotEmpty(RetransmissionQueue retransmissionQueue)
throws Exception {
+ long start = System.currentTimeMillis();
+ while (true) {
+ Thread.sleep(100);
+ if (!retransmissionQueue.isEmpty()) {
+ return;
+ }
+ long total = System.currentTimeMillis() - start;
+ if (total > 10000L) {
+ fail("RetransmissionQueue must not be empty");
+ }
+ }
+ }
+
+ private void waitForEmpty(RetransmissionQueue retransmissionQueue) throws
Exception {
+ long start = System.currentTimeMillis();
+ while (true) {
+ Thread.sleep(100);
+ if (retransmissionQueue.isEmpty()) {
+ return;
+ }
+ long total = System.currentTimeMillis() - start;
+ if (total > 10000L) {
+ fail("RetransmissionQueue must be empty");
+ }
+ }
+ }
+
protected void setupGreeter(String cfgResource) throws
NumberFormatException, MalformedURLException {
SpringBusFactory bf = new SpringBusFactory();