Examples of BlockingInputStream


Examples of org.jgroups.util.BlockingInputStream

        }
    }


    public void testWritingBeyondLength() throws IOException {
        final BlockingInputStream in=new BlockingInputStream(800);

        new Thread() {
            public void run() {
                byte[] buf=new byte[800+600];
                try {
                    in.write(buf);
                }
                catch(IOException e) {
                    e.printStackTrace();
                }
            }
        }.start();

        byte[] buf=new byte[1000];
        int read=in.read(buf);
        assert read == buf.length;
    }
View Full Code Here

Examples of org.jgroups.util.BlockingInputStream

        assert read == buf.length;
    }


    public void testSimpleWrite() throws Exception {
        final BlockingInputStream input=new BlockingInputStream(8192);
        byte[] in={'B', 'e', 'l', 'a'};
        input.write(in);

        byte[] buf=new byte[5];
        for(int i=0; i < in.length; i++) {
            int read=input.read(buf, i, 1);
            assert read == 1;
        }
        for(int i=0; i < in.length; i++)
            assert in[i] == buf[i];
    }
View Full Code Here

Examples of org.jgroups.util.BlockingInputStream

            assert in[i] == buf[i];
    }


    public void testObjectStreaming() throws Exception {
        final BlockingInputStream input=new BlockingInputStream(8192);

        Map<String,List<Long>> map=new HashMap<String,List<Long>>(4);
        for(String key: Arrays.asList("A", "B", "C", "D")) {
            List<Long> list=new ArrayList<Long>(1000);
            map.put(key, list);
            for(int i=1; i <= 1000; i++)
                list.add((long)i);
        }

        ByteArrayOutputStream output=new ByteArrayOutputStream(8192);
        OutputStream out=new BufferedOutputStream(output);
        Util.objectToStream(map, new DataOutputStream(out));
        out.flush();
        final byte[] buffer=output.toByteArray();

        Thread writer=new Thread() {
            public void run() {
                try {
                    input.write(buffer);
                }
                catch(IOException e) {
                    e.printStackTrace();
                }
            }
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.