FileDocCategorySizeDatePackage
WrappedByteBufferTest.javaAPI DocAndroid 1.5 API3278Wed May 06 22:41:04 BST 2009org.apache.harmony.nio.tests.java.nio

WrappedByteBufferTest

public class WrappedByteBufferTest extends ByteBufferTest

Fields Summary
Constructors Summary
Methods Summary
protected voidsetUp()

        capacity = BUFFER_LENGTH;
        buf = ByteBuffer.wrap(new byte[BUFFER_LENGTH]);
        loadTestData1(buf);
        baseBuf = buf;
    
protected voidtearDown()

        buf = null;
        baseBuf = null;
    
public voidtestWrappedByteBuffer_IllegalArg()

tests
java.nio.ByteBuffer#allocate(byte[],int,int)

        byte array[] = new byte[BUFFER_LENGTH];
        try {
            ByteBuffer.wrap(array, -1, 0);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ByteBuffer.wrap(array, BUFFER_LENGTH + 1, 0);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ByteBuffer.wrap(array, 0, -1);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ByteBuffer.wrap(array, 0, BUFFER_LENGTH + 1);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ByteBuffer.wrap(array, 1, Integer.MAX_VALUE);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ByteBuffer.wrap(array, Integer.MAX_VALUE, 1);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ByteBuffer.wrap((byte[])null, 1, Integer.MAX_VALUE);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (NullPointerException e) {
            // expected
        }