Search in sources :

Example 76 with PrintStream

use of java.io.PrintStream in project buck by facebook.

the class DirtyPrintStreamDecoratorTest method testWriteBytes.

@Test
public void testWriteBytes() throws IOException {
    PrintStream delegate = createMock(PrintStream.class);
    byte[] bytes = new byte[] { 65, 66, 67 };
    delegate.write(bytes);
    delegate.close();
    EasyMock.expectLastCall().anyTimes();
    replay(delegate);
    try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) {
        dirtyPrintStream.write(bytes);
        verify(delegate);
        assertTrue(dirtyPrintStream.isDirty());
    }
}
Also used : PrintStream(java.io.PrintStream) Test(org.junit.Test)

Example 77 with PrintStream

use of java.io.PrintStream in project buck by facebook.

the class DirtyPrintStreamDecoratorTest method testPrintlnInt.

@Test
public void testPrintlnInt() {
    PrintStream delegate = createMock(PrintStream.class);
    int value = 144;
    delegate.println(value);
    delegate.close();
    EasyMock.expectLastCall().anyTimes();
    replay(delegate);
    try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) {
        dirtyPrintStream.println(value);
        verify(delegate);
        assertTrue(dirtyPrintStream.isDirty());
    }
}
Also used : PrintStream(java.io.PrintStream) Test(org.junit.Test)

Example 78 with PrintStream

use of java.io.PrintStream in project buck by facebook.

the class DirtyPrintStreamDecoratorTest method testPrintLong.

@Test
public void testPrintLong() {
    PrintStream delegate = createMock(PrintStream.class);
    long value = Long.MAX_VALUE;
    delegate.print(value);
    delegate.close();
    EasyMock.expectLastCall().anyTimes();
    replay(delegate);
    try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) {
        dirtyPrintStream.print(value);
        verify(delegate);
        assertTrue(dirtyPrintStream.isDirty());
    }
}
Also used : PrintStream(java.io.PrintStream) Test(org.junit.Test)

Example 79 with PrintStream

use of java.io.PrintStream in project buck by facebook.

the class DirtyPrintStreamDecoratorTest method testPrintlnChar.

@Test
public void testPrintlnChar() {
    PrintStream delegate = createMock(PrintStream.class);
    char value = 'z';
    delegate.println(value);
    delegate.close();
    EasyMock.expectLastCall().anyTimes();
    replay(delegate);
    try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) {
        dirtyPrintStream.println(value);
        verify(delegate);
        assertTrue(dirtyPrintStream.isDirty());
    }
}
Also used : PrintStream(java.io.PrintStream) Test(org.junit.Test)

Example 80 with PrintStream

use of java.io.PrintStream in project buck by facebook.

the class DirtyPrintStreamDecoratorTest method testPrintDouble.

@Test
public void testPrintDouble() {
    PrintStream delegate = createMock(PrintStream.class);
    double value = Math.PI;
    delegate.print(value);
    delegate.close();
    EasyMock.expectLastCall().anyTimes();
    replay(delegate);
    try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) {
        dirtyPrintStream.print(value);
        verify(delegate);
        assertTrue(dirtyPrintStream.isDirty());
    }
}
Also used : PrintStream(java.io.PrintStream) Test(org.junit.Test)

Aggregations

PrintStream (java.io.PrintStream)1828 ByteArrayOutputStream (java.io.ByteArrayOutputStream)805 Test (org.junit.Test)583 File (java.io.File)331 IOException (java.io.IOException)295 FileOutputStream (java.io.FileOutputStream)207 ArrayList (java.util.ArrayList)89 FileNotFoundException (java.io.FileNotFoundException)83 OutputStream (java.io.OutputStream)81 Before (org.junit.Before)66 BufferedReader (java.io.BufferedReader)53 BufferedOutputStream (java.io.BufferedOutputStream)49 Map (java.util.Map)49 Date (java.util.Date)46 Path (org.apache.hadoop.fs.Path)42 UnsupportedEncodingException (java.io.UnsupportedEncodingException)41 InputStreamReader (java.io.InputStreamReader)38 Matchers.anyString (org.mockito.Matchers.anyString)38 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)36 List (java.util.List)35