package net.kuujo.copycat.log;

import java.util.UUID;

import net.openhft.chronicle.ChronicleConfig;

import org.testng.annotations.Test;

/**
 * Chronicle log test.
 *
 * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
 */
@Test
public class ChronicleLogTest extends AbstractLogTest {
  @Override
  protected AbstractLog createLog() throws Throwable {
    LogConfig config = new LogConfig().withSegmentSize(segmentSize);
    String id = UUID.randomUUID().toString();
    ChronicleConfig chronicleConfig = ChronicleConfig.DEFAULT.indexFileCapacity(1024 * 1024)
      .indexFileExcerpts(8 * 1024)
      .dataBlockSize(8 * 1024)
      .messageCapacity(8192 / 2);
    chronicleConfig.minimiseFootprint(true);
    return new ChronicleLog(id, config, chronicleConfig);
  }

  @Override
  protected int entrySize() {
    return 17;
  }
}

@@ -21,24 +21,286 @@
 pycat.log;%0A%0A
+import java.io.File;%0Aimport java.io.IOException;%0Aimport java.nio.file.FileVisitResult;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.nio.file.SimpleFileVisitor;%0Aimport java.nio.file.attribute.BasicFileAttributes;%0A
 import java.
@@ -354,24 +354,65 @@
 cleConfig;%0A%0A
+import org.testng.annotations.AfterTest;%0A
 import org.t
@@ -598,16 +598,594 @@
 gTest %7B%0A
+  @AfterTest%0A  protected void cleanLogDir() throws IOException %7B%0A    Path directory = Paths.get(%22target/test-logs/%22);%0A    Files.walkFileTree(directory, new SimpleFileVisitor%3CPath%3E() %7B%0A      @Override%0A      public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException %7B%0A        Files.delete(file);%0A        return FileVisitResult.CONTINUE;%0A      %7D%0A%0A      @Override%0A      public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException %7B%0A        Files.delete(dir);%0A        return FileVisitResult.CONTINUE;%0A      %7D%0A    %7D);%0A  %7D%0A%0A%0A
   @Overr
@@ -1243,16 +1243,62 @@
 wable %7B%0A
+    String id = UUID.randomUUID().toString();%0A
     LogC
@@ -1360,53 +1360,80 @@
 ize)
-;%0A    String id = UUID.randomUUID().toString(
+.withDirectory(%0A      new File(String.format(%22target/test-logs/%25s%22, id))
 );%0A 

Clean test log files upon test completion