<commit_before>package org.ensembl.healthcheck.eg_gui;

import java.awt.BorderLayout;
import java.util.List;

import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import org.ensembl.healthcheck.DatabaseRegistry;
import org.ensembl.healthcheck.DatabaseRegistryEntry;
import org.ensembl.healthcheck.ReportLine;
import org.ensembl.healthcheck.ReportManager;
import org.ensembl.healthcheck.eg_gui.GuiTestResultWindowTab;
import org.ensembl.healthcheck.eg_gui.TestProgressDialog;
import org.ensembl.healthcheck.testcase.AbstractPerlBasedTestCase;
import org.ensembl.healthcheck.testcase.EnsTestCase;
import org.ensembl.healthcheck.testcase.MultiDatabaseTestCase;
import org.ensembl.healthcheck.testcase.OrderedDatabaseTestCase;
import org.ensembl.healthcheck.testcase.PerlScriptConfig;
import org.ensembl.healthcheck.testcase.SingleDatabaseTestCase;

import com.mysql.jdbc.Connection;

import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

public class GuiTestRunner {

	/**
	 * <p>
	 * 	Sets a logger for a test which forwards anything logged to the 
	 * ReportManager instead to the console where it would probably be
	 * ignored.
	 * </p>
	 * 
	 */
	protected static void setLoggingForTest(final EnsTestCase e) {
	
		Handler guiLoggingHandler = new Handler() {
    		public void publish(LogRecord logRecord) {
  	    	  
    			ReportManager.correct(
    				e, 
    				(Connection) null, 
    				ReportLine.CORRECT
    				+ ": " 
    				+ logRecord.getSourceClassName() 
    				+ ":\n" 
    				+ logRecord.getSourceMethodName() 
    				+ ": " 
    				+ logRecord.getMessage() + "\n" 
    			);
    		}

			@Override public void close() throws SecurityException {}
			@Override public void flush() {}
    	};
    	
    	Logger logger = Logger.getLogger("HealthCheckLogger");
    	logger.addHandler(guiLoggingHandler);
    	e.setLogger(logger);
	}
	
    /**
     * <p>
     * 	Run all the tests in a list.
     * </p><commit_msg>minor<commit_after>package org.ensembl.healthcheck.eg_gui;

import java.awt.BorderLayout;
import java.util.List;

import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import org.ensembl.healthcheck.DatabaseRegistry;
import org.ensembl.healthcheck.DatabaseRegistryEntry;
import org.ensembl.healthcheck.ReportLine;
import org.ensembl.healthcheck.ReportManager;
import org.ensembl.healthcheck.eg_gui.GuiTestResultWindowTab;
import org.ensembl.healthcheck.eg_gui.TestProgressDialog;
import org.ensembl.healthcheck.testcase.AbstractPerlBasedTestCase;
import org.ensembl.healthcheck.testcase.EnsTestCase;
import org.ensembl.healthcheck.testcase.MultiDatabaseTestCase;
import org.ensembl.healthcheck.testcase.OrderedDatabaseTestCase;
import org.ensembl.healthcheck.testcase.PerlScriptConfig;
import org.ensembl.healthcheck.testcase.SingleDatabaseTestCase;

import com.mysql.jdbc.Connection;

import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

public class GuiTestRunner {

	/**
	 * <p>
	 * 	Sets a logger for a test which forwards anything logged to the 
	 * ReportManager instead to the console where it would probably be
	 * ignored.
	 * </p>
	 * 
	 */
	protected static void setLoggingForTest(final EnsTestCase e) {
	
		Handler guiLoggingHandler = new Handler() {
    		public void publish(LogRecord logRecord) {
  	    	  
    			ReportManager.correct(
    				e, 
    				(Connection) null, 
    				logRecord.getLevel()
    				+ ": " 
    				+ logRecord.getSourceClassName() 
    				+ ":\n" 
    				+ logRecord.getSourceMethodName() 
    				+ ": " 
    				+ logRecord.getMessage() + "\n" 
    			);
    		}

			@Override public void close() throws SecurityException {}
			@Override public void flush() {}
    	};
    	
    	Logger logger = Logger.getLogger("HealthCheckLogger");
    	logger.addHandler(guiLoggingHandler);
    	e.setLogger(logger);
	}
	
    /**
     * <p>
     * 	Run all the tests in a list.
     * </p>
{'fraction_non_alphanumeric': 0.10004952947003468, 'fraction_numerical': 0.0, 'mean_word_length': 3.553551296505073, 'pattern_counts': {'":': 6, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5708596', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1270, 'n_words': 239}