-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that the task is not in the tasks queue when it is rejected fr…
…om the executor Closes #4900
- Loading branch information
Showing
2 changed files
with
54 additions
and
3 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
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,34 @@ | ||
package io.vertx.core.impl; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.Test; | ||
|
||
import java.util.concurrent.Executor; | ||
import java.util.concurrent.RejectedExecutionException; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
/** | ||
* @author Alexander Schwartz | ||
*/ | ||
public class TaskQueueTest { | ||
|
||
Executor executorThatAlwaysThrowsRejectedExceptions = new Executor() { | ||
@Override | ||
public void execute(Runnable command) { | ||
throw new RejectedExecutionException(); | ||
} | ||
}; | ||
|
||
TaskQueue taskQueue = new TaskQueue(); | ||
|
||
@Test | ||
public void shouldNotHaveTaskInQueueWhenTaskHasBeenRejected() { | ||
assertThatThrownBy( | ||
() -> taskQueue.execute(new Thread(), executorThatAlwaysThrowsRejectedExceptions) | ||
).isInstanceOf(RejectedExecutionException.class); | ||
|
||
Assertions.assertThat(taskQueue.isEmpty()).isTrue(); | ||
} | ||
|
||
} |