Search in sources :

Example 1 with LineBufferingOutputStream

use of org.gradle.internal.io.LineBufferingOutputStream in project gradle by gradle.

the class LineBufferingOutputStreamTest method logsLineWhichIsLongerThanInitialBufferLength.

@Test
public void logsLineWhichIsLongerThanInitialBufferLength() throws IOException {
    System.setProperty("line.separator", "-");
    LineBufferingOutputStream outputStream = new LineBufferingOutputStream(action, 8);
    context.checking(new Expectations() {

        {
            one(action).text("a line longer than 8 bytes long-");
            one(action).text("line 2");
        }
    });
    outputStream.write("a line longer than 8 bytes long-".getBytes());
    outputStream.write("line 2".getBytes());
    outputStream.flush();
}
Also used : Expectations(org.jmock.Expectations) LineBufferingOutputStream(org.gradle.internal.io.LineBufferingOutputStream) Test(org.junit.Test)

Example 2 with LineBufferingOutputStream

use of org.gradle.internal.io.LineBufferingOutputStream in project gradle by gradle.

the class LineBufferingOutputStreamTest method handlesMultiCharacterLineSeparator.

@Test
public void handlesMultiCharacterLineSeparator() throws IOException {
    final String separator = new String(new byte[] { '\r', '\n' });
    System.setProperty("line.separator", separator);
    LineBufferingOutputStream outputStream = new LineBufferingOutputStream(action, 8);
    context.checking(new Expectations() {

        {
            one(action).text("line 1" + separator);
            one(action).text("line 2" + separator);
        }
    });
    outputStream.write(("line 1" + separator + "line 2" + separator).getBytes());
}
Also used : Expectations(org.jmock.Expectations) LineBufferingOutputStream(org.gradle.internal.io.LineBufferingOutputStream) Test(org.junit.Test)

Example 3 with LineBufferingOutputStream

use of org.gradle.internal.io.LineBufferingOutputStream in project gradle by gradle.

the class LineBufferingOutputStreamTest method logsNothingOnCloseWhenCompleteLineHasBeenWrittenToStream.

@Test
public void logsNothingOnCloseWhenCompleteLineHasBeenWrittenToStream() throws IOException {
    System.setProperty("line.separator", "-");
    LineBufferingOutputStream outputStream = new LineBufferingOutputStream(action, 8);
    context.checking(new Expectations() {

        {
            one(action).text("line 1-");
            one(action).endOfStream(null);
        }
    });
    outputStream.write("line 1-".getBytes());
    outputStream.close();
}
Also used : Expectations(org.jmock.Expectations) LineBufferingOutputStream(org.gradle.internal.io.LineBufferingOutputStream) Test(org.junit.Test)

Example 4 with LineBufferingOutputStream

use of org.gradle.internal.io.LineBufferingOutputStream in project gradle by gradle.

the class LineBufferingOutputStreamTest method logsPartialLineOnFlush.

@Test
public void logsPartialLineOnFlush() throws IOException {
    LineBufferingOutputStream outputStream = new LineBufferingOutputStream(action, 8);
    context.checking(new Expectations() {

        {
            one(action).text("line 1");
        }
    });
    outputStream.write("line 1".getBytes());
    outputStream.flush();
}
Also used : Expectations(org.jmock.Expectations) LineBufferingOutputStream(org.gradle.internal.io.LineBufferingOutputStream) Test(org.junit.Test)

Example 5 with LineBufferingOutputStream

use of org.gradle.internal.io.LineBufferingOutputStream in project gradle by gradle.

the class LineBufferingOutputStreamTest method logsEmptyLines.

@Test
public void logsEmptyLines() throws IOException {
    System.setProperty("line.separator", "-");
    LineBufferingOutputStream outputStream = new LineBufferingOutputStream(action, 8);
    context.checking(new Expectations() {

        {
            one(action).text("-");
            one(action).text("-");
        }
    });
    outputStream.write("--".getBytes());
}
Also used : Expectations(org.jmock.Expectations) LineBufferingOutputStream(org.gradle.internal.io.LineBufferingOutputStream) Test(org.junit.Test)

Aggregations

LineBufferingOutputStream (org.gradle.internal.io.LineBufferingOutputStream)14 Expectations (org.jmock.Expectations)12 Test (org.junit.Test)12 IOException (java.io.IOException)1 AsynchronousCloseException (java.nio.channels.AsynchronousCloseException)1 TeeOutputStream (org.apache.commons.io.output.TeeOutputStream)1 ConsoleOutput (org.gradle.api.logging.configuration.ConsoleOutput)1 TextStream (org.gradle.internal.io.TextStream)1 LoggingManagerInternal (org.gradle.internal.logging.LoggingManagerInternal)1 DisconnectableInputStream (org.gradle.util.DisconnectableInputStream)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1