Package freenet.support.api

Examples of freenet.support.api.RandomAccessBuffer.free()


   
    private void innerTestSize(long sz) throws IOException {
        RandomAccessBuffer raf = construct(sz);
        assertEquals(raf.size(), sz);
        raf.close();
        raf.free();
    }

    /** Test that we can create and free a RandomAccessBuffer of various sizes, and it returns the correct
     * size. */
    public void testSize() throws IOException {
View Full Code Here


            for(int i=0;i<buf.length;i++) assertEquals(buf[i], f.getByte(i+x));
            x += toRead;
        }
        x = 0;
        raf.close();
        raf.free();
    }
   
    /** Test that we can't write or read after the size limit */
    public void testWriteOverLimit() throws IOException {
        Random r = new Random(21092506);
View Full Code Here

        readWriteMustFail(raf, sz, buf, 0, buf.length); // Read, write at the end fail.
        readWriteMustFail(raf, sz+1, buf, 0, buf.length); // One byte into end
        readWriteMustFail(raf, sz+1025, buf, 0, buf.length); // 1KB in
        readWriteMustFail(raf, sz+buf.length, buf, 0, buf.length);
        raf.close();
        raf.free();
    }

    private void readWriteMustSucceed(RandomAccessBuffer raf, long startAt, byte[] buf, int offset, int length) throws IOException {
        raf.pread(startAt, buf, 0, buf.length); // Should work
        raf.pwrite(startAt, buf, 0, buf.length); // Should work
View Full Code Here

    protected void innerTestClose(long sz) throws IOException {
        RandomAccessBuffer raf = construct(sz);
        raf.close();
        byte[] buf = new byte[(int)Math.min(1024, sz)];
        readWriteMustFail(raf, 0L, buf, 0, buf.length);
        raf.free();
    }
   
    public void testArray() throws IOException {
        Random r = new Random(21162506);
        for(int size : sizeList)
View Full Code Here

        }
        checkArraySectionEqualsReadData(buf, raf, 0, len, readOnly);
        if(len > 1)
            checkArraySectionEqualsReadData(buf, raf, 1, len-1, readOnly);
        raf.close();
        raf.free();
    }

    /** Check that the array section equals the read data, then write it and repeat the check. */
    public static void checkArraySectionEqualsReadData(byte[] buf, RandomAccessBuffer raf, int start, int end, boolean readOnly) throws IOException {
        int len = end - start;
View Full Code Here

        assertTrue(t.hasMigrated());
        assertEquals(factory.getRamUsed(), 0);
        raf.pwrite(0L, buf, 0, buf.length);
        checkArrayInner(buf, raf, len, r);
        raf.close();
        raf.free();
    }
   
    public void testBucketToRAFWhileArray() throws IOException {
        int len = 4095;
        Random r = new Random(21162101);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.