FileDocCategorySizeDatePackage
ZipOutputStreamTest.javaAPI DocApache Ant 1.702662Wed Dec 13 06:16:18 GMT 2006org.apache.tools.zip

ZipOutputStreamTest

public class ZipOutputStreamTest extends TestCase

Fields Summary
private Date
time
private ZipLong
zl
Constructors Summary
public ZipOutputStreamTest(String name)
Constructor

        super(name);
    
Methods Summary
protected voidsetUp()

        time = new Date();
        Calendar cal = Calendar.getInstance();
        cal.setTime(time);
        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH) + 1;
        long value =  ((year - 1980) << 25)
            |         (month << 21)
            |	      (cal.get(Calendar.DAY_OF_MONTH) << 16)
            |         (cal.get(Calendar.HOUR_OF_DAY) << 11)
            |         (cal.get(Calendar.MINUTE) << 5)
            |         (cal.get(Calendar.SECOND) >> 1);

        byte[] result = new byte[4];
        result[0] = (byte) ((value & 0xFF));
        result[1] = (byte) ((value & 0xFF00) >> 8);
        result[2] = (byte) ((value & 0xFF0000) >> 16);
        result[3] = (byte) ((value & 0xFF000000L) >> 24);
        zl = new ZipLong(result);
    
protected voidtearDown()

        super.tearDown();
    
public voidtestAdjustToLong()

        assertEquals((long) Integer.MAX_VALUE,
                     ZipOutputStream.adjustToLong(Integer.MAX_VALUE));
        assertEquals(((long) Integer.MAX_VALUE) + 1,
                     ZipOutputStream.adjustToLong(Integer.MAX_VALUE + 1));
        assertEquals(2 * ((long) Integer.MAX_VALUE),
                     ZipOutputStream.adjustToLong(2 * Integer.MAX_VALUE));
    
public voidtestZipLong()

        ZipLong test = ZipOutputStream.toDosTime(time);
        assertEquals(test.getValue(), zl.getValue());