Ejemplo n.º 1
0
        /*
         * Order should not change. New states should be added as higher values and old states should not be replaced.
         */
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveExpectedValues()
        public virtual void ShouldHaveExpectedValues()
        {
            RequestMessageType[] givenStates = RequestMessageType.values();

            RequestMessageType[] exepctedStates = new RequestMessageType[] { TX_PULL_REQUEST, STORE, CORE_SNAPSHOT, STORE_ID, PREPARE_STORE_COPY, STORE_FILE, INDEX_SNAPSHOT, UNKNOWN };
            sbyte[] expectedValues = new sbyte[] { 1, 2, 3, 4, 5, 6, 7, unchecked (( sbyte )404) };

            assertEquals(exepctedStates.Length, givenStates.Length);
            assertEquals(exepctedStates.Length, expectedValues.Length);
            for (int i = 0; i < givenStates.Length; i++)
            {
                RequestMessageType exepctedState = exepctedStates[i];
                RequestMessageType givenState    = givenStates[i];
                assertEquals(format("Expected %s git %s", givenState, exepctedState), givenState.messageType(), exepctedState.messageType());
                assertEquals(givenState.messageType(), expectedValues[i]);
            }
        }
Ejemplo n.º 2
0
        public override void ChannelRead(ChannelHandlerContext ctx, object msg)
        {
            if (_protocol.isExpecting(CatchupServerProtocol.State.MessageType))
            {
                RequestMessageType requestMessageType = RequestMessageType.from((( ByteBuf )msg).readByte());

                if (requestMessageType.Equals(RequestMessageType.TxPullRequest))
                {
                    _protocol.expect(CatchupServerProtocol.State.TxPull);
                }
                else if (requestMessageType.Equals(RequestMessageType.StoreId))
                {
                    _protocol.expect(CatchupServerProtocol.State.GetStoreId);
                }
                else if (requestMessageType.Equals(RequestMessageType.CoreSnapshot))
                {
                    _protocol.expect(CatchupServerProtocol.State.GetCoreSnapshot);
                }
                else if (requestMessageType.Equals(RequestMessageType.PrepareStoreCopy))
                {
                    _protocol.expect(CatchupServerProtocol.State.PrepareStoreCopy);
                }
                else if (requestMessageType.Equals(RequestMessageType.StoreFile))
                {
                    _protocol.expect(CatchupServerProtocol.State.GetStoreFile);
                }
                else if (requestMessageType.Equals(RequestMessageType.IndexSnapshot))
                {
                    _protocol.expect(CatchupServerProtocol.State.GetIndexSnapshot);
                }
                else
                {
                    _log.warn("No handler found for message type %s", requestMessageType);
                }

                ReferenceCountUtil.release(msg);
            }
            else
            {
                ctx.fireChannelRead(msg);
            }
        }