@Test
public void testWrite() {

    try (final ChronicleQueue cq = ChronicleQueue.singleBuilder(basePath()).build()) {
        ChronicleLogWriter lw = new DefaultChronicleLogWriter(cq);
        lw.write(
                ChronicleLogLevel.ERROR,
                currentTimeMillis(),
                Thread.currentThread().getName(),
                this.getClass().getCanonicalName(),
                "Test message",
                new Exception("Test exception"),
                10,
                12.1
        );
        lw.write(
                ChronicleLogLevel.DEBUG,
                currentTimeMillis(),
                Thread.currentThread().getName(),
                this.getClass().getCanonicalName(),
                "Test debug message"
        );
    }
    try (final ChronicleQueue cq = ChronicleQueue.singleBuilder(basePath()).build()) {
        ExcerptTailer tailer = cq.createTailer();
        try (DocumentContext dc = tailer.readingDocument()) {
            Wire wire = dc.wire();
            assertNotNull(wire);
            assertTrue(wire.read("ts").int64() <= currentTimeMillis());
            assertEquals(ChronicleLogLevel.ERROR, wire.read("level").asEnum(ChronicleLogLevel.class));
            assertEquals(Thread.currentThread().getName(), wire.read("threadName").text());
            assertEquals(this.getClass().getCanonicalName(), wire.read("loggerName").text());
            assertEquals("Test message", wire.read("message").text());
            assertEquals("Test exception", wire.read("throwable").throwable(false).getMessage());
            List<Object> args = new ArrayList<>();
            assertTrue(wire.hasMore());
            wire.read("args").sequence(args, (l, vi) -> {
                while (vi.hasNextSequenceItem()) {
                    l.add(vi.object(Object.class));
                }
            });
            assertArrayEquals(new Object[]{10, 12.1}, args.toArray(new Object[args.size()]));
        }
        try (DocumentContext dc = tailer.readingDocument()) {
            Wire wire = dc.wire();
            assertNotNull(wire);
            assertTrue(wire.read("ts").int64() <= currentTimeMillis());
            assertEquals(ChronicleLogLevel.DEBUG, wire.read("level").asEnum(ChronicleLogLevel.class));
            assertEquals(Thread.currentThread().getName(), wire.read("threadName").text());
            assertEquals(this.getClass().getCanonicalName(), wire.read("loggerName").text());
            assertEquals("Test debug message", wire.read("message").text());
            assertFalse(wire.hasMore());
        }
        try (DocumentContext dc = tailer.readingDocument()) {
            Wire wire = dc.wire();
            assertNull(wire);
        }
    }
}