@Test public void testInvalidFile() throws FileNotFoundException { @NotNull File dir = new File(OS.TARGET + "/deleteme-" + System.nanoTime()); dir.mkdir(); try (@NotNull MappedBytes bytes = MappedBytes.mappedBytes(new File(dir, "19700102" + SingleChronicleQueue.SUFFIX), 64 << 10)) { bytes.write8bit("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>"); try (@NotNull RollingChronicleQueue queue = binary(dir) .rollCycle(RollCycles.TEST4_DAILY) .testBlockSize() .build()) { assertEquals(1, queue.firstCycle()); assertEquals(1, queue.lastCycle()); try { @NotNull ExcerptTailer tailer = queue.createTailer(); tailer.toEnd(); fail(); } catch (Exception e) { assertEquals("java.io.StreamCorruptedException: Unexpected magic number 783f3c37", e.toString()); } } } System.gc(); try { IOTools.shallowDeleteDirWithFiles(dir.getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); } }