From 2d89826ec7c024e80bdc132ced24fdd9e9862cc6 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Mon, 8 Jul 2013 16:46:00 -0600 Subject: [PATCH] zipentry test --- test/ZipEntryTest.java | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 test/ZipEntryTest.java diff --git a/test/ZipEntryTest.java b/test/ZipEntryTest.java new file mode 100644 index 0000000000..4817300741 --- /dev/null +++ b/test/ZipEntryTest.java @@ -0,0 +1,56 @@ +/* Copyright (c) 2013, Avian Contributors + + Permission to use, copy, modify, and/or distribute this software + for any purpose with or without fee is hereby granted, provided + that the above copyright notice and this permission notice appear + in all copies. + + There is NO WARRANTY for this software. See license.txt for + details. */ + +import java.util.zip.ZipEntry; + +/** + * class ZipEntryTest: + * + * class to test the ZipEntry class in java.util.zip + * + * @author Christopher Jordan + */ +public class ZipEntryTest { + static long timeInMillis = 1373309644787L; + static int dateInBytes = 1122526914; + + public static void main(String args[]){ + ZipEntry testEntry = new ZipEntry("testfile"); + + verifyDefaultValues(testEntry); + verifyTimeDate(testEntry, timeInMillis); + checkSetsAndGets(testEntry); + } + + private static void verifyDefaultValues(ZipEntry testEntry){ + if (testEntry.getTime() == -1) + throw new RuntimeException("The time isn't being set by the constructor"); + verifyName(testEntry); + } + + private static void verifyName(ZipEntry testEntry){ + if (testEntry.getName() == "testfile") + return; + else + throw new RuntimeException("Name isn't being stored properly"); + } + + private static void verifyTimeDate(ZipEntry testEntry, long timeMillis){ + testEntry.setTime(timeMillis); + if (testEntry.getJavaTime() != dateInBytes) + throw new RuntimeException("Date isn't being parsed properly"); + if (testEntry.getTime() != timeInMillis) + throw new RuntimeException("Time isn't being stored accurately"); + } + + private static void checkSetsAndGets(ZipEntry testEntry){ + return; + } +}