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 java.io.File;
23 import java.util.List;
24 import java.util.regex.Pattern;
25
26 import org.apache.maven.it.util.ResourceExtractor;
27
28
29
30
31
32 public class MavenITmng3641ProfileActivationWarningTest
33 extends AbstractMavenIntegrationTestCase
34 {
35
36 public MavenITmng3641ProfileActivationWarningTest()
37 {
38 super( "[2.0.11,2.1.0-M1),[2.1.0,4.0.0-alpha-1)" );
39 }
40
41 public void testitMNG3641()
42 throws Exception
43 {
44
45 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3641" );
46
47 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
48 verifier.setAutoclean( false );
49
50
51 verifier.deleteArtifact( "org.apache.maven.its.mng3641", "parent", "1.0", "pom" );
52
53
54 verifier.addCliOption( "-P mng-3641-it-provided-profile" );
55 verifier.setLogFileName( "log-1.txt" );
56 verifier.executeGoal( "validate" );
57 verifier.verifyErrorFreeLog();
58 verifier.resetStreams();
59
60 List<String> logFile = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
61 assertNull( findWarning( logFile, "mng-3641-it-provided-profile" ) );
62
63
64 verifier = newVerifier( testDir.getAbsolutePath() );
65 verifier.addCliOption( "-P mng-3641-TWlzdGVyIFQgd2FzIGhlcmUuICheX14p" );
66 verifier.setLogFileName( "log-2.txt" );
67 verifier.executeGoal( "validate" );
68 verifier.verifyErrorFreeLog();
69 verifier.resetStreams();
70
71 logFile = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
72 assertNotNull( findWarning( logFile, "mng-3641-TWlzdGVyIFQgd2FzIGhlcmUuICheX14p" ) );
73
74
75
76 verifier = newVerifier( testDir.getAbsolutePath() );
77 verifier.addCliOption( "-P mng-3641-it-provided-profile,mng-3641-TWlzdGVyIFQgd2FzIGhlcmUuICheX14p" );
78 verifier.setLogFileName( "log-3.txt" );
79 verifier.executeGoal( "validate" );
80 verifier.verifyErrorFreeLog();
81 verifier.resetStreams();
82
83 logFile = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
84 assertNull( findWarning( logFile, "mng-3641-it-provided-profile" ) );
85 assertNotNull( findWarning( logFile, "mng-3641-TWlzdGVyIFQgd2FzIGhlcmUuICheX14p" ) );
86
87
88 verifier = newVerifier( testDir.getAbsolutePath() );
89 verifier.addCliOption( "-P mng-3641-it-provided-profile-child" );
90 verifier.setLogFileName( "log-4.txt" );
91 verifier.executeGoal( "validate" );
92 verifier.verifyErrorFreeLog();
93 verifier.resetStreams();
94
95 logFile = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
96 assertNull( findWarning( logFile, "mng-3641-it-provided-profile-child" ) );
97
98
99 verifier = newVerifier( new File( testDir, "child1" ).getAbsolutePath() );
100 verifier.addCliOption( "-P mng-3641-it-provided-profile-child" );
101 verifier.setLogFileName( "log-5.txt" );
102 verifier.executeGoal( "validate" );
103 verifier.verifyErrorFreeLog();
104 verifier.resetStreams();
105
106 logFile = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
107 assertNull( findWarning( logFile, "mng-3641-it-provided-profile-child" ) );
108
109
110 verifier = newVerifier( new File( testDir, "child1" ).getAbsolutePath() );
111 verifier.addCliOption( "-P mng-3641-it-provided-profile" );
112 verifier.setLogFileName( "log-6.txt" );
113 verifier.executeGoal( "validate" );
114 verifier.verifyErrorFreeLog();
115 verifier.resetStreams();
116
117 logFile = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
118 assertNull( findWarning( logFile, "mng-3641-it-provided-profile" ) );
119 }
120
121 private String findWarning( List<String> logLines, String profileId )
122 {
123 Pattern pattern = Pattern.compile( "(?i).*profile\\s.*\\Q" + profileId + "\\E.*\\snot\\s.*activated.*" );
124
125 for ( String logLine : logLines )
126 {
127 if ( pattern.matcher( logLine ).matches() )
128 {
129 return logLine;
130 }
131 }
132
133 return null;
134 }
135
136 }