@Test public void writeTest() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); RecordWriter writer = new RecordWriter(out); int numMessages = 10; for (int i = 0; i < numMessages; i++) { int n = writer.write(createMessage("This is log message " + i)); assertTrue(n > 0); } byte[] data = out.toByteArray(); ByteArrayInputStream inp = new ByteArrayInputStream(data); Timber.LogEvent ev = null; int count = 0; do { ev = Timber.LogEvent.parseDelimitedFrom(inp); if (null != ev) { count++; assertEquals("T", ev.getType()); } } while (null != ev); assertEquals(numMessages, count); }
public int write(Timber.LogEvent logEvent) throws IOException { logEvent.writeDelimitedTo(out); return out.getLastBytesWritten(); }
RecordWriter { public int write(Timber.LogEvent logEvent) throws IOException { logEvent.writeDelimitedTo(out); return out.getLastBytesWritten(); } }
RecordWriter { public int write(Timber.LogEvent logEvent) throws IOException { logEvent.writeDelimitedTo(out); return out.getLastBytesWritten(); } RecordWriter(OutputStream out); }
RecordWriter { public int write(Timber.LogEvent logEvent) throws IOException { logEvent.writeDelimitedTo(out); return out.getLastBytesWritten(); } RecordWriter(OutputStream out); int write(Timber.LogEvent logEvent); void close(); void flush(); }
RecordWriter { public int write(Timber.LogEvent logEvent) throws IOException { logEvent.writeDelimitedTo(out); return out.getLastBytesWritten(); } RecordWriter(OutputStream out); int write(Timber.LogEvent logEvent); void close(); void flush();  }