Search in sources :

Example 26 with BufferOverflowException

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

the class BufferOverflowExceptionTest method test_Constructor.

/**
     *@tests {@link java.nio.BufferOverflowException#BufferOverflowException()}
     */
public void test_Constructor() {
    BufferOverflowException exception = new BufferOverflowException();
    assertNull(exception.getMessage());
    assertNull(exception.getLocalizedMessage());
    assertNull(exception.getCause());
}
Also used : BufferOverflowException(java.nio.BufferOverflowException)

Example 27 with BufferOverflowException

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

the class ByteBufferTest method testPutbyteArray.

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

Example 28 with BufferOverflowException

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

the class LongBufferTest method testPutLongBuffer.

/*
     * Class under test for java.nio.LongBuffer put(java.nio.LongBuffer)
     */
public void testPutLongBuffer() {
    LongBuffer other = LongBuffer.allocate(buf.capacity());
    try {
        buf.put(buf);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IllegalArgumentException e) {
    // expected
    }
    try {
        buf.put(LongBuffer.allocate(buf.capacity() + 1));
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferOverflowException e) {
    // expected
    }
    try {
        buf.flip();
        buf.put((LongBuffer) null);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (NullPointerException e) {
    // expected
    }
    loadTestData2(other);
    other.clear();
    buf.clear();
    LongBuffer ret = buf.put(other);
    assertEquals(other.position(), other.capacity());
    assertEquals(buf.position(), buf.capacity());
    assertContentEquals(other, buf);
    assertSame(ret, buf);
}
Also used : LongBuffer(java.nio.LongBuffer) BufferOverflowException(java.nio.BufferOverflowException)

Example 29 with BufferOverflowException

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

the class FloatBufferTest method testPutFloatBuffer.

/*
     * Class under test for java.nio.FloatBuffer put(java.nio.FloatBuffer)
     */
public void testPutFloatBuffer() {
    FloatBuffer other = FloatBuffer.allocate(buf.capacity());
    try {
        buf.put(buf);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (IllegalArgumentException e) {
    // expected
    }
    try {
        buf.put(FloatBuffer.allocate(buf.capacity() + 1));
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (BufferOverflowException e) {
    // expected
    }
    try {
        buf.flip();
        buf.put((FloatBuffer) null);
        //$NON-NLS-1$
        fail("Should throw Exception");
    } catch (NullPointerException e) {
    // expected
    }
    buf.clear();
    loadTestData2(other);
    other.clear();
    buf.clear();
    FloatBuffer ret = buf.put(other);
    assertEquals(other.position(), other.capacity());
    assertEquals(buf.position(), buf.capacity());
    assertContentEquals(other, buf);
    assertSame(ret, buf);
}
Also used : FloatBuffer(java.nio.FloatBuffer) BufferOverflowException(java.nio.BufferOverflowException)

Example 30 with BufferOverflowException

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

the class IntBufferTest method testPutint.

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

Aggregations

BufferOverflowException (java.nio.BufferOverflowException)78 ByteBuffer (java.nio.ByteBuffer)27 ShortBufferException (javax.crypto.ShortBufferException)10 CharBuffer (java.nio.CharBuffer)9 ShortBuffer (java.nio.ShortBuffer)7 Test (org.junit.Test)7 FloatBuffer (java.nio.FloatBuffer)6 IntBuffer (java.nio.IntBuffer)6 IOException (java.io.IOException)5 BufferUnderflowException (java.nio.BufferUnderflowException)5 ReadOnlyBufferException (java.nio.ReadOnlyBufferException)5 IpPrefix (android.net.IpPrefix)4 Inet6Address (java.net.Inet6Address)4 DoubleBuffer (java.nio.DoubleBuffer)4 LongBuffer (java.nio.LongBuffer)4 MappedByteBuffer (java.nio.MappedByteBuffer)4 Pointer (com.cetsoft.imcache.offheap.bytebuffer.Pointer)2 EOFException (java.io.EOFException)2 CoderResult (java.nio.charset.CoderResult)2 JSONObject (org.json_voltpatches.JSONObject)2