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
}
}
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
}
}
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
}
}
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
}
}
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));
}
Aggregations