Search in sources :

Example 16 with BufferUnderflowException

use of java.nio.BufferUnderflowException in project robovm by robovm.

the class ByteBufferTest method testGetbyteArray.

/*
     * Class under test for java.nio.ByteBuffer get(byte[])
     */
public void testGetbyteArray() {
    byte[] array = new byte[1];
    buf.clear();
    for (int i = 0; i < buf.capacity(); i++) {
        assertEquals(buf.position(), i);
        ByteBuffer ret = buf.get(array);
        assertEquals(array[0], buf.get(i));
        assertSame(ret, buf);
    }
    try {
        buf.get(array);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferUnderflowException e) {
    // expected
    }
    try {
        buf.get((byte[]) null);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (NullPointerException e) {
    // expected
    }
}
Also used : ByteBuffer(java.nio.ByteBuffer) BufferUnderflowException(java.nio.BufferUnderflowException)

Example 17 with BufferUnderflowException

use of java.nio.BufferUnderflowException in project robovm by robovm.

the class LongBufferTest method testGetlongArray.

/*
     * Class under test for java.nio.LongBuffer get(long[])
     */
public void testGetlongArray() {
    long[] array = new long[1];
    buf.clear();
    for (int i = 0; i < buf.capacity(); i++) {
        assertEquals(buf.position(), i);
        LongBuffer ret = buf.get(array);
        assertEquals(array[0], buf.get(i));
        assertSame(ret, buf);
    }
    try {
        buf.get(array);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferUnderflowException e) {
    // expected
    }
    try {
        buf.position(buf.limit());
        buf.get((long[]) null);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (NullPointerException e) {
    // expected
    }
}
Also used : LongBuffer(java.nio.LongBuffer) BufferUnderflowException(java.nio.BufferUnderflowException)

Example 18 with BufferUnderflowException

use of java.nio.BufferUnderflowException in project robovm by robovm.

the class LongBufferTest method testGetlongArrayintint.

/*
     * Class under test for java.nio.LongBuffer get(long[], int, int)
     */
public void testGetlongArrayintint() {
    buf.clear();
    long[] array = new long[buf.capacity()];
    try {
        buf.get(new long[buf.capacity() + 1], 0, buf.capacity() + 1);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferUnderflowException e) {
    // expected
    }
    assertEquals(buf.position(), 0);
    try {
        buf.get(array, -1, array.length);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    buf.get(array, array.length, 0);
    try {
        buf.get(array, array.length + 1, 1);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    assertEquals(buf.position(), 0);
    try {
        buf.get(array, 2, -1);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    try {
        buf.get((long[]) null, 2, -1);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (NullPointerException e) {
    // expected
    }
    try {
        buf.get(array, 2, array.length);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    try {
        buf.get(array, 1, Integer.MAX_VALUE);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferUnderflowException expected) {
    } catch (IndexOutOfBoundsException expected) {
    }
    try {
        buf.get(array, Integer.MAX_VALUE, 1);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    assertEquals(buf.position(), 0);
    buf.clear();
    LongBuffer ret = buf.get(array, 0, array.length);
    assertEquals(buf.position(), buf.capacity());
    assertContentEquals(buf, array, 0, array.length);
    assertSame(ret, buf);
}
Also used : LongBuffer(java.nio.LongBuffer) BufferUnderflowException(java.nio.BufferUnderflowException)

Example 19 with BufferUnderflowException

use of java.nio.BufferUnderflowException in project robovm by robovm.

the class IntBufferTest method testGetintArrayintint.

/*
     * Class under test for java.nio.IntBuffer get(int[], int, int)
     */
public void testGetintArrayintint() {
    buf.clear();
    int[] array = new int[buf.capacity()];
    try {
        buf.get(new int[buf.capacity() + 1], 0, buf.capacity() + 1);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferUnderflowException e) {
    // expected
    }
    assertEquals(buf.position(), 0);
    try {
        buf.get(array, -1, array.length);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    buf.get(array, array.length, 0);
    try {
        buf.get(array, array.length + 1, 1);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    assertEquals(buf.position(), 0);
    try {
        buf.get(array, 2, -1);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    try {
        buf.get((int[]) null, 2, -1);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (NullPointerException e) {
    // expected
    }
    try {
        buf.get(array, 2, array.length);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    try {
        buf.get(array, 1, Integer.MAX_VALUE);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferUnderflowException expected) {
    } catch (IndexOutOfBoundsException expected) {
    }
    try {
        buf.get(array, Integer.MAX_VALUE, 1);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IndexOutOfBoundsException e) {
    // expected
    }
    assertEquals(buf.position(), 0);
    buf.clear();
    IntBuffer ret = buf.get(array, 0, array.length);
    assertEquals(buf.position(), buf.capacity());
    assertContentEquals(buf, array, 0, array.length);
    assertSame(ret, buf);
}
Also used : IntBuffer(java.nio.IntBuffer) BufferUnderflowException(java.nio.BufferUnderflowException)

Example 20 with BufferUnderflowException

use of java.nio.BufferUnderflowException in project robovm by robovm.

the class IntBufferTest method testGetintArray.

/*
     * Class under test for java.nio.IntBuffer get(int[])
     */
public void testGetintArray() {
    int[] array = new int[1];
    buf.clear();
    for (int i = 0; i < buf.capacity(); i++) {
        assertEquals(buf.position(), i);
        IntBuffer ret = buf.get(array);
        assertEquals(array[0], buf.get(i));
        assertSame(ret, buf);
    }
    try {
        buf.get(array);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferUnderflowException e) {
    // expected
    }
    try {
        buf.get((int[]) null);
        //$NON-NLS-1$
        fail("Should throw NPE");
    } catch (NullPointerException e) {
    // expected
    }
}
Also used : IntBuffer(java.nio.IntBuffer) BufferUnderflowException(java.nio.BufferUnderflowException)

Aggregations

BufferUnderflowException (java.nio.BufferUnderflowException)121 ByteBuffer (java.nio.ByteBuffer)69 IOException (java.io.IOException)25 ArrayList (java.util.ArrayList)22 DirectByteBuffer (java.nio.DirectByteBuffer)15 Test (org.junit.Test)14 CertificateException (java.security.cert.CertificateException)12 X509Certificate (java.security.cert.X509Certificate)11 BigInteger (java.math.BigInteger)10 ByteSource (org.apache.geode.internal.tcp.ByteBufferInputStream.ByteSource)9 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)9 SerializationTest (org.apache.geode.test.junit.categories.SerializationTest)9 UnitTest (org.apache.geode.test.junit.categories.UnitTest)9 CharBuffer (java.nio.CharBuffer)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 FloatBuffer (java.nio.FloatBuffer)6 CertificateFactory (java.security.cert.CertificateFactory)6 HashMap (java.util.HashMap)6 ArrayMap (android.util.ArrayMap)5 HSIconFileElement (com.android.anqp.HSIconFileElement)5