@Test
public void testLocateStartOfEocd_WithFile() throws IOException {

  // Create a temp file with some zeroes, the EOCD header, and more zeroes.
  int bytesBefore = 53754;
  int bytesAfter = 107;
  File tempFile = File.createTempFile("MinimalZipParserTest", "zip");
  tempFile.deleteOnExit();
  try {
    FileOutputStream out = new FileOutputStream(tempFile);
    out.write(new byte[bytesBefore]);
    out.write(new byte[] {0x50, 0x4b, 0x05, 0x06});
    out.write(new byte[bytesAfter]);
    out.flush();
    out.close();
  } catch (IOException e) {
    try {
      tempFile.delete();
    } catch (Exception ignored) {
      // Nothing
    }
    throw e;
  }
  // Now expect to find the EOCD at the right place.
  try (RandomAccessFileInputStream in = new RandomAccessFileInputStream(tempFile)) {
    long eocdOffset = MinimalZipParser.locateStartOfEocd(in, 32768);
    Assert.assertEquals(bytesBefore, eocdOffset);
  }
}