Beispiel #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());
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void transactionIdGetsTransmitted()
        public virtual void TransactionIdGetsTransmitted()
        {
            // given
            long transactionId = long.MaxValue;

            // when a transaction id is serialised
            PrepareStoreCopyResponse prepareStoreCopyResponse = PrepareStoreCopyResponse.Success(new File[0], LongSets.immutable.empty(), transactionId);

            SendToChannel(prepareStoreCopyResponse, _embeddedChannel);

            // then it can be deserialised
            PrepareStoreCopyResponse readPrepareStoreCopyResponse = _embeddedChannel.readInbound();

            assertEquals(prepareStoreCopyResponse.LastTransactionId(), readPrepareStoreCopyResponse.LastTransactionId());
        }
Beispiel #3
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());
        }
//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();
        }
Beispiel #5
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());
        }
Beispiel #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void storeIdIsTransmitted()
        public virtual void StoreIdIsTransmitted()
        {
            // given store id requests transmit store id
            StoreId storeId = new StoreId(1, 2, 3, 4);
            PrepareStoreCopyRequest prepareStoreCopyRequest = new PrepareStoreCopyRequest(storeId);

            // when transmitted
            SendToChannel(prepareStoreCopyRequest, EmbeddedChannel);

            // then it can be received/deserialised
            PrepareStoreCopyRequest prepareStoreCopyRequestRead = EmbeddedChannel.readInbound();

            assertEquals(prepareStoreCopyRequest.StoreId, prepareStoreCopyRequestRead.StoreId);
        }
Beispiel #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getsTransmitted()
        public virtual void GetsTransmitted()
        {
            // given
            GetStoreFileRequest expectedStoreRequest = new GetStoreFileRequest(_expectedStore, _expectedFile, EXPECTED_LAST_TRANSACTION.Value);

            // when
            SendToChannel(expectedStoreRequest, EmbeddedChannel);

            // then
            GetStoreFileRequest actualStoreRequest = EmbeddedChannel.readInbound();

            assertEquals(_expectedStore, actualStoreRequest.ExpectedStoreId());
            assertEquals(_expectedFile, actualStoreRequest.File());
            assertEquals(EXPECTED_LAST_TRANSACTION.Value, actualStoreRequest.RequiredTransactionId());
        }
Beispiel #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getsTransmitted()
        public virtual void GetsTransmitted()
        {
            // given
            GetIndexFilesRequest expectedIndexSnapshotRequest = new GetIndexFilesRequest(_expectedStore, EXEPCTED_INDEX_ID, EXPECTED_LAST_TRANSACTION.Value);

            // when
            SendToChannel(expectedIndexSnapshotRequest, _embeddedChannel);

            // then
            GetIndexFilesRequest actualIndexRequest = _embeddedChannel.readInbound();

            assertEquals(_expectedStore, actualIndexRequest.ExpectedStoreId());
            assertEquals(EXEPCTED_INDEX_ID, actualIndexRequest.IndexId());
            assertEquals(EXPECTED_LAST_TRANSACTION.Value, actualIndexRequest.RequiredTransactionId());
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }