package net.openhft.chronicle.queue;

import net.openhft.chronicle.queue.impl.single.SingleChronicleQueue;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder;
import org.junit.Assert;
import org.junit.Test;

import java.util.UUID;

/**
 * Created by Rob Austin
 */
public class BackwardWithPretouchTest {

    @Test
    public void testAppenderBackwardWithPretoucher() throws Exception {

        SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(UUID.randomUUID().toString()).rollCycle(RollCycles.TEST_SECONDLY).build();
        ExcerptAppender excerptAppender = queue.acquireAppender();
        excerptAppender.writeText("hello");

        // sleep til next cycle
        Thread.sleep(1000);

        // pretouch to create next cycle file  ----- IF YOU UNCOMMENT THIS LINE THE TEST PASSES
        excerptAppender.pretouch();

        ExcerptTailer tailer = queue.createTailer().direction(TailerDirection.BACKWARD);
        Assert.assertEquals("hello", tailer.toEnd().readText());
    }
}

@@ -31,16 +31,72 @@
 queue;%0A%0A
+import net.openhft.chronicle.core.time.SetTimeProvider;%0A
 import n
@@ -297,52 +297,17 @@
 ava.
-util.UUID;%0A%0A/**%0A * Created by Rob Austin%0A */
+io.File;%0A
 %0Apub
@@ -341,16 +341,47 @@
 uchTest 
+extends ChronicleQueueTestBase 
 %7B%0A%0A    @
@@ -442,27 +442,175 @@
 r() 
-throws Exception %7B%0A
+%7B%0A%0A        SetTimeProvider timeProvider = new SetTimeProvider();%0A        timeProvider.currentTimeMillis(System.currentTimeMillis());%0A        File tmpDir = getTmpDir();
 %0A   
@@ -682,36 +682,41 @@
 ary(
-UUID.randomUUID().toString()
+tmpDir).timeProvider(timeProvider
 ).ro
@@ -882,52 +882,34 @@
     
-// sleep til next cycle%0A        Thread.sleep
+timeProvider.advanceMillis
 (100
@@ -977,10 +977,8 @@
 YOU 
-UN
 COMM

Improve the test case