// verify build number
File metadataFile = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/"
+ MetadataTools.MAVEN_METADATA );
ArchivaRepositoryMetadata artifactMetadata = MavenMetadataReader.read( metadataFile );
SnapshotVersion snapshotVersion = artifactMetadata.getSnapshotVersion();
assertEquals( "Incorrect build number set in artifact metadata.", 1, snapshotVersion.getBuildNumber() );
String timestampPart = StringUtils.substringBeforeLast( timestampPath, "-" );
assertEquals( "Incorrect timestamp set in artifact metadata.", timestampPart, snapshotVersion.getTimestamp() );
String buildnumber = StringUtils.substringAfterLast( timestampPath, "-" );
assertEquals( "Incorrect build number in filename.", "1", buildnumber );
repoFactoryControl.reset();
control.reset();
control.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
// MRM-1353
// upload snapshot artifact again and check if build number was incremented
setUploadParameters( "1.0-SNAPSHOT", null, new File( FileUtil.getBasedir(),
"target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
null, true );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
repoFactoryControl.replay();
fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
timestamp = fmt.format( new Date() );
control = mockAuditLogs( Arrays.asList(
"org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-2.jar",
"org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-2.pom" ) );
returnString = uploadAction.doUpload();
assertEquals( Action.SUCCESS, returnString );
repoFactoryControl.verify();
control.verify();
artifactsList = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" ).list();
Arrays.sort( artifactsList );
assertEquals( 15, artifactsList.length );
timestampPath = getTimestamp( artifactsList, startIndex, 6 );
assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0-" + timestampPath,
"1.0-SNAPSHOT" );
verifyArtifactChecksums( repoLocation, "artifact-upload-1.0-" + timestampPath, "1.0-SNAPSHOT" );
verifyPomChecksums( repoLocation, "artifact-upload-1.0-" + timestampPath, "1.0-SNAPSHOT" );
verifyProjectMetadataChecksums( repoLocation );
verifyVersionMetadataChecksums( repoLocation, "1.0-SNAPSHOT" );
// verify build number set in metadata and in filename
metadataFile = new File( repoLocation,
"/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA );
artifactMetadata = MavenMetadataReader.read( metadataFile );
snapshotVersion = artifactMetadata.getSnapshotVersion();
assertEquals( "Incorrect build number set in artifact metadata.", 2, snapshotVersion.getBuildNumber() );
timestampPart = StringUtils.substringBeforeLast( timestampPath, "-" );
assertEquals( "Incorrect timestamp set in artifact metadata.", timestampPart, snapshotVersion.getTimestamp() );
buildnumber = StringUtils.substringAfterLast( timestampPath, "-" );
assertEquals( "Incorrect build number in filename.", "2", buildnumber );
}