diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2008-02-07 18:15:20 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2008-02-07 18:15:20 +0000 |
| commit | 021713fbe45e92e5eef13184be711c7156d7db00 (patch) | |
| tree | 525bbaa32a1099f1ae35b0e92b03684bd6c1cdee /java/common/src | |
| parent | 06ca351132b86961e14ee59f7353c1f7e1a0f50a (diff) | |
| download | qpid-python-021713fbe45e92e5eef13184be711c7156d7db00.tar.gz | |
added test for exception listener; fixed NPE
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@619538 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/src')
| -rw-r--r-- | java/common/src/main/java/org/apache/qpid/util/concurrent/Condition.java | 50 | ||||
| -rw-r--r-- | java/common/src/test/java/org/apache/qpidity/transport/ConnectionTest.java | 23 |
2 files changed, 52 insertions, 21 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 new file mode 100644 index 0000000000..bbd1722677 --- /dev/null +++ b/java/common/src/main/java/org/apache/qpid/util/concurrent/Condition.java @@ -0,0 +1,50 @@ +/* + * + * 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/qpidity/transport/ConnectionTest.java b/java/common/src/test/java/org/apache/qpidity/transport/ConnectionTest.java index 167b02a556..55d53ebaae 100644 --- a/java/common/src/test/java/org/apache/qpidity/transport/ConnectionTest.java +++ b/java/common/src/test/java/org/apache/qpidity/transport/ConnectionTest.java @@ -22,6 +22,8 @@ package org.apache.qpidity.transport; import org.apache.mina.util.AvailablePortFinder; +import org.apache.qpid.util.concurrent.Condition; + import org.apache.qpidity.transport.network.mina.MinaHandler; import org.apache.qpidity.transport.util.Logger; @@ -63,27 +65,6 @@ public class ConnectionTest extends TestCase MinaHandler.accept("0.0.0.0", port, server); } - private 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; - } - } - private Connection connect(final Condition closed) { Connection conn = MinaHandler.connect("0.0.0.0", port, new ConnectionDelegate() |
