use of java.util.zip.ZipException in project j2objc by google.
the class ZipInputStreamTest method test_closeAfterException.
public void test_closeAfterException() throws Exception {
File resources = Support_Resources.createTempFolder();
Support_Resources.copyFile(resources, null, "Broken_manifest.jar");
FileInputStream fis = new FileInputStream(new File(resources, "Broken_manifest.jar"));
ZipInputStream zis1 = new ZipInputStream(fis);
try {
for (int i = 0; i < 6; i++) {
zis1.getNextEntry();
}
fail("ZipException expected");
} catch (ZipException ee) {
// expected
}
zis1.close();
try {
zis1.getNextEntry();
fail("IOException expected");
} catch (IOException ee) {
// expected
}
}
use of java.util.zip.ZipException in project j2objc by google.
the class ZipFileTest method test_ConstructorLjava_lang_String.
/**
* @throws IOException
* java.util.zip.ZipFile#ZipFile(java.lang.String)
*/
public void test_ConstructorLjava_lang_String() throws IOException {
// about to reopen the same temp file
zfile.close();
ZipFile zip = new ZipFile(tempFileName);
zip.close();
File file = File.createTempFile("zip", "tmp");
try {
zip = new ZipFile(file.getAbsolutePath());
fail("ZipException expected");
} catch (ZipException ee) {
// expected
}
file.delete();
}
use of java.util.zip.ZipException in project j2objc by google.
the class InflaterTest method setUp.
@Override
protected void setUp() {
try {
java.io.InputStream infile = Support_Resources.getStream("hyts_compressD.bin");
BufferedInputStream inflatIP = new BufferedInputStream(infile);
inflatIP.read(outPutBuff1, 0, outPutBuff1.length);
inflatIP.close();
java.io.InputStream infile2 = Support_Resources.getStream("hyts_compDiction.bin");
BufferedInputStream inflatIP2 = new BufferedInputStream(infile2);
inflatIP2.read(outPutDiction, 0, outPutDiction.length);
inflatIP2.close();
} catch (FileNotFoundException e) {
fail("input file to test InflaterInputStream constructor is not found");
} catch (ZipException e) {
fail("read() threw an zip exception while testing constructor");
} catch (IOException e) {
fail("read() threw an exception while testing constructor");
}
}
use of java.util.zip.ZipException in project j2objc by google.
the class AbstractZipFileTest method testSTORED.
public void testSTORED() throws IOException {
ZipOutputStream out = createZipOutputStream(createTemporaryZipFile());
CRC32 crc = new CRC32();
// Missing CRC, size, and compressed size => failure.
try {
ZipEntry ze = new ZipEntry("a");
ze.setMethod(ZipEntry.STORED);
out.putNextEntry(ze);
fail();
} catch (ZipException expected) {
}
// Missing CRC and compressed size => failure.
try {
ZipEntry ze = new ZipEntry("a");
ze.setMethod(ZipEntry.STORED);
ze.setSize(0);
out.putNextEntry(ze);
fail();
} catch (ZipException expected) {
}
// Missing CRC and size => failure.
try {
ZipEntry ze = new ZipEntry("a");
ze.setMethod(ZipEntry.STORED);
ze.setSize(0);
ze.setCompressedSize(0);
out.putNextEntry(ze);
fail();
} catch (ZipException expected) {
}
// Missing size and compressed size => failure.
try {
ZipEntry ze = new ZipEntry("a");
ze.setMethod(ZipEntry.STORED);
ze.setCrc(crc.getValue());
out.putNextEntry(ze);
fail();
} catch (ZipException expected) {
}
// Missing size is copied from compressed size.
{
ZipEntry ze = new ZipEntry("okay1");
ze.setMethod(ZipEntry.STORED);
ze.setCrc(crc.getValue());
assertEquals(-1, ze.getSize());
assertEquals(-1, ze.getCompressedSize());
ze.setCompressedSize(0);
assertEquals(-1, ze.getSize());
assertEquals(0, ze.getCompressedSize());
out.putNextEntry(ze);
assertEquals(0, ze.getSize());
assertEquals(0, ze.getCompressedSize());
}
// Missing compressed size is copied from size.
{
ZipEntry ze = new ZipEntry("okay2");
ze.setMethod(ZipEntry.STORED);
ze.setCrc(crc.getValue());
assertEquals(-1, ze.getSize());
assertEquals(-1, ze.getCompressedSize());
ze.setSize(0);
assertEquals(0, ze.getSize());
assertEquals(-1, ze.getCompressedSize());
out.putNextEntry(ze);
assertEquals(0, ze.getSize());
assertEquals(0, ze.getCompressedSize());
}
// Mismatched size and compressed size => failure.
try {
ZipEntry ze = new ZipEntry("a");
ze.setMethod(ZipEntry.STORED);
ze.setCrc(crc.getValue());
ze.setCompressedSize(1);
ze.setSize(0);
out.putNextEntry(ze);
fail();
} catch (ZipException expected) {
}
// Everything present => success.
ZipEntry ze = new ZipEntry("okay");
ze.setMethod(ZipEntry.STORED);
ze.setCrc(crc.getValue());
ze.setSize(0);
ze.setCompressedSize(0);
out.putNextEntry(ze);
out.close();
}
use of java.util.zip.ZipException in project j2objc by google.
the class OldZipExceptionTest method testZipException.
public void testZipException() {
ZipException zz = new ZipException();
assertEquals(zz.getMessage(), null);
}
Aggregations