summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2011-06-09 15:31:15 -0700
committerElliott Hughes <enh@google.com>2011-06-09 15:31:15 -0700
commit660d4da8ff5dcb1f0bd2dcec2d18dc9f0ed901c0 (patch)
tree4a694211289da701990bbd90c648de17750b7f06
parent432e5a61bb824f25ad2ab12df50d76bc387be57e (diff)
downloadapache-harmony-660d4da8ff5dcb1f0bd2dcec2d18dc9f0ed901c0.tar.gz
Fix broken tests.
Change-Id: Icbdb2567c8ed33b9340b86c7e1cf565fb8f3df76
-rw-r--r--nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java209
1 files changed, 37 insertions, 172 deletions
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 @@ public class FileChannelTest extends TestCase {
}
}
- /**
- * @tests java.nio.channels.FileChannel#read(ByteBuffer)
- */
public void test_readLByteBuffer() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
@@ -1188,110 +1185,57 @@ public class FileChannelTest extends TestCase {
}
}
- /**
- * @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
- }
-
- try {
- readWriteFileChannel.read(readBuffer, 0);
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // expected
+ readOnlyFileChannel.read(null, 0);
+ fail();
+ } catch (NullPointerException 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
- }
-
- try {
- readWriteFileChannel.read(readBuffer, -1);
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // expected
+ fail();
+ } catch (IllegalArgumentException 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 @@ public class FileChannelTest extends TestCase {
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 @@ public class FileChannelTest extends TestCase {
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
- }
-
- 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
+ readWriteFileChannel.write(null, 0);
+ fail();
+ } catch (NullPointerException expected) {
+ } catch (NonWritableChannelException expected) {
}
try {
- readWriteFileChannel.write(writeBuffer, 0);
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // expected
+ writeOnlyFileChannel.write(null, 0);
+ fail();
+ } catch (NullPointerException 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
+ fail();
+ } catch (ClosedChannelException 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();
+ ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
try {
readOnlyFileChannel.write(writeBuffer, 10);
fail();
- } catch (ClosedChannelException expected) {
} 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
- }
-
- try {
- readWriteFileChannel.write(writeBuffer, -1);
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // expected
+ fail();
+ } catch (IllegalArgumentException expected) {
}
- // throws IllegalArgumentException first.
- readWriteFileChannel.close();
try {
readWriteFileChannel.write(writeBuffer, -1);
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // expected
+ fail();
+ } catch (IllegalArgumentException expected) {
}
}