Search in sources :

Example 81 with PrintStream

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

the class DirtyPrintStreamDecoratorTest method testPrintlnBoolean.

@Test
public void testPrintlnBoolean() {
    PrintStream delegate = createMock(PrintStream.class);
    boolean value = false;
    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 82 with PrintStream

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

the class DirtyPrintStreamDecoratorTest method testAppendChar.

@Test
public void testAppendChar() {
    PrintStream delegate = createMock(PrintStream.class);
    char value = 'q';
    expect(delegate.append(value)).andReturn(delegate);
    replay(delegate);
    DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate);
    PrintStream valueToChain = dirtyPrintStream.append(value);
    verify(delegate);
    assertEquals(dirtyPrintStream, valueToChain);
    assertTrue(dirtyPrintStream.isDirty());
}
Also used : PrintStream(java.io.PrintStream) Test(org.junit.Test)

Example 83 with PrintStream

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

the class DirtyPrintStreamDecoratorTest method testPrintInt.

@Test
public void testPrintInt() {
    PrintStream delegate = createMock(PrintStream.class);
    int value = 42;
    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 84 with PrintStream

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

the class DirtyPrintStreamDecoratorTest method testPrintCharArray.

@Test
public void testPrintCharArray() {
    PrintStream delegate = createMock(PrintStream.class);
    char[] value = new char[] { 'h', 'e', 'l', 'l', 'o' };
    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 85 with PrintStream

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

the class DirtyPrintStreamDecoratorTest method testFormatWithoutLocale.

@Test
public void testFormatWithoutLocale() {
    PrintStream delegate = createMock(PrintStream.class);
    String formatString = "Build target [%s] does not exist.";
    String greeter = "//foo:bar";
    expect(delegate.format(formatString, greeter)).andReturn(delegate);
    replay(delegate);
    DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate);
    PrintStream valueToChain = dirtyPrintStream.format(formatString, greeter);
    verify(delegate);
    assertEquals(dirtyPrintStream, valueToChain);
    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