Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEncodeAndDecodeVoteRequest()
        public virtual void ShouldEncodeAndDecodeVoteRequest()
        {
            // given
            MemberId member = new MemberId(System.Guid.randomUUID());

            Org.Neo4j.causalclustering.core.consensus.RaftMessages_Vote_Request request = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Vote_Request(member, 1, member, 1, 1);

            // when
            _channel.writeOutbound(request);
            object message = _channel.readOutbound();

            _channel.writeInbound(message);

            // then
            assertEquals(request, _channel.readInbound());
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGiveErrorResponseIfStoreMismatch()
        public virtual void ShouldGiveErrorResponseIfStoreMismatch()
        {
            // given store id doesn't match

            // when PrepareStoreCopyRequest is written to channel
            _embeddedChannel.writeInbound(new PrepareStoreCopyRequest(_storeIdMismatching));

            // then there is a store id mismatch message
            assertEquals(ResponseMessageType.PREPARE_STORE_COPY_RESPONSE, _embeddedChannel.readOutbound());
            PrepareStoreCopyResponse response = PrepareStoreCopyResponse.Error(PrepareStoreCopyResponse.Status.EStoreIdMismatch);

            assertEquals(response, _embeddedChannel.readOutbound());

            // and the expected message type is reset back to message type
            assertTrue(_catchupServerProtocol.isExpecting(CatchupServerProtocol.State.MESSAGE_TYPE));
        }
//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();
        }
Exemple #4
0
        private static void SendToChannel(GetStoreFileRequest getStoreFileRequest, EmbeddedChannel embeddedChannel)
        {
            embeddedChannel.writeOutbound(getStoreFileRequest);

            ByteBuf @object = embeddedChannel.readOutbound();

            embeddedChannel.writeInbound(@object);
        }
Exemple #5
0
        public static void SendToChannel <E>(E e, EmbeddedChannel embeddedChannel)
        {
            embeddedChannel.writeOutbound(e);

            ByteBuf @object = embeddedChannel.readOutbound();

            embeddedChannel.writeInbound(@object);
        }
Exemple #6
0
        private static void SendToChannel(GetIndexFilesRequest expectedIndexSnapshotRequest, EmbeddedChannel embeddedChannel)
        {
            embeddedChannel.writeOutbound(expectedIndexSnapshotRequest);

            ByteBuf @object = embeddedChannel.readOutbound();

            embeddedChannel.writeInbound(@object);
        }
Exemple #7
0
        private static void SendToChannel(PrepareStoreCopyResponse prepareStoreCopyResponse, EmbeddedChannel embeddedChannel)
        {
            embeddedChannel.writeOutbound(prepareStoreCopyResponse);

            ByteBuf @object = embeddedChannel.readOutbound();

            embeddedChannel.writeInbound(@object);
        }
Exemple #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteOnNettyChannel()
        public virtual void ShouldWriteOnNettyChannel()
        {
            // given
            SimpleNettyChannel channel = new SimpleNettyChannel(_nettyChannel, NullLog.Instance);

            // when
            object        msg           = new object();
            Future <Void> writeComplete = channel.Write(msg);

            // then
            assertNull(_nettyChannel.readOutbound());
            assertFalse(writeComplete.Done);

            // when
            _nettyChannel.flush();

            // then
            assertTrue(writeComplete.Done);
            assertEquals(msg, _nettyChannel.readOutbound());
        }
Exemple #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEncodeAndDecodePullRequestMessage()
        public virtual void ShouldEncodeAndDecodePullRequestMessage()
        {
            // given
            EmbeddedChannel           channel = new EmbeddedChannel(new StoreCopyFinishedResponseEncoder(), new StoreCopyFinishedResponseDecoder());
            StoreCopyFinishedResponse sent    = new StoreCopyFinishedResponse(Status.E_STORE_ID_MISMATCH);

            // when
            channel.writeOutbound(sent);
            object message = channel.readOutbound();

            channel.writeInbound(message);

            // then
            StoreCopyFinishedResponse received = channel.readInbound();

            assertNotSame(sent, received);
            assertEquals(sent, received);
        }
Exemple #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEncodeAndDecodePullResponseMessage()
        public virtual void ShouldEncodeAndDecodePullResponseMessage()
        {
            // given
            EmbeddedChannel channel = new EmbeddedChannel(new TxPullResponseEncoder(), new TxPullResponseDecoder());
            TxPullResponse  sent    = new TxPullResponse(new StoreId(1, 2, 3, 4), NewCommittedTransactionRepresentation());

            // when
            channel.writeOutbound(sent);
            object message = channel.readOutbound();

            channel.writeInbound(message);

            // then
            TxPullResponse received = channel.readInbound();

            assertNotSame(sent, received);
            assertEquals(sent, received);
        }
Exemple #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEncodeAndDecodePullRequestMessage()
        public virtual void ShouldEncodeAndDecodePullRequestMessage()
        {
            // given
            EmbeddedChannel          channel = new EmbeddedChannel(new TxStreamFinishedResponseEncoder(), new TxStreamFinishedResponseDecoder());
            TxStreamFinishedResponse sent    = new TxStreamFinishedResponse(SUCCESS_END_OF_STREAM, 1000);

            // when
            channel.writeOutbound(sent);
            object message = channel.readOutbound();

            channel.writeInbound(message);

            // then
            TxStreamFinishedResponse received = channel.readInbound();

            assertNotSame(sent, received);
            assertEquals(sent, received);
        }
Exemple #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEncodeAndDecodePullRequestMessage()
        public virtual void ShouldEncodeAndDecodePullRequestMessage()
        {
            // given
            EmbeddedChannel channel     = new EmbeddedChannel(new TxPullRequestEncoder(), new TxPullRequestDecoder());
            const long      arbitraryId = 23;
            TxPullRequest   sent        = new TxPullRequest(arbitraryId, new StoreId(1, 2, 3, 4));

            // when
            channel.writeOutbound(sent);
            object message = channel.readOutbound();

            channel.writeInbound(message);

            // then
            TxPullRequest received = channel.readInbound();

            assertNotSame(sent, received);
            assertEquals(sent, received);
        }
//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();
        }
//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();
        }