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 import org.apache.maven.shared.utils.io.FileUtils;
24 import org.codehaus.plexus.util.xml.Xpp3Dom;
25 import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
26 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
27
28 import java.io.File;
29 import java.io.FileReader;
30 import java.io.IOException;
31
32
33
34
35
36
37 public class MavenITmng3441MetadataUpdatedFromDeploymentRepositoryTest
38 extends AbstractMavenIntegrationTestCase
39 {
40 public MavenITmng3441MetadataUpdatedFromDeploymentRepositoryTest()
41 {
42 super( "(2.0.8,)" );
43 }
44
45 public void testitMNG3441()
46 throws Exception
47 {
48 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3441" );
49
50 File targetRepository = new File( testDir, "target-repo" );
51 FileUtils.deleteDirectory( targetRepository );
52 FileUtils.copyDirectoryStructure( new File( testDir, "deploy-repo" ), targetRepository );
53
54 Verifier verifier;
55
56 verifier = newVerifier( testDir.getAbsolutePath(), "remote" );
57
58 verifier.addCliOption( "-s" );
59 verifier.addCliOption( "settings.xml" );
60 verifier.executeGoal( "deploy" );
61
62 verifier.verifyErrorFreeLog();
63
64 Xpp3Dom dom = readDom( new File( targetRepository,
65 "org/apache/maven/its/mng3441/test-artifact/1.0-SNAPSHOT/maven-metadata.xml"
66 ) );
67 assertEquals( "2", dom.getChild( "versioning" ).getChild( "snapshot" ).getChild( "buildNumber" ).getValue() );
68
69 dom = readDom( new File( targetRepository, "org/apache/maven/its/mng3441/maven-metadata.xml" ) );
70 Xpp3Dom[] plugins = dom.getChild( "plugins" ).getChildren();
71 assertEquals( "other-plugin", plugins[0].getChild( "prefix" ).getValue() );
72 assertEquals( "test-artifact", plugins[1].getChild( "prefix" ).getValue() );
73
74 verifier.resetStreams();
75 }
76
77 private Xpp3Dom readDom( File file )
78 throws XmlPullParserException, IOException
79 {
80 try ( FileReader reader = new FileReader( file ) )
81 {
82 return Xpp3DomBuilder.build( reader );
83 }
84 }
85 }