directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: rev 57033 - in incubator/directory/seda/trunk: . src/java/org/apache/seda/listener src/test/org/apache/seda/examples
Date Tue, 09 Nov 2004 12:59:37 GMT
Author: trustin
Date: Tue Nov  9 04:59:36 2004
New Revision: 57033

Modified:
   incubator/directory/seda/trunk/project.properties
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java
   incubator/directory/seda/trunk/src/test/org/apache/seda/examples/EchoProtocolProviderTest.java
Log:
Fixed: AvailablePortFinder does not check UDP port.
Fixed: 'maven java:compile' does not work in JDK 1.5
Uncommented EchoProtocolProviderTest.testUDP()

Modified: incubator/directory/seda/trunk/project.properties
==============================================================================
--- incubator/directory/seda/trunk/project.properties	(original)
+++ incubator/directory/seda/trunk/project.properties	Tue Nov  9 04:59:36 2004
@@ -11,3 +11,5 @@
 maven.repo.central=minotaur.apache.org
 maven.repo.central.directory=/www/cvs.apache.org/repository
 maven.remote.group=apcvs
+
+maven.compile.source = 1.3
\ No newline at end of file

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java
(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java
Tue Nov  9 04:59:36 2004
@@ -18,9 +18,8 @@
 package org.apache.seda.listener;
 
 import java.io.IOException;
-
+import java.net.DatagramSocket;
 import java.net.ServerSocket;
-
 import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.TreeSet;
@@ -91,11 +90,12 @@
 
         for (int i = fromPort; i <= MAX_PORT_NUMBER; i++)
         {
-            ServerSocket s = null;
-
+            ServerSocket ss = null;
+            DatagramSocket ds = null;
             try
             {
-                s = new ServerSocket(i);
+                ss = new ServerSocket(i);
+                ds = new DatagramSocket(i);
                 return i;
             }
             catch (IOException e)
@@ -103,11 +103,16 @@
             }
             finally
             {
-                if (s != null)
+                if (ds != null)
+                {
+                    ds.close();
+                }
+
+                if (ss != null)
                 {
                     try
                     {
-                        s.close();
+                        ss.close();
                     }
                     catch (IOException e)
                     {

Modified: incubator/directory/seda/trunk/src/test/org/apache/seda/examples/EchoProtocolProviderTest.java
==============================================================================
--- incubator/directory/seda/trunk/src/test/org/apache/seda/examples/EchoProtocolProviderTest.java
(original)
+++ incubator/directory/seda/trunk/src/test/org/apache/seda/examples/EchoProtocolProviderTest.java
Tue Nov  9 04:59:36 2004
@@ -91,40 +91,40 @@
 
     public void testUDP() throws Exception
     {
-//    	EchoUDPClient client = new EchoUDPClient();
-//        client.open();
-//        client.setSoTimeout(3000);
-//
-//        byte[] writeBuf = new byte[16];
-//
-//        for (int i = 0; i < 10; i++)
-//        {
-//            fillWriteBuffer(writeBuf, i);
-//            client.send(writeBuf, writeBuf.length, InetAddress.getLocalHost(), port);
-//        }
-//
-//        byte[] readBuf = new byte[writeBuf.length];
-//
-//        for (int i = 0; i < 10; i++)
-//        {
-//            fillWriteBuffer(writeBuf, i);
-//
-//            assertEquals(readBuf.length, client.receive(readBuf, readBuf.length));
-//            assertEquals(writeBuf, readBuf);
-//        }
-//
-//        client.setSoTimeout(100);
-//
-//        try
-//        {
-//            client.receive(readBuf);
-//            fail("Unexpected incoming data.");
-//        }
-//        catch (SocketTimeoutException e)
-//        {
-//        }
-//
-//        client.close();
+    	EchoUDPClient client = new EchoUDPClient();
+        client.open();
+        client.setSoTimeout(3000);
+
+        byte[] writeBuf = new byte[16];
+
+        for (int i = 0; i < 10; i++)
+        {
+            fillWriteBuffer(writeBuf, i);
+            client.send(writeBuf, writeBuf.length, InetAddress.getLocalHost(), port);
+        }
+
+        byte[] readBuf = new byte[writeBuf.length];
+
+        for (int i = 0; i < 10; i++)
+        {
+            fillWriteBuffer(writeBuf, i);
+
+            assertEquals(readBuf.length, client.receive(readBuf, readBuf.length));
+            assertEquals(writeBuf, readBuf);
+        }
+
+        client.setSoTimeout(100);
+
+        try
+        {
+            client.receive(readBuf);
+            fail("Unexpected incoming data.");
+        }
+        catch (SocketTimeoutException e)
+        {
+        }
+
+        client.close();
     }
 
 	private void fillWriteBuffer(byte[] writeBuf, int i) {

Mime
View raw message