diff options
author | Elliott Hughes <enh@google.com> | 2013-04-26 18:05:49 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-04-26 18:05:49 -0700 |
commit | 105a9405b2e059352185f9ca1138cc8480ccb9bc (patch) | |
tree | 86432261882b51cb9a9bc90fa87c96d2815e8738 /harmony-tests/src | |
parent | f2068d4c93e59742565349b1701cf2b64b06ec30 (diff) | |
download | libcore-105a9405b2e059352185f9ca1138cc8480ccb9bc.zip libcore-105a9405b2e059352185f9ca1138cc8480ccb9bc.tar.gz libcore-105a9405b2e059352185f9ca1138cc8480ccb9bc.tar.bz2 |
Fix various of the harmony nio tests.
Plus one real bug, in FileChannelImpl. The expectation I've removed was for a
test that doesn't seem to exist in either our tests or the harmony tests.
Change-Id: I1ea99042f3f8897f07ba8b4ad8e9a15f30ace79b
Diffstat (limited to 'harmony-tests/src')
3 files changed, 42 insertions, 22 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java b/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java index c0a4aac..5fa9335 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java +++ b/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java @@ -109,21 +109,20 @@ public class WrappedCharBufferTest2 extends ReadOnlyCharBufferTest { CharBuffer other = CharBuffer.allocate(1); try { buf.put(other); - fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$ - } catch (ReadOnlyBufferException e) { - // expected + fail(); + } catch (ReadOnlyBufferException expected) { } try { buf.put((CharBuffer) null); - fail("Should throw NullPointerException"); //$NON-NLS-1$ - } catch (NullPointerException e) { - // expected + fail(); + } catch (ReadOnlyBufferException expected) { + } catch (NullPointerException expected) { } try { buf.put(buf); - fail("Should throw IllegalArgumentException"); //$NON-NLS-1$ - } catch (IllegalArgumentException e) { - // expected + fail(); + } catch (ReadOnlyBufferException expected) { + } catch (IllegalArgumentException expected) { } } } diff --git a/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java b/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java index e14c1ec..53fdae4 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java @@ -349,16 +349,27 @@ public class SourceChannelTest extends TestCase { ByteBuffer[] nullBufArrayRef = null; try { source.read(nullBufArrayRef, 0, 1); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - // expected + fail(); + } catch (NullPointerException expected) { } try { source.read(nullBufArrayRef, 0, -1); - fail("should throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - // expected + fail(); + } catch (NullPointerException expected) { + } catch (IndexOutOfBoundsException expected) { + } + + try { + source.read(new ByteBuffer[0], 0, -1); + fail(); + } catch (IndexOutOfBoundsException expected) { + } + + try { + source.read(new ByteBuffer[0], -1, 0); + fail(); + } catch (IndexOutOfBoundsException expected) { } // ByteBuffer array contains null element @@ -457,16 +468,27 @@ public class SourceChannelTest extends TestCase { ByteBuffer[] nullBufArrayRef = null; try { source.read(nullBufArrayRef, 0, 1); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - // expected + fail(); + } catch (NullPointerException expected) { } try { source.read(nullBufArrayRef, 0, -1); - fail("should throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - // expected + fail(); + } catch (NullPointerException expected) { + } catch (IndexOutOfBoundsException expected) { + } + + try { + source.read(new ByteBuffer[0], 0, -1); + fail(); + } catch (IndexOutOfBoundsException expected) { + } + + try { + source.read(new ByteBuffer[0], -1, 1); + fail(); + } catch (IndexOutOfBoundsException expected) { } // ByteBuffer array contains null element diff --git a/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java b/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java index e2dab1e..5072dc9 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java @@ -62,7 +62,6 @@ public class AbstractInterruptibleChannelTest extends TestCase { } finally { testChannel.superEnd(complete); } - testChannel.superEnd(complete); testChannel.superBegin(); try { |