Search in sources :

Example 6 with ReadOnlyBufferException

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

the class ReadOnlyDoubleBufferTest method testPutDoubleBuffer.

public void testPutDoubleBuffer() {
    DoubleBuffer other = DoubleBuffer.allocate(1);
    try {
        buf.put(other);
        //$NON-NLS-1$
        fail("Should throw ReadOnlyBufferException");
    } catch (ReadOnlyBufferException e) {
    // expected
    }
    try {
        buf.put((DoubleBuffer) null);
        //$NON-NLS-1$
        fail("Should throw ReadOnlyBufferException");
    } catch (ReadOnlyBufferException e) {
    // expected
    }
    try {
        buf.put(buf);
        //$NON-NLS-1$
        fail("Should throw ReadOnlyBufferException");
    } catch (ReadOnlyBufferException e) {
    // expected
    }
}
Also used : DoubleBuffer(java.nio.DoubleBuffer) ReadOnlyBufferException(java.nio.ReadOnlyBufferException)

Example 7 with ReadOnlyBufferException

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

the class ReadOnlyIntBufferTest method testPutIntBuffer.

public void testPutIntBuffer() {
    IntBuffer other = IntBuffer.allocate(1);
    try {
        buf.put(other);
        //$NON-NLS-1$
        fail("Should throw ReadOnlyBufferException");
    } catch (ReadOnlyBufferException e) {
    // expected
    }
    try {
        buf.put((IntBuffer) null);
        //$NON-NLS-1$
        fail("Should throw ReadOnlyBufferException");
    } catch (ReadOnlyBufferException e) {
    // expected
    }
    try {
        buf.put(buf);
        //$NON-NLS-1$
        fail("Should throw ReadOnlyBufferException");
    } catch (ReadOnlyBufferException e) {
    // expected
    }
}
Also used : ReadOnlyBufferException(java.nio.ReadOnlyBufferException) IntBuffer(java.nio.IntBuffer)

Example 8 with ReadOnlyBufferException

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

the class ReadOnlyShortBufferTest method testPutShortBuffer.

public void testPutShortBuffer() {
    ShortBuffer other = ShortBuffer.allocate(1);
    try {
        buf.put(other);
        //$NON-NLS-1$
        fail("Should throw ReadOnlyBufferException");
    } catch (ReadOnlyBufferException e) {
    // expected
    }
    try {
        buf.put((ShortBuffer) null);
        //$NON-NLS-1$
        fail("Should throw ReadOnlyBufferException");
    } catch (ReadOnlyBufferException e) {
    // expected
    }
    try {
        buf.put(buf);
        //$NON-NLS-1$
        fail("Should throw ReadOnlyBufferException");
    } catch (ReadOnlyBufferException e) {
    // expected
    }
}
Also used : ReadOnlyBufferException(java.nio.ReadOnlyBufferException) ShortBuffer(java.nio.ShortBuffer)

Example 9 with ReadOnlyBufferException

use of java.nio.ReadOnlyBufferException 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 10 with ReadOnlyBufferException

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

the class CharBufferTest method testReadReadOnly.

public void testReadReadOnly() throws IOException {
    CharBuffer source = CharBuffer.wrap("String");
    CharBuffer target = CharBuffer.allocate(10).asReadOnlyBuffer();
    try {
        source.read(target);
        fail("should throw ReadOnlyBufferException.");
    } catch (ReadOnlyBufferException ex) {
    // expected;
    }
    // if target has no remaining, needn't to check the isReadOnly
    target.flip();
    assertEquals(0, source.read(target));
}
Also used : ReadOnlyBufferException(java.nio.ReadOnlyBufferException) CharBuffer(java.nio.CharBuffer)

Aggregations

ReadOnlyBufferException (java.nio.ReadOnlyBufferException)35 ByteBuffer (java.nio.ByteBuffer)22 SSLException (javax.net.ssl.SSLException)10 IOException (java.io.IOException)7 SSLEngineResult (javax.net.ssl.SSLEngineResult)7 SSLEngine (javax.net.ssl.SSLEngine)6 BufferOverflowException (java.nio.BufferOverflowException)5 KeyManagementException (java.security.KeyManagementException)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 CharBuffer (java.nio.CharBuffer)4 KnownFailure (dalvik.annotation.KnownFailure)3 BufferUnderflowException (java.nio.BufferUnderflowException)3 ByteBuf (io.netty.buffer.ByteBuf)2 MappedByteBuffer (java.nio.MappedByteBuffer)2 AlgorithmParameterSpec (java.security.spec.AlgorithmParameterSpec)2 Cipher (javax.crypto.Cipher)2 ShortBufferException (javax.crypto.ShortBufferException)2 IvParameterSpec (javax.crypto.spec.IvParameterSpec)2 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)2 SSLPeerUnverifiedException (javax.net.ssl.SSLPeerUnverifiedException)2