diff options
author | Elliott Hughes <enh@google.com> | 2011-05-24 14:57:02 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-05-24 14:57:02 -0700 |
commit | fc053fff59bf6692a21cf2bf26039b850f491eaa (patch) | |
tree | 8efef240c73ab310d8f3a1f29ff09e1cf5cab2a2 | |
parent | fb07add399a5514d3516c30811303f3fc8f1ffe1 (diff) | |
parent | c6100bc7726280a3a7b3d406ddfbe8176e28510f (diff) | |
download | apache-harmony-fc053fff59bf6692a21cf2bf26039b850f491eaa.tar.gz |
Merge "Fix a couple of DatagramChannel tests." into dalvik-dev
-rw-r--r-- | nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java b/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java index 5a1568f..172d803 100644 --- a/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java +++ b/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java @@ -1717,21 +1717,18 @@ public class DatagramChannelTest extends TestCase { writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL); try { this.channel1.write(null, 0, 2); - fail("should throw NPE"); - } catch (NullPointerException e) { - // correct + fail(); + } catch (NullPointerException expected) { } try { - this.channel1.write(null, -1, 2); - fail("should throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - // correct + this.channel1.write(writeBuf, -1, 2); + fail(); + } catch (IndexOutOfBoundsException expected) { } try { - this.channel1.write(null, 0, 3); - fail("should throw NPE"); - } catch (NullPointerException e) { - // correct + this.channel1.write(writeBuf, 0, 3); + fail(); + } catch (IndexOutOfBoundsException expected) { } } @@ -1836,24 +1833,24 @@ public class DatagramChannelTest extends TestCase { assertEquals(0, this.channel1.read(readBuf, 0, 1)); assertEquals(0, this.channel1.read(readBuf, 0, 2)); datagramSocket1.close(); + } + + public void testReadByteBufferArrayIntInt_exceptions() throws IOException { //regression test for HARMONY-932 try { - DatagramChannel.open().read(new ByteBuffer[] {}, 2, Integer.MAX_VALUE); - fail("should throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - // correct + DatagramChannel.open().read(new ByteBuffer[] {}, 2, Integer.MAX_VALUE); + fail(); + } catch (IndexOutOfBoundsException expected) { } try { - DatagramChannel.open().write(new ByteBuffer[] {}, 2, Integer.MAX_VALUE); - fail("should throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - // correct + DatagramChannel.open().read(new ByteBuffer[] {}, -1, 0); + fail(); + } catch (IndexOutOfBoundsException expected) { } try { - DatagramChannel.open().write((ByteBuffer[])null, -1, 2); - fail("should throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - // correct + DatagramChannel.open().read((ByteBuffer[]) null, 0, 0); + fail(); + } catch (NullPointerException expected) { } } @@ -2464,6 +2461,7 @@ public class DatagramChannelTest extends TestCase { channel.read(c.asReadOnlyBuffer()); fail("Should throw NotYetConnectedException"); } catch (NotYetConnectedException e){ + } catch (IllegalArgumentException e){ // expected } channel.connect(localAddr1); |