01: package com.kirkk.analyzer.framework.bcelbundle.test;
02:
03: import junit.framework.*;
04: import java.io.*;
05: import com.kirkk.analyzer.framework.bcelbundle.*;
06: import com.kirkk.analyzer.framework.*;
07: import com.kirkk.analyzer.framework.JarCollection;
08: import java.util.*;
09:
10: public class TestJarCollection extends TestCase {
11: public void testBuildJarCollection() throws Exception {
12: JarCollection jarCollection = new JarCollectionImpl(new File(
13: "testdata/acyclictestproject/dist"));
14: //List jars = jarCollection.getJars(new File("test/acyclictestproject/dist"), new ArrayList());
15: assertEquals(jarCollection.getJarCount(), 2);
16:
17: }
18:
19: public void testFindPackage() throws Exception {
20: JarCollection jarCollection = new JarCollectionImpl(new File(
21: "testdata/acyclictestproject/dist"));
22: Jar jar = jarCollection
23: .getJarContainingPackage("com.kirkk.analyzer.jar1.test1");
24: assertEquals(jar.getJarFileName(), "Test1.jar");
25: }
26:
27: /*public void testNoIgnoredJars() throws Exception {
28:
29: }
30:
31: public void testIgnoredPackages() throws Exception {
32:
33: }*/
34:
35: public void testIgnoredJars() throws Exception {
36: List ignoredJars = new ArrayList();
37: ignoredJars.add("Test2.jar");
38: JarCollection jarCollection = new JarCollectionImpl(new File(
39: "testdata/acyclictestproject/dist"), new ArrayList(),
40: ignoredJars);
41: //List jars = jarCollection.getJars(new File("test/acyclictestproject/dist"), new ArrayList());
42: assertEquals("Should ignore Jar2 - count should be 1", 1,
43: jarCollection.getJarCount());
44:
45: assertNull("Collection should not contain Test2.jar",
46: jarCollection.getJar("Test2.jar"));
47: }
48:
49: public void testToArray() throws Exception {
50: JarCollection jarCollection = new JarCollectionImpl(new File(
51: "testdata/acyclictestproject/dist"));
52: Jar[] jar = jarCollection.toArray();
53: assertEquals("Array size should be 2", 2, jar.length);
54:
55: assertTrue((jar[0].getJarFileName().equals("Test1.jar"))
56: || (jar[0].getJarFileName().equals("Test2.jar")));
57: }
58: }
|