Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDecodeMaxSizeChunk()
        public virtual void ShouldDecodeMaxSizeChunk()
        {
            sbyte[] message = new sbyte[0xFFFF];

            ByteBuf input = buffer();

            input.writeShort(message.Length);
            input.writeBytes(message);

            assertTrue(_channel.writeInbound(input));
            assertTrue(_channel.finish());

            assertEquals(1, _channel.inboundMessages().size());
            assertByteBufEquals(wrappedBuffer(message), _channel.readInbound());
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDecodeSplitChunk()
        public virtual void ShouldDecodeSplitChunk()
        {
            // first part of the chunk contains size header and some bytes
            ByteBuf input1 = buffer();

            input1.writeShort(9);
            input1.writeByte(1);
            input1.writeByte(11);
            input1.writeByte(2);
            // nothing should be available for reading
            assertFalse(_channel.writeInbound(input1));

            // second part contains just a single byte
            ByteBuf input2 = buffer();

            input2.writeByte(22);
            // nothing should be available for reading
            assertFalse(_channel.writeInbound(input2));

            // third part contains couple more bytes
            ByteBuf input3 = buffer();

            input3.writeByte(3);
            input3.writeByte(33);
            input3.writeByte(4);
            // nothing should be available for reading
            assertFalse(_channel.writeInbound(input3));

            // fourth part contains couple more bytes, and the chunk is now complete
            ByteBuf input4 = buffer();

            input4.writeByte(44);
            input4.writeByte(5);
            // there should be something to read now
            assertTrue(_channel.writeInbound(input4));

            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(wrappedBuffer(new sbyte[] { 1, 11, 2, 22, 3, 33, 4, 44, 5 }), _channel.readInbound());
        }
Example #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());
        }
Example #4
0
 public override WritableChannel PutShort(short value)
 {
     @delegate.writeShort(value);
     return(this);
 }
Example #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.storageengine.api.WritableChannel putShort(short value) throws MessageTooBigException
        public override WritableChannel PutShort(short value)
        {
            CheckSize(Short.BYTES);
            @delegate.writeShort(value);
            return(this);
        }