Fix broken tests.

Change-Id: Icbdb2567c8ed33b9340b86c7e1cf565fb8f3df76
diff --git a/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java b/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java
index 78fcd3e..9a89f7e 100644
--- a/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java
+++ b/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java
@@ -1172,9 +1172,6 @@
         }
     }
 
-    /**
-     * @tests java.nio.channels.FileChannel#read(ByteBuffer)
-     */
     public void test_readLByteBuffer() throws Exception {
         writeDataToFile(fileOfReadOnlyFileChannel);
 
@@ -1188,110 +1185,57 @@
         }
     }
 
-    /**
-     * @tests java.nio.channels.FileChannel#read(ByteBuffer, long)
-     */
     public void test_readLByteBufferJ_Null() throws Exception {
-        ByteBuffer readBuffer = null;
-
         try {
-            readOnlyFileChannel.read(readBuffer, 0);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected
-        }
-
-        // first throws NullPointerException
-        try {
-            readOnlyFileChannel.read(readBuffer, -1);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected
-        }
-
-        // first throws NullPointerException
-        writeOnlyFileChannel.close();
-        try {
-            writeOnlyFileChannel.read(readBuffer, 0);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected
+            readOnlyFileChannel.read(null, 0);
+            fail();
+        } catch (NullPointerException expected) {
         }
 
         try {
-            readWriteFileChannel.read(readBuffer, 0);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected
-        }
-
-        // first throws NullPointerException
-        writeOnlyFileChannel.close();
-        try {
-            writeOnlyFileChannel.read(readBuffer, 0);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected
+            readWriteFileChannel.read(null, 0);
+            fail();
+        } catch (NullPointerException expected) {
         }
     }
 
-    /**
-     * @tests java.nio.channels.FileChannel#read(ByteBuffer, long)
-     */
     public void test_readLByteBufferJ_Closed() throws Exception {
         ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
 
         readOnlyFileChannel.close();
         try {
             readOnlyFileChannel.read(readBuffer, 0);
-            fail("should throw ClosedChannelException");
-        } catch (ClosedChannelException e) {
-            // expected
+            fail();
+        } catch (ClosedChannelException expected) {
         }
 
         readWriteFileChannel.close();
         try {
             readWriteFileChannel.read(readBuffer, 0);
-            fail("should throw ClosedChannelException");
-        } catch (ClosedChannelException e) {
-            // expected
+            fail();
+        } catch (ClosedChannelException expected) {
         }
     }
 
-    /**
-     * @tests java.nio.channels.FileChannel#read(ByteBuffer, long)
-     */
     public void test_readLByteBufferJ_IllegalArgument() throws Exception {
         ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
 
         try {
             readOnlyFileChannel.read(readBuffer, -1);
-            fail("should throw IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected
+            fail();
+        } catch (IllegalArgumentException expected) {
         }
 
         try {
             writeOnlyFileChannel.read(readBuffer, -1);
-            fail("should throw IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected
+            fail();
+        } catch (IllegalArgumentException expected) {
         }
 
         try {
             readWriteFileChannel.read(readBuffer, -1);
-            fail("should throw IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        // throws IllegalArgumentException first.
-        readWriteFileChannel.close();
-        try {
-            readWriteFileChannel.read(readBuffer, -1);
-            fail("should throw IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected
+            fail();
+        } catch (IllegalArgumentException expected) {
         }
     }
 
@@ -1303,14 +1247,6 @@
             fail();
         } catch (NonReadableChannelException expected) {
         }
-
-        writeOnlyFileChannel.close();
-        try {
-            writeOnlyFileChannel.read(readBuffer, 0);
-            fail();
-        } catch (ClosedChannelException expected) {
-        } catch (NonReadableChannelException expected) {
-        }
     }
 
     public void test_readLByteBufferJ_Emptyfile() throws Exception {
@@ -2096,144 +2032,73 @@
         assertTrue(Arrays.equals(test.getBytes("iso8859-1"), inputBuffer));
     }
 
-    /**
-     * @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
-     */
     public void test_writeLByteBufferJ_Null() throws Exception {
-        ByteBuffer writeBuffer = null;
-
         try {
-            readOnlyFileChannel.write(writeBuffer, 0);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected
+            readWriteFileChannel.write(null, 0);
+            fail();
+        } catch (NullPointerException expected) {
+        } catch (NonWritableChannelException expected) {
         }
 
         try {
-            writeOnlyFileChannel.write(writeBuffer, 0);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected
-        }
-
-        // first throws NullPointerException
-        try {
-            readOnlyFileChannel.write(writeBuffer, -1);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected
+            writeOnlyFileChannel.write(null, 0);
+            fail();
+        } catch (NullPointerException expected) {
         }
 
         try {
-            readWriteFileChannel.write(writeBuffer, 0);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected
-        }
-
-        // first throws NullPointerException
-        readWriteFileChannel.close();
-        try {
-            readWriteFileChannel.write(writeBuffer, 0);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected
+            readWriteFileChannel.write(null, 0);
+            fail();
+        } catch (NullPointerException expected) {
         }
     }
 
-    /**
-     * @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
-     */
     public void test_writeLByteBufferJ_Closed() throws Exception {
         ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
 
         writeOnlyFileChannel.close();
         try {
             writeOnlyFileChannel.write(writeBuffer, 0);
-            fail("should throw ClosedChannelException");
-        } catch (ClosedChannelException e) {
-            // expected
+            fail();
+        } catch (ClosedChannelException expected) {
         }
 
         readWriteFileChannel.close();
         try {
             readWriteFileChannel.write(writeBuffer, 0);
-            fail("should throw ClosedChannelException");
-        } catch (ClosedChannelException e) {
-            // expected
-        }
-    }
-
-    /**
-     * @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
-     */
-    public void test_writeLByteBufferJ_ReadOnly() throws Exception {
-        ByteBuffer writeBuffer = null;
-        try {
-            readOnlyFileChannel.write(writeBuffer, 10);
-            fail();
-        } catch (NullPointerException expected) {
-        } catch (NonWritableChannelException expected) {
-        }
-
-        writeBuffer = ByteBuffer.allocate(CAPACITY);
-        try {
-            readOnlyFileChannel.write(writeBuffer, 10);
-            fail();
-        } catch (NonWritableChannelException expected) {
-        }
-
-        try {
-            readOnlyFileChannel.write(writeBuffer, -1);
-            fail();
-        } catch (IllegalArgumentException expected) {
-        } catch (NonWritableChannelException expected) {
-        }
-
-        // regression test for Harmony-903
-        readOnlyFileChannel.close();
-        try {
-            readOnlyFileChannel.write(writeBuffer, 10);
             fail();
         } catch (ClosedChannelException expected) {
+        }
+    }
+
+    public void test_writeLByteBufferJ_ReadOnly() throws Exception {
+        ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
+        try {
+            readOnlyFileChannel.write(writeBuffer, 10);
+            fail();
         } catch (NonWritableChannelException expected) {
         }
     }
 
-    /**
-     * @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
-     */
     public void test_writeLByteBufferJ_IllegalArgument() throws Exception {
         ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
 
         try {
             readOnlyFileChannel.write(writeBuffer, -1);
-            fail("should throw IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected
+            fail();
+        } catch (IllegalArgumentException expected) {
         }
 
         try {
             writeOnlyFileChannel.write(writeBuffer, -1);
-            fail("should throw IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected
+            fail();
+        } catch (IllegalArgumentException expected) {
         }
 
         try {
             readWriteFileChannel.write(writeBuffer, -1);
-            fail("should throw IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        // throws IllegalArgumentException first.
-        readWriteFileChannel.close();
-        try {
-            readWriteFileChannel.write(writeBuffer, -1);
-            fail("should throw IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected
+            fail();
+        } catch (IllegalArgumentException expected) {
         }
     }