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 import java.util.Properties;
26
27 import static org.junit.Assert.assertNotEquals;
28
29
30
31
32
33
34
35 public class MavenITmng0469ReportConfigTest
36 extends AbstractMavenIntegrationTestCase
37 {
38
39 public MavenITmng0469ReportConfigTest()
40 {
41 super( "[2.0.0,)" );
42 }
43
44
45
46
47
48
49 public void testitReportConfigOverridesBuildDefaults()
50 throws Exception
51 {
52 requiresMavenVersion( "[2.0.0,3.0-alpha-1)" );
53
54 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0469/test0" );
55
56 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
57 verifier.deleteDirectory( "target" );
58 verifier.setAutoclean( false );
59 verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-configuration:2.1-SNAPSHOT:config" );
60 verifier.verifyErrorFreeLog();
61 verifier.resetStreams();
62
63 Properties props = verifier.loadProperties( "target/config.properties" );
64 assertEquals( "not-the-default-value", props.getProperty( "defaultParam" ) );
65 }
66
67
68
69
70
71
72 public void testitBuildConfigDominantDuringBuild()
73 throws Exception
74 {
75 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0469/test1" );
76
77 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
78 verifier.deleteDirectory( "target" );
79 verifier.setAutoclean( false );
80 verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-configuration:2.1-SNAPSHOT:config" );
81 verifier.assertFilePresent( "target/build.txt" );
82 verifier.assertFileNotPresent( "target/reporting.txt" );
83 verifier.verifyErrorFreeLog();
84 verifier.resetStreams();
85 }
86
87
88
89
90
91
92 public void testitBuildConfigIrrelevantForReports()
93 throws Exception
94 {
95 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0469/test2" );
96
97 Verifier verifier = newVerifier( testDir.getAbsolutePath(), "remote" );
98 verifier.deleteDirectory( "target" );
99 verifier.setAutoclean( false );
100 if ( matchesVersionRange( "(,3.0-alpha-1)" ) )
101 {
102 verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-site:2.1-SNAPSHOT:generate" );
103 verifier.assertFilePresent( "target/site/info.properties" );
104 }
105 else
106 {
107 verifier.executeGoal( "validate" );
108 Properties props = verifier.loadProperties( "target/config.properties" );
109 assertEquals( "maven-it-plugin-site", props.getProperty( "project.reporting.plugins.0.artifactId" ) );
110 assertNotEquals( "fail.properties", props.getProperty( "project.reporting.plugins.0.configuration.children.infoFile.0.value" ) );
111 }
112 verifier.verifyErrorFreeLog();
113 verifier.resetStreams();
114 }
115
116 }