Fix test-failures caused by NPE (#11619)

Motivation:

We did miss to update some code that setup the EventLoop mock and so did see test-failures due NPE's

Modifications:

Correctly mock the newPromise() method.

Result:

No more test-failures
This commit is contained in:
Norman Maurer 2021-08-26 09:41:41 +02:00 committed by GitHub
parent e21591fa25
commit 2a7cc36536
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ package io.netty.channel;
import io.netty.util.NetUtil;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.ImmediateEventExecutor;
import io.netty.util.concurrent.Promise;
import org.junit.jupiter.api.Test;
@ -77,6 +78,7 @@ public class AbstractChannelTest {
// This allows us to have a single-threaded test
when(eventLoop.inEventLoop()).thenReturn(true);
when(eventLoop.unsafe()).thenReturn(mock(EventLoop.Unsafe.class));
when(eventLoop.newPromise()).thenReturn(ImmediateEventExecutor.INSTANCE.newPromise());
doAnswer(invocationOnMock -> {
((Runnable) invocationOnMock.getArgument(0)).run();
@ -132,7 +134,7 @@ public class AbstractChannelTest {
// This allows us to have a single-threaded test
when(eventLoop.inEventLoop()).thenReturn(true);
when(eventLoop.unsafe()).thenReturn(mock(EventLoop.Unsafe.class));
when(eventLoop.newPromise()).thenReturn(ImmediateEventExecutor.INSTANCE.newPromise());
doAnswer(invocationOnMock -> {
((Runnable) invocationOnMock.getArgument(0)).run();
return null;