diff options
author | Elliott Hughes <enh@google.com> | 2011-05-24 14:55:13 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2011-05-24 14:55:13 -0700 |
commit | c6100bc7726280a3a7b3d406ddfbe8176e28510f (patch) | |
tree | 72d61f60d47462df5998a8784a8514b8d4c3af87 | |
parent | 6067762af2ef856d3761da07d072bf02b63f4b35 (diff) | |
download | apache-harmony-c6100bc7726280a3a7b3d406ddfbe8176e28510f.tar.gz |
Fix a couple of DatagramChannel tests.
Change-Id: I1f67f232e0d63dde0ac33ece3fc5491cb0315295
-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); |