Java 11 migrate remaining (g,h,i) (#1116)
* Moves game-loop to Java 11 * Moves guarded-suspension to Java 11 * Moves half-sync-half-async to Java 11 * Moves hexagonal to Java 11 * Moves intercepting-filter to Java 11 * Moves interpreter to Java 11 * Moves iterator to Java 11
This commit is contained in:
committed by
Ilkka Seppälä
parent
7d0a5c0edb
commit
f835d3d516
@ -70,7 +70,7 @@ public class App {
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
AsynchronousService service = new AsynchronousService(new LinkedBlockingQueue<>());
|
||||
var service = new AsynchronousService(new LinkedBlockingQueue<>());
|
||||
/*
|
||||
* A new task to calculate sum is received but as this is main thread, it should not block. So
|
||||
* it passes it to the asynchronous task layer to compute and proceeds with handling other
|
||||
|
@ -25,12 +25,8 @@ package com.iluwatar.halfsynchalfasync;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
|
@ -57,13 +57,13 @@ public class AsynchronousServiceTest {
|
||||
|
||||
@Test
|
||||
public void testPerfectExecution() throws Exception {
|
||||
final Object result = new Object();
|
||||
final var result = new Object();
|
||||
when(task.call()).thenReturn(result);
|
||||
service.execute(task);
|
||||
|
||||
verify(task, timeout(2000)).onPostCall(eq(result));
|
||||
|
||||
final InOrder inOrder = inOrder(task);
|
||||
final var inOrder = inOrder(task);
|
||||
inOrder.verify(task, times(1)).onPreCall();
|
||||
inOrder.verify(task, times(1)).call();
|
||||
inOrder.verify(task, times(1)).onPostCall(eq(result));
|
||||
@ -73,13 +73,13 @@ public class AsynchronousServiceTest {
|
||||
|
||||
@Test
|
||||
public void testCallException() throws Exception {
|
||||
final IOException exception = new IOException();
|
||||
final var exception = new IOException();
|
||||
when(task.call()).thenThrow(exception);
|
||||
service.execute(task);
|
||||
|
||||
verify(task, timeout(2000)).onError(eq(exception));
|
||||
|
||||
final InOrder inOrder = inOrder(task);
|
||||
final var inOrder = inOrder(task);
|
||||
inOrder.verify(task, times(1)).onPreCall();
|
||||
inOrder.verify(task, times(1)).call();
|
||||
inOrder.verify(task, times(1)).onError(exception);
|
||||
@ -89,13 +89,13 @@ public class AsynchronousServiceTest {
|
||||
|
||||
@Test
|
||||
public void testPreCallException() {
|
||||
final IllegalStateException exception = new IllegalStateException();
|
||||
final var exception = new IllegalStateException();
|
||||
doThrow(exception).when(task).onPreCall();
|
||||
service.execute(task);
|
||||
|
||||
verify(task, timeout(2000)).onError(eq(exception));
|
||||
|
||||
final InOrder inOrder = inOrder(task);
|
||||
final var inOrder = inOrder(task);
|
||||
inOrder.verify(task, times(1)).onPreCall();
|
||||
inOrder.verify(task, times(1)).onError(exception);
|
||||
|
||||
|
Reference in New Issue
Block a user