Author: bentmann
Date: Sun Jun 21 16:03:00 2009
New Revision: 787044

URL: http://svn.apache.org/viewvc?rev=787044&view=rev
Log:
o Reduced coupling to format of warning

Modified:
    
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java

Modified: 
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java
URL: 
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java?rev=787044&r1=787043&r2=787044&view=diff
==============================================================================
--- 
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java
 (original)
+++ 
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java
 Sun Jun 21 16:03:00 2009
@@ -21,7 +21,9 @@
 
 import java.io.File;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
+import java.util.regex.Pattern;
 
 import org.apache.maven.it.util.ResourceExtractor;
 
@@ -57,7 +59,7 @@
         verifier.resetStreams();
 
         List logFile = verifier.loadFile( verifier.getBasedir(), 
verifier.getLogFileName(), false );
-        assertFalse( logFile.contains( "Profile with id: 
'mng-3641-it-provided-profile' has not been activated." ) );
+        assertNull( findWarning( logFile, "mng-3641-it-provided-profile" ) );
 
         // (2) make sure the profile was not found and a warning was printed.
         verifier = new Verifier( testDir.getAbsolutePath() );
@@ -68,7 +70,7 @@
         verifier.resetStreams();
 
         logFile = verifier.loadFile( verifier.getBasedir(), 
verifier.getLogFileName(), false );
-        assertTrue( logFile.contains( "Profile with id: 
'mng-3641-TWlzdGVyIFQgd2FzIGhlcmUuICheX14p' has not been activated." ) );
+        assertNotNull( findWarning( logFile, 
"mng-3641-TWlzdGVyIFQgd2FzIGhlcmUuICheX14p" ) );
 
         // (3) make sure the first profile is found while the other is not and 
a warning was printed
         // accordingly.
@@ -80,8 +82,8 @@
         verifier.resetStreams();
 
         logFile = verifier.loadFile( verifier.getBasedir(), 
verifier.getLogFileName(), false );
-        assertFalse( logFile.contains( "Profile with id: 
'mng-3641-it-provided-profile' has not been activated." ) );
-        assertTrue( logFile.contains( "Profile with id: 
'mng-3641-TWlzdGVyIFQgd2FzIGhlcmUuICheX14p' has not been activated." ) );
+        assertNull( findWarning( logFile, "mng-3641-it-provided-profile" ) );
+        assertNotNull( findWarning( logFile, 
"mng-3641-TWlzdGVyIFQgd2FzIGhlcmUuICheX14p" ) );
 
         // (4) make sure the warning is only printed when the profile is 
missing in all projects
         verifier = new Verifier( testDir.getAbsolutePath() );
@@ -92,7 +94,7 @@
         verifier.resetStreams();
 
         logFile = verifier.loadFile( verifier.getBasedir(), 
verifier.getLogFileName(), false );
-        assertFalse( logFile.contains( "Profile with id: 
'mng-3641-it-provided-profile-child' has not been activated." ) );
+        assertNull( findWarning( logFile, "mng-3641-it-provided-profile-child" 
) );
 
         // (5) make sure the profile is found in subproject. Must not contain 
a warning.
         verifier = new Verifier( new File( testDir, "child1" 
).getAbsolutePath() );
@@ -103,7 +105,7 @@
         verifier.resetStreams();
 
         logFile = verifier.loadFile( verifier.getBasedir(), 
verifier.getLogFileName(), false );
-        assertFalse( logFile.contains( "Profile with id: 
'mng-3641-it-provided-profile-child' has not been activated." ) );
+        assertNull( findWarning( logFile, "mng-3641-it-provided-profile-child" 
) );
 
         // (6) make sure the profile is found from parent in subproject. Must 
not contain a warning.
         verifier = new Verifier( new File( testDir, "child1" 
).getAbsolutePath() );
@@ -114,7 +116,24 @@
         verifier.resetStreams();
 
         logFile = verifier.loadFile( verifier.getBasedir(), 
verifier.getLogFileName(), false );
-        assertFalse( logFile.contains( "Profile with id: 
'mng-3641-it-provided-profile' has not been activated." ) );
+        assertNull( findWarning( logFile, "mng-3641-it-provided-profile" ) );
+    }
+
+    private String findWarning( List logLines, String profileId )
+    {
+        Pattern pattern = Pattern.compile( "(?i).*profile\\s.*\\Q" + profileId 
+ "\\E.*\\snot\\s.*activated.*" );
 
+        for ( Iterator it = logLines.iterator(); it.hasNext(); )
+        {
+            String logLine = (String) it.next();
+
+            if ( pattern.matcher( logLine ).matches() )
+            {
+                return logLine;
+            }
+        }
+
+        return null;
     }
+
 }


Reply via email to