Package com.jitlogic.zorka.common.util

Examples of com.jitlogic.zorka.common.util.TapInputStream


public class StreamTappingUnitTest {


    @Test
    public void testTapInputStreamReadChars() throws Exception {
        TapInputStream tis = new TapInputStream(new ByteArrayInputStream("ABCD".getBytes()));

        assertEquals(65, tis.read());
        assertEquals(66, tis.read());

        assertEquals("AB", tis.asString());
    }
View Full Code Here


    }


    @Test
    public void testTapInputStreamReadArray() throws Exception {
        TapInputStream tis = new TapInputStream(new ByteArrayInputStream("ABCD".getBytes()));

        assertEquals(4, tis.read(new byte[4]));

        assertEquals("ABCD", tis.asString("UTF-8"));
    }
View Full Code Here

    }


    @Test
    public void testTapInputStreamReadArrayWithOffset() throws Exception {
        TapInputStream tis = new TapInputStream(new ByteArrayInputStream("ABCD".getBytes()));

        assertEquals(2, tis.read(new byte[4], 2, 2));

        assertEquals("AB", tis.asString());
    }
View Full Code Here

    }


    @Test
    public void testTapInputStreamWithMarkAndReset() throws Exception {
        TapInputStream tis = new TapInputStream(new ByteArrayInputStream("ABCDEF".getBytes()));

        tis.read(new byte[2]); tis.mark(100);
        tis.read(new byte[2]); tis.reset();
        tis.read(new byte[3]);

        assertEquals("ABCDE", tis.asString());
    }
View Full Code Here

    public String base64(byte[] buf) {
        return Base64.encode(buf, false);
    }

    public TapInputStream tapInputStream(InputStream is, long init, long limit) {
        return new TapInputStream(is, (int)init, (int)limit);
    }
View Full Code Here

TOP

Related Classes of com.jitlogic.zorka.common.util.TapInputStream

Copyright © 2018 www.massapicom. 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.