示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleFragmentedMessage()
        public virtual void ShouldHandleFragmentedMessage()
        {
            // Given
            BoltProtocol        protocol       = NewBoltProtocol(1);
            BoltProtocolFactory handlerFactory = NewProtocolFactory(1, protocol);
            EmbeddedChannel     channel        = new EmbeddedChannel(new ProtocolHandshaker(handlerFactory, _boltChannel, _logProvider, false, true));

            // When
            channel.writeInbound(Unpooled.wrappedBuffer(new sbyte[] { ( sbyte )0x60, ( sbyte )0x60, unchecked (( sbyte )0xB0) }));
            assertEquals(0, channel.outboundMessages().size());
            channel.writeInbound(Unpooled.wrappedBuffer(new sbyte[] { ( sbyte )0x17, 0, 0, 0 }));
            assertEquals(0, channel.outboundMessages().size());
            channel.writeInbound(Unpooled.wrappedBuffer(new sbyte[] { 0, 0, 0 }));
            assertEquals(0, channel.outboundMessages().size());
            channel.writeInbound(Unpooled.wrappedBuffer(new sbyte[] { 0, 1, 0, 0, 0 }));
            assertEquals(0, channel.outboundMessages().size());
            channel.writeInbound(Unpooled.wrappedBuffer(new sbyte[] { 0, 0, 0 }));
            assertEquals(0, channel.outboundMessages().size());
            channel.writeInbound(Unpooled.wrappedBuffer(new sbyte[] { 0, 0 }));

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

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

            assertTrue(channel.Active);
            verify(protocol).install();
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRejectIfInsecureWhenEncryptionRequired()
        public virtual void ShouldRejectIfInsecureWhenEncryptionRequired()
        {
            // Given
            BoltProtocol        protocol       = NewBoltProtocol(1);
            BoltProtocolFactory handlerFactory = NewProtocolFactory(1, protocol);
            EmbeddedChannel     channel        = new EmbeddedChannel(new ProtocolHandshaker(handlerFactory, _boltChannel, _logProvider, true, false));

            // When
            ByteBuf input = Unpooled.wrappedBuffer(new sbyte[] { ( sbyte )0x60, ( sbyte )0x60, unchecked (( sbyte )0xB0), ( sbyte )0x17 }, new sbyte[] { 0, 0, 0, 1 }, new sbyte[] { 0, 0, 0, 2 }, new sbyte[] { 0, 0, 0, 3 }, new sbyte[] { 0, 0, 0, 4 });                 // fourth choice - no protocol

            channel.writeInbound(input);

            // Then
            assertEquals(0, channel.outboundMessages().size());
            assertFalse(channel.Active);
            verify(protocol, never()).install();
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFallbackToNoProtocolIfNoMatch()
        public virtual void ShouldFallbackToNoProtocolIfNoMatch()
        {
            // 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, 2 }, new sbyte[] { 0, 0, 0, 3 }, new sbyte[] { 0, 0, 0, 4 });                 // fourth choice - no protocol

            channel.writeInbound(input);

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

            assertFalse(channel.Active);
            verify(protocol, never()).install();
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleMaxVersionNumber()
        public virtual void ShouldHandleMaxVersionNumber()
        {
            long maxVersionNumber = 4_294_967_295L;

            // Given
            BoltProtocol        protocol       = NewBoltProtocol(maxVersionNumber);
            BoltProtocolFactory handlerFactory = NewProtocolFactory(maxVersionNumber, 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[] { unchecked (( sbyte )0xFF), unchecked (( sbyte )0xFF), unchecked (( sbyte )0xFF), unchecked (( sbyte )0xFF) }, new sbyte[] { 0, 0, 0, 0 }, new sbyte[] { 0, 0, 0, 0 }, new sbyte[] { 0, 0, 0, 0 });                         // fourth choice - no protocol

            channel.writeInbound(input);

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

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

            assertTrue(channel.Active);
            verify(protocol).install();
        }