Package org.jgroups.util

Examples of org.jgroups.util.ByteArrayDataOutputStream.position()


    public void testWriteChars() throws IOException {
        String name="Bela";
        ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(2);
        out.writeChars(name);
        assert out.position() == name.length() * 2;
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(out.buffer());
        char[] tmp=new char[name.length()];
        for(int i=0; i < name.length(); i++)
            tmp[i]=in.readChar();
        assert name.equals(new String(tmp));
View Full Code Here


    public void testUTF() throws IOException {
        String name="Bela";
        ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(2);
        out.writeUTF(name);
        assert out.position() == name.length() + 2;
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(out.buffer());
        String tmp=in.readUTF();
        assert name.equals(tmp);
    }
View Full Code Here

    public void testUTFWithDoubleByteChar() throws IOException {
        String name="Bela\234";
        ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(2);
        out.writeUTF(name);
        assert out.position() == Bits.sizeUTF(name);
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(out.buffer());
        String tmp=in.readUTF();
        assert name.equals(tmp);
    }
View Full Code Here

    public void testUTFWithDoubleByteChar2() throws IOException {
        String name="Bela\420";
        ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(2);
        out.writeUTF(name);
        assert out.position() == Bits.sizeUTF(name);
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(out.buffer());
        String tmp=in.readUTF();
        assert name.equals(tmp);

        name="";
View Full Code Here

        assert name.equals(tmp);

        name="";
        out=new ByteArrayDataOutputStream(2);
        out.writeUTF(name);
        assert out.position() == Bits.sizeUTF(name);
        in=new ByteArrayDataInputStream(out.buffer());
        tmp=in.readUTF();
        assert name.equals(tmp);

        name=null;
View Full Code Here

        assert name.equals(tmp);

        name=null;
        out=new ByteArrayDataOutputStream(2);
        out.writeUTF(name);
        assert out.position() == Bits.sizeUTF(name);
        in=new ByteArrayDataInputStream(out.buffer());
        tmp=in.readUTF();
        assert tmp == null;
    }
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.