harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r413712 - /incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SinkChannelTest.java
Date Mon, 12 Jun 2006 17:22:28 GMT
Author: gharley
Date: Mon Jun 12 10:22:28 2006
New Revision: 413712

URL: http://svn.apache.org/viewvc?rev=413712&view=rev
Log:
Update unit test that is behaving in an unstable manner on Linux only. 

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SinkChannelTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SinkChannelTest.java?rev=413712&r1=413711&r2=413712&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SinkChannelTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SinkChannelTest.java
Mon Jun 12 10:22:28 2006
@@ -103,35 +103,36 @@
 	 */
 	public void test_write_LByteBuffer_mutliThread() throws IOException,
 	        InterruptedException {
-		final int THREAD_NUM = 20;
-		Thread[] thread = new Thread[THREAD_NUM];
-		for (int i = 0; i < THREAD_NUM; i++) {
-			thread[i] = new Thread() {
-				public void run() {
-					try {
-						sink
-						        .write(ByteBuffer.wrap("bytes"
-						                .getBytes(ISO8859_1)));
-					} catch (IOException e) {
-						// ignore
-					}
-				}
-			};
-		}
-		for (int i = 0; i < THREAD_NUM; i++) {
-			thread[i].start();
-		}
-		for (int i = 0; i < THREAD_NUM; i++) {
-			thread[i].join();
-		}
-		ByteBuffer readBuf = ByteBuffer.allocate(THREAD_NUM * BUFFER_SIZE);
-		source.read(readBuf);
-		StringBuffer buf = new StringBuffer();
-		for (int i = 0; i < THREAD_NUM; i++) {
-			buf.append("bytes");
-		}
-		String readString = buf.toString();
-		assertEquals(readString, new String(readBuf.array(), ISO8859_1));
+        final int THREAD_NUM = 20;
+        Thread[] thread = new Thread[THREAD_NUM];
+        for (int i = 0; i < THREAD_NUM; i++) {
+            thread[i] = new Thread() {
+                public void run() {
+                    try {
+                        sink
+                                .write(ByteBuffer.wrap("bytes"
+                                        .getBytes(ISO8859_1)));
+                    } catch (IOException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            };
+        }
+        for (int i = 0; i < THREAD_NUM; i++) {
+            thread[i].start();
+        }
+        for (int i = 0; i < THREAD_NUM; i++) {
+            thread[i].join();
+        }
+        ByteBuffer readBuf = ByteBuffer.allocate(THREAD_NUM * BUFFER_SIZE);
+        long readVal = source.read(readBuf);
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < THREAD_NUM; i++) {
+            buf.append("bytes");
+        }
+        String readString = buf.toString();
+        assertEquals(readString.length(), readVal);
+        assertEquals(readString, new String(readBuf.array(), ISO8859_1));
 	}
 
 	/**



Mime
View raw message