harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r419264 - /incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SocketChannelTest.java
Date Wed, 05 Jul 2006 15:57:11 GMT
Author: gharley
Date: Wed Jul  5 08:57:11 2006
New Revision: 419264

URL: http://svn.apache.org/viewvc?rev=419264&view=rev
Log:
Backing out HARMONY-755 changes due to test failures on Linux. Win XP seems OK. 

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=419264&r1=419263&r2=419264&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 08:57:11 2006
@@ -1596,28 +1596,29 @@
         this.channel1.connect(localAddr1);
         assertFalse(this.channel1.isConnected());
         ensureServerOpen();
-
-        assertFalse(this.channel1.finishConnect());
-        assertFalse(this.channel1.isBlocking());
-        assertFalse(this.channel1.isConnected());
-        assertTrue(this.channel1.isConnectionPending());
-        assertTrue(this.channel1.isOpen());
+        // cannot connect?
         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
-        }
-        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
+            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");
         }
     }
 
@@ -1654,28 +1655,29 @@
         this.channel1.connect(localAddr1);
         assertFalse(this.channel1.isConnected());
         ensureServerOpen();
-
-        assertFalse(this.channel1.finishConnect());
-        assertFalse(this.channel1.isBlocking());
-        assertFalse(this.channel1.isConnected());
-        assertTrue(this.channel1.isConnectionPending());
-        assertTrue(this.channel1.isOpen());
-        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
-        }
-        this.channel1.configureBlocking(true);
+        // cannot connect?
         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
+            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");
         }
     }
 
@@ -1716,6 +1718,35 @@
     // -------------------------------------------------------------------
     // 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