Skip to content

Commit

Permalink
add extra test
Browse files Browse the repository at this point in the history
  • Loading branch information
epickrram committed Oct 19, 2017
1 parent 325e16a commit 3d31f50
Showing 1 changed file with 30 additions and 1 deletion.
Expand Up @@ -22,7 +22,7 @@ public final class RollAtEndOfCycleTest {
private final AtomicLong clock = new AtomicLong(System.currentTimeMillis());

@Test
public void shouldRollAtEndOfCycle() throws Exception {
public void shouldRollAndAppendToNewFile() throws Exception {
try (final SingleChronicleQueue queue = createQueue()) {
final ExcerptAppender appender = queue.acquireAppender();

Expand Down Expand Up @@ -51,6 +51,35 @@ public void shouldRollAtEndOfCycle() throws Exception {
}
}

@Test
public void shouldAppendToExistingQueueFile() throws Exception {
try (final SingleChronicleQueue queue = createQueue()) {
final ExcerptAppender appender = queue.acquireAppender();

appender.writeDocument(1, (w, i) -> {
w.int32(i);
});

final ExcerptTailer tailer = queue.createTailer();
try (final DocumentContext context = tailer.readingDocument()) {
assertTrue(context.isPresent());
}

assertQueueFileCount(queue.path.toPath(), 1);

assertFalse(tailer.readingDocument().isPresent());

appender.writeDocument(2, (w, i) -> {
w.int32(i);
});

assertQueueFileCount(queue.path.toPath(), 1);
try (final DocumentContext context = tailer.readingDocument()) {
assertTrue(context.isPresent());
}
}
}

private static void assertQueueFileCount(final Path path, final long expectedCount) throws IOException {
final long count = Files.list(path).filter(p -> p.toString().
endsWith(SingleChronicleQueue.SUFFIX)).count();
Expand Down

0 comments on commit 3d31f50

Please sign in to comment.