KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > kirkk > analyzer > framework > bcelbundle > test > TestJarCollection


1 package com.kirkk.analyzer.framework.bcelbundle.test;
2
3 import junit.framework.*;
4 import java.io.*;
5 import com.kirkk.analyzer.framework.bcelbundle.*;
6 import com.kirkk.analyzer.framework.*;
7 import com.kirkk.analyzer.framework.JarCollection;
8 import java.util.*;
9
10 public class TestJarCollection extends TestCase {
11     public void testBuildJarCollection() throws Exception JavaDoc {
12         JarCollection jarCollection = new JarCollectionImpl(new File("testdata/acyclictestproject/dist"));
13         //List jars = jarCollection.getJars(new File("test/acyclictestproject/dist"), new ArrayList());
14
assertEquals(jarCollection.getJarCount(),2);
15
16     }
17
18     public void testFindPackage() throws Exception JavaDoc {
19         JarCollection jarCollection = new JarCollectionImpl(new File("testdata/acyclictestproject/dist"));
20         Jar jar = jarCollection.getJarContainingPackage("com.kirkk.analyzer.jar1.test1");
21         assertEquals(jar.getJarFileName(), "Test1.jar");
22     }
23
24
25     /*public void testNoIgnoredJars() throws Exception {
26
27     }
28
29     public void testIgnoredPackages() throws Exception {
30
31     }*/

32
33     public void testIgnoredJars() throws Exception JavaDoc {
34         List ignoredJars = new ArrayList();
35         ignoredJars.add("Test2.jar");
36         JarCollection jarCollection = new JarCollectionImpl(new File("testdata/acyclictestproject/dist"), new ArrayList(), ignoredJars);
37         //List jars = jarCollection.getJars(new File("test/acyclictestproject/dist"), new ArrayList());
38
assertEquals("Should ignore Jar2 - count should be 1", 1, jarCollection.getJarCount());
39
40         assertNull("Collection should not contain Test2.jar", jarCollection.getJar("Test2.jar"));
41     }
42
43     public void testToArray() throws Exception JavaDoc {
44         JarCollection jarCollection = new JarCollectionImpl(new File("testdata/acyclictestproject/dist"));
45         Jar[] jar = jarCollection.toArray();
46         assertEquals("Array size should be 2", 2, jar.length);
47
48         assertTrue( (jar[0].getJarFileName().equals("Test1.jar")) || (jar[0].getJarFileName().equals("Test2.jar")));
49     }
50 }
Popular Tags