<commit_before>/**
 * This code is free software; you can redistribute it and/or modify it under
 * the terms of the new BSD License.
 *
 * Copyright (c) 2011, <NAME>
 */

package com.github.koraktor.mavanagaiata;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.Properties;

import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;

import org.junit.Before;

import junit.framework.ComparisonFailure;
import junit.framework.TestCase;

public abstract class AbstractMojoTest<T extends AbstractGitMojo> extends TestCase {

    protected String headId = "c823991841bda5f99919ae59a4e59b5607f0450b";

    protected T mojo;

    protected Properties projectProperties;

    protected void testError(String errorMessage) {
        try {
            this.mojo.baseDir = new File("src/test/resources/broken-project").getAbsoluteFile();
            this.mojo.execute();
            fail("No exception thrown.");
        } catch(Exception e) {
            assertEquals(MojoExecutionException.class, e.getClass());
            assertEquals(errorMessage, e.getMessage());
            assertEquals(IOException.class, e.getCause().getClass());
        }
    }

    @Before
    @Override
    public void setUp() throws Exception {
        File pom = new File("src/test/resources/test-project/pom.xml");
        MavenXpp3Reader reader = new MavenXpp3Reader();
        Model model = reader.read(new FileReader(pom));
        final MavenProject testProject = new MavenProject(model);
        testProject.setFile(pom.getAbsoluteFile());

        this.projectProperties = testProject.getProperties();
<commit_msg>Close dangling FileReader in test setup<commit_after>/**
 * This code is free software; you can redistribute it and/or modify it under
 * the terms of the new BSD License.
 *
 * Copyright (c) 2011, <NAME>
 */

package com.github.koraktor.mavanagaiata;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.Properties;

import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;

import org.junit.Before;

import junit.framework.ComparisonFailure;
import junit.framework.TestCase;

public abstract class AbstractMojoTest<T extends AbstractGitMojo> extends TestCase {

    protected String headId = "c823991841bda5f99919ae59a4e59b5607f0450b";

    protected T mojo;

    protected Properties projectProperties;

    protected void testError(String errorMessage) {
        try {
            this.mojo.baseDir = new File("src/test/resources/broken-project").getAbsoluteFile();
            this.mojo.execute();
            fail("No exception thrown.");
        } catch(Exception e) {
            assertEquals(MojoExecutionException.class, e.getClass());
            assertEquals(errorMessage, e.getMessage());
            assertEquals(IOException.class, e.getCause().getClass());
        }
    }

    @Before
    @Override
    public void setUp() throws Exception {
        File pom = new File("src/test/resources/test-project/pom.xml");
        MavenXpp3Reader reader = new MavenXpp3Reader();
        FileReader fileReader = new FileReader(pom);
        Model model = reader.read(fileReader);
        fileReader.close();
        final MavenProject testProject = new MavenProject(model);
        testProject.setFile(pom.getAbsoluteFile());

        this.projectProperties = testProject.getProperties();

{'fraction_non_alphanumeric': 0.10199789695057834, 'fraction_numerical': 0.01892744479495268, 'mean_word_length': 3.562350119904077, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6721295', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1082, 'n_words': 245}