### Question:
LogbackThriftLogger extends BaseThriftLogger { public void close() { appender.stop(); } @Deprecated  LogbackThriftLogger(Appender<LogMessage> appender);  LogbackThriftLogger(String topic, Appender<LogMessage> appender); @Override void append(byte[] partitionKey, byte[] message, long timeNanos); @Override void append(byte[] partitionKey, TBase thriftMessage, long timeNanos); void close();  }### Answer:
@Test public void testLoggerWithConsecutiveReads() throws IOException, TException { File tmpDir = TempDirectory.create(true); String logFilePath = tmpDir.getPath(); String testFilePath = initialize(logFilePath, testFileName); RandomAccessFile tfile = null; TTransport transport = null; try { tfile = new RandomAccessFile(testFilePath, "r"); InputStream is = new FileInputStream(tfile.getFD()); transport = new TFastFramedTransport(new TIOStreamTransport(is), 10000); TProtocol protocol = new TBinaryProtocol(transport); LogMessage logMessage = new LogMessage(); for (int i = 0; i < messages.length; i++) { logMessage.read(protocol); assertEquals(logMessage, messages[i]); } } catch (IOException e) { e.printStackTrace(); assert (false); } finally { if (transport != null) { transport.close(); } if (tfile != null) { tfile.close(); } } cleanup(logFilePath); }
@Test public void testLoggerWithSeekReads() throws IOException { File tmpDir = TempDirectory.create(true); String logFilePath = tmpDir.getPath(); String testFilePath = initialize(logFilePath, testFileName); long startOffset = 0; for (int i = 0; i < messages.length; i++) { RandomAccessFile tfile = null; TTransport transport = null; try { tfile = new RandomAccessFile(testFilePath, "r"); tfile.seek(startOffset); InputStream is = new FileInputStream(tfile.getFD()); transport = new TFastFramedTransport(new TIOStreamTransport(is), 10000); TProtocol protocol = new TBinaryProtocol(transport); LogMessage logMessage = new LogMessage(); logMessage.read(protocol); int bufferPos = transport.getBufferPosition(); int bytesRemainingInBuffer = transport.getBytesRemainingInBuffer(); System.out.println("startOffset = " + startOffset + "bufferPos = " + bufferPos + " bytesRemainingInBuffer = " + bytesRemainingInBuffer); assertEquals(logMessage, messages[i]); startOffset = startOffset + transport.getBufferPosition() - transport.getBytesRemainingInBuffer() + 4; } catch (Exception e) { e.printStackTrace(); assert (false); } finally { if (transport != null) { transport.close(); } if (tfile != null) { tfile.close(); } } } cleanup(logFilePath); }