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 { 14 JarBuilder jarBuilder = new JarBuilderImpl(); 15 String 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 { 21 JarBuilder jarBuilder = new JarBuilderImpl(); 22 String file = "testdata/acyclictestproject/dist/Test1.jar"; 23 Jar jar = jarBuilder.buildJar(new JarFile(new File(file)), new ArrayList()); 24 assertEquals(jar.getPackageCount(), 2); 26 assertEquals(jar.getClassCount(), 5); 27 assertTrue(jar.containsPackage("com.kirkk.analyzer.jar1.test1")); 28 29 37 } 38 39 public void testIgnorePackages() throws Exception { 40 List ignorePackages = new ArrayList(); 41 ignorePackages.add("java.util"); 42 JarBuilder jarBuilder = new JarBuilderImpl(); 43 String 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 { 50 JarBuilder jarBuilder = new JarBuilderImpl(); 51 String 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 { 58 JarBuilder jarBuilder = new JarBuilderImpl(); 59 String 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 67 } | Popular Tags |