Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions twin/src/test/java/com/iluwatar/twin/BallThreadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,23 @@

/** BallThreadTest */
class BallThreadTest {

/** Verify if the {@link BallThread} can be resumed */
@Test
void testSuspend() {
assertTimeout(
ofMillis(5000),
() -> {
final var ballThread = new BallThread();

final var ballItem = mock(BallItem.class);
ballThread.setTwin(ballItem);

ballThread.start();
sleep(200);
verify(ballItem, atLeastOnce()).draw();
verify(ballItem, atLeastOnce()).move();
ballThread.suspendMe();

sleep(1000);

ballThread.stopMe();
ballThread.join();

verifyNoMoreInteractions(ballItem);
});
}
Expand All @@ -73,25 +67,18 @@ void testResume() {
ofMillis(5000),
() -> {
final var ballThread = new BallThread();

final var ballItem = mock(BallItem.class);
ballThread.setTwin(ballItem);

ballThread.suspendMe();
ballThread.start();

sleep(1000);

verifyNoMoreInteractions(ballItem);

ballThread.resumeMe();
sleep(300);
verify(ballItem, atLeastOnce()).draw();
verify(ballItem, atLeastOnce()).move();

ballThread.stopMe();
ballThread.join();

verifyNoMoreInteractions(ballItem);
});
}
Expand All @@ -109,7 +96,6 @@ void testInterrupt() {
ballThread.start();
ballThread.interrupt();
ballThread.join();

verify(exceptionHandler).uncaughtException(eq(ballThread), any(RuntimeException.class));
verifyNoMoreInteractions(exceptionHandler);
});
Expand Down
Loading