Search in sources :

Example 86 with PrintStream

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

the class DirtyPrintStreamDecoratorTest method testWriteBytesAndOffset.

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

Example 87 with PrintStream

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

the class DirtyPrintStreamDecoratorTest method testPrintfWithLocale.

@Test
public void testPrintfWithLocale() {
    PrintStream delegate = createMock(PrintStream.class);
    Locale locale = Locale.ENGLISH;
    String formatString = "Build target [%s] does not exist.";
    String greeter = "//foo:bar";
    expect(delegate.printf(locale, formatString, greeter)).andReturn(delegate);
    replay(delegate);
    DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate);
    PrintStream valueToChain = dirtyPrintStream.printf(locale, formatString, greeter);
    verify(delegate);
    assertEquals(dirtyPrintStream, valueToChain);
    assertTrue(dirtyPrintStream.isDirty());
}
Also used : Locale(java.util.Locale) PrintStream(java.io.PrintStream) Test(org.junit.Test)

Example 88 with PrintStream

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

the class DirtyPrintStreamDecoratorTest method testPrintFloat.

@Test
public void testPrintFloat() {
    PrintStream delegate = createMock(PrintStream.class);
    float value = 3.14f;
    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 89 with PrintStream

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

the class DirtyPrintStreamDecoratorTest method testPrintObject.

@Test
public void testPrintObject() {
    PrintStream delegate = createMock(PrintStream.class);
    Object value = new Object();
    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 90 with PrintStream

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

the class DirtyPrintStreamDecoratorTest method testFormatWithLocale.

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