<commit_before>package net.sf.clirr.checks;

import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;

import junit.framework.TestCase;
import net.sf.clirr.Checker;
import net.sf.clirr.CheckerFactory;
import net.sf.clirr.event.ApiDifference;
import net.sf.clirr.framework.ClassChangeCheck;
import net.sf.clirr.framework.ClassSelector;
import org.apache.bcel.util.ClassSet;

/**
 * Abstract Baseclass to test individual Checks.
 * @author lkuehne
 */
public abstract class AbstractCheckTestCase extends TestCase
{
    protected final File getTestInputDir()
    {
        // property is set in project.properties
        return new File(System.getProperty("testinput"));
    }

    protected void verify(
            Checker checker,
            ClassSet baseline, ClassSet current,
            ApiDifference[] expected)
    {
    }

    protected File[] getBaseLine()
    {
        return new File[]{
            new File(getTestInputDir(), "testlib-v1.jar")
        };
    }

    protected File[] getCurrent()
    {
        return new File[]{
            new File(getTestInputDir(), "testlib-v2.jar")
        };
    }

    protected void verify(ApiDifference[] expected)
    {
        TestDiffListener tdl = new TestDiffListener();
        Checker checker = CheckerFactory.createChecker(createCheck(tdl));
        ClassSelector classSelector = createClassSelector();
        
        try
        {
            checker.reportDiffs(
                getBaseLine(), getCurrent(), 
                new URLClassLoader(new URL[]{}), 
                new URLClassLoader(new URL[]{}),
                classSelector);
        }
        catch(Exception ex)
        {
            fail("Exception generated:" + ex.getMessage());
        }
            
        tdl.checkExpected(expected);
    }

    /**
     * Creates an object which selects the appropriate classes from the
     * test jars for this test.<commit_msg>Don't catch exceptions; allow junit to catch them instead. This means that the output actually has the real exception cause displayed, making tracking bugs down much easier..<commit_after>package net.sf.clirr.checks;

import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;

import junit.framework.TestCase;
import net.sf.clirr.Checker;
import net.sf.clirr.CheckerFactory;
import net.sf.clirr.event.ApiDifference;
import net.sf.clirr.framework.ClassChangeCheck;
import net.sf.clirr.framework.ClassSelector;
import org.apache.bcel.util.ClassSet;

/**
 * Abstract Baseclass to test individual Checks.
 * @author lkuehne
 */
public abstract class AbstractCheckTestCase extends TestCase
{
    protected final File getTestInputDir()
    {
        // property is set in project.properties
        return new File(System.getProperty("testinput"));
    }

    protected void verify(
            Checker checker,
            ClassSet baseline, ClassSet current,
            ApiDifference[] expected)
    {
    }

    protected File[] getBaseLine()
    {
        return new File[]{
            new File(getTestInputDir(), "testlib-v1.jar")
        };
    }

    protected File[] getCurrent()
    {
        return new File[]{
            new File(getTestInputDir(), "testlib-v2.jar")
        };
    }

    protected void verify(ApiDifference[] expected)
    throws Exception
    {
        TestDiffListener tdl = new TestDiffListener();
        Checker checker = CheckerFactory.createChecker(createCheck(tdl));
        ClassSelector classSelector = createClassSelector();
        
        checker.reportDiffs(
            getBaseLine(), getCurrent(), 
            new URLClassLoader(new URL[]{}), 
            new URLClassLoader(new URL[]{}),
            classSelector);
            
        tdl.checkExpected(expected);
    }

    /**
     * Creates an object which selects the appropriate classes from the
     * test jars for this test.
{'fraction_non_alphanumeric': 0.09669079627714582, 'fraction_numerical': 0.001034126163391934, 'mean_word_length': 2.466845878136201, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3746374', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1054, 'n_words': 267}