Package com.dtolabs.rundeck.core.utils

Examples of com.dtolabs.rundeck.core.utils.PartialLineBuffer


        assertEquals("Test3: ", partialLineBuffer.getPartialLine());
        assertNull(partialLineBuffer.getPartialLine());
    }

    public void testPartialLineBufferFull3() {
        PartialLineBuffer partialLineBuffer = new PartialLineBuffer();
        char[] data = "Test1\nTest2\nTest3: ".toCharArray();
        partialLineBuffer.addData(data, 0, data.length);

        assertEquals(2, partialLineBuffer.getLines().size());
        assertEquals("Test3: ", partialLineBuffer.getPartialLine(false));

        assertEquals("Test1", partialLineBuffer.readLine());
        assertEquals("Test2", partialLineBuffer.readLine());
        assertNull(partialLineBuffer.readLine());

        assertEquals("Test3: ", partialLineBuffer.getPartialLine());
        assertNull(partialLineBuffer.getPartialLine());
    }
View Full Code Here


        assertEquals("Test3: ", partialLineBuffer.getPartialLine());
        assertNull(partialLineBuffer.getPartialLine());
    }

    public void testPartialLineBufferEmptyLine() {
        PartialLineBuffer partialLineBuffer = new PartialLineBuffer();
        char[] data = "Test1\nTest2\n".toCharArray();
        partialLineBuffer.addData(data, 0, data.length);

        assertEquals(2, partialLineBuffer.getLines().size());
        assertNull(partialLineBuffer.getPartialLine());

        assertEquals("Test1", partialLineBuffer.readLine());
        assertEquals("Test2", partialLineBuffer.readLine());
        assertNull(partialLineBuffer.readLine());

        data = "\r\n".toCharArray();
        partialLineBuffer.addData(data, 0, data.length);
        assertEquals("", partialLineBuffer.readLine());
        assertNull(partialLineBuffer.getPartialLine());

        data = "\r\n\r\n".toCharArray();
        partialLineBuffer.addData(data, 0, data.length);
        assertEquals("", partialLineBuffer.readLine());
        assertEquals("", partialLineBuffer.readLine());
        assertNull(partialLineBuffer.getPartialLine());
    }
View Full Code Here

        assertEquals("", partialLineBuffer.readLine());
        assertEquals("", partialLineBuffer.readLine());
        assertNull(partialLineBuffer.getPartialLine());
    }
    public void testUnmarkPartial() {
        PartialLineBuffer partialLineBuffer = new PartialLineBuffer();
        char[] data = "Test1\r\nTest2\r\nTest3: ".toCharArray();
        partialLineBuffer.addData(data, 0, data.length);

        assertEquals(2, partialLineBuffer.getLines().size());
        assertEquals("Test3: ", partialLineBuffer.getPartialLine(false));
        assertEquals("Test3: ", partialLineBuffer.getPartialLine());
        assertEquals(null, partialLineBuffer.getPartialLine());
        partialLineBuffer.unmarkPartial();
        assertEquals("Test3: ", partialLineBuffer.getPartialLine(false));
    }
View Full Code Here

    /**
     * Test input ending with CR, then empty string
     */
    public void testCRLine(){
        PartialLineBuffer partialLineBuffer = new PartialLineBuffer();
        char[] data = "Test1\r".toCharArray();
        partialLineBuffer.addData(data, 0, data.length);

        data = "".toCharArray();
        partialLineBuffer.addData(data, 0, data.length);

        List<String> lines = partialLineBuffer.getLines();
        assertEquals(0, lines.size());

        String partialLine = partialLineBuffer.getPartialLine(true);
        assertEquals("Test1",partialLine);
    }
View Full Code Here

    /**
     * test input ending with CR, then NL
     */
    public void testCRNLLine(){
        PartialLineBuffer partialLineBuffer = new PartialLineBuffer();
        char[] data = "Test1\r".toCharArray();
        partialLineBuffer.addData(data, 0, data.length);

        data = "\n".toCharArray();
        partialLineBuffer.addData(data, 0, data.length);

        List<String> lines = partialLineBuffer.getLines();
        assertEquals(1, lines.size());
        assertEquals("Test1", lines.get(0));

        String partialLine = partialLineBuffer.getPartialLine(true);
        assertEquals(null,partialLine);
    }
View Full Code Here

public class TestResponderThread extends TestCase {

    public void testDetectSuccess() throws Exception {
        ByteArrayInputStream bais = new ByteArrayInputStream("Test1\nTest2: blah\n".getBytes());
        boolean result = ResponderTask.detect("^Test2: .*", null, 1000, 20, new InputStreamReader(bais),
                                              new PartialLineBuffer());
        assertTrue(result);
    }
View Full Code Here

    }

    public void testDetectFail() throws Exception {
        ByteArrayInputStream bais = new ByteArrayInputStream("Test1\nTest2: blah\n".getBytes());
        boolean result = ResponderTask.detect(null, "^Test2: .*", 1000, 20, new InputStreamReader(bais),
                                              new PartialLineBuffer());
        assertFalse(result);
    }
View Full Code Here

    }

    public void testDetectSuccessPartial() throws Exception {
        ByteArrayInputStream bais = new ByteArrayInputStream("Test1\nTest2: blah".getBytes());
        boolean result = ResponderTask.detect("^Test2: .*", null, 1000, 20, new InputStreamReader(bais),
                                              new PartialLineBuffer());
        assertTrue(result);
    }
View Full Code Here

    }

    public void testDetectFailPartial() throws Exception {
        ByteArrayInputStream bais = new ByteArrayInputStream("Test1\nTest2: blah".getBytes());
        boolean result = ResponderTask.detect(null, "^Test2: .*", 1000, 20, new InputStreamReader(bais),
                                              new PartialLineBuffer());
        assertFalse(result);
    }
View Full Code Here

    }

    public void testDetectSuccessPartial2() throws Exception {
        ByteArrayInputStream bais = new ByteArrayInputStream("Test1\r\nTest2: blah\r".getBytes());
        boolean result = ResponderTask.detect("^Test2: .*", null, 1000, 20, new InputStreamReader(bais),
                                              new PartialLineBuffer());
        assertTrue(result);
    }
View Full Code Here

TOP

Related Classes of com.dtolabs.rundeck.core.utils.PartialLineBuffer

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.