Use assertThrows() in common-util
[yangtools.git] / common / util / src / test / java / org / opendaylight / yangtools / util / concurrent / CountingRejectedExecutionHandlerTest.java
index e6dd9f3f5e024552228ec90e4f7e31b4b613ed49..d69565166c993074a0bd54511dd6e3b951650307 100644 (file)
@@ -5,12 +5,11 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.util.concurrent;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -80,12 +79,7 @@ public class CountingRejectedExecutionHandlerTest {
 
         int tasks = 5;
         for (int i = 0; i < tasks - 1; i++) {
-            try {
-                executor.execute(new Task(null, null, null, null, 0));
-                fail("Expected RejectedExecutionException");
-            } catch (RejectedExecutionException e) {
-                // Expected
-            }
+            assertThrows(RejectedExecutionException.class, () -> executor.execute(new Task(null, null, null, null, 0)));
         }
 
         assertEquals("getRejectedTaskCount", tasks - 1, countingHandler.getRejectedTaskCount());