KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > kirkk > analyzer > framework > bcel > test > TestBCELClass


1 package com.kirkk.analyzer.framework.bcel.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.bcelbundle.*;
7 import java.util.*;
8
9 public class TestBCELClass extends TestCase {
10
11     public TestBCELClass (String JavaDoc name) {
12         super(name);
13     }
14
15     public void testGetClassParsing() throws Exception JavaDoc {
16         String JavaDoc file = "testdata/acyclictestproject/dist/Test2.jar";
17         String JavaDoc className = "com/kirkk/analyzer/jar2/test3/Test3.class";
18         BCELPublicClass javaClass = new BCELPublicClass(file, className);
19         assertTrue(javaClass.getLongName().equals("com.kirkk.analyzer.jar2.test3.Test3"));
20     }
21
22     public void testWithNoIgnoredPackages() throws Exception JavaDoc {
23         String JavaDoc file = "testdata/acyclictestproject/dist/Test2.jar";
24         String JavaDoc className = "com/kirkk/analyzer/jar2/test3/Test3.class";
25         BCELPublicClass javaClass = new BCELPublicClass(file, className);
26         List list = javaClass.getImportedPackageNames();
27         assertTrue("Should contain java.lang", list.contains("java.lang"));
28         assertTrue("Should contain com.kirkk.analyzer.jar1.test2", list.contains("com.kirkk.analyzer.jar1.test2"));
29
30     }
31
32     public void testWithIgnoredPackages() throws Exception JavaDoc {
33         List ignore = new ArrayList();
34         ignore.add("java.lang");
35
36         String JavaDoc file = "testdata/acyclictestproject/dist/Test2.jar";
37         String JavaDoc className = "com/kirkk/analyzer/jar2/test3/Test3.class";
38         BCELPublicClass javaClass = new BCELPublicClass(file, className, ignore);
39         List list = javaClass.getImportedPackageNames();
40         assertTrue("Should ignore java.lang", !list.contains("java.lang"));
41         assertTrue("Should contain com.kirkk.analyzer.jar1.test2", list.contains("com.kirkk.analyzer.jar1.test2"));
42     }
43
44     public void testClassWithInlineImports() throws Exception JavaDoc {
45         String JavaDoc file = "testdata/acyclictestproject/dist/Test2.jar";
46         String JavaDoc className = "com/kirkk/analyzer/jar2/test3/Test3.class";
47         BCELPublicClass javaClass = new BCELPublicClass(file, className);
48         List list = javaClass.getImportedPackageNames();
49         assertTrue("Should contain java.util", list.contains("java.util"));
50     }
51
52     //public void testClassWithNoImports
53

54
55
56 }
Popular Tags