package org.keycloak.testsuite.util;

import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.jboss.logging.Logger;

/**
 *
 * @author vramik
 * @author tkyjovsk
 */
public class LogChecker {

    private static final Logger log = Logger.getLogger(LogChecker.class);

    public static void checkServerLog(File logFile) throws IOException {
        log.info(String.format("Checking server log: '%s'", logFile.getAbsolutePath()));
        String logContent = FileUtils.readFileToString(logFile);

        boolean containsError
                = logContent.contains("ERROR")
                || logContent.contains("SEVERE")
                || logContent.contains("Exception ");

        //There is expected string "Exception" in server log: Adding provider 
        //singleton org.keycloak.services.resources.ModelExceptionMapper
        if (containsError) {
            throw new RuntimeException(String.format("Server log file contains ERROR: '%s'", logFile.getPath()));
        }
    }

    public static void checkJBossServerLog(String jbossHome) throws IOException {
        checkServerLog(new File(jbossHome + "/standalone/log/server.log"));
    }

}

@@ -35,57 +35,8 @@
 l;%0A%0A
-import java.io.File;%0Aimport java.io.IOException;%0A
 impo
@@ -105,16 +105,66 @@
 ogger;%0A%0A
+import java.io.File;%0Aimport java.io.IOException;%0A%0A
 /**%0A *%0A 
@@ -302,24 +302,122 @@
 er.class);%0A%0A
+    private static final String%5B%5D IGNORED = new String%5B%5D %7B %22.*Jetty ALPN support not found.*%22 %7D;%0A%0A
     public s
@@ -580,16 +580,18 @@
   String
+%5B%5D
  logCont
@@ -635,166 +635,153 @@
 ile)
-;%0A%0A        boolean containsError%0A                = logContent.contains(%22ERROR%22)%0A                %7C%7C logContent.contains(%22SEVERE%22)%0A                %7C%7C logContent
+.split(%22%5Cn%22);%0A%0A        for (String log : logContent) %7B%0A            boolean containsError = log.contains(%22ERROR%22) %7C%7C log.contains(%22SEVERE%22) %7C%7C log
 .con
@@ -797,25 +797,28 @@
 ception %22);%0A
-%0A
+    
         //Th
@@ -886,10 +886,13 @@
 ider
- 
 %0A
+    
     
@@ -968,16 +968,20 @@
         
+ 
+   
 if (cont
@@ -989,24 +989,298 @@
 insError) %7B%0A
+                boolean ignore = false;%0A                for (String i : IGNORED) %7B%0A                    if (log.matches(i)) %7B%0A                        ignore = true;%0A                        break;%0A                    %7D%0A                %7D%0A                if (!ignore) %7B%0A        
             
@@ -1367,35 +1367,54 @@
  log
-File.getPath()));%0A        %7D
+));%0A                %7D%0A            %7D%0A        %7D%0A
 %0A   

Allow ignoring patterns in LogChecker