You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ma...@apache.org on 2007/07/02 18:06:24 UTC
svn commit: r552524 [4/9] - in /maven/plugins/trunk/maven-dependency-plugin:
./ src/changes/ src/it/copy-dependencies/ src/it/copy-dependencies2/
src/it/mdep-27/ src/it/mdep-50/ src/it/mdep-61/ src/it/mdep-66/
src/it/mdep-67/ src/main/java/org/apache/m...
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java?view=diff&rev=552524&r1=552523&r2=552524
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java Mon Jul 2 09:06:19 2007
@@ -1,747 +1,747 @@
-package org.apache.maven.plugin.dependency;
-
-/*
- * 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.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
-import org.apache.maven.plugin.dependency.utils.DependencyUtil;
-import org.apache.maven.plugin.dependency.utils.markers.DefaultFileMarkerHandler;
-import org.apache.maven.plugin.testing.stubs.StubArtifactRepository;
-import org.apache.maven.plugin.testing.stubs.StubArtifactResolver;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.StringUtils;
-
-public class TestCopyDependenciesMojo
- extends AbstractDependencyMojoTestCase
-{
-
- CopyDependenciesMojo mojo;
-
- protected void setUp()
- throws Exception
- {
- // required for mojo lookups to work
- super.setUp( "copy-dependencies", true );
-
- File testPom = new File( getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml" );
- mojo = (CopyDependenciesMojo) lookupMojo( "copy-dependencies", testPom );
- mojo.outputDirectory = new File( this.testDir, "outputDirectory" );
- // mojo.silent = true;
-
- assertNotNull( mojo );
- assertNotNull( mojo.getProject() );
- MavenProject project = mojo.getProject();
-
- Set artifacts = this.stubFactory.getScopedArtifacts();
- Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
- artifacts.addAll( directArtifacts );
-
- project.setArtifacts( artifacts );
- project.setDependencyArtifacts( directArtifacts );
- mojo.markersDirectory = new File( this.testDir, "markers" );
-
- }
-
- public void assertNoMarkerFile( Artifact artifact )
- {
- DefaultFileMarkerHandler handle = new DefaultFileMarkerHandler( artifact, mojo.markersDirectory );
- try
- {
- assertFalse( handle.isMarkerSet() );
- }
- catch ( MojoExecutionException e )
- {
- fail( e.getLongMessage() );
- }
-
- }
-
- public void testCopyFile()
- throws MojoExecutionException, IOException
- {
- File src = File.createTempFile( "copy", null );
-
- File dest = new File( mojo.outputDirectory, "toMe.jar" );
-
- assertFalse( dest.exists() );
-
- mojo.copyFile( src, dest );
- assertTrue( dest.exists() );
- }
-
- /**
- * tests the proper discovery and configuration of the mojo
- *
- * @throws Exception
- */
- public void testMojo()
- throws Exception
- {
- mojo.execute();
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertTrue( file.exists() );
-
- // there should be no markers for the copy mojo
- assertNoMarkerFile( artifact );
- }
- }
-
- public void testStripVersion()
- throws Exception
- {
- mojo.stripVersion = true;
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, true );
- File file = new File( mojo.outputDirectory, fileName );
- assertTrue( file.exists() );
- }
- }
-
- public void testNoTransitive()
- throws Exception
- {
- mojo.excludeTransitive = true;
- mojo.execute();
- Iterator iter = mojo.project.getDependencyArtifacts().iterator();
-
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertTrue( file.exists() );
- }
- }
-
- public void testExcludeType()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.excludeTypes = "jar";
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertEquals( artifact.getType().equalsIgnoreCase( "jar" ), !file.exists() );
- }
- }
-
- public void testIncludeType()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
-
- mojo.includeTypes = "jar";
- mojo.excludeTypes = "jar";
- //shouldn't get anything.
-
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertFalse(file.exists() );
- }
-
- mojo.excludeTypes = "";
- mojo.execute();
-
- iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertEquals( artifact.getType().equalsIgnoreCase( "jar" ), file.exists() );
- }
- }
-
-
- public void testExcludeArtifactId()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getArtifactArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.excludeArtifactIds = "one";
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertEquals( artifact.getArtifactId().equals( "one" ), !file.exists() );
- }
- }
-
- public void testIncludeArtifactId()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getArtifactArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
-
- mojo.includeArtifactIds = "one";
- mojo.excludeArtifactIds = "one";
- //shouldn't get anything
-
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertFalse( file.exists() );
- }
-
- mojo.excludeArtifactIds = "";
- mojo.execute();
-
- iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertEquals( artifact.getArtifactId().equals( "one" ), file.exists() );
- }
- }
-
- public void testIncludeGroupId()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getGroupIdArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.includeGroupIds = "one";
- mojo.excludeGroupIds = "one";
- //shouldn't get anything
-
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertFalse(file.exists() );
- }
-
- mojo.excludeGroupIds = "";
- mojo.execute();
-
- iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertEquals( artifact.getGroupId().equals( "one" ), file.exists() );
- }
-
- }
-
- public void testExcludeGroupId()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getGroupIdArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.excludeGroupIds = "one";
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
-
- assertEquals( artifact.getGroupId().equals( "one" ), !file.exists() );
- }
- }
- public void testExcludeMultipleGroupIds()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getGroupIdArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.excludeGroupIds = "one,two";
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
-
- assertEquals( artifact.getGroupId().equals( "one" ) || artifact.getGroupId().equals( "two" ), !file.exists() );
- }
- }
-
- public void testExcludeClassifier()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getClassifiedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.excludeClassifiers = "one";
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertEquals( artifact.getClassifier().equals( "one" ), !file.exists() );
- }
- }
-
- public void testIncludeClassifier()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getClassifiedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
-
- mojo.includeClassifiers = "one";
- mojo.excludeClassifiers = "one";
- //shouldn't get anything
-
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertFalse( file.exists() );
- }
-
- mojo.excludeClassifiers = "";
- mojo.execute();
-
- iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertEquals( artifact.getClassifier().equals( "one" ), file.exists() );
- }
-
- }
-
- public void testSubPerType()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.useSubDirectoryPerType = true;
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File folder = DependencyUtil.getFormattedOutputDirectory( true, false, false, false, mojo.outputDirectory,
- artifact );
- File file = new File( folder, fileName );
- assertTrue( file.exists() );
- }
- }
-
- public void testCDMClassifier()
- throws Exception
- {
- dotestClassifierType( "jdk14", null );
- }
-
- public void testCDMType()
- throws Exception
- {
- dotestClassifierType( null, "sources" );
- }
-
- public void testCDMClassifierType()
- throws Exception
- {
- dotestClassifierType( "jdk14", "sources" );
- }
-
- public void dotestClassifierType( String testClassifier, String testType )
- throws Exception
- {
- mojo.classifier = testClassifier;
- mojo.type = testType;
-
- // init classifier things
- mojo.setFactory( DependencyTestUtils.getArtifactFactory() );
- mojo.setResolver( new StubArtifactResolver( stubFactory, false, false ) );
- mojo.setLocal( new StubArtifactRepository( this.testDir.getAbsolutePath() ) );
-
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
-
- String useClassifier = artifact.getClassifier();
- String useType = artifact.getType();
-
- if ( StringUtils.isNotEmpty( testClassifier ) )
- {
- useClassifier = "-" + testClassifier;
- // type is only used if classifier is used.
- if ( StringUtils.isNotEmpty( testType ) )
- {
- useType = testType;
- }
- }
- String fileName = artifact.getArtifactId() + "-" + artifact.getVersion() + useClassifier + "." + useType;
- File file = new File( mojo.outputDirectory, fileName );
-
- if ( !file.exists() )
- {
- fail( "Can't find:" + file.getAbsolutePath() );
- }
-
- // there should be no markers for the copy mojo
- assertNoMarkerFile( artifact );
- }
- }
-
- public void testArtifactNotFound()
- throws Exception
- {
- dotestArtifactExceptions( false, true );
- }
-
- public void testArtifactResolutionException()
- throws Exception
- {
- dotestArtifactExceptions( true, false );
- }
-
- public void dotestArtifactExceptions( boolean are, boolean anfe )
- throws Exception
- {
- mojo.classifier = "jdk";
- mojo.type = "java-sources";
-
- // init classifier things
- mojo.factory = DependencyTestUtils.getArtifactFactory();
- mojo.resolver = new StubArtifactResolver( null, are, anfe );
- mojo.local = new StubArtifactRepository( this.testDir.getAbsolutePath() );
-
- try
- {
- mojo.execute();
- fail( "ExpectedException" );
- }
- catch ( MojoExecutionException e )
- {
-
- }
- }
-
- /*
- * public void testOverwrite() { stubFactory.setCreateFiles( false );
- * Artifact artifact = stubFactory.createArtifact( "test", "artifact", "1.0" );
- *
- * File testFile = new File( getBasedir() + File.separatorChar +
- * "target/test-classes/unit/copy-dependencies-test/test.zip" ); }
- */
-
- public void testDontOverWriteRelease()
- throws MojoExecutionException, InterruptedException, IOException
- {
-
- Set artifacts = new HashSet();
- Artifact release = stubFactory.getReleaseArtifact();
- release.getFile().setLastModified( System.currentTimeMillis() - 2000 );
-
- artifacts.add( release );
-
- mojo.project.setArtifacts( artifacts );
- mojo.project.setDependencyArtifacts( artifacts );
-
- mojo.overWriteIfNewer = false;
-
- mojo.execute();
-
- File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( release, false ) );
-
- Thread.sleep( 100 );
- // round up to the next second
- long time = System.currentTimeMillis() + 1000;
- time = time - ( time % 1000 );
- copiedFile.setLastModified( time );
- Thread.sleep( 100 );
-
- mojo.execute();
-
- assertEquals( time, copiedFile.lastModified() );
- }
-
- public void testOverWriteRelease()
- throws MojoExecutionException, InterruptedException, IOException
- {
-
- Set artifacts = new HashSet();
- Artifact release = stubFactory.getReleaseArtifact();
- release.getFile().setLastModified( System.currentTimeMillis() - 2000 );
-
- artifacts.add( release );
-
- mojo.project.setArtifacts( artifacts );
- mojo.project.setDependencyArtifacts( artifacts );
-
- mojo.overWriteReleases = true;
- mojo.overWriteIfNewer = false;
-
- mojo.execute();
-
- File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( release, false ) );
-
- Thread.sleep( 100 );
- // round down to the last second
- long time = System.currentTimeMillis();
- time = time - ( time % 1000 );
- copiedFile.setLastModified( time );
- // wait at least a second for filesystems that only record to the
- // nearest second.
- Thread.sleep( 1000 );
-
- mojo.execute();
-
- assertTrue( time < copiedFile.lastModified() );
- }
-
- public void testDontOverWriteSnap()
- throws MojoExecutionException, InterruptedException, IOException
- {
-
- Set artifacts = new HashSet();
- Artifact snap = stubFactory.getSnapshotArtifact();
- snap.getFile().setLastModified( System.currentTimeMillis() - 2000 );
-
- artifacts.add( snap );
-
- mojo.project.setArtifacts( artifacts );
- mojo.project.setDependencyArtifacts( artifacts );
-
- mojo.overWriteReleases = false;
- mojo.overWriteSnapshots = false;
- mojo.overWriteIfNewer = false;
-
- mojo.execute();
-
- File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( snap, false ) );
-
- Thread.sleep( 100 );
- // round up to the next second
- long time = System.currentTimeMillis() + 1000;
- time = time - ( time % 1000 );
- copiedFile.setLastModified( time );
- Thread.sleep( 100 );
-
- mojo.execute();
-
- assertEquals( time, copiedFile.lastModified() );
- }
-
- public void testOverWriteSnap()
- throws MojoExecutionException, InterruptedException, IOException
- {
-
- Set artifacts = new HashSet();
- Artifact snap = stubFactory.getSnapshotArtifact();
- snap.getFile().setLastModified( System.currentTimeMillis() - 2000 );
-
- artifacts.add( snap );
-
- mojo.project.setArtifacts( artifacts );
- mojo.project.setDependencyArtifacts( artifacts );
-
- mojo.overWriteReleases = false;
- mojo.overWriteSnapshots = true;
- mojo.overWriteIfNewer = false;
-
- mojo.execute();
-
- File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( snap, false ) );
-
- Thread.sleep( 100 );
- // round down to the last second
- long time = System.currentTimeMillis();
- time = time - ( time % 1000 );
- copiedFile.setLastModified( time );
- // wait at least a second for filesystems that only record to the
- // nearest second.
- Thread.sleep( 1000 );
-
- mojo.execute();
-
- assertTrue( time < copiedFile.lastModified() );
- }
-
- public void testGetDependencies()
- throws MojoExecutionException
- {
- assertEquals( mojo.getResolvedDependencies( true ).toString(), mojo.getDependencySets( true )
- .getResolvedDependencies().toString() );
- }
-
- public void testExcludeProvidedScope()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.excludeScope = "provided";
- // mojo.silent = false;
-
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertEquals( artifact.getScope().equals( "provided" ), !file.exists() );
- file.delete();
- assertFalse( file.exists() );
- }
-
- }
-
- public void testExcludeSystemScope()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.excludeScope = "system";
- // mojo.silent = false;
-
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertEquals( artifact.getScope().equals( "system" ), !file.exists() );
- file.delete();
- assertFalse( file.exists() );
- }
-
- }
-
- public void testExcludeCompileScope()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.excludeScope = "compile";
- mojo.execute();
- ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
-
- assertEquals( !saf.include( artifact ), file.exists() );
- }
- }
-
- public void testExcludeTestScope()
- throws IOException
- {
- mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.excludeScope = "test";
-
- try
- {
- mojo.execute();
- fail( "expected an exception" );
- }
- catch ( MojoExecutionException e )
- {
-
- }
-
- }
-
- public void testExcludeRuntimeScope()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.excludeScope = "runtime";
- mojo.execute();
- ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
-
- assertEquals( !saf.include( artifact ), file.exists() );
- }
- }
-}
+package org.apache.maven.plugin.dependency;
+
+/*
+ * 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.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
+import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.plugin.dependency.utils.markers.DefaultFileMarkerHandler;
+import org.apache.maven.plugin.testing.stubs.StubArtifactRepository;
+import org.apache.maven.plugin.testing.stubs.StubArtifactResolver;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.StringUtils;
+
+public class TestCopyDependenciesMojo
+ extends AbstractDependencyMojoTestCase
+{
+
+ CopyDependenciesMojo mojo;
+
+ protected void setUp()
+ throws Exception
+ {
+ // required for mojo lookups to work
+ super.setUp( "copy-dependencies", true );
+
+ File testPom = new File( getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml" );
+ mojo = (CopyDependenciesMojo) lookupMojo( "copy-dependencies", testPom );
+ mojo.outputDirectory = new File( this.testDir, "outputDirectory" );
+ // mojo.silent = true;
+
+ assertNotNull( mojo );
+ assertNotNull( mojo.getProject() );
+ MavenProject project = mojo.getProject();
+
+ Set artifacts = this.stubFactory.getScopedArtifacts();
+ Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
+ artifacts.addAll( directArtifacts );
+
+ project.setArtifacts( artifacts );
+ project.setDependencyArtifacts( directArtifacts );
+ mojo.markersDirectory = new File( this.testDir, "markers" );
+
+ }
+
+ public void assertNoMarkerFile( Artifact artifact )
+ {
+ DefaultFileMarkerHandler handle = new DefaultFileMarkerHandler( artifact, mojo.markersDirectory );
+ try
+ {
+ assertFalse( handle.isMarkerSet() );
+ }
+ catch ( MojoExecutionException e )
+ {
+ fail( e.getLongMessage() );
+ }
+
+ }
+
+ public void testCopyFile()
+ throws MojoExecutionException, IOException
+ {
+ File src = File.createTempFile( "copy", null );
+
+ File dest = new File( mojo.outputDirectory, "toMe.jar" );
+
+ assertFalse( dest.exists() );
+
+ mojo.copyFile( src, dest );
+ assertTrue( dest.exists() );
+ }
+
+ /**
+ * tests the proper discovery and configuration of the mojo
+ *
+ * @throws Exception
+ */
+ public void testMojo()
+ throws Exception
+ {
+ mojo.execute();
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertTrue( file.exists() );
+
+ // there should be no markers for the copy mojo
+ assertNoMarkerFile( artifact );
+ }
+ }
+
+ public void testStripVersion()
+ throws Exception
+ {
+ mojo.stripVersion = true;
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, true );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertTrue( file.exists() );
+ }
+ }
+
+ public void testNoTransitive()
+ throws Exception
+ {
+ mojo.excludeTransitive = true;
+ mojo.execute();
+ Iterator iter = mojo.project.getDependencyArtifacts().iterator();
+
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertTrue( file.exists() );
+ }
+ }
+
+ public void testExcludeType()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeTypes = "jar";
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getType().equalsIgnoreCase( "jar" ), !file.exists() );
+ }
+ }
+
+ public void testIncludeType()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+
+ mojo.includeTypes = "jar";
+ mojo.excludeTypes = "jar";
+ //shouldn't get anything.
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertFalse(file.exists() );
+ }
+
+ mojo.excludeTypes = "";
+ mojo.execute();
+
+ iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getType().equalsIgnoreCase( "jar" ), file.exists() );
+ }
+ }
+
+
+ public void testExcludeArtifactId()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getArtifactArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeArtifactIds = "one";
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getArtifactId().equals( "one" ), !file.exists() );
+ }
+ }
+
+ public void testIncludeArtifactId()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getArtifactArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+
+ mojo.includeArtifactIds = "one";
+ mojo.excludeArtifactIds = "one";
+ //shouldn't get anything
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertFalse( file.exists() );
+ }
+
+ mojo.excludeArtifactIds = "";
+ mojo.execute();
+
+ iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getArtifactId().equals( "one" ), file.exists() );
+ }
+ }
+
+ public void testIncludeGroupId()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getGroupIdArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.includeGroupIds = "one";
+ mojo.excludeGroupIds = "one";
+ //shouldn't get anything
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertFalse(file.exists() );
+ }
+
+ mojo.excludeGroupIds = "";
+ mojo.execute();
+
+ iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getGroupId().equals( "one" ), file.exists() );
+ }
+
+ }
+
+ public void testExcludeGroupId()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getGroupIdArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeGroupIds = "one";
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+
+ assertEquals( artifact.getGroupId().equals( "one" ), !file.exists() );
+ }
+ }
+ public void testExcludeMultipleGroupIds()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getGroupIdArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeGroupIds = "one,two";
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+
+ assertEquals( artifact.getGroupId().equals( "one" ) || artifact.getGroupId().equals( "two" ), !file.exists() );
+ }
+ }
+
+ public void testExcludeClassifier()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getClassifiedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeClassifiers = "one";
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getClassifier().equals( "one" ), !file.exists() );
+ }
+ }
+
+ public void testIncludeClassifier()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getClassifiedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+
+ mojo.includeClassifiers = "one";
+ mojo.excludeClassifiers = "one";
+ //shouldn't get anything
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertFalse( file.exists() );
+ }
+
+ mojo.excludeClassifiers = "";
+ mojo.execute();
+
+ iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getClassifier().equals( "one" ), file.exists() );
+ }
+
+ }
+
+ public void testSubPerType()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.useSubDirectoryPerType = true;
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File folder = DependencyUtil.getFormattedOutputDirectory( true, false, false, false, mojo.outputDirectory,
+ artifact );
+ File file = new File( folder, fileName );
+ assertTrue( file.exists() );
+ }
+ }
+
+ public void testCDMClassifier()
+ throws Exception
+ {
+ dotestClassifierType( "jdk14", null );
+ }
+
+ public void testCDMType()
+ throws Exception
+ {
+ dotestClassifierType( null, "sources" );
+ }
+
+ public void testCDMClassifierType()
+ throws Exception
+ {
+ dotestClassifierType( "jdk14", "sources" );
+ }
+
+ public void dotestClassifierType( String testClassifier, String testType )
+ throws Exception
+ {
+ mojo.classifier = testClassifier;
+ mojo.type = testType;
+
+ // init classifier things
+ mojo.setFactory( DependencyTestUtils.getArtifactFactory() );
+ mojo.setResolver( new StubArtifactResolver( stubFactory, false, false ) );
+ mojo.setLocal( new StubArtifactRepository( this.testDir.getAbsolutePath() ) );
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+
+ String useClassifier = artifact.getClassifier();
+ String useType = artifact.getType();
+
+ if ( StringUtils.isNotEmpty( testClassifier ) )
+ {
+ useClassifier = "-" + testClassifier;
+ // type is only used if classifier is used.
+ if ( StringUtils.isNotEmpty( testType ) )
+ {
+ useType = testType;
+ }
+ }
+ String fileName = artifact.getArtifactId() + "-" + artifact.getVersion() + useClassifier + "." + useType;
+ File file = new File( mojo.outputDirectory, fileName );
+
+ if ( !file.exists() )
+ {
+ fail( "Can't find:" + file.getAbsolutePath() );
+ }
+
+ // there should be no markers for the copy mojo
+ assertNoMarkerFile( artifact );
+ }
+ }
+
+ public void testArtifactNotFound()
+ throws Exception
+ {
+ dotestArtifactExceptions( false, true );
+ }
+
+ public void testArtifactResolutionException()
+ throws Exception
+ {
+ dotestArtifactExceptions( true, false );
+ }
+
+ public void dotestArtifactExceptions( boolean are, boolean anfe )
+ throws Exception
+ {
+ mojo.classifier = "jdk";
+ mojo.type = "java-sources";
+
+ // init classifier things
+ mojo.factory = DependencyTestUtils.getArtifactFactory();
+ mojo.resolver = new StubArtifactResolver( null, are, anfe );
+ mojo.local = new StubArtifactRepository( this.testDir.getAbsolutePath() );
+
+ try
+ {
+ mojo.execute();
+ fail( "ExpectedException" );
+ }
+ catch ( MojoExecutionException e )
+ {
+
+ }
+ }
+
+ /*
+ * public void testOverwrite() { stubFactory.setCreateFiles( false );
+ * Artifact artifact = stubFactory.createArtifact( "test", "artifact", "1.0" );
+ *
+ * File testFile = new File( getBasedir() + File.separatorChar +
+ * "target/test-classes/unit/copy-dependencies-test/test.zip" ); }
+ */
+
+ public void testDontOverWriteRelease()
+ throws MojoExecutionException, InterruptedException, IOException
+ {
+
+ Set artifacts = new HashSet();
+ Artifact release = stubFactory.getReleaseArtifact();
+ release.getFile().setLastModified( System.currentTimeMillis() - 2000 );
+
+ artifacts.add( release );
+
+ mojo.project.setArtifacts( artifacts );
+ mojo.project.setDependencyArtifacts( artifacts );
+
+ mojo.overWriteIfNewer = false;
+
+ mojo.execute();
+
+ File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( release, false ) );
+
+ Thread.sleep( 100 );
+ // round up to the next second
+ long time = System.currentTimeMillis() + 1000;
+ time = time - ( time % 1000 );
+ copiedFile.setLastModified( time );
+ Thread.sleep( 100 );
+
+ mojo.execute();
+
+ assertEquals( time, copiedFile.lastModified() );
+ }
+
+ public void testOverWriteRelease()
+ throws MojoExecutionException, InterruptedException, IOException
+ {
+
+ Set artifacts = new HashSet();
+ Artifact release = stubFactory.getReleaseArtifact();
+ release.getFile().setLastModified( System.currentTimeMillis() - 2000 );
+
+ artifacts.add( release );
+
+ mojo.project.setArtifacts( artifacts );
+ mojo.project.setDependencyArtifacts( artifacts );
+
+ mojo.overWriteReleases = true;
+ mojo.overWriteIfNewer = false;
+
+ mojo.execute();
+
+ File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( release, false ) );
+
+ Thread.sleep( 100 );
+ // round down to the last second
+ long time = System.currentTimeMillis();
+ time = time - ( time % 1000 );
+ copiedFile.setLastModified( time );
+ // wait at least a second for filesystems that only record to the
+ // nearest second.
+ Thread.sleep( 1000 );
+
+ mojo.execute();
+
+ assertTrue( time < copiedFile.lastModified() );
+ }
+
+ public void testDontOverWriteSnap()
+ throws MojoExecutionException, InterruptedException, IOException
+ {
+
+ Set artifacts = new HashSet();
+ Artifact snap = stubFactory.getSnapshotArtifact();
+ snap.getFile().setLastModified( System.currentTimeMillis() - 2000 );
+
+ artifacts.add( snap );
+
+ mojo.project.setArtifacts( artifacts );
+ mojo.project.setDependencyArtifacts( artifacts );
+
+ mojo.overWriteReleases = false;
+ mojo.overWriteSnapshots = false;
+ mojo.overWriteIfNewer = false;
+
+ mojo.execute();
+
+ File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( snap, false ) );
+
+ Thread.sleep( 100 );
+ // round up to the next second
+ long time = System.currentTimeMillis() + 1000;
+ time = time - ( time % 1000 );
+ copiedFile.setLastModified( time );
+ Thread.sleep( 100 );
+
+ mojo.execute();
+
+ assertEquals( time, copiedFile.lastModified() );
+ }
+
+ public void testOverWriteSnap()
+ throws MojoExecutionException, InterruptedException, IOException
+ {
+
+ Set artifacts = new HashSet();
+ Artifact snap = stubFactory.getSnapshotArtifact();
+ snap.getFile().setLastModified( System.currentTimeMillis() - 2000 );
+
+ artifacts.add( snap );
+
+ mojo.project.setArtifacts( artifacts );
+ mojo.project.setDependencyArtifacts( artifacts );
+
+ mojo.overWriteReleases = false;
+ mojo.overWriteSnapshots = true;
+ mojo.overWriteIfNewer = false;
+
+ mojo.execute();
+
+ File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( snap, false ) );
+
+ Thread.sleep( 100 );
+ // round down to the last second
+ long time = System.currentTimeMillis();
+ time = time - ( time % 1000 );
+ copiedFile.setLastModified( time );
+ // wait at least a second for filesystems that only record to the
+ // nearest second.
+ Thread.sleep( 1000 );
+
+ mojo.execute();
+
+ assertTrue( time < copiedFile.lastModified() );
+ }
+
+ public void testGetDependencies()
+ throws MojoExecutionException
+ {
+ assertEquals( mojo.getResolvedDependencies( true ).toString(), mojo.getDependencySets( true )
+ .getResolvedDependencies().toString() );
+ }
+
+ public void testExcludeProvidedScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "provided";
+ // mojo.silent = false;
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getScope().equals( "provided" ), !file.exists() );
+ file.delete();
+ assertFalse( file.exists() );
+ }
+
+ }
+
+ public void testExcludeSystemScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "system";
+ // mojo.silent = false;
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getScope().equals( "system" ), !file.exists() );
+ file.delete();
+ assertFalse( file.exists() );
+ }
+
+ }
+
+ public void testExcludeCompileScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "compile";
+ mojo.execute();
+ ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+
+ assertEquals( !saf.include( artifact ), file.exists() );
+ }
+ }
+
+ public void testExcludeTestScope()
+ throws IOException
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "test";
+
+ try
+ {
+ mojo.execute();
+ fail( "expected an exception" );
+ }
+ catch ( MojoExecutionException e )
+ {
+
+ }
+
+ }
+
+ public void testExcludeRuntimeScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "runtime";
+ mojo.execute();
+ ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+
+ assertEquals( !saf.include( artifact ), file.exists() );
+ }
+ }
+}
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo2.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo2.java?view=diff&rev=552524&r1=552523&r2=552524
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo2.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo2.java Mon Jul 2 09:06:19 2007
@@ -1,276 +1,276 @@
-package org.apache.maven.plugin.dependency;
-
-/*
- * 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.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.dependency.utils.DependencyUtil;
-import org.apache.maven.plugin.dependency.utils.markers.DefaultFileMarkerHandler;
-import org.apache.maven.project.MavenProject;
-
-public class TestCopyDependenciesMojo2
- extends AbstractDependencyMojoTestCase
-{
-
- CopyDependenciesMojo mojo;
-
- protected void setUp()
- throws Exception
- {
- // required for mojo lookups to work
- super.setUp( "copy-dependencies", true );
-
- File testPom = new File( getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml" );
- mojo = (CopyDependenciesMojo) lookupMojo( "copy-dependencies", testPom );
- mojo.outputDirectory = new File( this.testDir, "outputDirectory" );
- // mojo.silent = true;
-
- assertNotNull( mojo );
- assertNotNull( mojo.getProject() );
- MavenProject project = mojo.getProject();
-
- Set artifacts = this.stubFactory.getScopedArtifacts();
- Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
- artifacts.addAll( directArtifacts );
-
- project.setArtifacts( artifacts );
- project.setDependencyArtifacts( directArtifacts );
- mojo.markersDirectory = new File( this.testDir, "markers" );
-
- }
-
- public void assertNoMarkerFile( Artifact artifact )
- {
- DefaultFileMarkerHandler handle = new DefaultFileMarkerHandler( artifact, mojo.markersDirectory );
- try
- {
- assertFalse( handle.isMarkerSet() );
- }
- catch ( MojoExecutionException e )
- {
- fail( e.getLongMessage() );
- }
-
- }
-
- public void testCopyDependenciesMojoIncludeCompileScope()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.includeScope = "compile";
- mojo.execute();
- ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope );
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
-
- assertEquals( saf.include( artifact ), file.exists() );
- }
- }
-
- public void testCopyDependenciesMojoIncludeTestScope()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.includeScope = "test";
-
- mojo.execute();
- ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope );
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
-
- assertEquals( saf.include( artifact ), file.exists() );
- }
- }
-
- public void testCopyDependenciesMojoIncludeRuntimeScope()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.includeScope = "runtime";
- mojo.execute();
- ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope );
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
-
- assertEquals( saf.include( artifact ), file.exists() );
- }
- }
-
- public void testCopyDependenciesMojoIncludeprovidedScope()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.includeScope = "provided";
-
- mojo.execute();
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
- assertEquals( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ), file.exists() );
- }
- }
-
- public void testCopyDependenciesMojoIncludesystemScope()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.includeScope = "system";
-
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File file = new File( mojo.outputDirectory, fileName );
-
- assertEquals( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ), file.exists() );
- }
- }
-
- public void testSubPerArtifact()
- throws Exception
- {
- mojo.useSubDirectoryPerArtifact = true;
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File folder = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, mojo.outputDirectory,
- artifact );
- File file = new File( folder, fileName );
- assertTrue( file.exists() );
- }
- }
-
- public void testSubPerArtifactAndType()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.useSubDirectoryPerArtifact = true;
- mojo.useSubDirectoryPerType = true;
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File folder = DependencyUtil.getFormattedOutputDirectory( true, true, false, false, mojo.outputDirectory,
- artifact );
- File file = new File( folder, fileName );
- assertTrue( file.exists() );
- }
- }
-
- public void testRepositoryLayout()
- throws Exception
- {
- mojo.useRepositoryLayout = true;
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, false );
- File folder = DependencyUtil.getFormattedOutputDirectory( false, true, mojo.useRepositoryLayout, false,
- mojo.outputDirectory, artifact );
- File file = new File( folder, fileName );
- assertTrue( file.exists() );
- }
- }
-
- public void testSubPerArtifactRemoveVersion()
- throws Exception
- {
- mojo.useSubDirectoryPerArtifact = true;
- mojo.stripVersion = true;
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, true );
- File folder = DependencyUtil.getFormattedOutputDirectory( false, true, false, true, mojo.outputDirectory,
- artifact );
- File file = new File( folder, fileName );
- assertTrue( file.exists() );
- }
- }
-
- public void testSubPerArtifactAndTypeRemoveVersion()
- throws Exception
- {
- mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
- mojo.project.setDependencyArtifacts( new HashSet() );
- mojo.useSubDirectoryPerArtifact = true;
- mojo.useSubDirectoryPerType = true;
- mojo.stripVersion = true;
- mojo.execute();
-
- Iterator iter = mojo.project.getArtifacts().iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- String fileName = DependencyUtil.getFormattedFileName( artifact, true );
- File folder = DependencyUtil.getFormattedOutputDirectory( true, true, false, true, mojo.outputDirectory,
- artifact );
- File file = new File( folder, fileName );
- assertTrue( file.exists() );
- }
- }
-
-}
+package org.apache.maven.plugin.dependency;
+
+/*
+ * 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.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.plugin.dependency.utils.markers.DefaultFileMarkerHandler;
+import org.apache.maven.project.MavenProject;
+
+public class TestCopyDependenciesMojo2
+ extends AbstractDependencyMojoTestCase
+{
+
+ CopyDependenciesMojo mojo;
+
+ protected void setUp()
+ throws Exception
+ {
+ // required for mojo lookups to work
+ super.setUp( "copy-dependencies", true );
+
+ File testPom = new File( getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml" );
+ mojo = (CopyDependenciesMojo) lookupMojo( "copy-dependencies", testPom );
+ mojo.outputDirectory = new File( this.testDir, "outputDirectory" );
+ // mojo.silent = true;
+
+ assertNotNull( mojo );
+ assertNotNull( mojo.getProject() );
+ MavenProject project = mojo.getProject();
+
+ Set artifacts = this.stubFactory.getScopedArtifacts();
+ Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
+ artifacts.addAll( directArtifacts );
+
+ project.setArtifacts( artifacts );
+ project.setDependencyArtifacts( directArtifacts );
+ mojo.markersDirectory = new File( this.testDir, "markers" );
+
+ }
+
+ public void assertNoMarkerFile( Artifact artifact )
+ {
+ DefaultFileMarkerHandler handle = new DefaultFileMarkerHandler( artifact, mojo.markersDirectory );
+ try
+ {
+ assertFalse( handle.isMarkerSet() );
+ }
+ catch ( MojoExecutionException e )
+ {
+ fail( e.getLongMessage() );
+ }
+
+ }
+
+ public void testCopyDependenciesMojoIncludeCompileScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.includeScope = "compile";
+ mojo.execute();
+ ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope );
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+
+ assertEquals( saf.include( artifact ), file.exists() );
+ }
+ }
+
+ public void testCopyDependenciesMojoIncludeTestScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.includeScope = "test";
+
+ mojo.execute();
+ ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope );
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+
+ assertEquals( saf.include( artifact ), file.exists() );
+ }
+ }
+
+ public void testCopyDependenciesMojoIncludeRuntimeScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.includeScope = "runtime";
+ mojo.execute();
+ ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope );
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+
+ assertEquals( saf.include( artifact ), file.exists() );
+ }
+ }
+
+ public void testCopyDependenciesMojoIncludeprovidedScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.includeScope = "provided";
+
+ mojo.execute();
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ), file.exists() );
+ }
+ }
+
+ public void testCopyDependenciesMojoIncludesystemScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.includeScope = "system";
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+
+ assertEquals( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ), file.exists() );
+ }
+ }
+
+ public void testSubPerArtifact()
+ throws Exception
+ {
+ mojo.useSubDirectoryPerArtifact = true;
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File folder = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, mojo.outputDirectory,
+ artifact );
+ File file = new File( folder, fileName );
+ assertTrue( file.exists() );
+ }
+ }
+
+ public void testSubPerArtifactAndType()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.useSubDirectoryPerArtifact = true;
+ mojo.useSubDirectoryPerType = true;
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File folder = DependencyUtil.getFormattedOutputDirectory( true, true, false, false, mojo.outputDirectory,
+ artifact );
+ File file = new File( folder, fileName );
+ assertTrue( file.exists() );
+ }
+ }
+
+ public void testRepositoryLayout()
+ throws Exception
+ {
+ mojo.useRepositoryLayout = true;
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File folder = DependencyUtil.getFormattedOutputDirectory( false, true, mojo.useRepositoryLayout, false,
+ mojo.outputDirectory, artifact );
+ File file = new File( folder, fileName );
+ assertTrue( file.exists() );
+ }
+ }
+
+ public void testSubPerArtifactRemoveVersion()
+ throws Exception
+ {
+ mojo.useSubDirectoryPerArtifact = true;
+ mojo.stripVersion = true;
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, true );
+ File folder = DependencyUtil.getFormattedOutputDirectory( false, true, false, true, mojo.outputDirectory,
+ artifact );
+ File file = new File( folder, fileName );
+ assertTrue( file.exists() );
+ }
+ }
+
+ public void testSubPerArtifactAndTypeRemoveVersion()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.useSubDirectoryPerArtifact = true;
+ mojo.useSubDirectoryPerType = true;
+ mojo.stripVersion = true;
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, true );
+ File folder = DependencyUtil.getFormattedOutputDirectory( true, true, false, true, mojo.outputDirectory,
+ artifact );
+ File file = new File( folder, fileName );
+ assertTrue( file.exists() );
+ }
+ }
+
+}
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo2.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo2.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java?view=diff&rev=552524&r1=552523&r2=552524
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java Mon Jul 2 09:06:19 2007
@@ -1,86 +1,86 @@
-package org.apache.maven.plugin.dependency;
-
-/*
- * 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.util.Set;
-
-import org.apache.maven.plugin.dependency.resolvers.ResolveDependenciesMojo;
-import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
-import org.apache.maven.plugin.testing.SilentLog;
-import org.apache.maven.project.MavenProject;
-
-public class TestResolveMojo
- extends AbstractDependencyMojoTestCase
-{
-
- protected void setUp()
- throws Exception
- {
- // required for mojo lookups to work
- super.setUp( "markers", false );
- }
-
- /**
- * tests the proper discovery and configuration of the mojo
- *
- * @throws Exception
- */
- public void testresolveTestEnvironment()
- throws Exception
- {
- File testPom = new File( getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml" );
- ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo( "resolve", testPom );
-
- assertNotNull( mojo );
- assertNotNull( mojo.getProject() );
- MavenProject project = mojo.getProject();
-
- mojo.silent = true;
- Set artifacts = this.stubFactory.getScopedArtifacts();
- Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
- artifacts.addAll( directArtifacts );
-
- project.setArtifacts( artifacts );
- project.setDependencyArtifacts( directArtifacts );
-
- mojo.execute();
- DependencyStatusSets results = mojo.getResults();
- assertNotNull( results );
- assertEquals( artifacts.size(), results.getResolvedDependencies().size() );
-
- setVariableValueToObject( mojo, "excludeTransitive", Boolean.TRUE );
-
- mojo.execute();
- results = mojo.getResults();
- assertNotNull( results );
- assertEquals( directArtifacts.size(), results.getResolvedDependencies().size() );
- }
-
- public void testSilent()
- throws Exception
- {
- File testPom = new File( getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml" );
- ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo( "resolve", testPom );
- mojo.silent = false;
-
- assertFalse( mojo.getLog() instanceof SilentLog );
- } // TODO: Test skipping artifacts.
+package org.apache.maven.plugin.dependency;
+
+/*
+ * 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.util.Set;
+
+import org.apache.maven.plugin.dependency.resolvers.ResolveDependenciesMojo;
+import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
+import org.apache.maven.plugin.testing.SilentLog;
+import org.apache.maven.project.MavenProject;
+
+public class TestResolveMojo
+ extends AbstractDependencyMojoTestCase
+{
+
+ protected void setUp()
+ throws Exception
+ {
+ // required for mojo lookups to work
+ super.setUp( "markers", false );
+ }
+
+ /**
+ * tests the proper discovery and configuration of the mojo
+ *
+ * @throws Exception
+ */
+ public void testresolveTestEnvironment()
+ throws Exception
+ {
+ File testPom = new File( getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml" );
+ ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo( "resolve", testPom );
+
+ assertNotNull( mojo );
+ assertNotNull( mojo.getProject() );
+ MavenProject project = mojo.getProject();
+
+ mojo.silent = true;
+ Set artifacts = this.stubFactory.getScopedArtifacts();
+ Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
+ artifacts.addAll( directArtifacts );
+
+ project.setArtifacts( artifacts );
+ project.setDependencyArtifacts( directArtifacts );
+
+ mojo.execute();
+ DependencyStatusSets results = mojo.getResults();
+ assertNotNull( results );
+ assertEquals( artifacts.size(), results.getResolvedDependencies().size() );
+
+ setVariableValueToObject( mojo, "excludeTransitive", Boolean.TRUE );
+
+ mojo.execute();
+ results = mojo.getResults();
+ assertNotNull( results );
+ assertEquals( directArtifacts.size(), results.getResolvedDependencies().size() );
+ }
+
+ public void testSilent()
+ throws Exception
+ {
+ File testPom = new File( getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml" );
+ ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo( "resolve", testPom );
+ mojo.silent = false;
+
+ assertFalse( mojo.getLog() instanceof SilentLog );
+ } // TODO: Test skipping artifacts.
}
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision