public void Setup() { _testServer = new TestServerHandler(); }
private async Task TestGatheringWrite0( ServerBootstrap sb, Bootstrap cb, byte[] data, bool composite, bool autoRead) { sb.ChildOption(ChannelOption.AutoRead, autoRead); cb.Option(ChannelOption.AutoRead, autoRead); IPromise serverDonePromise = new DefaultPromise(); TestServerHandler sh = new TestServerHandler(autoRead, serverDonePromise, data.Length); TestHandler ch = new TestHandler(autoRead); cb.Handler(ch); sb.ChildHandler(sh); IChannel sc = await sb.BindAsync(); IChannel cc = await cb.ConnectAsync(sc.LocalAddress); for (int i = 0; i < data.Length;) { int length = Math.Min(s_random.Next(1024 * 8), data.Length - i); if (composite && i % 2 == 0) { int firstBufLength = length / 2; CompositeByteBuffer comp = Unpooled.CompositeBuffer(); comp.AddComponent(true, Unpooled.WrappedBuffer(data, i, firstBufLength)) .AddComponent(true, Unpooled.WrappedBuffer(data, i + firstBufLength, length - firstBufLength)); cc.WriteAsync(comp).Ignore(); } else { cc.WriteAsync(Unpooled.WrappedBuffer(data, i, length)).Ignore(); } i += length; } var cf = cc.WriteAndFlushAsync(Unpooled.Empty); Assert.NotEqual(cc.VoidPromise().Task, cf); try { Assert.True(cf.Wait(60000)); await cf; } catch (Exception) { throw; } await serverDonePromise.Task; await sh._channel.CloseAsync(); await ch._channel.CloseAsync(); await sc.CloseAsync(); if (sh._exception.Value != null && !(sh._exception.Value is SocketException || (sh._exception.Value is ChannelException chexc && chexc.InnerException is OperationException) || sh._exception.Value is OperationException)) { throw sh._exception.Value; } if (sh._exception.Value != null) { throw sh._exception.Value; } if (ch._exception.Value != null && !(ch._exception.Value is SocketException || (sh._exception.Value is ChannelException chexc1 && chexc1.InnerException is OperationException) || sh._exception.Value is OperationException)) { throw ch._exception.Value; } if (ch._exception.Value != null) { throw ch._exception.Value; } IByteBuffer expected = Unpooled.WrappedBuffer(data); Assert.Equal(expected, sh._received); expected.Release(); sh._received.Release(); }
public void Setup() { _testServer = new TestServerHandler(); _wediumContextOptions = _testServer.getWediumContextOptions(); }
public void SetUp() { TestServerHandler server = new TestServerHandler(); _wediumContextOptions = server.getWediumContextOptions(); }