diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2010-04-22 00:03:56 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2010-04-22 00:03:56 +0000 |
commit | 49902715d753ef740af36a47e9ee9e98c3735227 (patch) | |
tree | 5e04c4dd38e99a5100089a934596bec2bf70b3e5 | |
parent | efb0bd0b298dd086309fa409643737b4e3b8dab5 (diff) | |
download | qpid-python-49902715d753ef740af36a47e9ee9e98c3735227.tar.gz |
QPID-2508, Committing a patch from Emmanuel Bourg
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@936575 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 12 insertions, 62 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/util/concurrent/Condition.java b/java/common/src/main/java/org/apache/qpid/util/concurrent/Condition.java deleted file mode 100644 index bbd1722677..0000000000 --- a/java/common/src/main/java/org/apache/qpid/util/concurrent/Condition.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * 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.qpid.util.concurrent; - - -/** - * Condition - * - */ - -public class Condition -{ - - private boolean value = false; - - public synchronized void set() - { - value = true; - notifyAll(); - } - - public synchronized boolean get(long timeout) throws InterruptedException - { - if (!value) - { - wait(timeout); - } - - return value; - } - -} diff --git a/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java b/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java index 6554b135f5..0ca4a0c659 100644 --- a/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java +++ b/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java @@ -22,8 +22,6 @@ package org.apache.qpid.transport; import org.apache.mina.util.AvailablePortFinder; -import org.apache.qpid.util.concurrent.Condition; - import org.apache.qpid.transport.network.ConnectionBinding; import org.apache.qpid.transport.network.io.IoAcceptor; import org.apache.qpid.transport.util.Logger; @@ -34,6 +32,8 @@ import junit.framework.TestCase; import java.util.ArrayList; import java.util.List; import java.util.Collections; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import java.io.IOException; import static org.apache.qpid.transport.Option.*; @@ -157,7 +157,7 @@ public class ConnectionTest extends TestCase implements SessionListener null, msg, sync ? SYNC : NONE); } - private Connection connect(final Condition closed) + private Connection connect(final CountDownLatch closed) { Connection conn = new Connection(); conn.addConnectionListener(new ConnectionListener() @@ -171,7 +171,7 @@ public class ConnectionTest extends TestCase implements SessionListener { if (closed != null) { - closed.set(); + closed.countDown(); } } }); @@ -188,7 +188,7 @@ public class ConnectionTest extends TestCase implements SessionListener // Start server as 0-9 to froce a ProtocolVersionException startServer(new ProtocolHeader(1, 0, 9)); - Condition closed = new Condition(); + CountDownLatch closed = new CountDownLatch(1); try { @@ -249,13 +249,13 @@ public class ConnectionTest extends TestCase implements SessionListener { startServer(); - Condition closed = new Condition(); + CountDownLatch closed = new CountDownLatch(1); Connection conn = connect(closed); Session ssn = conn.createSession(1); send(ssn, "CLOSE"); - if (!closed.get(3000)) + if (!closed.await(3, TimeUnit.SECONDS)) { fail("never got notified of connection close"); } diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java index 6f31f7bc65..e87902dad3 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java @@ -22,8 +22,8 @@ package org.apache.qpid.test.unit.client.connection; import org.apache.qpid.test.utils.QpidTestCase; -import org.apache.qpid.util.concurrent.Condition; - +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import javax.jms.Connection; import javax.jms.ExceptionListener; import javax.jms.JMSException; @@ -42,18 +42,18 @@ public class ExceptionListenerTest extends QpidTestCase conn.start(); - final Condition fired = new Condition(); + final CountDownLatch fired = new CountDownLatch(1); conn.setExceptionListener(new ExceptionListener() { public void onException(JMSException e) { - fired.set(); + fired.countDown(); } }); stopBroker(); - if (!fired.get(3000)) + if (!fired.await(3, TimeUnit.SECONDS)) { fail("exception listener was not fired"); } |