01: package com.kirkk.analyzer.framework.bcelbundle.test;
02:
03: import com.kirkk.analyzer.framework.jar.*;
04: import junit.framework.*;
05: import com.kirkk.analyzer.framework.bcel.*;
06: import com.kirkk.analyzer.framework.*;
07: import com.kirkk.analyzer.framework.bcelbundle.*;
08: import java.util.*;
09: import java.io.*;
10:
11: public class TestJarBuilderImpl extends TestCase {
12:
13: public void testBuildJarBundle() throws Exception {
14: JarBuilder jarBuilder = new JarBuilderImpl();
15: String file = "testdata/acyclictestproject/dist/Test1.jar";
16: Jar jar = jarBuilder.buildJar(new JarFile(new File(file)),
17: new ArrayList());
18: assertTrue(jar.getJarFileName().equals("Test1.jar"));
19: }
20:
21: public void testStructureValidity() throws Exception {
22: JarBuilder jarBuilder = new JarBuilderImpl();
23: String file = "testdata/acyclictestproject/dist/Test1.jar";
24: Jar jar = jarBuilder.buildJar(new JarFile(new File(file)),
25: new ArrayList());
26: //assertEquals(jar.getLevel(), 1);
27: assertEquals(jar.getPackageCount(), 2);
28: assertEquals(jar.getClassCount(), 5);
29: assertTrue(jar.containsPackage("com.kirkk.analyzer.jar1.test1"));
30:
31: /*jar.getAllContainedPackages();
32: jar.getAllExternallyReferencedPackages();
33:
34: jar.getDependentJars();
35: jar.getAllUnidentifiableExternallyReferencedPackages();
36:
37: jar.hasCycles();
38: jar.getCyclicJars();*/
39: }
40:
41: public void testIgnorePackages() throws Exception {
42: List ignorePackages = new ArrayList();
43: ignorePackages.add("java.util");
44: JarBuilder jarBuilder = new JarBuilderImpl();
45: String file = "testdata/acyclictestproject/dist/Test2.jar";
46: Jar jar = jarBuilder.buildJar(new JarFile(new File(file)),
47: ignorePackages);
48:
49: assertTrue("Should ignore java.util", !jar
50: .getAllExternallyReferencedPackages().contains(
51: "java.util"));
52: }
53:
54: public void testClassCount() throws Exception {
55: JarBuilder jarBuilder = new JarBuilderImpl();
56: String file = "testdata/acyclictestproject/dist/Test1.jar";
57: Jar jar = jarBuilder.buildJar(new JarFile(new File(file)),
58: new ArrayList());
59:
60: assertEquals("Class count should be 5", 5, jar.getClassCount());
61: }
62:
63: public void testAbstractClassCount() throws Exception {
64: JarBuilder jarBuilder = new JarBuilderImpl();
65: String file = "testdata/acyclictestproject/dist/Test1.jar";
66: Jar jar = jarBuilder.buildJar(new JarFile(new File(file)),
67: new ArrayList());
68:
69: assertEquals("Abstract class count should be 2", 2, jar
70: .getAbstractClassCount());
71: }
72: //public void testInvalidJarFile
73: //public void testEmptyJarFile
74:
75: }
|