Package org.apache.ace.processlauncher.util

Examples of org.apache.ace.processlauncher.util.InputStreamRedirector


            m_processStreamListener.setStdout(m_launchConfiguration, process.getInputStream());

            return null;
        }
        // Redirect to /dev/null!
        return new InputStreamRedirector(process.getInputStream());
    }
View Full Code Here


    @Test
    public void testInputStreamEOFCausesOutputStreamToBeClosedOk() throws IOException {
        InputStream myIS = new ByteArrayInputStream("hello world!".getBytes());
        OutputStream mockOS = mock(OutputStream.class);

        InputStreamRedirector redirector = new InputStreamRedirector(myIS, mockOS);
        redirector.run();

        verify(mockOS).close();
    }
View Full Code Here

        String input = "hello world!";

        InputStream myIS = new ByteArrayInputStream(input.getBytes());
        ByteArrayOutputStream myOS = new ByteArrayOutputStream();

        InputStreamRedirector redirector = new InputStreamRedirector(myIS, myOS);
        redirector.run();

        assertEquals(input, myOS.toString());
    }
View Full Code Here

    @Test
    public void testInterruptRedirectorOk() throws Exception {
        InputStream myIS = createBlockingInputStream();
        OutputStream myOS = mock(OutputStream.class);

        InputStreamRedirector redirector = new InputStreamRedirector(myIS, myOS);

        Thread redirectorThread = new Thread(redirector);
        redirectorThread.start();

        // Sleep for a little while to ensure everything is up and running...
View Full Code Here

    @Test
    public void testRecoverFromExceptionInInputStreamWithoutOutputStreamOk() throws Exception {
        InputStream myIS = createExceptionThrowingInputStream();
        ByteArrayOutputStream myOS = new ByteArrayOutputStream();

        InputStreamRedirector redirector = new InputStreamRedirector(myIS, myOS);

        redirector.run();

        verify(myIS, atLeast(1)).read(Mockito.<byte[]>any(), anyInt(), anyInt());

        // Verify that the exception is indeed logged...
        String stdout = myOS.toString();
View Full Code Here

    @Test
    public void testRecoverFromExceptionInInputStreamWithOutputStreamOk() throws Exception {
        InputStream myIS = createExceptionThrowingInputStream();
        OutputStream myOS = mock(OutputStream.class);

        InputStreamRedirector redirector = new InputStreamRedirector(myIS, myOS);

        redirector.run();

        verify(myIS, atLeast(1)).read(Mockito.<byte[]>any(), anyInt(), anyInt());
        verify(myOS).close();
    }
View Full Code Here

     */
    @Test
    public void testWithoutOutputStreamOk() throws Exception {
        InputStream myIS = new ByteArrayInputStream("hello world!".getBytes());

        InputStreamRedirector redirector = new InputStreamRedirector(myIS);

        redirector.run();
    }
View Full Code Here

            m_stdin = outputStream;
        }

        public void setStdout(LaunchConfiguration launchConfiguration, InputStream inputStream) {
            m_stdout = new ByteArrayOutputStream(1024);
            InputStreamRedirector isr = new InputStreamRedirector(inputStream, m_stdout);
            isr.start();
        }
View Full Code Here

TOP

Related Classes of org.apache.ace.processlauncher.util.InputStreamRedirector

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.