Author: brianf
Date: Thu Jun 14 18:50:14 2007
New Revision: 547483
URL: http://svn.apache.org/viewvc?view=rev&rev=547483
Log:
MDEP-59: updated dependencies to get the new unarchiver for rar. Had to move
around the tests to avoid new heap size issues.
Added:
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo2.java
Modified:
maven/plugins/trunk/maven-dependency-plugin/pom.xml
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/ArtifactStubFactory.java
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTypeFilter.java
Modified: maven/plugins/trunk/maven-dependency-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/pom.xml?view=diff&rev=547483&r1=547482&r2=547483
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-dependency-plugin/pom.xml Thu Jun 14 18:50:14 2007
@@ -138,13 +138,18 @@
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<scope>test</scope>
- <version>1.0-beta-1</version>
+ <version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
- <version>1.0-alpha-8</version>
+ <version>1.0-alpha-9-SNAPSHOT</version>
</dependency>
+<!-- <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ <version>1.0-alpha-9</version>
+ </dependency>-->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java?view=diff&rev=547483&r1=547482&r2=547483
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java
Thu Jun 14 18:50:14 2007
@@ -83,10 +83,15 @@
super.tearDown();
mojo = null;
+ System.gc();
}
public void assertUnpacked( Artifact artifact )
- {
+ {
+ if (artifact.getType().equals( "rar"))
+ {
+ System.out.println("Found RaR.");
+ }
assertUnpacked( true, artifact );
}
@@ -641,138 +646,7 @@
return new DefaultFileMarkerHandler( artifact,
mojo.getMarkersDirectory() );
}
- 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();
-
- assertUnpacked( release, false );
- }
-
- 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();
-
- assertUnpacked( release, true );
- }
-
- 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();
-
- assertUnpacked( snap, false );
- }
-
- 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();
-
- assertUnpacked( snap, true );
-
- }
-
- public void testOverWriteIfNewer()
- 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 unpackedFile = getUnpackedFile( snap );
-
- // round down to the last second
- long time = System.currentTimeMillis();
- time = time - ( time % 1000 );
- // set source to be newer and dest to be a known value.
- snap.getFile().setLastModified( time + 3000 );
- unpackedFile.setLastModified( time );
- // wait at least a second for filesystems that only record to the
- // nearest second.
- Thread.sleep( 1000 );
-
- assertEquals( time, unpackedFile.lastModified() );
- mojo.execute();
-
- // make sure it didn't overwrite
- assertEquals( time, unpackedFile.lastModified() );
-
- mojo.overWriteIfNewer = true;
-
- mojo.execute();
-
- assertTrue( time != unpackedFile.lastModified() );
-
- System.gc();
- }
-
+
public void assertUnpacked( Artifact artifact, boolean overWrite )
throws InterruptedException, MojoExecutionException
{
Added:
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo2.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo2.java?view=auto&rev=547483
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo2.java
(added)
+++
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo2.java
Thu Jun 14 18:50:14 2007
@@ -0,0 +1,257 @@
+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.ArtifactStubFactory;
+import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
+import
org.apache.maven.plugin.dependency.testUtils.stubs.StubArtifactRepository;
+import org.apache.maven.plugin.dependency.testUtils.stubs.StubArtifactResolver;
+import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import
org.apache.maven.plugin.dependency.utils.markers.DefaultFileMarkerHandler;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.StringUtils;
+
+public class TestUnpackDependenciesMojo2
+ extends AbstractDependencyMojoTestCase
+{
+
+ private final String UNPACKABLE_FILE = "test.txt";
+
+ private final String UNPACKABLE_FILE_PATH =
"target/test-classes/unit/unpack-dependencies-test/" + UNPACKABLE_FILE;
+
+ UnpackDependenciesMojo mojo;
+
+ protected void setUp()
+ throws Exception
+ {
+ // required for mojo lookups to work
+ super.setUp( "unpack-dependencies", true );
+
+ File testPom = new File( getBasedir(),
"target/test-classes/unit/unpack-dependencies-test/plugin-config.xml" );
+ mojo = (UnpackDependenciesMojo) lookupMojo( "unpack-dependencies",
testPom );
+ mojo.outputDirectory = new File( this.testDir, "outputDirectory" );
+ // mojo.silent = true;
+
+ // it needs to get the archivermanager
+ stubFactory.setUnpackableFile( mojo.getArchiverManager() );
+ // i'm using one file repeatedly to archive so I can test the name
+ // programmatically.
+ stubFactory.setSrcFile( new File( getBasedir() + File.separatorChar +
UNPACKABLE_FILE_PATH ) );
+
+ 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" );
+
+ }
+
+ protected void tearDown()
+ {
+ super.tearDown();
+
+ mojo = null;
+ System.gc();
+ }
+
+ public File getUnpackedFile( Artifact artifact )
+ {
+ File destDir = DependencyUtil.getFormattedOutputDirectory(
mojo.isUseSubDirectoryPerType(), mojo
+ .isUseSubDirectoryPerArtifact(), mojo.useRepositoryLayout,
mojo.stripVersion, mojo.getOutputDirectory(),
+ artifact );
+ File unpacked = new File( destDir,
ArtifactStubFactory.getUnpackableFileName( artifact ) );
+ assertTrue( unpacked.exists() );
+ return unpacked;
+ }
+
+ 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();
+
+ assertUnpacked( release, false );
+ }
+
+ 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();
+
+ assertUnpacked( release, true );
+ }
+
+ 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();
+
+ assertUnpacked( snap, false );
+ }
+
+ 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();
+
+ assertUnpacked( snap, true );
+
+ }
+
+ public void testOverWriteIfNewer()
+ 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 unpackedFile = getUnpackedFile( snap );
+
+ // round down to the last second
+ long time = System.currentTimeMillis();
+ time = time - ( time % 1000 );
+ // set source to be newer and dest to be a known value.
+ snap.getFile().setLastModified( time + 3000 );
+ unpackedFile.setLastModified( time );
+ // wait at least a second for filesystems that only record to the
+ // nearest second.
+ Thread.sleep( 1000 );
+
+ assertEquals( time, unpackedFile.lastModified() );
+ mojo.execute();
+ System.gc();
+ // make sure it didn't overwrite
+ assertEquals( time, unpackedFile.lastModified() );
+
+ mojo.overWriteIfNewer = true;
+
+ mojo.execute();
+
+ assertTrue( time != unpackedFile.lastModified() );
+
+ System.gc();
+ }
+
+ public void assertUnpacked( Artifact artifact, boolean overWrite )
+ throws InterruptedException, MojoExecutionException
+ {
+ File unpackedFile = getUnpackedFile( artifact );
+
+ Thread.sleep( 100 );
+ // round down to the last second
+ long time = System.currentTimeMillis();
+ time = time - ( time % 1000 );
+ unpackedFile.setLastModified( time );
+ // wait at least a second for filesystems that only record to the
+ // nearest second.
+ Thread.sleep( 1000 );
+
+ assertEquals( time, unpackedFile.lastModified() );
+ mojo.execute();
+
+ if ( overWrite )
+ {
+ assertTrue( time != unpackedFile.lastModified() );
+ }
+ else
+ {
+ assertEquals( time, unpackedFile.lastModified() );
+ }
+ }
+}
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/ArtifactStubFactory.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/ArtifactStubFactory.java?view=diff&rev=547483&r1=547482&r2=547483
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/ArtifactStubFactory.java
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/ArtifactStubFactory.java
Thu Jun 14 18:50:14 2007
@@ -221,6 +221,7 @@
set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE,
"jar", null ) );
set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE,
"sources", null ) );
set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE,
"zip", null ) );
+ set.add( createArtifact( "g", "e", "1.0", Artifact.SCOPE_COMPILE,
"rar", null ) );
return set;
}
@@ -242,6 +243,7 @@
set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE,
"war", null ) );
set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE,
"jar", null ) );
set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE,
"zip", null ) );
+ set.add( createArtifact( "g", "e", "1.0", Artifact.SCOPE_COMPILE,
"rar", null ) );
return set;
}
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTypeFilter.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTypeFilter.java?view=diff&rev=547483&r1=547482&r2=547483
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTypeFilter.java
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTypeFilter.java
Thu Jun 14 18:50:14 2007
@@ -86,13 +86,13 @@
{
TypeFilter filter = new TypeFilter( null, "war,jar," );
Set result = filter.filter( artifacts, log );
- assertEquals( 2, result.size() );
+ assertEquals( 3, result.size() );
Iterator iter = result.iterator();
while ( iter.hasNext() )
{
Artifact artifact = (Artifact) iter.next();
- assertTrue( artifact.getType().equals( "sources" ) ||
artifact.getType().equals( "zip" ) );
+ assertTrue( !artifact.getType().equals( "war" ) &&
!artifact.getType().equals( "jar" ) );
}
}
@@ -100,6 +100,6 @@
{
TypeFilter filter = new TypeFilter( null, null );
Set result = filter.filter( artifacts, log );
- assertEquals( 4, result.size() );
+ assertEquals( 5, result.size() );
}
}