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());
}
}
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());
}
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());
}
}
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());
}
}
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());
}
Aggregations