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