~ubuntu-branches/debian/stretch/libcommons-compress-java/stretch

« back to all changes in this revision

Viewing changes to src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2015-08-31 23:22:38 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20150831232238-gz3ynyvs68tok1a3
Tags: 1.10-1
* New upstream release
* Updated the OSGi metadata

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
                                       "zip6/5GB_of_Zeros");
131
131
    }
132
132
 
 
133
    @Test public void writeAndRead5GBOfZerosUsingZipFile() throws Throwable {
 
134
        File f = null;
 
135
        try {
 
136
            f = write5GBZerosFile("writeAndRead5GBOfZerosUsingZipFile");
 
137
            read5GBOfZerosUsingZipFileImpl(f, "5GB_of_Zeros");
 
138
        } finally {
 
139
            if (f != null) {
 
140
                AbstractTestCase.tryHardToDelete(f);
 
141
            }
 
142
        }
 
143
    }
 
144
 
 
145
    private static File write5GBZerosFile(String testName) throws Throwable {
 
146
        File f = getTempFile(testName);
 
147
        ZipArchiveOutputStream zos = new ZipArchiveOutputStream(f);
 
148
        try {
 
149
            zos.setUseZip64(Zip64Mode.Always);
 
150
            byte[] buf = new byte[ONE_MILLION];
 
151
            ZipArchiveEntry zae = new ZipArchiveEntry("5GB_of_Zeros");
 
152
            zae.setSize(FIVE_BILLION);
 
153
            zae.setMethod(ZipEntry.DEFLATED);
 
154
            zae.setCrc(0x8a408f16L);
 
155
            zos.putArchiveEntry(zae);
 
156
            for (int j = 0; j < FIVE_BILLION / 1000 / 1000; j++) {
 
157
                zos.write(buf);
 
158
            }
 
159
            zos.closeArchiveEntry();
 
160
            zos.close();
 
161
        } catch (IOException ex) {
 
162
            System.err.println("Failed to write archive because of: "
 
163
                               + ex.getMessage()
 
164
                               + " - likely not enough disk space.");
 
165
            assumeTrue(false);
 
166
        } finally {
 
167
            zos.destroy();
 
168
        }
 
169
        return f;
 
170
    }
 
171
 
133
172
    @Test public void read100KFilesUsingZipFile() throws Throwable {
134
173
        read100KFilesUsingZipFileImpl(get100KFileFile());
135
174
    }