maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe...@apache.org
Subject svn commit: r512020 - in /maven/sandbox/trunk/shared/maven-dependency-analyzer/src: main/java/org/apache/maven/shared/dependency/analyzer/asm/ test/java/org/apache/maven/shared/dependency/analyzer/ test/java/org/apache/maven/shared/dependency/analyzer/...
Date Mon, 26 Feb 2007 21:34:14 GMT
Author: joehni
Date: Mon Feb 26 13:34:13 2007
New Revision: 512020

URL: http://svn.apache.org/viewvc?view=rev&rev=512020
Log:
Fix DependencyVisitor. Improve test coverage (MNG-2850).

Added:
    maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/AbstractFileTest.java   (with props)
    maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultClassAnalyzerTest.java   (with props)
    maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalysisTest.java   (with props)
    maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzerExceptionTest.java   (with props)
    maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/
    maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitorTest.java   (with props)
    maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/MockAttribute.java   (with props)
Modified:
    maven/sandbox/trunk/shared/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitor.java
    maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ClassFileVisitorUtilsTest.java

Modified: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitor.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitor.java?view=diff&rev=512020&r1=512019&r2=512020
==============================================================================
--- maven/sandbox/trunk/shared/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitor.java (original)
+++ maven/sandbox/trunk/shared/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitor.java Mon Feb 26 13:34:13 2007
@@ -1,573 +1,585 @@
-package org.apache.maven.shared.dependency.analyzer.asm;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.Attribute;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Type;
-import org.objectweb.asm.signature.SignatureReader;
-import org.objectweb.asm.signature.SignatureVisitor;
-
-/**
- * Inspired by <code>org.objectweb.asm.depend.DependencyVisitor</code> in the ASM dependencies example.
- * 
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id$
- */
-public class DependencyVisitor
-    implements AnnotationVisitor, SignatureVisitor, ClassVisitor, FieldVisitor, MethodVisitor
-{
-    // fields -----------------------------------------------------------------
-
-    private final Set classes;
-
-    // constructors -----------------------------------------------------------
-
-    public DependencyVisitor()
-    {
-        classes = new HashSet();
-    }
-
-    // ClassVisitor methods ---------------------------------------------------
-
-    /*
-     * @see org.objectweb.asm.ClassVisitor#visit(int, int, java.lang.String, java.lang.String, java.lang.String,
-     *      java.lang.String[])
-     */
-    public void visit( final int version, final int access, final String name, final String signature,
-                       final String superName, final String[] interfaces )
-    {
-        if ( signature == null )
-        {
-            addName( superName );
-            addNames( interfaces );
-        }
-        else
-        {
-            addSignature( signature );
-        }
-    }
-
-    /*
-     * @see org.objectweb.asm.ClassVisitor#visitSource(java.lang.String, java.lang.String)
-     */
-    public void visitSource( final String source, final String debug )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.ClassVisitor#visitOuterClass(java.lang.String, java.lang.String, java.lang.String)
-     */
-    public void visitOuterClass( final String owner, final String name, final String desc )
-    {
-        // addName(owner);
-        // addMethodDesc(desc);
-    }
-
-    /*
-     * @see org.objectweb.asm.ClassVisitor#visitAnnotation(java.lang.String, boolean)
-     */
-    public AnnotationVisitor visitAnnotation( final String desc, final boolean visible )
-    {
-        addDesc( desc );
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.ClassVisitor#visitAttribute(org.objectweb.asm.Attribute)
-     */
-    public void visitAttribute( final Attribute attr )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.ClassVisitor#visitInnerClass(java.lang.String, java.lang.String, java.lang.String, int)
-     */
-    public void visitInnerClass( final String name, final String outerName, final String innerName, final int access )
-    {
-        // addName( outerName);
-        // addName( innerName);
-    }
-
-    /*
-     * @see org.objectweb.asm.ClassVisitor#visitField(int, java.lang.String, java.lang.String, java.lang.String,
-     *      java.lang.Object)
-     */
-    public FieldVisitor visitField( final int access, final String name, final String desc, final String signature,
-                                    final Object value )
-    {
-        if ( signature == null )
-            addDesc( desc );
-        else
-            addTypeSignature( signature );
-
-        if ( value instanceof Type )
-            addType( (Type) value );
-
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.ClassVisitor#visitMethod(int, java.lang.String, java.lang.String, java.lang.String,
-     *      java.lang.String[])
-     */
-    public MethodVisitor visitMethod( final int access, final String name, final String desc, final String signature,
-                                      final String[] exceptions )
-    {
-        if ( signature == null )
-            addMethodDesc( desc );
-        else
-            addSignature( signature );
-
-        addNames( exceptions );
-
-        return this;
-    }
-
-    // MethodVisitor methods --------------------------------------------------
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitAnnotationDefault()
-     */
-    public AnnotationVisitor visitAnnotationDefault()
-    {
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitParameterAnnotation(int, java.lang.String, boolean)
-     */
-    public AnnotationVisitor visitParameterAnnotation( final int parameter, final String desc, final boolean visible )
-    {
-        addDesc( desc );
-
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitCode()
-     */
-    public void visitCode()
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitFrame(int, int, java.lang.Object[], int, java.lang.Object[])
-     */
-    public void visitFrame( final int type, final int nLocal, final Object[] local, final int nStack,
-                            final Object[] stack )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitInsn(int)
-     */
-    public void visitInsn( final int opcode )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitIntInsn(int, int)
-     */
-    public void visitIntInsn( final int opcode, final int operand )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitVarInsn(int, int)
-     */
-    public void visitVarInsn( final int opcode, final int var )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitTypeInsn(int, java.lang.String)
-     */
-    public void visitTypeInsn( final int opcode, final String desc )
-    {
-        if ( desc.charAt( 0 ) == '[' )
-            addDesc( desc );
-        else
-            addName( desc );
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitFieldInsn(int, java.lang.String, java.lang.String, java.lang.String)
-     */
-    public void visitFieldInsn( final int opcode, final String owner, final String name, final String desc )
-    {
-        addName( owner );
-        addDesc( desc );
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitMethodInsn(int, java.lang.String, java.lang.String, java.lang.String)
-     */
-    public void visitMethodInsn( final int opcode, final String owner, final String name, final String desc )
-    {
-        addName( owner );
-        addMethodDesc( desc );
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitJumpInsn(int, org.objectweb.asm.Label)
-     */
-    public void visitJumpInsn( final int opcode, final Label label )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitLabel(org.objectweb.asm.Label)
-     */
-    public void visitLabel( final Label label )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitLdcInsn(java.lang.Object)
-     */
-    public void visitLdcInsn( final Object cst )
-    {
-        if ( cst instanceof Type )
-            addType( (Type) cst );
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitIincInsn(int, int)
-     */
-    public void visitIincInsn( final int var, final int increment )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitTableSwitchInsn(int, int, org.objectweb.asm.Label,
-     *      org.objectweb.asm.Label[])
-     */
-    public void visitTableSwitchInsn( final int min, final int max, final Label dflt, final Label[] labels )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitLookupSwitchInsn(org.objectweb.asm.Label, int[],
-     *      org.objectweb.asm.Label[])
-     */
-    public void visitLookupSwitchInsn( final Label dflt, final int[] keys, final Label[] labels )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitMultiANewArrayInsn(java.lang.String, int)
-     */
-    public void visitMultiANewArrayInsn( final String desc, final int dims )
-    {
-        addDesc( desc );
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitTryCatchBlock(org.objectweb.asm.Label, org.objectweb.asm.Label,
-     *      org.objectweb.asm.Label, java.lang.String)
-     */
-    public void visitTryCatchBlock( final Label start, final Label end, final Label handler, final String type )
-    {
-        addName( type );
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitLocalVariable(java.lang.String, java.lang.String, java.lang.String,
-     *      org.objectweb.asm.Label, org.objectweb.asm.Label, int)
-     */
-    public void visitLocalVariable( final String name, final String desc, final String signature, final Label start,
-                                    final Label end, final int index )
-    {
-        addTypeSignature( signature );
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitLineNumber(int, org.objectweb.asm.Label)
-     */
-    public void visitLineNumber( final int line, final Label start )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.MethodVisitor#visitMaxs(int, int)
-     */
-    public void visitMaxs( final int maxStack, final int maxLocals )
-    {
-        // no-op
-    }
-
-    // AnnotationVisitor methods ----------------------------------------------
-
-    /*
-     * @see org.objectweb.asm.AnnotationVisitor#visit(java.lang.String, java.lang.Object)
-     */
-    public void visit( final String name, final Object value )
-    {
-        if ( value instanceof Type )
-            addType( (Type) value );
-    }
-
-    /*
-     * @see org.objectweb.asm.AnnotationVisitor#visitEnum(java.lang.String, java.lang.String, java.lang.String)
-     */
-    public void visitEnum( final String name, final String desc, final String value )
-    {
-        addDesc( desc );
-    }
-
-    /*
-     * @see org.objectweb.asm.AnnotationVisitor#visitAnnotation(java.lang.String, java.lang.String)
-     */
-    public AnnotationVisitor visitAnnotation( final String name, final String desc )
-    {
-        addDesc( desc );
-
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.AnnotationVisitor#visitArray(java.lang.String)
-     */
-    public AnnotationVisitor visitArray( final String name )
-    {
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.AnnotationVisitor#visitEnd()
-     */
-    public void visitEnd()
-    {
-        // no-op
-    }
-
-    // SignatureVisitor methods -----------------------------------------------
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitFormalTypeParameter(java.lang.String)
-     */
-    public void visitFormalTypeParameter( final String name )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitClassBound()
-     */
-    public SignatureVisitor visitClassBound()
-    {
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitInterfaceBound()
-     */
-    public SignatureVisitor visitInterfaceBound()
-    {
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitSuperclass()
-     */
-    public SignatureVisitor visitSuperclass()
-    {
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitInterface()
-     */
-    public SignatureVisitor visitInterface()
-    {
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitParameterType()
-     */
-    public SignatureVisitor visitParameterType()
-    {
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitReturnType()
-     */
-    public SignatureVisitor visitReturnType()
-    {
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitExceptionType()
-     */
-    public SignatureVisitor visitExceptionType()
-    {
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitBaseType(char)
-     */
-    public void visitBaseType( final char descriptor )
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitTypeVariable(java.lang.String)
-     */
-    public void visitTypeVariable( final String name )
-    {
-        // TODO: verify
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitArrayType()
-     */
-    public SignatureVisitor visitArrayType()
-    {
-        return this;
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitClassType(java.lang.String)
-     */
-    public void visitClassType( final String name )
-    {
-        addName( name );
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitInnerClassType(java.lang.String)
-     */
-    public void visitInnerClassType( final String name )
-    {
-        addName( name );
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitTypeArgument()
-     */
-    public void visitTypeArgument()
-    {
-        // no-op
-    }
-
-    /*
-     * @see org.objectweb.asm.signature.SignatureVisitor#visitTypeArgument(char)
-     */
-    public SignatureVisitor visitTypeArgument( final char wildcard )
-    {
-        return this;
-    }
-
-    // public methods ---------------------------------------------------------
-
-    public Set getClasses()
-    {
-        return classes;
-    }
-
-    // private methods --------------------------------------------------------
-
-    private void addName( String name )
-    {
-        if ( name == null )
-            return;
-
-        // decode arrays
-        if ( name.startsWith( "[L" ) && name.endsWith( ";" ) )
-            name = name.substring( 2, name.length() - 1 );
-
-        // decode internal representation
-        name = name.replace( '/', '.' );
-
-        classes.add( name );
-    }
-
-    private void addNames( final String[] names )
-    {
-        for ( int i = 0; names != null && i < names.length; i++ )
-            addName( names[i] );
-    }
-
-    private void addDesc( final String desc )
-    {
-        addType( Type.getType( desc ) );
-    }
-
-    private void addMethodDesc( final String desc )
-    {
-        addType( Type.getReturnType( desc ) );
-        Type[] types = Type.getArgumentTypes( desc );
-
-        for ( int i = 0; i < types.length; i++ )
-            addType( types[i] );
-    }
-
-    private void addType( final Type t )
-    {
-        switch ( t.getSort() )
-        {
-            case Type.ARRAY:
-                addType( t.getElementType() );
-                break;
-
-            case Type.OBJECT:
-                addName( t.getClassName().replace( '.', '/' ) );
-                break;
-        }
-    }
-
-    private void addSignature( final String signature )
-    {
-        if ( signature != null )
-            new SignatureReader( signature ).accept( this );
-    }
-
-    private void addTypeSignature( final String signature )
-    {
-        if ( signature != null )
-            new SignatureReader( signature ).acceptType( this );
-    }
-}
+package org.apache.maven.shared.dependency.analyzer.asm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.signature.SignatureReader;
+import org.objectweb.asm.signature.SignatureVisitor;
+
+/**
+ * Inspired by <code>org.objectweb.asm.depend.DependencyVisitor</code> in the ASM dependencies example.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ */
+public class DependencyVisitor
+    implements AnnotationVisitor, SignatureVisitor, ClassVisitor, FieldVisitor, MethodVisitor
+{
+    // fields -----------------------------------------------------------------
+
+    private final Set classes;
+
+    // constructors -----------------------------------------------------------
+
+    public DependencyVisitor()
+    {
+        classes = new HashSet();
+    }
+
+    // ClassVisitor methods ---------------------------------------------------
+
+    /*
+     * @see org.objectweb.asm.ClassVisitor#visit(int, int, java.lang.String, java.lang.String, java.lang.String,
+     *      java.lang.String[])
+     */
+    public void visit( final int version, final int access, final String name, final String signature,
+                       final String superName, final String[] interfaces )
+    {
+        if ( signature == null )
+        {
+            addName( superName );
+            addNames( interfaces );
+        }
+        else
+        {
+            addSignature( signature );
+        }
+    }
+
+    /*
+     * @see org.objectweb.asm.ClassVisitor#visitSource(java.lang.String, java.lang.String)
+     */
+    public void visitSource( final String source, final String debug )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.ClassVisitor#visitOuterClass(java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void visitOuterClass( final String owner, final String name, final String desc )
+    {
+        // addName(owner);
+        // addMethodDesc(desc);
+    }
+
+    /*
+     * @see org.objectweb.asm.ClassVisitor#visitAnnotation(java.lang.String, boolean)
+     */
+    public AnnotationVisitor visitAnnotation( final String desc, final boolean visible )
+    {
+        addDesc( desc );
+        
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.ClassVisitor#visitAttribute(org.objectweb.asm.Attribute)
+     */
+    public void visitAttribute( final Attribute attr )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.ClassVisitor#visitInnerClass(java.lang.String, java.lang.String, java.lang.String, int)
+     */
+    public void visitInnerClass( final String name, final String outerName, final String innerName, final int access )
+    {
+        // addName( outerName);
+        // addName( innerName);
+    }
+
+    /*
+     * @see org.objectweb.asm.ClassVisitor#visitField(int, java.lang.String, java.lang.String, java.lang.String,
+     *      java.lang.Object)
+     */
+    public FieldVisitor visitField( final int access, final String name, final String desc, final String signature,
+                                    final Object value )
+    {
+        if ( signature == null )
+            addDesc( desc );
+        else
+            addTypeSignature( signature );
+
+        if ( value instanceof Type )
+            addType( (Type) value );
+
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.ClassVisitor#visitMethod(int, java.lang.String, java.lang.String, java.lang.String,
+     *      java.lang.String[])
+     */
+    public MethodVisitor visitMethod( final int access, final String name, final String desc, final String signature,
+                                      final String[] exceptions )
+    {
+        if ( signature == null )
+            addMethodDesc( desc );
+        else
+            addSignature( signature );
+
+        addNames( exceptions );
+
+        return this;
+    }
+
+    // MethodVisitor methods --------------------------------------------------
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitAnnotationDefault()
+     */
+    public AnnotationVisitor visitAnnotationDefault()
+    {
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitParameterAnnotation(int, java.lang.String, boolean)
+     */
+    public AnnotationVisitor visitParameterAnnotation( final int parameter, final String desc, final boolean visible )
+    {
+        addDesc( desc );
+
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitCode()
+     */
+    public void visitCode()
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitFrame(int, int, java.lang.Object[], int, java.lang.Object[])
+     */
+    public void visitFrame( final int type, final int nLocal, final Object[] local, final int nStack,
+                            final Object[] stack )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitInsn(int)
+     */
+    public void visitInsn( final int opcode )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitIntInsn(int, int)
+     */
+    public void visitIntInsn( final int opcode, final int operand )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitVarInsn(int, int)
+     */
+    public void visitVarInsn( final int opcode, final int var )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitTypeInsn(int, java.lang.String)
+     */
+    public void visitTypeInsn( final int opcode, final String desc )
+    {
+        if ( desc.charAt( 0 ) == '[' )
+            addDesc( desc );
+        else
+            addName( desc );
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitFieldInsn(int, java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void visitFieldInsn( final int opcode, final String owner, final String name, final String desc )
+    {
+        addName( owner );
+        addDesc( desc );
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitMethodInsn(int, java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void visitMethodInsn( final int opcode, final String owner, final String name, final String desc )
+    {
+        addName( owner );
+        addMethodDesc( desc );
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitJumpInsn(int, org.objectweb.asm.Label)
+     */
+    public void visitJumpInsn( final int opcode, final Label label )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitLabel(org.objectweb.asm.Label)
+     */
+    public void visitLabel( final Label label )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitLdcInsn(java.lang.Object)
+     */
+    public void visitLdcInsn( final Object cst )
+    {
+        if ( cst instanceof Type )
+            addType( (Type) cst );
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitIincInsn(int, int)
+     */
+    public void visitIincInsn( final int var, final int increment )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitTableSwitchInsn(int, int, org.objectweb.asm.Label,
+     *      org.objectweb.asm.Label[])
+     */
+    public void visitTableSwitchInsn( final int min, final int max, final Label dflt, final Label[] labels )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitLookupSwitchInsn(org.objectweb.asm.Label, int[],
+     *      org.objectweb.asm.Label[])
+     */
+    public void visitLookupSwitchInsn( final Label dflt, final int[] keys, final Label[] labels )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitMultiANewArrayInsn(java.lang.String, int)
+     */
+    public void visitMultiANewArrayInsn( final String desc, final int dims )
+    {
+        addDesc( desc );
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitTryCatchBlock(org.objectweb.asm.Label, org.objectweb.asm.Label,
+     *      org.objectweb.asm.Label, java.lang.String)
+     */
+    public void visitTryCatchBlock( final Label start, final Label end, final Label handler, final String type )
+    {
+        addName( type );
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitLocalVariable(java.lang.String, java.lang.String, java.lang.String,
+     *      org.objectweb.asm.Label, org.objectweb.asm.Label, int)
+     */
+    public void visitLocalVariable( final String name, final String desc, final String signature, final Label start,
+                                    final Label end, final int index )
+    {
+        if ( signature == null )
+        {
+            addDesc( desc );
+        }
+        else
+        {
+            addTypeSignature( signature );
+        }
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitLineNumber(int, org.objectweb.asm.Label)
+     */
+    public void visitLineNumber( final int line, final Label start )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.MethodVisitor#visitMaxs(int, int)
+     */
+    public void visitMaxs( final int maxStack, final int maxLocals )
+    {
+        // no-op
+    }
+
+    // AnnotationVisitor methods ----------------------------------------------
+
+    /*
+     * @see org.objectweb.asm.AnnotationVisitor#visit(java.lang.String, java.lang.Object)
+     */
+    public void visit( final String name, final Object value )
+    {
+        if ( value instanceof Type )
+            addType( (Type) value );
+    }
+
+    /*
+     * @see org.objectweb.asm.AnnotationVisitor#visitEnum(java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void visitEnum( final String name, final String desc, final String value )
+    {
+        addDesc( desc );
+    }
+
+    /*
+     * @see org.objectweb.asm.AnnotationVisitor#visitAnnotation(java.lang.String, java.lang.String)
+     */
+    public AnnotationVisitor visitAnnotation( final String name, final String desc )
+    {
+        addDesc( desc );
+
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.AnnotationVisitor#visitArray(java.lang.String)
+     */
+    public AnnotationVisitor visitArray( final String name )
+    {
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.AnnotationVisitor#visitEnd()
+     */
+    public void visitEnd()
+    {
+        // no-op
+    }
+
+    // SignatureVisitor methods -----------------------------------------------
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitFormalTypeParameter(java.lang.String)
+     */
+    public void visitFormalTypeParameter( final String name )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitClassBound()
+     */
+    public SignatureVisitor visitClassBound()
+    {
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitInterfaceBound()
+     */
+    public SignatureVisitor visitInterfaceBound()
+    {
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitSuperclass()
+     */
+    public SignatureVisitor visitSuperclass()
+    {
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitInterface()
+     */
+    public SignatureVisitor visitInterface()
+    {
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitParameterType()
+     */
+    public SignatureVisitor visitParameterType()
+    {
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitReturnType()
+     */
+    public SignatureVisitor visitReturnType()
+    {
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitExceptionType()
+     */
+    public SignatureVisitor visitExceptionType()
+    {
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitBaseType(char)
+     */
+    public void visitBaseType( final char descriptor )
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitTypeVariable(java.lang.String)
+     */
+    public void visitTypeVariable( final String name )
+    {
+        // TODO: verify
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitArrayType()
+     */
+    public SignatureVisitor visitArrayType()
+    {
+        return this;
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitClassType(java.lang.String)
+     */
+    public void visitClassType( final String name )
+    {
+        addName( name );
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitInnerClassType(java.lang.String)
+     */
+    public void visitInnerClassType( final String name )
+    {
+        addName( name );
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitTypeArgument()
+     */
+    public void visitTypeArgument()
+    {
+        // no-op
+    }
+
+    /*
+     * @see org.objectweb.asm.signature.SignatureVisitor#visitTypeArgument(char)
+     */
+    public SignatureVisitor visitTypeArgument( final char wildcard )
+    {
+        return this;
+    }
+
+    // public methods ---------------------------------------------------------
+
+    public Set getClasses()
+    {
+        return classes;
+    }
+
+    // private methods --------------------------------------------------------
+
+    private void addName( String name )
+    {
+        if ( name == null )
+            return;
+
+        // decode arrays
+        if ( name.startsWith( "[L" ) && name.endsWith( ";" ) )
+            name = name.substring( 2, name.length() - 1 );
+
+        // decode internal representation
+        name = name.replace( '/', '.' );
+
+        classes.add( name );
+    }
+
+    private void addNames( final String[] names )
+    {
+        if ( names == null )
+            return;
+        
+        for ( int i = 0; i < names.length; i++ )
+            addName( names[i] );
+    }
+
+    private void addDesc( final String desc )
+    {
+        addType( Type.getType( desc ) );
+    }
+
+    private void addMethodDesc( final String desc )
+    {
+        addType( Type.getReturnType( desc ) );
+        
+        Type[] types = Type.getArgumentTypes( desc );
+
+        for ( int i = 0; i < types.length; i++ )
+            addType( types[i] );
+    }
+
+    private void addType( final Type t )
+    {
+        switch ( t.getSort() )
+        {
+            case Type.ARRAY:
+                addType( t.getElementType() );
+                break;
+
+            case Type.OBJECT:
+                addName( t.getClassName().replace( '.', '/' ) );
+                break;
+        }
+    }
+
+    private void addSignature( final String signature )
+    {
+        if ( signature != null )
+            new SignatureReader( signature ).accept( this );
+    }
+
+    private void addTypeSignature( final String signature )
+    {
+        if ( signature != null )
+            new SignatureReader( signature ).acceptType( this );
+    }
+}

Added: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/AbstractFileTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/AbstractFileTest.java?view=auto&rev=512020
==============================================================================
--- maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/AbstractFileTest.java (added)
+++ maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/AbstractFileTest.java Mon Feb 26 13:34:13 2007
@@ -0,0 +1,90 @@
+package org.apache.maven.shared.dependency.analyzer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipEntry;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.jmock.MockObjectTestCase;
+
+/**
+ * 
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ */
+public abstract class AbstractFileTest extends MockObjectTestCase
+{
+    // protected methods ------------------------------------------------------
+
+    protected File createJar() throws IOException
+    {
+        File file = File.createTempFile( "test", ".jar" );
+        file.deleteOnExit();
+
+        return file;
+    }
+
+    protected File createDir() throws IOException
+    {
+        File file = File.createTempFile( "test", null );
+        file.delete();
+
+        if ( !file.mkdir() )
+            throw new IOException( "Cannot create temporary directory: " + file );
+
+        return file;
+    }
+
+    protected File createFile( File parent, String child, String data ) throws IOException
+    {
+        File file = new File( parent, child );
+
+        OutputStream out = new FileOutputStream( file );
+        IOUtil.copy( data, out );
+        out.close();
+
+        return file;
+    }
+
+    protected File mkdirs( File parent, String child ) throws IOException
+    {
+        File dir = new File( parent, child );
+
+        FileUtils.forceMkdir( dir );
+
+        return dir;
+    }
+
+    protected void writeEntry( JarOutputStream out, String path, String data ) throws IOException
+    {
+        out.putNextEntry( new ZipEntry( path ) );
+
+        byte[] bytes = data.getBytes( "UTF-8" );
+
+        out.write( bytes, 0, bytes.length );
+    }
+}

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/AbstractFileTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/AbstractFileTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id HeadURL Revision

Modified: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ClassFileVisitorUtilsTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ClassFileVisitorUtilsTest.java?view=diff&rev=512020&r1=512019&r2=512020
==============================================================================
--- maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ClassFileVisitorUtilsTest.java (original)
+++ maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ClassFileVisitorUtilsTest.java Mon Feb 26 13:34:13 2007
@@ -1,222 +1,163 @@
-package org.apache.maven.shared.dependency.analyzer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.jar.JarOutputStream;
-import java.util.zip.ZipEntry;
-
-import org.apache.maven.shared.dependency.analyzer.ClassFileVisitor;
-import org.apache.maven.shared.dependency.analyzer.ClassFileVisitorUtils;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
-import org.jmock.Mock;
-import org.jmock.MockObjectTestCase;
-
-/**
- * Tests <code>ClassFileVisitorUtils</code>.
- * 
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id$
- * @see ClassFileVisitorUtils
- */
-public class ClassFileVisitorUtilsTest
-    extends MockObjectTestCase
-{
-    // tests ------------------------------------------------------------------
-
-    public void testAcceptJar()
-        throws IOException
-    {
-        File file = createJar();
-        JarOutputStream out = new JarOutputStream( new FileOutputStream( file ) );
-        writeEntry( out, "a/b/c.class", "class a.b.c" );
-        writeEntry( out, "x/y/z.class", "class x.y.z" );
-        out.close();
-
-        Mock mock = mock( ClassFileVisitor.class );
-        expectVisitClass( mock, "a.b.c", "class a.b.c" );
-        expectVisitClass( mock, "x.y.z", "class x.y.z" );
-
-        ClassFileVisitorUtils.accept( file.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
-
-        mock.verify();
-    }
-
-    public void testAcceptJarWithNonClassEntry()
-        throws IOException
-    {
-        File file = createJar();
-        JarOutputStream out = new JarOutputStream( new FileOutputStream( file ) );
-        writeEntry( out, "a/b/c.jpg", "jpeg a.b.c" );
-        out.close();
-
-        Mock mock = mock( ClassFileVisitor.class );
-
-        ClassFileVisitorUtils.accept( file.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
-
-        mock.verify();
-    }
-
-    public void testAcceptDir()
-        throws IOException
-    {
-        File dir = createDir();
-
-        File abDir = mkdirs( dir, "a/b" );
-        createFile( abDir, "c.class", "class a.b.c" );
-
-        File xyDir = mkdirs( dir, "x/y" );
-        createFile( xyDir, "z.class", "class x.y.z" );
-
-        Mock mock = mock( ClassFileVisitor.class );
-        expectVisitClass( mock, "a.b.c", "class a.b.c" );
-        expectVisitClass( mock, "x.y.z", "class x.y.z" );
-
-        ClassFileVisitorUtils.accept( dir.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
-
-        FileUtils.deleteDirectory( dir );
-
-        mock.verify();
-    }
-
-    public void testAcceptDirWithNonClassFile()
-        throws IOException
-    {
-        File dir = createDir();
-
-        File abDir = mkdirs( dir, "a/b" );
-        createFile( abDir, "c.jpg", "jpeg a.b.c" );
-
-        Mock mock = mock( ClassFileVisitor.class );
-
-        ClassFileVisitorUtils.accept( dir.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
-
-        FileUtils.deleteDirectory( dir );
-
-        mock.verify();
-    }
-
-    public void testAcceptWithFile()
-        throws IOException
-    {
-        File file = File.createTempFile( "test", ".class" );
-        file.deleteOnExit();
-
-        Mock mock = mock( ClassFileVisitor.class );
-
-        URL url = file.toURI().toURL();
-
-        try
-        {
-            ClassFileVisitorUtils.accept( url, (ClassFileVisitor) mock.proxy() );
-        }
-        catch ( IllegalArgumentException exception )
-        {
-            assertEquals( "Cannot accept visitor on URL: " + url, exception.getMessage() );
-        }
-    }
-
-    public void testAcceptWithUnsupportedScheme()
-        throws IOException
-    {
-        Mock mock = mock( ClassFileVisitor.class );
-
-        URL url = new URL( "http://localhost/" );
-
-        try
-        {
-            ClassFileVisitorUtils.accept( url, (ClassFileVisitor) mock.proxy() );
-        }
-        catch ( IllegalArgumentException exception )
-        {
-            assertEquals( "Cannot accept visitor on URL: " + url, exception.getMessage() );
-        }
-    }
-
-    // private methods --------------------------------------------------------
-
-    private File createJar()
-        throws IOException
-    {
-        File file = File.createTempFile( "test", ".jar" );
-        file.deleteOnExit();
-
-        return file;
-    }
-
-    private File createDir()
-        throws IOException
-    {
-        File file = File.createTempFile( "test", null );
-        file.delete();
-
-        if ( !file.mkdir() )
-            throw new IOException( "Cannot create temporary directory: " + file );
-
-        return file;
-    }
-
-    private File createFile( File parent, String child, String data )
-        throws IOException
-    {
-        File file = new File( parent, child );
-
-        OutputStream out = new FileOutputStream( file );
-        IOUtil.copy( data, out );
-        out.close();
-
-        return file;
-    }
-
-    private File mkdirs( File parent, String child )
-        throws IOException
-    {
-        File dir = new File( parent, child );
-
-        FileUtils.forceMkdir( dir );
-
-        return dir;
-    }
-
-    private void writeEntry( JarOutputStream out, String path, String data )
-        throws IOException
-    {
-        out.putNextEntry( new ZipEntry( path ) );
-
-        byte[] bytes = data.getBytes( "UTF-8" );
-
-        out.write( bytes, 0, bytes.length );
-    }
-
-    private void expectVisitClass( Mock mock, String className, String data )
-    {
-        mock.expects( atLeastOnce() ).method( "visitClass" ).with( eq( className ), in( data ) );
-    }
-
-    private InputStreamConstraint in( String expected )
-    {
-        return new InputStreamConstraint( expected );
-    }
-}
+package org.apache.maven.shared.dependency.analyzer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.jar.JarOutputStream;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.jmock.Mock;
+
+/**
+ * Tests <code>ClassFileVisitorUtils</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see ClassFileVisitorUtils
+ */
+public class ClassFileVisitorUtilsTest
+    extends AbstractFileTest
+{
+    // tests ------------------------------------------------------------------
+
+    public void testAcceptJar()
+        throws IOException
+    {
+        File file = createJar();
+        JarOutputStream out = new JarOutputStream( new FileOutputStream( file ) );
+        writeEntry( out, "a/b/c.class", "class a.b.c" );
+        writeEntry( out, "x/y/z.class", "class x.y.z" );
+        out.close();
+
+        Mock mock = mock( ClassFileVisitor.class );
+        expectVisitClass( mock, "a.b.c", "class a.b.c" );
+        expectVisitClass( mock, "x.y.z", "class x.y.z" );
+
+        ClassFileVisitorUtils.accept( file.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
+
+        mock.verify();
+    }
+
+    public void testAcceptJarWithNonClassEntry()
+        throws IOException
+    {
+        File file = createJar();
+        JarOutputStream out = new JarOutputStream( new FileOutputStream( file ) );
+        writeEntry( out, "a/b/c.jpg", "jpeg a.b.c" );
+        out.close();
+
+        Mock mock = mock( ClassFileVisitor.class );
+
+        ClassFileVisitorUtils.accept( file.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
+
+        mock.verify();
+    }
+
+    public void testAcceptDir()
+        throws IOException
+    {
+        File dir = createDir();
+
+        File abDir = mkdirs( dir, "a/b" );
+        createFile( abDir, "c.class", "class a.b.c" );
+
+        File xyDir = mkdirs( dir, "x/y" );
+        createFile( xyDir, "z.class", "class x.y.z" );
+
+        Mock mock = mock( ClassFileVisitor.class );
+        expectVisitClass( mock, "a.b.c", "class a.b.c" );
+        expectVisitClass( mock, "x.y.z", "class x.y.z" );
+
+        ClassFileVisitorUtils.accept( dir.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
+
+        FileUtils.deleteDirectory( dir );
+
+        mock.verify();
+    }
+
+    public void testAcceptDirWithNonClassFile()
+        throws IOException
+    {
+        File dir = createDir();
+
+        File abDir = mkdirs( dir, "a/b" );
+        createFile( abDir, "c.jpg", "jpeg a.b.c" );
+
+        Mock mock = mock( ClassFileVisitor.class );
+
+        ClassFileVisitorUtils.accept( dir.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
+
+        FileUtils.deleteDirectory( dir );
+
+        mock.verify();
+    }
+
+    public void testAcceptWithFile()
+        throws IOException
+    {
+        File file = File.createTempFile( "test", ".class" );
+        file.deleteOnExit();
+
+        Mock mock = mock( ClassFileVisitor.class );
+
+        URL url = file.toURI().toURL();
+
+        try
+        {
+            ClassFileVisitorUtils.accept( url, (ClassFileVisitor) mock.proxy() );
+        }
+        catch ( IllegalArgumentException exception )
+        {
+            assertEquals( "Cannot accept visitor on URL: " + url, exception.getMessage() );
+        }
+    }
+
+    public void testAcceptWithUnsupportedScheme()
+        throws IOException
+    {
+        Mock mock = mock( ClassFileVisitor.class );
+
+        URL url = new URL( "http://localhost/" );
+
+        try
+        {
+            ClassFileVisitorUtils.accept( url, (ClassFileVisitor) mock.proxy() );
+        }
+        catch ( IllegalArgumentException exception )
+        {
+            assertEquals( "Cannot accept visitor on URL: " + url, exception.getMessage() );
+        }
+    }
+
+    // private methods --------------------------------------------------------
+
+    private void expectVisitClass( Mock mock, String className, String data )
+    {
+        mock.expects( atLeastOnce() ).method( "visitClass" ).with( eq( className ), in( data ) );
+    }
+
+    private InputStreamConstraint in( String expected )
+    {
+        return new InputStreamConstraint( expected );
+    }
+}

Added: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultClassAnalyzerTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultClassAnalyzerTest.java?view=auto&rev=512020
==============================================================================
--- maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultClassAnalyzerTest.java (added)
+++ maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultClassAnalyzerTest.java Mon Feb 26 13:34:13 2007
@@ -0,0 +1,57 @@
+package org.apache.maven.shared.dependency.analyzer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.JarOutputStream;
+
+/**
+ * Tests <code>DefaultClassAnalyzer</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see DefaultClassAnalyzer
+ */
+public class DefaultClassAnalyzerTest extends AbstractFileTest
+{
+    // tests ------------------------------------------------------------------
+
+    public void testAnalyzeWithJar() throws IOException
+    {
+        File file = createJar();
+        JarOutputStream out = new JarOutputStream( new FileOutputStream( file ) );
+        writeEntry( out, "a/b/c.class", "class a.b.c" );
+        writeEntry( out, "x/y/z.class", "class x.y.z" );
+        out.close();
+
+        Set expectedClasses = new HashSet();
+        expectedClasses.add( "a.b.c" );
+        expectedClasses.add( "x.y.z" );
+
+        DefaultClassAnalyzer analyzer = new DefaultClassAnalyzer();
+        Set actualClasses = analyzer.analyze( file.toURI().toURL() );
+
+        assertEquals( expectedClasses, actualClasses );
+    }
+}

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultClassAnalyzerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultClassAnalyzerTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id HeadURL Revision

Added: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalysisTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalysisTest.java?view=auto&rev=512020
==============================================================================
--- maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalysisTest.java (added)
+++ maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalysisTest.java Mon Feb 26 13:34:13 2007
@@ -0,0 +1,51 @@
+package org.apache.maven.shared.dependency.analyzer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests <code>ProjectDependencyAnalysis</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see ProjectDependencyAnalysis
+ */
+public class ProjectDependencyAnalysisTest extends TestCase
+{
+    // tests ------------------------------------------------------------------
+
+    public void testConstructor()
+    {
+        Set usedDeclaredArtifacts = new HashSet();
+        Set usedUndeclaredArtifacts = new HashSet();
+        Set unusedDeclaredArtifacts = new HashSet();
+
+        ProjectDependencyAnalysis analysis =
+            new ProjectDependencyAnalysis( usedDeclaredArtifacts, usedUndeclaredArtifacts, unusedDeclaredArtifacts );
+
+        assertEquals( usedDeclaredArtifacts, analysis.getUsedDeclaredArtifacts() );
+        assertEquals( usedUndeclaredArtifacts, analysis.getUsedUndeclaredArtifacts() );
+        assertEquals( unusedDeclaredArtifacts, analysis.getUnusedDeclaredArtifacts() );
+    }
+}

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalysisTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalysisTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id HeadURL Revision

Added: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzerExceptionTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzerExceptionTest.java?view=auto&rev=512020
==============================================================================
--- maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzerExceptionTest.java (added)
+++ maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzerExceptionTest.java Mon Feb 26 13:34:13 2007
@@ -0,0 +1,50 @@
+package org.apache.maven.shared.dependency.analyzer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * Tests <code>ProjectDependencyAnalyzerException</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see ProjectDependencyAnalyzerException
+ */
+public class ProjectDependencyAnalyzerExceptionTest extends TestCase
+{
+    // tests ------------------------------------------------------------------
+
+    public void testConstructor()
+    {
+        ProjectDependencyAnalyzerException exception = new ProjectDependencyAnalyzerException( "a" );
+
+        assertEquals( "a", exception.getMessage() );
+    }
+
+    public void testConstructorWithThrowable()
+    {
+        Throwable throwable = new Exception();
+        ProjectDependencyAnalyzerException exception = new ProjectDependencyAnalyzerException( "a", throwable );
+
+        assertEquals( "a", exception.getMessage() );
+        assertEquals( throwable, exception.getCause() );
+    }
+}

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzerExceptionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzerExceptionTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id HeadURL Revision

Added: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitorTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitorTest.java?view=auto&rev=512020
==============================================================================
--- maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitorTest.java (added)
+++ maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitorTest.java Mon Feb 26 13:34:13 2007
@@ -0,0 +1,722 @@
+package org.apache.maven.shared.dependency.analyzer.asm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+/**
+ * Tests <code>DependencyVisitor</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see DependencyVisitor
+ */
+public class DependencyVisitorTest extends TestCase
+{
+    // TODO: finish tests
+
+    // fields -----------------------------------------------------------------
+
+    private DependencyVisitor visitor;
+
+    // TestCase methods -------------------------------------------------------
+
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        visitor = new DependencyVisitor();
+    }
+
+    // visit tests ------------------------------------------------------------
+
+    public void testVisitWithDefaultSuperclass()
+    {
+        // class a.b.c
+        visitor.visit( 50, 0, "a/b/c", null, "java/lang/Object", null );
+
+        assertClasses( "java.lang.Object" );
+    }
+
+    public void testVisitWithSuperclass()
+    {
+        // class a.b.c
+        visitor.visit( 50, 0, "a/b/c", null, "x/y/z", null );
+
+        assertClasses( "x.y.z" );
+    }
+
+    public void testVisitWithInterface()
+    {
+        // class a.b.c implements x.y.z
+        visitor.visit( 50, 0, "a/b/c", null, "java/lang/Object", new String[] { "x/y/z" } );
+
+        assertClasses( "java.lang.Object", "x.y.z" );
+    }
+
+    public void testVisitWithInterfaces()
+    {
+        // class a.b.c implements p.q.r, x.y.z
+        visitor.visit( 50, 0, "a/b/c", null, "java/lang/Object", new String[] { "p/q/r", "x/y/z" } );
+
+        assertClasses( "java.lang.Object", "p.q.r", "x.y.z" );
+    }
+
+    public void testVisitWithUnboundedClassTypeParameter()
+    {
+        // class a.b.c<T>
+        String signature = "<T:Ljava/lang/Object;>Ljava/lang/Object;";
+
+        visitor.visit( 50, 0, "a/b/c", signature, "java/lang/Object", null );
+
+        assertClasses( "java.lang.Object" );
+    }
+
+    public void testVisitWithBoundedClassTypeParameter()
+    {
+        // class a.b.c<T extends x.y.z>
+        String signature = "<T:Lx/y/z;>Ljava/lang/Object;";
+
+        visitor.visit( 50, 0, "a/b/c", signature, "java/lang/Object", null );
+
+        assertClasses( "java.lang.Object", "x.y.z" );
+    }
+
+    public void testVisitWithBoundedClassTypeParameters()
+    {
+        // class a.b.c<K extends p.q.r, V extends x.y.z>
+        String signature = "<K:Lp/q/r;V:Lx/y/z;>Ljava/lang/Object;";
+
+        visitor.visit( 50, 0, "a/b/c", signature, "java/lang/Object", null );
+
+        assertClasses( "java.lang.Object", "p.q.r", "x.y.z" );
+    }
+
+    public void testVisitWithGenericInterface()
+    {
+        // class a.b.c implements p.q.r<x.y.z>
+        String signature = "Ljava/lang/Object;Lp/q/r<Lx/y/z;>;";
+
+        visitor.visit( 50, 0, "a/b/c", signature, "java/lang/Object", new String[] { "p.q.r" } );
+
+        assertClasses( "java.lang.Object", "p.q.r", "x.y.z" );
+    }
+
+    public void testVisitWithInterfaceBound()
+    {
+        // class a.b.c<T> implements x.y.z<T>
+        String signature = "<T:Ljava/lang/Object;>Ljava/lang/Object;Lx/y/z<TT;>;";
+
+        visitor.visit( 50, 0, "a/b/c", signature, "java/lang/Object", new String[] { "x.y.z" } );
+
+        assertClasses( "java.lang.Object", "x.y.z" );
+    }
+
+    // visitSource tests ------------------------------------------------------
+
+    public void testVisitSource()
+    {
+        visitor.visitSource( null, null );
+
+        assertNoClasses();
+    }
+
+    // visitOuterClass tests --------------------------------------------------
+
+    public void testVisitOuterClass()
+    {
+        // class a.b.c
+        // {
+        //     class ...
+        //     {
+        //     }
+        // }
+        visitor.visitOuterClass( "a/b/c", null, null );
+
+        assertNoClasses();
+    }
+
+    public void testVisitOuterClassInMethod()
+    {
+        // class a.b.c
+        // {
+        //     x.y.z x(p.q.r p)
+        //     {
+        //         class ...
+        //         {
+        //         }
+        //     }
+        // }
+        visitor.visitOuterClass( "a/b/c", "x", "(Lp/q/r;)Lx/y/z;" );
+
+        assertNoClasses();
+    }
+
+    // visitAnnotation tests --------------------------------------------------
+
+    public void testVisitAnnotation()
+    {
+        assertVisitor( visitor.visitAnnotation( "La/b/c;", false ) );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitAnnotationWithRuntimeVisibility()
+    {
+        assertVisitor( visitor.visitAnnotation( "La/b/c;", true ) );
+
+        assertClasses( "a.b.c" );
+    }
+
+    // visitAttribute tests ---------------------------------------------------
+
+    public void testVisitAttribute()
+    {
+        visitor.visitAttribute( new MockAttribute( "a" ) );
+
+        assertNoClasses();
+    }
+
+    // visitInnerClass tests --------------------------------------------------
+
+    public void testVisitInnerClass()
+    {
+        // TODO: ensure innerName is correct
+
+        // class a.b.c { class x.y.z { } }
+        visitor.visitInnerClass( "x/y/z", "a/b/c", "z", 0 );
+
+        assertNoClasses();
+    }
+
+    public void testVisitInnerClassAnonymous()
+    {
+        // class a.b.c { new class x.y.z { } }
+        visitor.visitInnerClass( "x/y/z$1", "a/b/c", null, 0 );
+
+        assertNoClasses();
+    }
+
+    // visitField tests -------------------------------------------------------
+
+    public void testVisitField()
+    {
+        // a.b.c a
+        assertVisitor( visitor.visitField( 0, "a", "La/b/c;", null, null ) );
+
+        assertClasses( "a.b.c" );
+    }
+
+    // TODO: determine actual use of default values
+    // public void testVisitFieldWithValue()
+    // {
+    // }
+
+    public void testVisitFieldArray()
+    {
+        // a.b.c[] a
+        assertVisitor( visitor.visitField( 0, "a", "[La/b/c;", null, null ) );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitFieldGeneric()
+    {
+        // a.b.c<x.y.z> a
+        assertVisitor( visitor.visitField( 0, "a", "La/b/c;", "La/b/c<Lx/y/z;>;", null ) );
+
+        assertClasses( "a.b.c", "x.y.z" );
+    }
+
+    // visitMethod tests ------------------------------------------------------
+
+    public void testVisitMethod()
+    {
+        // void a()
+        assertVisitor( visitor.visitMethod( 0, "a", "()V", null, null ) );
+
+        assertNoClasses();
+    }
+
+    public void testVisitMethodWithPrimitiveArgument()
+    {
+        // void a(int)
+        assertVisitor( visitor.visitMethod( 0, "a", "(I)V", null, null ) );
+
+        assertNoClasses();
+    }
+
+    public void testVisitMethodWithPrimitiveArrayArgument()
+    {
+        // void a(int[])
+        assertVisitor( visitor.visitMethod( 0, "a", "([I)V", null, null ) );
+
+        assertNoClasses();
+    }
+
+    public void testVisitMethodWithObjectArgument()
+    {
+        // void a(a.b.c)
+        assertVisitor( visitor.visitMethod( 0, "a", "(La/b/c;)V", null, null ) );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitMethodWithObjectArguments()
+    {
+        // void a(a.b.c, x.y.z)
+        assertVisitor( visitor.visitMethod( 0, "a", "(La/b/c;Lx/y/z;)V", null, null ) );
+
+        assertClasses( "a.b.c", "x.y.z" );
+    }
+
+    public void testVisitMethodWithObjectArrayArgument()
+    {
+        // void a(a.b.c[])
+        assertVisitor( visitor.visitMethod( 0, "a", "([La/b/c;)V", null, null ) );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitMethodWithGenericArgument()
+    {
+        // void a(a.b.c<x.y.z>)
+        assertVisitor( visitor.visitMethod( 0, "a", "(La/b/c;)V", "(La/b/c<Lx/y/z;>;)V", null ) );
+
+        assertClasses( "a.b.c", "x.y.z" );
+    }
+
+    public void testVisitMethodWithPrimitiveReturnType()
+    {
+        // int a()
+        assertVisitor( visitor.visitMethod( 0, "a", "()I", null, null ) );
+
+        assertNoClasses();
+    }
+
+    public void testVisitMethodWithPrimitiveArrayReturnType()
+    {
+        // int[] a()
+        assertVisitor( visitor.visitMethod( 0, "a", "()[I", null, null ) );
+
+        assertNoClasses();
+    }
+
+    public void testVisitMethodWithObjectReturnType()
+    {
+        // a.b.c a()
+        assertVisitor( visitor.visitMethod( 0, "a", "()La/b/c;", null, null ) );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitMethodWithObjectArrayReturnType()
+    {
+        // a.b.c[] a()
+        assertVisitor( visitor.visitMethod( 0, "a", "()[La/b/c;", null, null ) );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitMethodWithException()
+    {
+        // void a() throws a.b.c
+        assertVisitor( visitor.visitMethod( 0, "a", "()V", null, new String[] { "a/b/c" } ) );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitMethodWithExceptions()
+    {
+        // void a() throws a.b.c, x.y.z
+        assertVisitor( visitor.visitMethod( 0, "a", "()V", null, new String[] { "a/b/c", "x/y/z" } ) );
+
+        assertClasses( "a.b.c", "x.y.z" );
+    }
+
+    // visitAnnotationDefault tests -------------------------------------------
+
+    public void testVisitAnnotationDefault()
+    {
+        assertVisitor( visitor.visitAnnotationDefault() );
+        assertNoClasses();
+    }
+
+    // visitParameterAnnotation tests -------------------------------------------
+
+    public void testVisitParameterAnnotation()
+    {
+        // @a.b.c
+        assertVisitor( visitor.visitParameterAnnotation( 0, "La/b/c;", false ) );
+
+        assertClasses( "a.b.c" );
+    }
+
+    // visitCode tests --------------------------------------------------------
+
+    public void testVisitCode()
+    {
+        visitor.visitCode();
+
+        assertNoClasses();
+    }
+
+    // visitFrame tests -------------------------------------------------------
+
+    public void testVisitFrame()
+    {
+        visitor.visitFrame( Opcodes.F_NEW, 0, new Object[0], 0, new Object[0] );
+
+        assertNoClasses();
+    }
+
+    // visitInsn tests --------------------------------------------------------
+
+    public void testVisitInsn()
+    {
+        visitor.visitInsn( Opcodes.NOP );
+
+        assertNoClasses();
+    }
+
+    // visitIntInsn tests -----------------------------------------------------
+
+    public void testVisitIntInsn()
+    {
+        visitor.visitIntInsn( Opcodes.BIPUSH, 0 );
+
+        assertNoClasses();
+    }
+
+    // visitVarInsn tests -----------------------------------------------------
+
+    public void testVisitVarInsn()
+    {
+        visitor.visitVarInsn( Opcodes.ILOAD, 0 );
+
+        assertNoClasses();
+    }
+
+    // visitTypeInsn tests ----------------------------------------------------
+
+    public void testVisitTypeInsn()
+    {
+        visitor.visitTypeInsn( Opcodes.NEW, "a/b/c" );
+
+        assertClasses( "a.b.c" );
+    }
+
+    // visitFieldInsn tests ---------------------------------------------------
+
+    public void testVisitFieldInsnWithPrimitive()
+    {
+        visitor.visitFieldInsn( Opcodes.GETFIELD, "a/b/c", "x", "I" );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitFieldInsnWithObject()
+    {
+        visitor.visitFieldInsn( Opcodes.GETFIELD, "a/b/c", "x", "Lx/y/z;" );
+
+        assertClasses( "a.b.c", "x.y.z" );
+    }
+
+    // visitMethodInsn tests --------------------------------------------------
+
+    public void testVisitMethodInsn()
+    {
+        visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "()V" );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitMethodInsnWithPrimitiveArgument()
+    {
+        visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "(I)V" );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitMethodInsnWithPrimitiveArrayArgument()
+    {
+        visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "([I)V" );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitMethodInsnWithObjectArgument()
+    {
+        visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "(Lx/y/z;)V" );
+
+        assertClasses( "a.b.c", "x.y.z" );
+    }
+
+    public void testVisitMethodInsnWithObjectArguments()
+    {
+        visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "(Lp/q/r;Lx/y/z;)V" );
+
+        assertClasses( "a.b.c", "p.q.r", "x.y.z" );
+    }
+
+    public void testVisitMethodInsnWithObjectArrayArgument()
+    {
+        visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "([Lx/y/z;)V" );
+
+        assertClasses( "a.b.c", "x.y.z" );
+    }
+
+    public void testVisitMethodInsnWithPrimitiveReturnType()
+    {
+        visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "()I" );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitMethodInsnWithPrimitiveArrayReturnType()
+    {
+        visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "()[I" );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitMethodInsnWithObjectReturnType()
+    {
+        visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "()Lx/y/z;" );
+
+        assertClasses( "a.b.c", "x.y.z" );
+    }
+
+    public void testVisitMethodInsnWithObjectArrayReturnType()
+    {
+        visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "()[Lx/y/z;" );
+
+        assertClasses( "a.b.c", "x.y.z" );
+    }
+
+    // visitJumpInsn tests ----------------------------------------------------
+
+    public void testVisitJumpInsn()
+    {
+        visitor.visitJumpInsn( Opcodes.IFEQ, new Label() );
+
+        assertNoClasses();
+    }
+
+    // visitLabel tests -------------------------------------------------------
+
+    public void testVisitLabel()
+    {
+        visitor.visitLabel( new Label() );
+
+        assertNoClasses();
+    }
+
+    // visitLdcInsn tests -----------------------------------------------------
+
+    public void testVisitLdcInsnWithNonType()
+    {
+        visitor.visitLdcInsn( "a" );
+
+        assertNoClasses();
+    }
+
+    public void testVisitLdcInsnWithPrimitiveType()
+    {
+        visitor.visitLdcInsn( Type.INT_TYPE );
+
+        assertNoClasses();
+    }
+
+    public void testVisitLdcInsnWithObjectType()
+    {
+        visitor.visitLdcInsn( Type.getType( "La/b/c;" ) );
+
+        assertClasses( "a.b.c" );
+    }
+
+    // visitIincInsn tests ----------------------------------------------------
+
+    public void testVisitIincInsn()
+    {
+        visitor.visitIincInsn( 0, 1 );
+
+        assertNoClasses();
+    }
+
+    // visitTableSwitchInsn tests ---------------------------------------------
+
+    public void testVisitTableSwitchInsn()
+    {
+        visitor.visitTableSwitchInsn( 0, 1, new Label(), new Label[] { new Label() } );
+
+        assertNoClasses();
+    }
+
+    // visitLookupSwitchInsn tests --------------------------------------------
+
+    public void testVisitLookupSwitchInsn()
+    {
+        visitor.visitLookupSwitchInsn( new Label(), new int[] { 0 }, new Label[] { new Label() } );
+
+        assertNoClasses();
+    }
+
+    // visitMultiANewArrayInsn tests ------------------------------------------
+
+    public void testVisitMultiANewArrayInsnWithPrimitive()
+    {
+        visitor.visitMultiANewArrayInsn( "I", 2 );
+
+        assertNoClasses();
+    }
+
+    public void testVisitMultiANewArrayInsnWithObject()
+    {
+        visitor.visitMultiANewArrayInsn( "La/b/c;", 2 );
+
+        assertClasses( "a.b.c" );
+    }
+
+    // visitTryCatchBlock tests -----------------------------------------------
+
+    public void testVisitTryCatchBlock()
+    {
+        visitor.visitTryCatchBlock( new Label(), new Label(), new Label(), "a/b/c" );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitTryCatchBlockForFinally()
+    {
+        visitor.visitTryCatchBlock( new Label(), new Label(), new Label(), null );
+
+        assertNoClasses();
+    }
+
+    // visitLocalVariable tests -----------------------------------------------
+
+    public void testVisitLocalVariableWithPrimitive()
+    {
+        visitor.visitLocalVariable( "a", "I", null, new Label(), new Label(), 0 );
+
+        assertNoClasses();
+    }
+
+    public void testVisitLocalVariableWithPrimitiveArray()
+    {
+        visitor.visitLocalVariable( "a", "[I", null, new Label(), new Label(), 0 );
+
+        assertNoClasses();
+    }
+
+    public void testVisitLocalVariableWithObject()
+    {
+        visitor.visitLocalVariable( "a", "La/b/c;", null, new Label(), new Label(), 0 );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitLocalVariableWithObjectArray()
+    {
+        visitor.visitLocalVariable( "a", "[La/b/c;", null, new Label(), new Label(), 0 );
+
+        assertClasses( "a.b.c" );
+    }
+
+    public void testVisitLocalVariableWithGenericObject()
+    {
+        visitor.visitLocalVariable( "a", "La/b/c;", "La/b/c<Lx/y/z;>;", new Label(), new Label(), 0 );
+
+        assertClasses( "a.b.c", "x.y.z" );
+    }
+
+    public void testVisitLocalVariableWithGenericObjectArray()
+    {
+        visitor.visitLocalVariable( "a", "La/b/c;", "[La/b/c<Lx/y/z;>;", new Label(), new Label(), 0 );
+
+        assertClasses( "a.b.c", "x.y.z" );
+    }
+
+    // visitLineNumber tests --------------------------------------------------
+
+    public void testVisitLineNumber()
+    {
+        visitor.visitLineNumber( 0, new Label() );
+
+        assertNoClasses();
+    }
+
+    // visitMaxs tests --------------------------------------------------------
+
+    public void testVisitMaxs()
+    {
+        visitor.visitMaxs( 0, 0 );
+
+        assertNoClasses();
+    }
+
+    // private methods --------------------------------------------------------
+
+    private void assertVisitor( Object actualVisitor )
+    {
+        assertEquals( visitor, actualVisitor );
+    }
+
+    private void assertNoClasses()
+    {
+        assertClasses( Collections.EMPTY_SET );
+    }
+
+    private void assertClasses( String element )
+    {
+        assertClasses( Collections.singleton( element ) );
+    }
+
+    private void assertClasses( String expectedClass1, String expectedClass2 )
+    {
+        assertClasses( new String[] { expectedClass1, expectedClass2 } );
+    }
+
+    private void assertClasses( String expectedClass1, String expectedClass2, String expectedClass3 )
+    {
+        assertClasses( new String[] { expectedClass1, expectedClass2, expectedClass3 } );
+    }
+
+    private void assertClasses( String[] expectedClasses )
+    {
+        assertClasses( new HashSet( Arrays.asList( expectedClasses ) ) );
+    }
+
+    private void assertClasses( Set expectedClasses )
+    {
+        assertEquals( expectedClasses, visitor.getClasses() );
+    }
+}

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitorTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id HeadURL Revision

Added: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/MockAttribute.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/MockAttribute.java?view=auto&rev=512020
==============================================================================
--- maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/MockAttribute.java (added)
+++ maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/MockAttribute.java Mon Feb 26 13:34:13 2007
@@ -0,0 +1,38 @@
+package org.apache.maven.shared.dependency.analyzer.asm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.objectweb.asm.Attribute;
+
+/**
+ * A simple ASM <code>Attribute</code> for use in tests.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ */
+public class MockAttribute extends Attribute
+{
+    // constructors -----------------------------------------------------------
+
+    public MockAttribute( String type )
+    {
+        super( type );
+    }
+}

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/MockAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/shared/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/MockAttribute.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id HeadURL Revision



Mime
View raw message