Radutamas/bael 1265 update junit with lambdas (#3196)

* Code for test article: Different Types of Bean Injection in Spring

* Adding jUnits for test article: Different Types of Bean Injection in Spring

* BAEL-1265: Adding jUnit for article

* BAEL-1265: Closing ExecutorService in jUnit

* BAEL-1265: Using lambdas instead of anonymous classes
This commit is contained in:
tamasradu 2017-12-04 18:34:13 +02:00 committed by maibin
parent 93fc61750e
commit d562f429a1
1 changed files with 10 additions and 18 deletions

View File

@ -9,7 +9,6 @@ import java.util.List;
import java.util.concurrent.*; import java.util.concurrent.*;
import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.fail;
public class WaitingForThreadsToFinishTest { public class WaitingForThreadsToFinishTest {
@ -40,9 +39,7 @@ public class WaitingForThreadsToFinishTest {
CountDownLatch latch = new CountDownLatch(2); CountDownLatch latch = new CountDownLatch(2);
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
WORKER_THREAD_POOL.submit(new Runnable() { WORKER_THREAD_POOL.submit(() -> {
@Override
public void run() {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
latch.countDown(); latch.countDown();
@ -50,7 +47,6 @@ public class WaitingForThreadsToFinishTest {
e.printStackTrace(); e.printStackTrace();
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
}
}); });
} }
@ -83,13 +79,9 @@ public class WaitingForThreadsToFinishTest {
awaitTerminationAfterShutdown(WORKER_THREAD_POOL); awaitTerminationAfterShutdown(WORKER_THREAD_POOL);
try { try {
WORKER_THREAD_POOL.submit(new Callable<String>() { WORKER_THREAD_POOL.submit((Callable<String>) () -> {
@Override
public String call() throws Exception {
fail("This thread should have been rejected !");
Thread.sleep(1000000); Thread.sleep(1000000);
return null; return null;
}
}); });
} catch (RejectedExecutionException ex) { } catch (RejectedExecutionException ex) {
// //