1 package org.apache.maven.it;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.it.util.ResourceExtractor;
23
24 import java.io.File;
25
26
27
28
29
30
31
32 public class MavenITmng1021EqualAttachmentBuildNumberTest
33 extends AbstractMavenIntegrationTestCase
34 {
35 public MavenITmng1021EqualAttachmentBuildNumberTest()
36 {
37 super( ALL_MAVEN_VERSIONS );
38 }
39
40
41
42
43
44
45
46 public void testitMNG1021()
47 throws Exception
48 {
49 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-1021" );
50 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
51 verifier.setAutoclean( false );
52 verifier.deleteDirectory( "repo" );
53 verifier.deleteArtifacts( "org.apache.maven.its.mng1021" );
54 verifier.executeGoal( "initialize" );
55 verifier.verifyErrorFreeLog();
56 verifier.resetStreams();
57
58 verifier.assertArtifactPresent( "org.apache.maven.its.mng1021", "test", "1-SNAPSHOT", "pom" );
59 verifier.assertArtifactPresent( "org.apache.maven.its.mng1021", "test", "1-SNAPSHOT", "jar" );
60
61 String dir = "repo/org/apache/maven/its/mng1021/test/";
62 String snapshot = getSnapshotVersion( new File( testDir, dir + "1-SNAPSHOT" ) );
63 assertTrue( snapshot, snapshot.endsWith( "-1" ) );
64
65 verifier.assertFilePresent( dir + "maven-metadata.xml" );
66 verifier.assertFilePresent( dir + "maven-metadata.xml.md5" );
67 verifier.assertFilePresent( dir + "maven-metadata.xml.sha1" );
68 verifier.assertFilePresent( dir + "1-SNAPSHOT/maven-metadata.xml" );
69 verifier.assertFilePresent( dir + "1-SNAPSHOT/maven-metadata.xml.md5" );
70 verifier.assertFilePresent( dir + "1-SNAPSHOT/maven-metadata.xml.sha1" );
71 verifier.assertFilePresent( dir + "1-SNAPSHOT/test-" + snapshot + ".pom" );
72 verifier.assertFilePresent( dir + "1-SNAPSHOT/test-" + snapshot + ".pom.md5" );
73 verifier.assertFilePresent( dir + "1-SNAPSHOT/test-" + snapshot + ".pom.sha1" );
74 verifier.assertFilePresent( dir + "1-SNAPSHOT/test-" + snapshot + ".jar" );
75 verifier.assertFilePresent( dir + "1-SNAPSHOT/test-" + snapshot + ".jar.md5" );
76 verifier.assertFilePresent( dir + "1-SNAPSHOT/test-" + snapshot + ".jar.sha1" );
77 verifier.assertFilePresent( dir + "1-SNAPSHOT/test-" + snapshot + "-it.jar" );
78 verifier.assertFilePresent( dir + "1-SNAPSHOT/test-" + snapshot + "-it.jar.md5" );
79 verifier.assertFilePresent( dir + "1-SNAPSHOT/test-" + snapshot + "-it.jar.sha1" );
80 }
81
82 private String getSnapshotVersion( File artifactDir )
83 {
84 File[] files = artifactDir.listFiles();
85 for ( File file : files )
86 {
87 String name = file.getName();
88 if ( name.endsWith( ".pom" ) )
89 {
90 return name.substring( "test-".length(), name.length() - ".pom".length() );
91 }
92 }
93 throw new IllegalStateException( "POM not found in " + artifactDir );
94 }
95
96 }