Package com.volantis.mcs.migrate.impl.framework.io

Examples of com.volantis.mcs.migrate.impl.framework.io.DefaultStreamBuffer


     *
     * @throws IOException
     */
    public void testFailureGetInputAfterCloseInput() throws IOException {

        StreamBuffer streamBuffer = new DefaultStreamBuffer();
        OutputStream output = streamBuffer.getOutput();
        output.write(new byte[]{1, 2, 3});
        output.close();
        InputStream input = streamBuffer.getInput();
        byte[] buffer = new byte[3];
        assertEquals(input.read(buffer), 3);
        assertEquals(new ArrayObject(buffer),
                     new ArrayObject(new byte[]{1, 2, 3}));
        assertEquals(input.read(buffer), -1);
        input.close();
        try {
            streamBuffer.getInput();
            fail("cannot get input once closed");
        } catch (Exception e) {
            // success
        }
    }
View Full Code Here


     *
     * @throws IOException
     */
    public void testSuccess() throws IOException {

        StreamBuffer streamBuffer = new DefaultStreamBuffer();
        OutputStream output = streamBuffer.getOutput();
        output.write(new byte[]{1, 2, 3});
        output.close();
        InputStream input = streamBuffer.getInput();
        byte[] buffer = new byte[3];
        assertEquals(input.read(buffer), 3);
        assertEquals(new ArrayObject(buffer),
                     new ArrayObject(new byte[]{1, 2, 3}));
        assertEquals(input.read(buffer), -1);
View Full Code Here

     *
     * @throws IOException
     */
    public void testFailureWriteOutputAfterClose() throws IOException {

        StreamBuffer streamBuffer = new DefaultStreamBuffer();
        OutputStream output = streamBuffer.getOutput();
        output.write(new byte[]{1, 2, 3, 4, 5});
        output.close();
        try {
            output.write(new byte[]{1, 2, 3, 4, 5});
            fail("Should not be able to write output after close");
View Full Code Here

    /**
     * Ensure if we attempt to get the input before we close the output we fail.
     */
    public void testFailureGetInputAfterWriteOutput() {

        StreamBuffer streamBuffer = new DefaultStreamBuffer();
        try {
            OutputStream output = streamBuffer.getOutput();
            output.write(new byte[]{1, 2, 3, 4, 5});
            streamBuffer.getInput();
            fail("Input should not be available till output completes");
        } catch (Exception e) {
            // success
        }
    }
View Full Code Here

     *
     * @throws IOException
     */
    public void testFailureReadInputAfterCloseInput() throws IOException {

        StreamBuffer streamBuffer = new DefaultStreamBuffer();
        OutputStream output = streamBuffer.getOutput();
        output.write(new byte[]{1, 2, 3});
        output.close();
        InputStream input = streamBuffer.getInput();
        byte[] buffer = new byte[3];
        assertEquals(input.read(buffer), 3);
        assertEquals(new ArrayObject(buffer),
                     new ArrayObject(new byte[]{1, 2, 3}));
        assertEquals(input.read(buffer), -1);
View Full Code Here

TOP

Related Classes of com.volantis.mcs.migrate.impl.framework.io.DefaultStreamBuffer

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.