FileDocCategorySizeDatePackage
ZipTest.javaAPI DocApache Ant 1.705735Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.taskdefs

ZipTest

public class ZipTest extends org.apache.tools.ant.BuildFileTest

Fields Summary
ZipFile
zfPrefixAddsDir
Constructors Summary
public ZipTest(String name)

       
        super(name);
    
Methods Summary
public voidsetUp()

        configureProject("src/etc/testcases/taskdefs/zip.xml");
    
public voidtearDown()

        try {
            if ( zfPrefixAddsDir != null) {
                zfPrefixAddsDir.close();
            }

        } catch (IOException e) {
            //ignored
        }
        executeTarget("cleanup");
    
public voidtest1()

        expectBuildException("test1", "required argument not specified");
    
public voidtest2()

        expectBuildException("test2", "required argument not specified");
    
public voidtest3()

        expectBuildException("test3", "zip cannot include itself");
    
public voidtest5()

        executeTarget("test5");
    
public voidtest6()

        executeTarget("test6");
    
public voidtest7()

        executeTarget("test7");
    
public voidtest8()

        executeTarget("test8");
    
public voidtestCompressionLevel()

        executeTarget("testCompressionLevel");
    
public voidtestDefaultExcludesAndUpdate()

        executeTarget("testDefaultExcludesAndUpdate");
        ZipFile f = null;
        try {
            f = new ZipFile(getProject().resolveFile("test3.zip"));
            assertNotNull("ziptest~ should be included",
                          f.getEntry("ziptest~"));
        } finally {
            if (f != null) {
                f.close();
            }
        }
    
public voidtestEmptySkip()

        executeTarget("testEmptySkip");
    
public voidtestFileResource()

        executeTarget("testFileResource");
    
public voidtestFilesOnlyDoesntCauseRecreate()

        executeTarget("testFilesOnlyDoesntCauseRecreateSetup");
        long l = getProject().resolveFile("test3.zip").lastModified();
        Thread.sleep(3000);
        executeTarget("testFilesOnlyDoesntCauseRecreate");
        assertEquals(l, getProject().resolveFile("test3.zip").lastModified());
    
public voidtestNonFileResource()

        executeTarget("testNonFileResource");
    
public voidtestPrefixAddsDir()

        executeTarget("testPrefixAddsDir");
        File archive = getProject().resolveFile("test3.zip");
        zfPrefixAddsDir = new ZipFile(archive);
        ZipEntry ze = zfPrefixAddsDir.getEntry("test/");
        assertNotNull("test/ has been added", ze);

    
public voidtestTarFileSet()

        executeTarget("testTarFileSet");
        org.apache.tools.zip.ZipFile zf = null;
        try {
            zf = new org.apache.tools.zip.ZipFile(getProject()
                                                  .resolveFile("test3.zip"));
            org.apache.tools.zip.ZipEntry ze = zf.getEntry("asf-logo.gif");
            assertEquals(UnixStat.FILE_FLAG | 0446, ze.getUnixMode());
        } finally {
            if (zf != null) {
                zf.close();
            }
        }
    
public voidtestUpdateIsNecessary()

        expectLogContaining("testUpdateIsNecessary", "Updating");
    
public voidtestUpdateNotNecessary()

        executeTarget("testUpdateNotNecessary");
        assertEquals(-1, getLog().indexOf("Updating"));
    
public voidtestZipEmptyCreate()

        expectLogContaining("zipEmptyCreate", "Note: creating empty");
    
public voidtestZipEmptyDir()

        executeTarget("zipEmptyDir");
    
public voidtestZipEmptyDirFilesOnly()

        executeTarget("zipEmptyDirFilesOnly");
    
public voidtestZipgroupfileset()

        executeTarget("testZipgroupfileset");

        ZipFile zipFile = new ZipFile(new File(getProjectDir(), "zipgroupfileset.zip"));

        assertTrue(zipFile.getEntry("ant.xml") != null);
        assertTrue(zipFile.getEntry("optional/jspc.xml") != null);
        assertTrue(zipFile.getEntry("zip/zipgroupfileset3.zip") != null);

        assertTrue(zipFile.getEntry("test6.mf") == null);
        assertTrue(zipFile.getEntry("test7.mf") == null);

        zipFile.close();