public override void Test() { var testHandler = new FailureTestHandler(); var b = new Bootstrap(); b .Group(Group) .Channel<TcpSocketChannel>() .Resolver(NoopNameResolver.Instance) .Handler(new ActionChannelInitializer<ISocketChannel>(ch => { var p = ch.Pipeline; p.AddLast(ClientHandlers); p.AddLast(new LineBasedFrameDecoder(64)); p.AddLast(testHandler); })); var finished = b.ConnectAsync(Destination).Result.CloseCompletion.Wait(TimeSpan.FromSeconds(10)); finished &= testHandler.Latch.Wait(TimeSpan.FromSeconds(10)); Logger.Debug("Recorded exceptions: {0}", testHandler.Exceptions); AssertProxyHandlers(false); Assert.Single(testHandler.Exceptions); var e = testHandler.Exceptions.Dequeue(); Assert.IsAssignableFrom<ProxyConnectException>(e); Assert.Contains(_expectedMessage, e.Message); Assert.True(finished); }
public override void Test() { const long timeout = 2000; foreach (var h in ClientHandlers) { if (h is ProxyHandler handler) handler.ConnectTimeout = TimeSpan.FromMilliseconds(timeout); } var testHandler = new FailureTestHandler(); var b = new Bootstrap() .Group(Group) .Channel<TcpSocketChannel>() .Resolver(NoopNameResolver.Instance) .Handler(new ActionChannelInitializer<ISocketChannel>(ch => { var p = ch.Pipeline; p.AddLast(ClientHandlers); p.AddLast(new LineBasedFrameDecoder(64)); p.AddLast(testHandler); })); var channel = b.ConnectAsync(DESTINATION).Result; var cf = channel.CloseCompletion; var finished = cf.Wait(TimeSpan.FromMilliseconds(timeout * 2)); finished &= testHandler.Latch.Wait(TimeSpan.FromMilliseconds(timeout * 2)); Logger.Debug("Recorded exceptions: {0}", testHandler.Exceptions); AssertProxyHandlers(false); Assert.Single(testHandler.Exceptions); var e = testHandler.Exceptions.Dequeue(); Assert.IsType<ProxyConnectException>(e); Assert.Contains("timeout", e.Message); Assert.True(finished); }