harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r419222 - /incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SocketChannelTest.java
Date Wed, 05 Jul 2006 13:09:52 GMT
Author: gharley
Date: Wed Jul  5 06:09:51 2006
New Revision: 419222

URL: http://svn.apache.org/viewvc?rev=419222&view=rev
Log:
HARMONY 755 : [nio] Refine tests in o.a.h.tests.java.nio.channels.SocketChannelTest

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SocketChannelTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SocketChannelTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SocketChannelTest.java?rev=419222&r1=419221&r2=419222&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SocketChannelTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SocketChannelTest.java
Wed Jul  5 06:09:51 2006
@@ -1596,29 +1596,28 @@
         this.channel1.connect(localAddr1);
         assertFalse(this.channel1.isConnected());
         ensureServerOpen();
-        // cannot connect?
+
+        assertFalse(this.channel1.finishConnect());
+        assertFalse(this.channel1.isBlocking());
+        assertFalse(this.channel1.isConnected());
+        assertTrue(this.channel1.isConnectionPending());
+        assertTrue(this.channel1.isOpen());
         try {
-            assertFalse(this.channel1.finishConnect());
-            assertFalse(this.channel1.isBlocking());
-            assertFalse(this.channel1.isConnected());
-            assertTrue(this.channel1.isConnectionPending());
-            assertTrue(this.channel1.isOpen());
-            try {
-                this.channel1.connect(localAddr1);
-                fail("Should throw ConnectionPendingException");
-            } catch (ConnectionPendingException e) {
-                // correct
-            }
-            this.channel1.configureBlocking(true);
-            try {
-                this.channel1.connect(localAddr1);
-                fail("Should throw ConnectionPendingException");
-            } catch (ConnectionPendingException e) {
-                // correct
-            }
-            tryFinish();
-        } catch (ConnectException e) {
-            // FIXME: assertEquals(e.getMessage(), "Connection refused");
+            // should throw ConnectionPendingException because channel.connect
+            // has already been invoked in the previous code.
+            this.channel1.connect(localAddr1);
+            fail("Should throw ConnectionPendingException");
+        } catch (ConnectionPendingException e) {
+            // correct
+        }
+        this.channel1.configureBlocking(true);
+        try {
+            // should throw ConnectionPendingException because channel.connect
+            // has already been invoked in the previous code.
+            this.channel1.connect(localAddr1);
+            fail("Should throw ConnectionPendingException");
+        } catch (ConnectionPendingException e) {
+            // correct
         }
     }
 
@@ -1655,29 +1654,28 @@
         this.channel1.connect(localAddr1);
         assertFalse(this.channel1.isConnected());
         ensureServerOpen();
-        // cannot connect?
+
+        assertFalse(this.channel1.finishConnect());
+        assertFalse(this.channel1.isBlocking());
+        assertFalse(this.channel1.isConnected());
+        assertTrue(this.channel1.isConnectionPending());
+        assertTrue(this.channel1.isOpen());
         try {
-            assertFalse(this.channel1.finishConnect());
-            assertFalse(this.channel1.isBlocking());
-            assertFalse(this.channel1.isConnected());
-            assertTrue(this.channel1.isConnectionPending());
-            assertTrue(this.channel1.isOpen());
-            try {
-                this.channel1.connect(localAddr1);
-                fail("Should throw ConnectionPendingException");
-            } catch (ConnectionPendingException e) {
-                // correct
-            }
-            this.channel1.configureBlocking(true);
-            try {
-                this.channel1.connect(localAddr1);
-                fail("Should throw ConnectionPendingException");
-            } catch (ConnectionPendingException e) {
-                // correct
-            }
-            tryFinish();
-        } catch (ConnectException e) {
-            // FIXME: assertEquals(e.getMessage(), "Connection refused");
+            // should throw ConnectionPendingException because channel.connect
+            // has already been invoked in the previous code.
+            this.channel1.connect(localAddr1);
+            fail("Should throw ConnectionPendingException");
+        } catch (ConnectionPendingException e) {
+            // correct
+        }
+        this.channel1.configureBlocking(true);
+        try {
+            // should throw ConnectionPendingException because channel.connect
+            // has already been invoked in the previous code.
+            this.channel1.connect(localAddr1);
+            fail("Should throw ConnectionPendingException");
+        } catch (ConnectionPendingException e) {
+            // correct
         }
     }
 
@@ -1718,35 +1716,6 @@
     // -------------------------------------------------------------------
     // End of original tests. Test method for CFII with real data.
     // -------------------------------------------------------------------
-
-    public void testConnect_Lock() throws Exception {
-        final Socket sock = new Socket();
-        new Thread() {
-            public void run() {
-                try {
-                    sock.connect(localAddr2);
-                } catch (Exception e) {
-                    System.out.println("in thread1" + e.getMessage());
-                }
-                if (!sock.isClosed())
-                    System.out.println("T1 not closed");
-            }
-        }.start();
-        new Thread() {
-            public void run() {
-                try {
-                    Thread.sleep(200);
-                    sock.connect(localAddr1);
-                } catch (Exception e) {
-                    System.out.println("in thread2" + e.getMessage());
-                }
-                if (!sock.isClosed())
-                    System.out.println("T2 not closed");
-            }
-        }.start();
-        Thread.sleep(2000);
-        sock.close();
-    }
 
     /**
      * @tests java.nio.channels.SocketChannel#read(ByteBuffer)



Mime
View raw message