import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.channel.DefaultChannelPromise;
+import io.netty.util.concurrent.EventExecutor;
import java.io.IOException;
import java.net.SocketAddress;
import java.util.concurrent.TimeUnit;
private SocketAddress localAddress;
@Mock
private ChannelConfig channelConfig;
+ @Mock
+ private EventExecutor executor;
private AsyncSshHandler asyncSshHandler;
doReturn(ctx).when(ctx).fireChannelInactive();
doReturn(mock(ChannelFuture.class)).when(ctx).disconnect(any(ChannelPromise.class));
doReturn(getMockedPromise()).when(ctx).newPromise();
+ doReturn(executor).when(ctx).executor();
+ doAnswer(invocation -> {
+ invocation.getArgument(0, Runnable.class).run();
+ return null;
+ }).when(executor).execute(any());
}
private void stubChannel() {
}
private static OpenFuture getSuccessOpenFuture() {
- final OpenFuture failedOpenFuture = mock(OpenFuture.class);
- doReturn(true).when(failedOpenFuture).isOpened();
- return failedOpenFuture;
+ final OpenFuture openFuture = mock(OpenFuture.class);
+ doReturn(null).when(openFuture).getException();
+ return openFuture;
}
private static AuthFuture getSuccessAuthFuture() {
final AuthFuture authFuture = mock(AuthFuture.class);
- doReturn(true).when(authFuture).isSuccess();
+ doReturn(null).when(authFuture).getException();
return authFuture;
}
private static ConnectFuture getSuccessConnectFuture(final ClientSession sshSession) {
final ConnectFuture connectFuture = mock(ConnectFuture.class);
- doReturn(true).when(connectFuture).isConnected();
+ doReturn(null).when(connectFuture).getException();
doReturn(sshSession).when(connectFuture).getSession();
return connectFuture;
private static AuthFuture getFailedAuthFuture() {
final AuthFuture authFuture = mock(AuthFuture.class);
- doReturn(false).when(authFuture).isSuccess();
doReturn(new IllegalStateException()).when(authFuture).getException();
return authFuture;
}
private static OpenFuture getFailedOpenFuture() {
- final OpenFuture authFuture = mock(OpenFuture.class);
- doReturn(false).when(authFuture).isOpened();
- doReturn(new IllegalStateException()).when(authFuture).getException();
- return authFuture;
+ final OpenFuture openFuture = mock(OpenFuture.class);
+ doReturn(new IllegalStateException()).when(openFuture).getException();
+ return openFuture;
}
@Test
private static ConnectFuture getFailedConnectFuture() {
final ConnectFuture connectFuture = mock(ConnectFuture.class);
- doReturn(false).when(connectFuture).isConnected();
doReturn(new IllegalStateException()).when(connectFuture).getException();
return connectFuture;
}