Package org.jnode.shell.io

Examples of org.jnode.shell.io.Pipeline


    private CommandIO getOutPipeIO(String name) throws IOException {
        if (parent != null) {
            return parent.getOutPipeIO(name);
        } else {
            Pipeline pipe = pipes.get(name);
            if (pipe == null) {
                pipe = new Pipeline();
                pipes.put(name, pipe);
            }
            return new CommandOutput(pipe.createSource());
        }
    }
View Full Code Here


    private CommandIO getInPipeIO(String name) throws IOException {
        if (parent != null) {
            return parent.getInPipeIO(name);
        } else {
            Pipeline pipe = pipes.get(name);
            if (pipe == null) {
                pipe = new Pipeline();
                pipes.put(name, pipe);
            }
            return new CommandInput(pipe.createSink());
        }
    }
View Full Code Here

        Assert.assertEquals(10000, sink.getCount((byte) '2'));
    }

    @Test
    public void testTwo100_One100() throws Throwable {
        Pipeline p = new Pipeline();
        InputStream is = p.createSink();
        OutputStream os = p.createSource();
        OutputStream os2 = p.createSource();
        p.activate();

        byte[] buff1 = new byte[100];
        Arrays.fill(buff1, (byte) '1');
        Source source = new Source(buff1, 100, -1, os);
        byte[] buff2 = new byte[100];
View Full Code Here

        Assert.assertEquals(10000, sink.getCount((byte) '2'));
    }

    @Test
    public void testTwo100_One100_SmallBuffer() throws Throwable {
        Pipeline p = new Pipeline(100);
        InputStream is = p.createSink();
        OutputStream os = p.createSource();
        OutputStream os2 = p.createSource();
        p.activate();

        byte[] buff1 = new byte[100];
        Arrays.fill(buff1, (byte) '1');
        Source source = new Source(buff1, 100, -1, os);
        byte[] buff2 = new byte[100];
View Full Code Here

public class PipelineTest {

    @Test
    public void testConstructor() {
        new Pipeline();
    }
View Full Code Here

        new Pipeline();
    }

    @Test
    public void testLifecycle() throws IOException {
        Pipeline p = new Pipeline();
        InputStream is = p.createSink();
        OutputStream os = p.createSource();
        Assert.assertFalse(p.isActive());
        Assert.assertFalse(p.isClosed());
        Assert.assertFalse(p.isShutdown());
        p.activate();
        Assert.assertTrue(p.isActive());
        Assert.assertFalse(p.isClosed());
        Assert.assertFalse(p.isShutdown());
        is.close();
        os.close();
        Assert.assertFalse(p.isActive());
        Assert.assertTrue(p.isClosed());
        Assert.assertFalse(p.isShutdown());
    }
View Full Code Here

        Assert.assertFalse(p.isShutdown());
    }

    @Test
    public void testLifecycle2() throws IOException {
        Pipeline p = new Pipeline();
        InputStream is = p.createSink();
        OutputStream os = p.createSource();
        Assert.assertFalse(p.isActive());
        Assert.assertFalse(p.isShutdown());
        p.activate();
        Assert.assertTrue(p.isActive());
        Assert.assertFalse(p.isShutdown());
        p.shutdown();
        Assert.assertFalse(p.isActive());
        Assert.assertTrue(p.isShutdown());
        Assert.assertEquals(-1, is.read());
        try {
            os.write('X');
            Assert.fail("no exception on write()");
        } catch (IOException ex) {
View Full Code Here

    @Test
    public void testOneOne() throws IOException {
        // This should work ... despite the source and sink being operated from
        // the same thread ... because we are reading/writing less than a buffer
        // full.
        Pipeline p = new Pipeline();
        InputStream is = p.createSink();
        OutputStream os = p.createSource();
        p.activate();
        Assert.assertEquals(0, is.available());
        os.write('A');
        Assert.assertEquals(1, is.available());
        Assert.assertEquals('A', is.read());
        os.write('B');
View Full Code Here

        Assert.assertEquals("the quick brown fox", new String(buffer, 0, len));
    }

    @Test
    public void testTwo1_One1() throws Throwable {
        Pipeline p = new Pipeline();
        InputStream is = p.createSink();
        OutputStream os = p.createSource();
        OutputStream os2 = p.createSource();
        p.activate();

        Source source = new Source("1".getBytes(), 10000, -1, os);
        Source source2 = new Source("2".getBytes(), 10000, -1, os2);
        Sink sink = new Sink(20000, 1, -1, is);
View Full Code Here

        Assert.assertEquals(10000, sink.getCount((byte) '2'));
    }

    @Test
    public void testTwo10_One10() throws Throwable {
        Pipeline p = new Pipeline();
        InputStream is = p.createSink();
        OutputStream os = p.createSource();
        OutputStream os2 = p.createSource();
        p.activate();

        Source source = new Source("1111111111".getBytes(), 1000, -1, os);
        Source source2 = new Source("2222222222".getBytes(), 1000, -1, os2);
        Sink sink = new Sink(20000, 10, -1, is);
View Full Code Here

TOP

Related Classes of org.jnode.shell.io.Pipeline

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.