Search in sources :

Example 1 with TestStreamByteDistributorStreamState

use of io.netty.handler.codec.http2.Http2TestUtil.TestStreamByteDistributorStreamState in project netty by netty.

the class AbstractWeightedFairQueueByteDistributorDependencyTest method initState.

void initState(final int streamId, final long pendingBytes, final boolean hasFrame, final boolean isWriteAllowed) {
    final Http2Stream stream = stream(streamId);
    TestStreamByteDistributorStreamState state = new TestStreamByteDistributorStreamState(stream, pendingBytes, hasFrame, isWriteAllowed);
    stateMap.put(streamId, state);
    distributor.updateStreamableBytes(state);
}
Also used : TestStreamByteDistributorStreamState(io.netty.handler.codec.http2.Http2TestUtil.TestStreamByteDistributorStreamState)

Example 2 with TestStreamByteDistributorStreamState

use of io.netty.handler.codec.http2.Http2TestUtil.TestStreamByteDistributorStreamState in project netty by netty.

the class AbstractWeightedFairQueueByteDistributorDependencyTest method writeAnswer.

Answer<Void> writeAnswer(final boolean closeIfNoFrame) {
    return new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock in) throws Throwable {
            Http2Stream stream = in.getArgument(0);
            int numBytes = in.getArgument(1);
            TestStreamByteDistributorStreamState state = stateMap.get(stream.id());
            state.pendingBytes -= numBytes;
            state.hasFrame = state.pendingBytes > 0;
            state.isWriteAllowed = state.hasFrame;
            if (closeIfNoFrame && !state.hasFrame) {
                stream.close();
            }
            distributor.updateStreamableBytes(state);
            return null;
        }
    };
}
Also used : Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) TestStreamByteDistributorStreamState(io.netty.handler.codec.http2.Http2TestUtil.TestStreamByteDistributorStreamState)

Example 3 with TestStreamByteDistributorStreamState

use of io.netty.handler.codec.http2.Http2TestUtil.TestStreamByteDistributorStreamState in project netty by netty.

the class UniformStreamByteDistributorTest method initState.

private void initState(final int streamId, final long pendingBytes, final boolean hasFrame, final boolean isWriteAllowed) {
    final Http2Stream stream = stream(streamId);
    TestStreamByteDistributorStreamState state = new TestStreamByteDistributorStreamState(stream, pendingBytes, hasFrame, isWriteAllowed);
    stateMap.put(streamId, state);
    distributor.updateStreamableBytes(state);
}
Also used : TestStreamByteDistributorStreamState(io.netty.handler.codec.http2.Http2TestUtil.TestStreamByteDistributorStreamState)

Example 4 with TestStreamByteDistributorStreamState

use of io.netty.handler.codec.http2.Http2TestUtil.TestStreamByteDistributorStreamState in project netty by netty.

the class UniformStreamByteDistributorTest method writeAnswer.

private Answer<Void> writeAnswer() {
    return new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock in) throws Throwable {
            Http2Stream stream = in.getArgument(0);
            int numBytes = in.getArgument(1);
            TestStreamByteDistributorStreamState state = stateMap.get(stream.id());
            state.pendingBytes -= numBytes;
            state.hasFrame = state.pendingBytes > 0;
            distributor.updateStreamableBytes(state);
            return null;
        }
    };
}
Also used : Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) TestStreamByteDistributorStreamState(io.netty.handler.codec.http2.Http2TestUtil.TestStreamByteDistributorStreamState)

Aggregations

TestStreamByteDistributorStreamState (io.netty.handler.codec.http2.Http2TestUtil.TestStreamByteDistributorStreamState)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1