Examples of StreamBuffer


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

     *
     * @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

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

     *
     * @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

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

    /**
     * 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

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

     *
     * @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

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

     *
     * @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

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

        Iterator steps = match.getSequence();
        if (steps.hasNext()) {
            // we have at least one step.

            // Loop over the steps, processing each in turn.
            StreamBuffer buffer = null;
            InputStream stepInput;
            OutputStream stepOutput;

            // Type of validation to be performed by each step
            StepType stepType = null;

            while (steps.hasNext()) {
                final Step step = (Step) steps.next();

                if (logger.isDebugEnabled()) {
                    logger.debug("Invoking migration step :"+step);
                }

                // Calculate the input stream for this step.
                // If we have a previous output, then that must be the
                // input for this step, otherwise use the original
                // input.
                if (buffer != null) {
                    stepInput = buffer.getInput();
                } else {
                    stepInput = inputStream;
                }
                // Calculate the output stream for this step.
                // If we have another step to process, then we must
                // buffer the output of the step, otherwise use the
                // original output.
                if (steps.hasNext()) {
                    buffer = streamBufferFactory.create();
                    stepOutput = buffer.getOutput();
                } else {
                    stepOutput = outputCreator.createOutputStream();
                }

                // Workout which step this is
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.