public void testCreateZipWithLargeFiles() throws IOException {
    MockApplicationInfo info = new MockApplicationInfo();
    File file = new File("/tmp/large.txt");
    RandomAccessFile randomaccessfile = new RandomAccessFile(file, "rw");
    randomaccessfile.setLength(THIRTY_MB);
    randomaccessfile.close();

    info.getApplicationFileBundles()
        .add(
            new DefaultApplicationFileBundle(
                BundleManifest.APPLICATION_LOGS,
                "large-file",
                "a really large file to test zip truncation",
                file.getAbsolutePath()));
    // write a lot of data to a file in the info bundle

    ValidationLog limitedValidationLog = new ValidationLog(info);
    ZipUtility.createSupportZip(info.getApplicationFileBundles(), info, limitedValidationLog, true);
    assertTrue(
        "No warning was issued when truncating an overly large file...",
        limitedValidationLog.hasWarnings());

    ValidationLog unlimitedValidationLog = new ValidationLog(info);
    ZipUtility.createSupportZip(
        info.getApplicationFileBundles(), info, unlimitedValidationLog, false);
    assertFalse(
        "A warning was issued regarding a large file even when the option to limit file sizes was disabled.",
        unlimitedValidationLog.hasWarnings());

    file.delete();
  }
  protected void performFileTest(
      boolean testSize, MockApplicationInfo applicationInfo, int fileSizeToTest, String name)
      throws FileNotFoundException, IOException, KeyException, GeneralSecurityException,
          ZipException, InterruptedException {
    String filename = "/tmp/" + name;
    File file = new File(filename);
    int counter = 0;
    while (file.exists() && counter < 5000) {
      counter++;
    }

    RandomAccessFile randomFile = new RandomAccessFile(file, "rw");
    randomFile.setLength(fileSizeToTest);
    randomFile.close();

    ApplicationInfoBundle fileBundle =
        new DefaultApplicationFileBundle(
            BundleManifest.APPLICATION_LOGS, "title", "description", file.getAbsolutePath());
    List<ApplicationInfoBundle> fileBundles = new ArrayList<ApplicationInfoBundle>();
    fileBundles.add(fileBundle);
    File supportZip =
        ZipUtility.createSupportZip(
            fileBundles, applicationInfo, new ValidationLog(applicationInfo));
    ZipInputStream zipStream = new ZipInputStream(new FileInputStream(supportZip));
    ZipEntry zipEntry = zipStream.getNextEntry();
    assertNotNull("Zip file '" + name + "' is null.", zipEntry);
    assertTrue(
        "Zip entry '" + name + "'does not start with bundle key",
        zipEntry.getName().startsWith(BundleManifest.APPLICATION_LOGS.getKey()));
    assertTrue(
        "Zip entry '" + name + "' does not end with the correct file name.",
        zipEntry.getName().endsWith(zipEntry.getName()));

    if (testSize) {
      // ZipInputStream has a known limitation. It does not initialize zip
      // entry sizes
      // if the content is encrypted - we can not use ZipFile as it does
      // not allow us to pass a CipherInputStream
      ZipFile zipFile = new ZipFile(supportZip);
      int expectedSize = Math.min(fileSizeToTest, TWENTY_MB);
      assertEquals(
          "Zip entry '" + name + "'is the wrong size.",
          expectedSize,
          zipFile.entries().nextElement().getSize());
    }
    file.delete();
    supportZip.delete();
  }