Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDecodeMessageWithSingleChunk()
        public virtual void ShouldDecodeMessageWithSingleChunk()
        {
            assertFalse(_channel.writeInbound(wrappedBuffer(new sbyte[] { 1, 2, 3, 4, 5 })));
            assertTrue(_channel.writeInbound(wrappedBuffer(new sbyte[0])));
            assertTrue(_channel.finish());

            assertEquals(1, _channel.inboundMessages().size());
            assertByteBufEquals(wrappedBuffer(new sbyte[] { 1, 2, 3, 4, 5 }), _channel.readInbound());
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleHandshakeFollowedImmediatelyByMessage()
        public virtual void ShouldHandleHandshakeFollowedImmediatelyByMessage()
        {
            // Given
            BoltProtocol        protocol       = NewBoltProtocol(1);
            BoltProtocolFactory handlerFactory = NewProtocolFactory(1, protocol);
            EmbeddedChannel     channel        = new EmbeddedChannel(new ProtocolHandshaker(handlerFactory, _boltChannel, _logProvider, false, true));

            // When
            ByteBuf input = Unpooled.wrappedBuffer(new sbyte[] { ( sbyte )0x60, ( sbyte )0x60, unchecked (( sbyte )0xB0), ( sbyte )0x17 }, new sbyte[] { 0, 0, 0, 0 }, new sbyte[] { 0, 0, 0, 1 }, new sbyte[] { 0, 0, 0, 0 }, new sbyte[] { 0, 0, 0, 0 }, new sbyte[] { 1, 2, 3, 4 });                // this is a message

            channel.writeInbound(input);

            // Then
            assertEquals(1, channel.outboundMessages().size());
            assertByteBufEquals(Unpooled.buffer().writeInt(1), channel.readOutbound());

            assertEquals(1, channel.inboundMessages().size());
            assertByteBufEquals(Unpooled.wrappedBuffer(new sbyte[] { 1, 2, 3, 4 }), channel.readInbound());

            Thrown.expect(typeof(NoSuchElementException));
            channel.pipeline().remove(typeof(ProtocolHandshaker));

            assertTrue(channel.Active);
            verify(protocol).install();
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDecodeFullChunk()
        public virtual void ShouldDecodeFullChunk()
        {
            // whole chunk with header and body arrives at once
            ByteBuf input = buffer();

            input.writeShort(7);
            input.writeByte(1);
            input.writeByte(11);
            input.writeByte(2);
            input.writeByte(22);
            input.writeByte(3);
            input.writeByte(33);
            input.writeByte(4);

            // after buffer is written there should be something to read on the other side
            assertTrue(_channel.writeInbound(input));
            assertTrue(_channel.finish());

            // there should only be a single chunk available for reading
            assertEquals(1, _channel.inboundMessages().size());
            // it should have no size header and expected body
            assertByteBufEquals(input.slice(2, 7), _channel.readInbound());
        }