forked from junit-team/junit4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work on issue junit-team#1365, cleared interrupt status flag in runLe…
…af method of parent runner
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/test/java/org/junit/tests/running/classes/ThreadsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.junit.tests.running.classes; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.Description; | ||
import org.junit.runner.JUnitCore; | ||
import org.junit.runner.Result; | ||
import org.junit.runner.notification.RunListener; | ||
|
||
public class ThreadsTest { | ||
|
||
public static class TestWithInterrupt { | ||
|
||
@Test | ||
public void interruptCurrentThread() { | ||
assertFalse(Thread.interrupted()); | ||
|
||
Thread.currentThread().interrupt(); | ||
} | ||
|
||
@Test | ||
public void otherTestCase() { | ||
assertFalse(Thread.interrupted()); | ||
|
||
Thread.currentThread().interrupt(); | ||
} | ||
} | ||
|
||
@Test | ||
public void interruptStatusIsClearedAfterTestExecution() { | ||
JUnitCore jUnitCore = new JUnitCore(); | ||
jUnitCore.addListener(new RunListener() { | ||
@Override | ||
public void testStarted(Description description) { | ||
System.out.println(description.getMethodName()); | ||
} | ||
}); | ||
|
||
Result result = jUnitCore.run(TestWithInterrupt.class); | ||
assertEquals(0, result.getFailureCount()); | ||
} | ||
} |