Skip to content

Commit 1fa908c

Browse files
committed
ThreadServiceTest: add @before and @after
This is in preparation for additional similar unit tests.
1 parent 0221cc8 commit 1fa908c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/test/java/org/scijava/thread/ThreadServiceTest.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
import static org.junit.Assert.assertSame;
3535

36+
import org.junit.After;
37+
import org.junit.Before;
3638
import org.junit.Test;
3739
import org.scijava.Context;
3840

@@ -43,18 +45,29 @@
4345
*/
4446
public class ThreadServiceTest {
4547

48+
private Context context;
49+
private ThreadService threadService;
50+
51+
@Before
52+
public void setUp() {
53+
context = new Context(ThreadService.class);
54+
threadService = context.getService(ThreadService.class);
55+
}
56+
57+
@After
58+
public void tearDown() {
59+
context.dispose();
60+
}
61+
4662
/**
4763
* Tests {@link ThreadService#getParent(Thread)} when called after
4864
* {@link ThreadService#invoke(Runnable)}.
4965
*/
5066
@Test
5167
public void testGetParent() throws Exception {
52-
final Context context = new Context(ThreadService.class);
53-
final ThreadService threadService = context.getService(ThreadService.class);
5468
final AskForParent ask = new AskForParent(threadService);
5569
threadService.invoke(ask);
5670
assertSame(Thread.currentThread(), ask.parent);
57-
context.dispose();
5871
}
5972

6073
private static class AskForParent implements Runnable {

0 commit comments

Comments
 (0)