1 package com.kirkk.analyzer.framework.jar.test; 2 3 import com.kirkk.analyzer.framework.jar.*; 4 import junit.framework.*; 5 import java.io.*; 6 7 public class TestJarFile extends TestCase { 8 9 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 } | Popular Tags |