qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ritch...@apache.org
Subject svn commit: r722669 - in /incubator/qpid/trunk/qpid/java/common/src: main/java/org/apache/qpid/transport/network/io/IoAcceptor.java test/java/org/apache/qpid/transport/ConnectionTest.java
Date Tue, 02 Dec 2008 23:25:58 GMT
Author: ritchiem
Date: Tue Dec  2 15:25:58 2008
New Revision: 722669

URL: http://svn.apache.org/viewvc?rev=722669&view=rev
Log:
QPID-1499 : Modification to IoAcceptor so ConnectionTest can close the open SocketServer.

Modified:
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoAcceptor.java
    incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoAcceptor.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoAcceptor.java?rev=722669&r1=722668&r2=722669&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoAcceptor.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoAcceptor.java
Tue Dec  2 15:25:58 2008
@@ -56,6 +56,17 @@
         setName(String.format("IoAcceptor - %s", socket.getInetAddress()));
     }
 
+    /**
+        Close the underlying ServerSocket if it has not already been closed.
+     */
+    public void close() throws IOException
+    {
+        if (!socket.isClosed())
+        {
+            socket.close();
+        }
+    }
+
     public IoAcceptor(String host, int port, Binding<E,ByteBuffer> binding)
         throws IOException
     {

Modified: incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java?rev=722669&r1=722668&r2=722669&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java
Tue Dec  2 15:25:58 2008
@@ -26,7 +26,6 @@
 
 import org.apache.qpid.transport.network.ConnectionBinding;
 import org.apache.qpid.transport.network.io.IoAcceptor;
-import org.apache.qpid.transport.network.io.IoTransport;
 import org.apache.qpid.transport.util.Logger;
 import org.apache.qpid.transport.util.Waiter;
 
@@ -34,7 +33,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Random;
 import java.util.Collections;
 import java.io.IOException;
 
@@ -52,12 +50,20 @@
     private List<MessageTransfer> messages = new ArrayList<MessageTransfer>();
     private List<MessageTransfer> incoming = new ArrayList<MessageTransfer>();
 
+    private IoAcceptor _ioa = null;
+
+
     protected void setUp() throws Exception
     {
         super.setUp();
 
         port = AvailablePortFinder.getNextAvailable(12000);
+    }
 
+    protected void tearDown() throws Exception
+    {
+        _ioa.close();
+        super.tearDown();
     }
 
     public void opened(Session ssn) {}
@@ -206,11 +212,9 @@
             }
         };
 
-        IoAcceptor ioa = null;
         try
         {
-            ioa = new IoAcceptor
-                    ("localhost", port, ConnectionBinding.get(server));
+            _ioa = new IoAcceptor("localhost", port, ConnectionBinding.get(server));
         }
         catch (IOException e)
         {
@@ -218,7 +222,7 @@
             fail("Unable to start Server for test due to:" + e.getMessage());
         }
 
-        ioa.start();
+        _ioa.start();
     }
 
     public void testClosedNotificationAndWriteToClosed() throws Exception



Mime
View raw message