maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r549521 [3/3] - in /maven/shared/trunk/maven-dependency-tree: ./ src/main/java/org/apache/maven/shared/dependency/tree/ src/main/java/org/apache/maven/shared/dependency/tree/filter/ src/main/java/org/apache/maven/shared/dependency/tree/trav...
Date Thu, 21 Jun 2007 15:53:45 GMT
Added: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/ResolutionNodeUtils.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/ResolutionNodeUtils.java?view=auto&rev=549521
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/ResolutionNodeUtils.java (added)
+++ maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/ResolutionNodeUtils.java Thu Jun 21 08:53:42 2007
@@ -0,0 +1,137 @@
+package org.apache.maven.shared.dependency.tree;
+
+/*
+ * 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.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Utilities for working with resolution nodes.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see ResolutionNode
+ */
+public final class ResolutionNodeUtils
+{
+    // constructors -----------------------------------------------------------
+    
+    private ResolutionNodeUtils()
+    {
+        // private constructor for utility class
+    }
+
+    // public methods ---------------------------------------------------------
+    
+    public static List getRootChildrenResolutionNodes( MavenProject project, ArtifactResolutionResult resolutionResult )
+    {
+        Set resolutionNodes = resolutionResult.getArtifactResolutionNodes();
+
+        // obtain root children nodes
+        
+        Map rootChildrenResolutionNodesByArtifact = new HashMap();
+        
+        for ( Iterator iterator = resolutionNodes.iterator(); iterator.hasNext(); )
+        {
+            ResolutionNode resolutionNode = (ResolutionNode) iterator.next();
+            
+            if ( resolutionNode.isChildOfRootNode() )
+            {
+                rootChildrenResolutionNodesByArtifact.put( resolutionNode.getArtifact(), resolutionNode );
+            }
+        }
+        
+        // order root children by project dependencies
+        
+        List rootChildrenResolutionNodes = new ArrayList();
+        
+        for ( Iterator iterator = project.getDependencyArtifacts().iterator(); iterator.hasNext(); )
+        {
+            Artifact artifact = (Artifact) iterator.next();
+            ResolutionNode resolutionNode = (ResolutionNode) rootChildrenResolutionNodesByArtifact.get( artifact );
+            
+            rootChildrenResolutionNodes.add( resolutionNode );
+        }
+
+        return rootChildrenResolutionNodes;
+    }
+    
+    public static String toString( MavenProject project, ArtifactResolutionResult result )
+    {
+        StringBuffer buffer = new StringBuffer();
+        
+        append( buffer, project, result );
+        
+        return buffer.toString();
+    }
+    
+    public static StringBuffer append( StringBuffer buffer, MavenProject project, ArtifactResolutionResult result )
+    {
+        ResolutionNode rootNode = new ResolutionNode( project.getArtifact(), Collections.EMPTY_LIST );
+        append( buffer, rootNode, 0 );
+
+        List rootChildrenNodes = getRootChildrenResolutionNodes( project, result );
+        append( buffer, rootChildrenNodes.iterator(), 1 );
+        
+        return buffer;
+    }
+    
+    // private methods --------------------------------------------------------
+    
+    private static StringBuffer append( StringBuffer buffer, Iterator nodesIterator, int depth )
+    {
+        while ( nodesIterator.hasNext() )
+        {
+            ResolutionNode node = (ResolutionNode) nodesIterator.next();
+            
+            append( buffer, node, depth );
+        }
+        
+        return buffer;
+    }
+
+    private static StringBuffer append( StringBuffer buffer, ResolutionNode node, int depth )
+    {
+        for ( int i = 0; i < depth; i++ )
+        {
+            buffer.append( "   " );
+        }
+        
+        buffer.append( node );
+        buffer.append( System.getProperty( "line.separator" ) );
+        
+        if ( node.isResolved() )
+        {
+            append( buffer, node.getChildrenIterator(), depth + 1 );
+        }
+        
+        return buffer;
+    }
+}

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/ResolutionNodeUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/ResolutionNodeUtils.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AbstractDependencyNodeFilterTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AbstractDependencyNodeFilterTest.java?view=auto&rev=549521
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AbstractDependencyNodeFilterTest.java (added)
+++ maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AbstractDependencyNodeFilterTest.java Thu Jun 21 08:53:42 2007
@@ -0,0 +1,44 @@
+package org.apache.maven.shared.dependency.tree.filter;
+
+/*
+ * 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.apache.maven.shared.dependency.tree.DependencyNode;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+/**
+ * Provides utility methods for testing dependency node filters.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ */
+public abstract class AbstractDependencyNodeFilterTest extends MockObjectTestCase
+{
+    // protected methods ---------------------------------------------------------
+
+    protected DependencyNodeFilter createDependencyNodeFilter( DependencyNode node, boolean accept )
+    {
+        Mock mock = mock( DependencyNodeFilter.class );
+
+        mock.stubs().method( "accept" ).with( same( node ) ).will( returnValue( accept ) );
+
+        return (DependencyNodeFilter) mock.proxy();
+    }
+}

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AbstractDependencyNodeFilterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AbstractDependencyNodeFilterTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilterTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilterTest.java?view=auto&rev=549521
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilterTest.java (added)
+++ maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilterTest.java Thu Jun 21 08:53:42 2007
@@ -0,0 +1,113 @@
+package org.apache.maven.shared.dependency.tree.filter;
+
+/*
+ * 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.apache.maven.shared.dependency.tree.AbstractDependencyNodeTest;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+
+/**
+ * Tests <code>AncestorOrSelfDependencyNodeFilter</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see AncestorOrSelfDependencyNodeFilter
+ */
+public class AncestorOrSelfDependencyNodeFilterTest extends AbstractDependencyNodeTest
+{
+    // constants --------------------------------------------------------------
+
+    private DependencyNode rootNode;
+
+    private DependencyNode childNode1;
+
+    private DependencyNode childNode2;
+
+    private DependencyNode grandChildNode;
+
+    private AncestorOrSelfDependencyNodeFilter filter;
+
+    // TestCase methods -------------------------------------------------------
+
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        /*
+         * p -> a -> c
+         *   -> b
+         */
+
+        rootNode = createNode( "g:p:t:1" );
+
+        childNode1 = createNode( "g:a:t:1" );
+        rootNode.addChild( childNode1 );
+
+        childNode2 = createNode( "g:b:t:1" );
+        rootNode.addChild( childNode2 );
+
+        grandChildNode = createNode( "g:c:t:1" );
+        childNode1.addChild( grandChildNode );
+    }
+
+    // tests ------------------------------------------------------------------
+
+    public void testSelf()
+    {
+        filter = new AncestorOrSelfDependencyNodeFilter( rootNode );
+
+        assertTrue( filter.accept( rootNode ) );
+    }
+
+    public void testParent()
+    {
+        filter = new AncestorOrSelfDependencyNodeFilter( childNode1 );
+
+        assertTrue( filter.accept( rootNode ) );
+    }
+
+    public void testGrandParent()
+    {
+        filter = new AncestorOrSelfDependencyNodeFilter( grandChildNode );
+
+        assertTrue( filter.accept( rootNode ) );
+    }
+
+    public void testCousin()
+    {
+        filter = new AncestorOrSelfDependencyNodeFilter( childNode2 );
+
+        assertFalse( filter.accept( childNode1 ) );
+    }
+
+    public void testChild()
+    {
+        filter = new AncestorOrSelfDependencyNodeFilter( rootNode );
+
+        assertFalse( filter.accept( childNode1 ) );
+    }
+
+    public void testGrandChild()
+    {
+        filter = new AncestorOrSelfDependencyNodeFilter( rootNode );
+
+        assertFalse( filter.accept( grandChildNode ) );
+    }
+}

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilterTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilterTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilterTest.java?view=auto&rev=549521
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilterTest.java (added)
+++ maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilterTest.java Thu Jun 21 08:53:42 2007
@@ -0,0 +1,90 @@
+package org.apache.maven.shared.dependency.tree.filter;
+
+/*
+ * 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.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.testing.stubs.ArtifactStub;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+
+/**
+ * Tests <code>AndDependencyNodeFilter</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see AndDependencyNodeFilter
+ */
+public class AndDependencyNodeFilterTest extends AbstractDependencyNodeFilterTest
+{
+    // fields -----------------------------------------------------------------
+
+    private Artifact artifact;
+
+    private DependencyNode node;
+
+    private DependencyNodeFilter includeFilter;
+
+    private DependencyNodeFilter excludeFilter;
+
+    private AndDependencyNodeFilter filter;
+
+    // TestCase methods -------------------------------------------------------
+
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        artifact = new ArtifactStub();
+        node = new DependencyNode( artifact );
+
+        includeFilter = createDependencyNodeFilter( node, true );
+        excludeFilter = createDependencyNodeFilter( node, false );
+    }
+
+    // tests ------------------------------------------------------------------
+
+    public void testIncludeInclude()
+    {
+        filter = new AndDependencyNodeFilter( includeFilter, includeFilter );
+
+        assertTrue( filter.accept( node ) );
+    }
+
+    public void testIncludeExclude()
+    {
+        filter = new AndDependencyNodeFilter( includeFilter, excludeFilter );
+
+        assertFalse( filter.accept( node ) );
+    }
+
+    public void testExcludeInclude()
+    {
+        filter = new AndDependencyNodeFilter( excludeFilter, includeFilter );
+
+        assertFalse( filter.accept( node ) );
+    }
+
+    public void testExcludeExclude()
+    {
+        filter = new AndDependencyNodeFilter( excludeFilter, excludeFilter );
+
+        assertFalse( filter.accept( node ) );
+    }
+}

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilterTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilterTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilterTest.java?view=auto&rev=549521
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilterTest.java (added)
+++ maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilterTest.java Thu Jun 21 08:53:42 2007
@@ -0,0 +1,87 @@
+package org.apache.maven.shared.dependency.tree.filter;
+
+/*
+ * 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.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.plugin.testing.stubs.ArtifactStub;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+/**
+ * Tests <code>ArtifactDependencyNodeFilter</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see ArtifactDependencyNodeFilter
+ */
+public class ArtifactDependencyNodeFilterTest extends MockObjectTestCase
+{
+    // fields -----------------------------------------------------------------
+
+    private Artifact artifact;
+
+    private DependencyNode node;
+
+    private ArtifactDependencyNodeFilter nodeFilter;
+
+    private ArtifactFilter artifactFilter;
+
+    // TestCase methods -------------------------------------------------------
+
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        artifact = new ArtifactStub();
+        node = new DependencyNode( artifact );
+    }
+
+    // tests ------------------------------------------------------------------
+
+    public void testArtifactFilterInclude()
+    {
+        artifactFilter = createArtifactFilter( artifact, true );
+        nodeFilter = new ArtifactDependencyNodeFilter( artifactFilter );
+
+        assertTrue( nodeFilter.accept( node ) );
+    }
+
+    public void testArtifactFilterExclude()
+    {
+        artifactFilter = createArtifactFilter( artifact, false );
+        nodeFilter = new ArtifactDependencyNodeFilter( artifactFilter );
+
+        assertFalse( nodeFilter.accept( node ) );
+    }
+
+    // private methods --------------------------------------------------------
+
+    private ArtifactFilter createArtifactFilter( Artifact artifact, boolean include )
+    {
+        Mock mock = mock( ArtifactFilter.class );
+
+        mock.stubs().method( "include" ).with( same( artifact ) ).will( returnValue( include ) );
+
+        return (ArtifactFilter) mock.proxy();
+    }
+}

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilterTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilterTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilterTest.java?view=auto&rev=549521
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilterTest.java (added)
+++ maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilterTest.java Thu Jun 21 08:53:42 2007
@@ -0,0 +1,106 @@
+package org.apache.maven.shared.dependency.tree.filter;
+
+/*
+ * 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;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.testing.stubs.ArtifactStub;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+
+/**
+ * Tests <code>StateDependencyNodeFilter</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see StateDependencyNodeFilter
+ */
+public class StateDependencyNodeFilterTest extends TestCase
+{
+    // fields -----------------------------------------------------------------
+
+    private StateDependencyNodeFilter filter;
+
+    private DependencyNode includedNode;
+
+    private DependencyNode omittedForDuplicateNode;
+
+    private DependencyNode omittedForConflictNode;
+
+    private DependencyNode omittedForCycleNode;
+
+    // TestCase methods -------------------------------------------------------
+
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        Artifact artifact = new ArtifactStub();
+        Artifact relatedArtifact = new ArtifactStub();
+
+        includedNode = new DependencyNode( artifact, DependencyNode.INCLUDED );
+        omittedForDuplicateNode = new DependencyNode( artifact, DependencyNode.OMITTED_FOR_DUPLICATE, relatedArtifact );
+        omittedForConflictNode = new DependencyNode( artifact, DependencyNode.OMITTED_FOR_CONFLICT, relatedArtifact );
+        omittedForCycleNode = new DependencyNode( artifact, DependencyNode.OMITTED_FOR_CYCLE );
+    }
+
+    // tests ------------------------------------------------------------------
+
+    public void testIncluded()
+    {
+        filter = new StateDependencyNodeFilter( DependencyNode.INCLUDED );
+
+        assertTrue( filter.accept( includedNode ) );
+        assertFalse( filter.accept( omittedForDuplicateNode ) );
+        assertFalse( filter.accept( omittedForConflictNode ) );
+        assertFalse( filter.accept( omittedForCycleNode ) );
+    }
+
+    public void testOmittedForDuplicate()
+    {
+        filter = new StateDependencyNodeFilter( DependencyNode.OMITTED_FOR_DUPLICATE );
+
+        assertFalse( filter.accept( includedNode ) );
+        assertTrue( filter.accept( omittedForDuplicateNode ) );
+        assertFalse( filter.accept( omittedForConflictNode ) );
+        assertFalse( filter.accept( omittedForCycleNode ) );
+    }
+
+    public void testOmittedForConflict()
+    {
+        filter = new StateDependencyNodeFilter( DependencyNode.OMITTED_FOR_CONFLICT );
+
+        assertFalse( filter.accept( includedNode ) );
+        assertFalse( filter.accept( omittedForDuplicateNode ) );
+        assertTrue( filter.accept( omittedForConflictNode ) );
+        assertFalse( filter.accept( omittedForCycleNode ) );
+    }
+
+    public void testOmittedForCycle()
+    {
+        filter = new StateDependencyNodeFilter( DependencyNode.OMITTED_FOR_CYCLE );
+
+        assertFalse( filter.accept( includedNode ) );
+        assertFalse( filter.accept( omittedForDuplicateNode ) );
+        assertFalse( filter.accept( omittedForConflictNode ) );
+        assertTrue( filter.accept( omittedForCycleNode ) );
+    }
+}

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilterTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitorTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitorTest.java?view=auto&rev=549521
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitorTest.java (added)
+++ maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitorTest.java Thu Jun 21 08:53:42 2007
@@ -0,0 +1,112 @@
+package org.apache.maven.shared.dependency.tree.traversal;
+
+/*
+ * 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.apache.maven.shared.dependency.tree.AbstractDependencyNodeTest;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+import org.jmock.Mock;
+
+/**
+ * Tests <code>BuildingDependencyNodeVisitor</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see BuildingDependencyNodeVisitor
+ */
+public class BuildingDependencyNodeVisitorTest extends AbstractDependencyNodeTest
+{
+    // fields -----------------------------------------------------------------
+
+    private BuildingDependencyNodeVisitor visitor;
+
+    // tests ------------------------------------------------------------------
+
+    public void testVisitNode()
+    {
+        DependencyNode sourceNode = createNode( "g:a:t:1" );
+
+        visitor = new BuildingDependencyNodeVisitor();
+        visitor.visit( sourceNode );
+        visitor.endVisit( sourceNode );
+
+        DependencyNode resultNode = visitor.getDependencyTree();
+        assertNotSame( sourceNode, resultNode );
+        assertEquals( sourceNode, resultNode );
+    }
+
+    public void testVisitNodeWithChild()
+    {
+        DependencyNode sourceNode = createNode( "g:a:t:1" );
+        DependencyNode sourceChildNode = createNode( "g:b:t:1" );
+        sourceNode.addChild( sourceChildNode );
+
+        visitor = new BuildingDependencyNodeVisitor();
+        visitor.visit( sourceNode );
+        visitor.visit( sourceChildNode );
+        visitor.endVisit( sourceChildNode );
+        visitor.endVisit( sourceNode );
+
+        DependencyNode resultNode = visitor.getDependencyTree();
+        assertNotSame( sourceNode, resultNode );
+        assertEquals( sourceNode, resultNode );
+    }
+
+    public void testVisitNodeWithVisitor()
+    {
+        DependencyNode sourceNode = createNode( "g:a:t:1" );
+
+        Mock nextVisitorMock = mock( DependencyNodeVisitor.class );
+        nextVisitorMock.expects( once() ).method( "visit" ).with( eq( sourceNode ) ).will( returnValue( true ) ).id( "1" );
+        nextVisitorMock.expects( once() ).method( "endVisit" ).with( eq( sourceNode ) ).after( "1" ).will( returnValue( true ) );
+        DependencyNodeVisitor nextVisitor = (DependencyNodeVisitor) nextVisitorMock.proxy();
+
+        visitor = new BuildingDependencyNodeVisitor( nextVisitor );
+        visitor.visit( sourceNode );
+        visitor.endVisit( sourceNode );
+
+        DependencyNode resultNode = visitor.getDependencyTree();
+        assertNotSame( sourceNode, resultNode );
+        assertEquals( sourceNode, resultNode );
+    }
+
+    public void testVisitNodeWithChildAndVisitor()
+    {
+        DependencyNode sourceNode = createNode( "g:a:t:1" );
+        DependencyNode sourceChildNode = createNode( "g:b:t:1" );
+        sourceNode.addChild( sourceChildNode );
+
+        Mock nextVisitorMock = mock( DependencyNodeVisitor.class );
+        nextVisitorMock.expects( once() ).method( "visit" ).with( eq( sourceNode ) ).will( returnValue( true ) ).id( "1" );
+        nextVisitorMock.expects( once() ).method( "visit" ).with( eq( sourceChildNode ) ).after( "1" ).will( returnValue( true ) ).id( "2" );
+        nextVisitorMock.expects( once() ).method( "endVisit" ).with( eq( sourceChildNode ) ).after( "2" ).will( returnValue( true ) ).id( "3" );
+        nextVisitorMock.expects( once() ).method( "endVisit" ).with( eq( sourceNode ) ).after( "3" ).will( returnValue( true ) );
+        DependencyNodeVisitor nextVisitor = (DependencyNodeVisitor) nextVisitorMock.proxy();
+
+        visitor = new BuildingDependencyNodeVisitor( nextVisitor );
+        visitor.visit( sourceNode );
+        visitor.visit( sourceChildNode );
+        visitor.endVisit( sourceChildNode );
+        visitor.endVisit( sourceNode );
+
+        DependencyNode resultNode = visitor.getDependencyTree();
+        assertNotSame( sourceNode, resultNode );
+        assertEquals( sourceNode, resultNode );
+    }
+}

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitorTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitorTest.java?view=auto&rev=549521
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitorTest.java (added)
+++ maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitorTest.java Thu Jun 21 08:53:42 2007
@@ -0,0 +1,102 @@
+package org.apache.maven.shared.dependency.tree.traversal;
+
+/*
+ * 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.List;
+
+import org.apache.maven.shared.dependency.tree.AbstractDependencyNodeTest;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+
+/**
+ * Tests <code>CollectingDependencyNodeVisitor</code>.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see CollectingDependencyNodeVisitor
+ */
+public class CollectingDependencyNodeVisitorTest extends AbstractDependencyNodeTest
+{
+    // fields -----------------------------------------------------------------
+    
+    private CollectingDependencyNodeVisitor visitor;
+    
+    private DependencyNode node1;
+
+    private DependencyNode node2;
+
+    private DependencyNode node3;
+
+    // TestCase methods -------------------------------------------------------
+    
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        visitor = new CollectingDependencyNodeVisitor();
+        node1 = createNode( "g:a:t:1" );
+        node2 = createNode( "g:b:t:1" );
+        node3 = createNode( "g:c:t:1" );
+    }
+    
+    // tests ------------------------------------------------------------------
+    
+    public void testVisitSingleNode()
+    {
+        assertEmptyNodes();
+        assertTrue( visitor.visit( node1 ) );
+        assertNodes( node1 );
+    }
+
+    public void testVisitMultipleNodes()
+    {
+        assertEmptyNodes();
+        assertTrue( visitor.visit( node1 ) );
+        assertTrue( visitor.visit( node2 ) );
+        assertTrue( visitor.visit( node3 ) );
+        assertNodes( Arrays.asList( new Object[] { node1, node2, node3 } ) );
+    }
+
+    public void testEndVisit()
+    {
+        assertEmptyNodes();
+        assertTrue( visitor.endVisit( node1 ) );
+        assertEmptyNodes();
+    }
+
+    // private methods --------------------------------------------------------
+    
+    private void assertEmptyNodes()
+    {
+        assertNodes( Collections.EMPTY_LIST );
+    }
+    
+    private void assertNodes( DependencyNode node )
+    {
+        assertNodes( Collections.singletonList( node ) );
+    }
+    
+    private void assertNodes( List expectedNodes )
+    {
+        assertEquals( "Collected nodes", expectedNodes, visitor.getNodes() );
+    }
+}

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitorTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitorTest.java?view=auto&rev=549521
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitorTest.java (added)
+++ maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitorTest.java Thu Jun 21 08:53:42 2007
@@ -0,0 +1,117 @@
+package org.apache.maven.shared.dependency.tree.traversal;
+
+/*
+ * 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.apache.maven.plugin.testing.stubs.ArtifactStub;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+import org.apache.maven.shared.dependency.tree.filter.AbstractDependencyNodeFilterTest;
+import org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter;
+import org.jmock.Mock;
+
+/**
+ * Tests <code>FilteringDependencyNodeVisitor</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see FilteringDependencyNodeVisitor
+ */
+public class FilteringDependencyNodeVisitorTest extends AbstractDependencyNodeFilterTest
+{
+    // fields -----------------------------------------------------------------
+
+    private FilteringDependencyNodeVisitor visitor;
+
+    private DependencyNode node;
+
+    private DependencyNodeFilter acceptingFilter;
+
+    private DependencyNodeFilter rejectingFilter;
+
+    // TestCase methods -------------------------------------------------------
+
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        node = new DependencyNode( new ArtifactStub() );
+
+        acceptingFilter = createDependencyNodeFilter( node, true );
+        rejectingFilter = createDependencyNodeFilter( node, false );
+    }
+
+    // tests ------------------------------------------------------------------
+
+    public void testVisitAcceptTrue()
+    {
+        Mock filteredVisitorMock = mock( DependencyNodeVisitor.class );
+        filteredVisitorMock.expects( once() ).method( "visit" ).with( eq( node ) ).will( returnValue( true ) );
+        DependencyNodeVisitor filteredVisitor = (DependencyNodeVisitor) filteredVisitorMock.proxy();
+
+        visitor = new FilteringDependencyNodeVisitor( filteredVisitor, acceptingFilter );
+        assertTrue( visitor.visit( node ) );
+    }
+
+    public void testVisitAcceptFalse()
+    {
+        Mock filteredVisitorMock = mock( DependencyNodeVisitor.class );
+        filteredVisitorMock.expects( once() ).method( "visit" ).with( eq( node ) ).will( returnValue( false ) );
+        DependencyNodeVisitor filteredVisitor = (DependencyNodeVisitor) filteredVisitorMock.proxy();
+
+        visitor = new FilteringDependencyNodeVisitor( filteredVisitor, acceptingFilter );
+        assertFalse( visitor.visit( node ) );
+    }
+
+    public void testVisitReject()
+    {
+        DependencyNodeVisitor filteredVisitor = (DependencyNodeVisitor) mock( DependencyNodeVisitor.class ).proxy();
+
+        visitor = new FilteringDependencyNodeVisitor( filteredVisitor, rejectingFilter );
+        assertTrue( visitor.visit( node ) );
+    }
+
+    public void testEndVisitAcceptTrue()
+    {
+        Mock filteredVisitorMock = mock( DependencyNodeVisitor.class );
+        filteredVisitorMock.expects( once() ).method( "endVisit" ).with( eq( node ) ).will( returnValue( true ) );
+        DependencyNodeVisitor filteredVisitor = (DependencyNodeVisitor) filteredVisitorMock.proxy();
+
+        visitor = new FilteringDependencyNodeVisitor( filteredVisitor, acceptingFilter );
+        assertTrue( visitor.endVisit( node ) );
+    }
+
+    public void testEndVisitAcceptFalse()
+    {
+        Mock filteredVisitorMock = mock( DependencyNodeVisitor.class );
+        filteredVisitorMock.expects( once() ).method( "endVisit" ).with( eq( node ) ).will( returnValue( false ) );
+        DependencyNodeVisitor filteredVisitor = (DependencyNodeVisitor) filteredVisitorMock.proxy();
+
+        visitor = new FilteringDependencyNodeVisitor( filteredVisitor, acceptingFilter );
+        assertFalse( visitor.endVisit( node ) );
+    }
+
+    public void testEndVisitReject()
+    {
+        DependencyNodeVisitor filteredVisitor = (DependencyNodeVisitor) mock( DependencyNodeVisitor.class ).proxy();
+
+        visitor = new FilteringDependencyNodeVisitor( filteredVisitor, rejectingFilter );
+        assertTrue( visitor.endVisit( node ) );
+    }
+}

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitorTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitorTest.java?view=auto&rev=549521
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitorTest.java (added)
+++ maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitorTest.java Thu Jun 21 08:53:42 2007
@@ -0,0 +1,134 @@
+package org.apache.maven.shared.dependency.tree.traversal;
+
+/*
+ * 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.StringWriter;
+
+import org.apache.maven.shared.dependency.tree.AbstractDependencyNodeTest;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+
+/**
+ * Tests <code>SerializingDependencyNodeVisitor</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see SerializingDependencyNodeVisitor
+ */
+public class SerializingDependencyNodeVisitorTest extends AbstractDependencyNodeTest
+{
+    // constants --------------------------------------------------------------
+
+    private static final String NEWLINE = System.getProperty( "line.separator" );
+
+    // fields -----------------------------------------------------------------
+
+    private StringWriter writer;
+
+    private SerializingDependencyNodeVisitor serializer;
+
+    // TestCase methods -------------------------------------------------------
+
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        writer = new StringWriter();
+
+        serializer = new SerializingDependencyNodeVisitor( writer, SerializingDependencyNodeVisitor.STANDARD_TOKENS );
+    }
+
+    // tests ------------------------------------------------------------------
+
+    public void testSingleNode()
+    {
+        DependencyNode rootNode = createNode( "g:p:t:1" );
+
+        assertTree( "g:p:t:1" + NEWLINE, rootNode );
+    }
+    
+    public void testNodeWithChild()
+    {
+        DependencyNode rootNode = createNode( "g:p:t:1" );
+        rootNode.addChild( createNode( "g:a:t:1" ) );
+
+        assertTree(
+            "g:p:t:1" + NEWLINE + 
+            "\\- g:a:t:1" + NEWLINE,
+            rootNode );
+    }
+    
+    public void testNodeWithMultipleChildren()
+    {
+        DependencyNode rootNode = createNode( "g:p:t:1" );
+        rootNode.addChild( createNode( "g:a:t:1" ) );
+        rootNode.addChild( createNode( "g:b:t:1" ) );
+        rootNode.addChild( createNode( "g:c:t:1" ) );
+        
+        assertTree(
+            "g:p:t:1" + NEWLINE + 
+            "+- g:a:t:1" + NEWLINE + 
+            "+- g:b:t:1" + NEWLINE + 
+            "\\- g:c:t:1" + NEWLINE,
+            rootNode );
+    }
+    
+    public void testNodeWithGrandchild()
+    {
+        DependencyNode rootNode = createNode( "g:p:t:1" );
+        DependencyNode childNode = createNode( "g:a:t:1" );
+        rootNode.addChild( childNode );
+        childNode.addChild( createNode( "g:b:t:1" ) );
+        
+        assertTree(
+            "g:p:t:1" + NEWLINE + 
+            "\\- g:a:t:1" + NEWLINE + 
+            "   \\- g:b:t:1" + NEWLINE,
+            rootNode );
+    }
+    
+    public void testNodeWithMultipleGrandchildren()
+    {
+        DependencyNode rootNode = createNode( "g:p:t:1" );
+        DependencyNode child1Node = createNode( "g:a:t:1" );
+        rootNode.addChild( child1Node );
+        child1Node.addChild( createNode( "g:b:t:1" ) );
+        DependencyNode child2Node = createNode( "g:c:t:1" );
+        rootNode.addChild( child2Node );
+        child2Node.addChild( createNode( "g:d:t:1" ) );
+        
+        assertTree(
+            "g:p:t:1" + NEWLINE + 
+            "+- g:a:t:1" + NEWLINE + 
+            "|  \\- g:b:t:1" + NEWLINE +
+            "\\- g:c:t:1" + NEWLINE + 
+            "   \\- g:d:t:1" + NEWLINE,
+            rootNode );
+    }
+    
+    // private methods --------------------------------------------------------
+
+    private void assertTree( String expectedTree, DependencyNode actualNode )
+    {
+        actualNode.accept( serializer );
+
+        assertEquals( expectedTree, writer.toString() );
+    }
+}

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/shared/trunk/maven-dependency-tree/src/test/resources/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.xml
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/resources/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.xml?view=auto&rev=549521
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/resources/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.xml (added)
+++ maven/shared/trunk/maven-dependency-tree/src/test/resources/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.xml Thu Jun 21 08:53:42 2007
@@ -0,0 +1,36 @@
+<!--
+  ~ 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.
+  -->
+
+<component-set>
+  <components>
+    <component>
+      <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
+      <implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
+        </requirement>
+      </requirements>
+    </component>
+    <component>
+      <role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
+      <implementation>org.apache.maven.artifact.resolver.DefaultArtifactCollector</implementation>
+    </component>
+  </components>
+</component-set>

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/resources/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-dependency-tree/src/test/resources/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message