01: package com.kirkk.analyzer.framework.jar.test;
02:
03: import com.kirkk.analyzer.framework.jar.*;
04: import junit.framework.*;
05: import java.io.*;
06:
07: public class TestJarFile extends TestCase {
08:
09: public TestJarFile(String name) {
10: super (name);
11: }
12:
13: public void testJarFile() throws Exception {
14: File f = new File("test/TestFile.zip");
15: JarFile jar = new JarFile(f);
16: assertTrue(jar.getFileName() != null);
17: assertTrue(jar.hasMoreClasses() == true);
18: assertTrue(jar.nextClass().equals("Test.class"));
19: jar.close();
20: }
21:
22: public void testIgnoreNonJavaFiles() throws Exception {
23: File f = new File("test/TestFile.zip");
24: JarFile jar = new JarFile(f);
25: int i = 0;
26: while (jar.hasMoreClasses()) {
27: i++;
28: }
29: assertTrue(i == 1);
30: jar.close();
31: }
32:
33: public void testShortFileName() throws Exception {
34: File f = new File("test/TestFile.zip");
35: JarFile jar = new JarFile(f);
36: assertTrue(jar.getShortFileName().equals("TestFile.zip"));
37: jar.close();
38: }
39: }
|