Examples of ByteArrayDataOutputStream


Examples of org.jgroups.util.ByteArrayDataOutputStream

            assert Arrays.equals(seq, new long[]{i, i+100});
        }
    }

    public void testFloat() throws IOException {
        ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(1024);
        float[] numbers={-322649.25f, 100.7531f, 0f, 1f, 2.75f, 3.1425f, 322649f, 322649.75f};
        for(float i: numbers)
            out.writeFloat(i);
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(out.buffer());
        for(float i: numbers) {
            float num=in.readFloat();
            assert num == i;
        }
    }
View Full Code Here

Examples of org.jgroups.util.ByteArrayDataOutputStream

            assert num == i;
        }
    }

    public void testDouble() throws IOException {
        ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(1024);
        double[] numbers={-322649.25, 100.7531, 0.0, 1.5, 2.75, 3.1425, 322649, 322649.75};
        for(double i: numbers)
            out.writeDouble(i);
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(out.buffer());
        for(double i: numbers) {
            double num=in.readDouble();
            assert num == i;
        }
    }
View Full Code Here

Examples of org.jgroups.util.ByteArrayDataOutputStream

    }


    public void testWriteBytes() {
        String name="Bela";
        ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(2);
        out.writeBytes(name);
        assert out.position() == name.length();
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(out.buffer());
        byte[] tmp=new byte[name.length()];
        int read=in.read(tmp, 0, tmp.length);
        assert read == name.length();
        assert name.equals(new String(tmp));
    }
View Full Code Here

Examples of org.jgroups.util.ByteArrayDataOutputStream

    }


    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

Examples of org.jgroups.util.ByteArrayDataOutputStream

    }

    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

Examples of org.jgroups.util.ByteArrayDataOutputStream

        assert name.equals(tmp);
    }

    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

Examples of org.jgroups.util.ByteArrayDataOutputStream

        assert name.equals(tmp);
    }

    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="";
        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;
        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.