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.List;
26 import java.util.regex.Pattern;
27
28
29
30
31
32
33 public class MavenITmng5608ProfileActivationWarningTest
34 extends AbstractMavenIntegrationTestCase
35 {
36
37 public MavenITmng5608ProfileActivationWarningTest()
38 {
39 super( "(3.2.1,)" );
40 }
41
42 public void testitMNG5608()
43 throws Exception
44 {
45 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5608-profile-activation-warning" );
46
47 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
48 verifier.executeGoal( "validate" );
49 verifier.verifyErrorFreeLog();
50 verifier.resetStreams();
51
52
53 assertFileExists( testDir, "target/exists-basedir" );
54 assertFileExists( testDir, "target/mng-5608-missing-project.basedir" );
55
56
57 List<String> logFile = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
58 assertNotNull( findWarning( logFile, "mng-5608-exists-project.basedir" ) );
59 assertNotNull( findWarning( logFile, "mng-5608-missing-project.basedir" ) );
60 }
61
62 private void assertFileExists( File dir, String filename )
63 {
64 File file = new File( dir, filename );
65 assertTrue( "expected file: " + file, file.exists() );
66 }
67
68 private String findWarning( List<String> logLines, String profileId )
69 {
70 Pattern pattern = Pattern.compile(
71 "(?i).*Failed to interpolate file location ..project.basedir./pom.xml for profile " + profileId + ": .*" );
72
73 for ( String logLine : logLines )
74 {
75 if ( pattern.matcher( logLine ).matches() )
76 {
77 return logLine;
78 }
79 }
80
81 return null;
82 }
83
84 }