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 name) { 12 super(name); 13 } 14 15 public void testGetClassParsing() throws Exception { 16 String file = "testdata/acyclictestproject/dist/Test2.jar"; 17 String 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 { 23 String file = "testdata/acyclictestproject/dist/Test2.jar"; 24 String 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 { 33 List ignore = new ArrayList(); 34 ignore.add("java.lang"); 35 36 String file = "testdata/acyclictestproject/dist/Test2.jar"; 37 String 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 { 45 String file = "testdata/acyclictestproject/dist/Test2.jar"; 46 String 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 54 55 56 } | Popular Tags |