<commit_before>package org.junit.tests.running.classes;

import org.junit.AfterClass;
import org.junit.Test;
import org.junit.internal.runners.ErrorReportingRunner;
import org.junit.runner.Description;
import org.junit.runner.JUnitCore;
import org.junit.runner.Request;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunListener;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.InitializationError;

import static org.junit.Assert.assertEquals;

public class ThreadsTest {
    private String log = "";

    public static class TestWithInterrupt {

        @Test
        public void interruptCurrentThread() {
            Thread.currentThread().interrupt();
        }

        @Test
        public void otherTestCaseInterruptingCurrentThread() {
            Thread.currentThread().interrupt();
        }

    }

    @Test
    public void currentThreadInterruptedStatusIsClearedAfterEachTestExecution() {
        log = "";
        JUnitCore jUnitCore = new JUnitCore();
        jUnitCore.addListener(new RunListener() {
            @Override
            public void testFinished(Description description) {
                log += Thread.currentThread().isInterrupted() + " ";
            }
        });

        Result result = jUnitCore.run(TestWithInterrupt.class);
        assertEquals(0, result.getFailureCount());
        assertEquals("false false ", log);
    }

    @RunWith(BlockJUnit4ClassRunner.class)
    public static class TestWithInterruptFromAfterClass {
        @AfterClass
        public static void interruptCurrentThread() {
            Thread.currentThread().interrupt();
        }

        @Test
        public void test() {
            // no-op
        }
    }

    @Test
    public void currentThreadInterruptStatusIsClearedAfterSuiteExecution() {
        log = "";
        JUnitCore jUnitCore = new JUnitCore();
        jUnitCore.addListener(new RunListener() {
            @Override
            public void testSuiteFinished(Description description) throws Exception {
                log += Thread.currentThread().isInterrupted();
            }
        });

        Request request = new Request() {
            @Override
            public Runner getRunner() {
                try {
                    return new BlockJUnit4ClassRunner(TestWithInterruptFromAfterClass.class) {
                    };
                } catch (InitializationError e) {
                    return new ErrorReportingRunner(TestWithInterruptFromAfterClass.class, e);
                }
            }
        };

        Result result = jUnitCore.run(request);
        assertEquals(0, result.getFailureCount());
        assertEquals("false", log);
    }
}<commit_msg>Polish ThreadsTest<commit_after>package org.junit.tests.running.classes;

import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.JUnitCore;
import org.junit.runner.Request;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
import org.junit.runner.notification.RunListener;
import org.junit.runners.BlockJUnit4ClassRunner;

import java.util.ArrayList;
import java.util.List;

import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.junit.Assert.assertEquals;

public class ThreadsTest {

    private List<Boolean> interruptedFlags = new ArrayList<Boolean>();
    private JUnitCore core = new JUnitCore();

    public static class TestWithInterrupt {

        @Test
        public void interruptCurrentThread() {
            Thread.currentThread().interrupt();
        }

        @Test
        public void otherTestCaseInterruptingCurrentThread() {
            Thread.currentThread().interrupt();
        }

    }

    @Test
    public void currentThreadInterruptedStatusIsClearedAfterEachTestExecution() {
        core.addListener(new RunListener() {
            @Override
            public void testFinished(Description description) {
                interruptedFlags.add(Thread.currentThread().isInterrupted());
            }
        });

        Result result = core.run(TestWithInterrupt.class);

        assertEquals(0, result.getFailureCount());
        assertEquals(asList(false, false), interruptedFlags);
    }

    @RunWith(BlockJUnit4ClassRunner.class)
    public static class TestWithInterruptFromAfterClass {
        @AfterClass
        public static void interruptCurrentThread() {
            Thread.currentThread().interrupt();
        }

        @Test
        public void test() {
            // no-op
        }
    }

    @Test
    public void currentThreadInterruptStatusIsClearedAfterSuiteExecution() {
        core.addListener(new RunListener() {
            @Override
            public void testSuiteFinished(Description description) {
                interruptedFlags.add(Thread.currentThread().isInterrupted());
            }
        });

        Request request = Request.aClass(TestWithInterruptFromAfterClass.class);

        Result result = core.run(request);

        assertEquals(0, result.getFailureCount());
        assertEquals(singletonList(false), interruptedFlags);
    }
}
{'fraction_non_alphanumeric': 0.09270254740471175, 'fraction_numerical': 0.001723807699674392, 'mean_word_length': 2.5669398907103824, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '677294', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1305, 'n_words': 256}