Package org.jgroups.util

Examples of org.jgroups.util.ByteArrayDataInputStream.limit()


    public void testLimit() {
        byte[] buf=new byte[100];
        buf[0]='B'; buf[1]='e'; buf[2]='l'; buf[3]='a';
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf);
        assert in.position() == 0;
        assert in.limit() == buf.length;
        assert in.capacity() == buf.length;

        in=new ByteArrayDataInputStream(buf, 0, 4);
        assert in.position() == 0;
        assert in.limit() == 4;
View Full Code Here


        assert in.limit() == buf.length;
        assert in.capacity() == buf.length;

        in=new ByteArrayDataInputStream(buf, 0, 4);
        assert in.position() == 0;
        assert in.limit() == 4;
        assert in.capacity() == buf.length;
        byte tmp[]=new byte[4];
        in.read(tmp, 0, tmp.length);
        assert "Bela".equals(new String(tmp));
    }
View Full Code Here

    public void testOffsetAndLimit() {
        byte[] buf=new byte[100];
        buf[10]='B'; buf[11]='e'; buf[12]='l'; buf[13]='a';
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, 10, 4);
        assert in.position() == 10;
        assert in.limit() == 14;
        assert in.capacity() == buf.length;
        byte tmp[]=new byte[4];
        in.read(tmp, 0, tmp.length);
        assert "Bela".equals(new String(tmp));
    }
View Full Code Here

    public void testReadBeyondLimit() {
        byte[] buf=new byte[100];
        buf[10]='B'; buf[11]='e'; buf[12]='l'; buf[13]='a';
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, 10, 4);
        assert in.position() == 10;
        assert in.limit() == 14;
        assert in.capacity() == buf.length;
        byte tmp[]=new byte[5];
        try {
            in.readFully(tmp, 0, tmp.length);
            assert false : " should have gotten an exception";
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.