additional test for proper handling of local installation

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@499367 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2007-01-24 11:41:46 +00:00
parent 8e74736918
commit 86dd270227
1 changed files with 50 additions and 2 deletions

View File

@ -113,11 +113,54 @@ public class MavenIT0108SnapshotUpdateTest
verifier.resetStreams(); verifier.resetStreams();
} }
public void testSnapshotUpdatedWithLocalMetadata()
throws Exception
{
File localMetadata =
getMetadataFile( "org/apache/maven/its/snapshotUpdate", "maven-it-snapshot-update", "1.0-SNAPSHOT" );
localMetadata.delete();
assertFalse( localMetadata.exists() );
File metadata =
new File( repository, "org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-metadata.xml" );
FileUtils.fileWrite( metadata.getAbsolutePath(), constructMetadata( "1", System.currentTimeMillis() - 5000 ) );
verifier.executeGoal( "package" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
assertArtifactContents( "originalArtifact" );
assertFalse( localMetadata.exists() );
FileUtils.fileWrite( artifact.getAbsolutePath(), "localArtifact" );
FileUtils.fileWrite( localMetadata.getAbsolutePath(), constructLocalMetadata( System.currentTimeMillis() ) );
verifier.executeGoal( "package" );
assertArtifactContents( "localArtifact" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
Calendar cal = Calendar.getInstance();
cal.add( Calendar.YEAR, -1 );
FileUtils.fileWrite( localMetadata.getAbsolutePath(), constructLocalMetadata( cal.getTimeInMillis() ) );
verifier.executeGoal( "package" );
assertArtifactContents( "localArtifact" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
}
public void testSnapshotLocalMetadataUpdatedOnInstall() public void testSnapshotLocalMetadataUpdatedOnInstall()
throws Exception throws Exception
{ {
File localMetadata = new File( verifier.localRepo, File localMetadata =
"org/apache/maven/its/snapshotUpdate/maven-it-snapshot-update/1.0-SNAPSHOT/maven-metadata-local.xml" ); getMetadataFile( "org/apache/maven/its/snapshotUpdate", "maven-it-snapshot-update", "1.0-SNAPSHOT" );
localMetadata.delete(); localMetadata.delete();
assertFalse( localMetadata.exists() ); assertFalse( localMetadata.exists() );
@ -141,6 +184,11 @@ public class MavenIT0108SnapshotUpdateTest
verifier.resetStreams(); verifier.resetStreams();
} }
private File getMetadataFile( String groupId, String artifactId, String version )
{
return new File( verifier.localRepo, groupId + "/" + artifactId + "/" + version + "/maven-metadata-local.xml" );
}
private void assertLocalMetadataIsToday( File localMetadata ) private void assertLocalMetadataIsToday( File localMetadata )
throws IOException throws IOException
{ {