jvanzyl 02/03/02 18:59:10
Modified: src/test/org/apache/maven/importscrubber
ClassParserWrapperTest.java
Log:
Start the little dep resolving tool as a test. We want to look into
a JAR file find all the class references, sort, collapse dupes and match
against a known list of package references. A package reference for
each project. I added them to the gump descriptors and I will update
the dvsl transformation so that I can process them.
Revision Changes Path
1.2 +41 -5
jakarta-turbine-maven/src/test/org/apache/maven/importscrubber/ClassParserWrapperTest.java
Index: ClassParserWrapperTest.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/test/org/apache/maven/importscrubber/ClassParserWrapperTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClassParserWrapperTest.java 2 Mar 2002 17:56:07 -0000 1.1
+++ ClassParserWrapperTest.java 3 Mar 2002 02:59:10 -0000 1.2
@@ -55,17 +55,25 @@
*/
import java.io.File;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
+import java.util.Map;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.maven.importscrubber.ClassParserWrapper;
+
+import org.apache.maven.util.JarUtil;
public class ClassParserWrapperTest
extends TestCase
{
- private static final String TEST_CLASS =
- "src/test-importscrubber/FunctionalTest.class";
+ private static final String TEST_JAR =
+ "src/test-importscrubber/test.jar";
public ClassParserWrapperTest(String name)
{
@@ -79,12 +87,40 @@
public void testDependencyResolving()
{
+ JarFile jarFile = null;
+ TreeMapListener treeMapListener = null;
+
try
- {
- ClassParserWrapper.parse(new File(TEST_CLASS), new PrintListener());
+ {
+ jarFile = new JarFile(new File(TEST_JAR));
+ treeMapListener = new TreeMapListener();
+ List classEntries = JarUtil.getClassEntries(jarFile);
+
+ for (Iterator i = classEntries.iterator(); i.hasNext();)
+ {
+ JarEntry jarEntry = (JarEntry) i.next();
+ InputStream classInputStream = jarFile.getInputStream(jarEntry);
+ ClassParserWrapper.parse(classInputStream, treeMapListener);
+ }
+
+ jarFile.close();
+
+ Map map = treeMapListener.getTreeMap();
+ for (Iterator i = map.keySet().iterator(); i.hasNext();)
+ {
+ String classReference = (String) i.next();
+
+ // Don't care about internal classes or classes
+ // that don't belong to a real package.
+ if (classReference.indexOf("$") < 0 && classReference.indexOf(".")
> 0)
+ {
+ System.out.println(map.get(classReference));
+ }
+ }
}
catch (Exception e)
{
+ e.printStackTrace();
fail();
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>