KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > kirkk > analyzer > framework > bcelbundle > test > TestJarBuilderImpl


1 package com.kirkk.analyzer.framework.bcelbundle.test;
2
3 import com.kirkk.analyzer.framework.jar.*;
4 import junit.framework.*;
5 import com.kirkk.analyzer.framework.bcel.*;
6 import com.kirkk.analyzer.framework.*;
7 import com.kirkk.analyzer.framework.bcelbundle.*;
8 import java.util.*;
9 import java.io.*;
10
11 public class TestJarBuilderImpl extends TestCase {
12
13     public void testBuildJarBundle() throws Exception JavaDoc {
14         JarBuilder jarBuilder = new JarBuilderImpl();
15         String JavaDoc file = "testdata/acyclictestproject/dist/Test1.jar";
16         Jar jar = jarBuilder.buildJar(new JarFile(new File(file)), new ArrayList());
17         assertTrue(jar.getJarFileName().equals("Test1.jar"));
18     }
19
20     public void testStructureValidity() throws Exception JavaDoc {
21         JarBuilder jarBuilder = new JarBuilderImpl();
22         String JavaDoc file = "testdata/acyclictestproject/dist/Test1.jar";
23         Jar jar = jarBuilder.buildJar(new JarFile(new File(file)), new ArrayList());
24         //assertEquals(jar.getLevel(), 1);
25
assertEquals(jar.getPackageCount(), 2);
26         assertEquals(jar.getClassCount(), 5);
27         assertTrue(jar.containsPackage("com.kirkk.analyzer.jar1.test1"));
28
29         /*jar.getAllContainedPackages();
30         jar.getAllExternallyReferencedPackages();
31
32         jar.getDependentJars();
33         jar.getAllUnidentifiableExternallyReferencedPackages();
34
35         jar.hasCycles();
36         jar.getCyclicJars();*/

37     }
38
39     public void testIgnorePackages() throws Exception JavaDoc {
40         List ignorePackages = new ArrayList();
41         ignorePackages.add("java.util");
42         JarBuilder jarBuilder = new JarBuilderImpl();
43         String JavaDoc file = "testdata/acyclictestproject/dist/Test2.jar";
44         Jar jar = jarBuilder.buildJar(new JarFile(new File(file)), ignorePackages);
45
46         assertTrue("Should ignore java.util", !jar.getAllExternallyReferencedPackages().contains("java.util"));
47     }
48
49     public void testClassCount() throws Exception JavaDoc {
50         JarBuilder jarBuilder = new JarBuilderImpl();
51         String JavaDoc file = "testdata/acyclictestproject/dist/Test1.jar";
52         Jar jar = jarBuilder.buildJar(new JarFile(new File(file)), new ArrayList());
53
54         assertEquals("Class count should be 5", 5, jar.getClassCount());
55     }
56
57     public void testAbstractClassCount() throws Exception JavaDoc {
58         JarBuilder jarBuilder = new JarBuilderImpl();
59         String JavaDoc file = "testdata/acyclictestproject/dist/Test1.jar";
60         Jar jar = jarBuilder.buildJar(new JarFile(new File(file)), new ArrayList());
61
62         assertEquals("Abstract class count should be 2", 2, jar.getAbstractClassCount());
63     }
64     //public void testInvalidJarFile
65
//public void testEmptyJarFile
66

67 }
Popular Tags