//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 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(); }
//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()); }
public static void SendToChannel <E>(E e, EmbeddedChannel embeddedChannel) { embeddedChannel.writeOutbound(e); ByteBuf @object = embeddedChannel.readOutbound(); embeddedChannel.writeInbound(@object); }
private static void SendToChannel(GetIndexFilesRequest expectedIndexSnapshotRequest, EmbeddedChannel embeddedChannel) { embeddedChannel.writeOutbound(expectedIndexSnapshotRequest); ByteBuf @object = embeddedChannel.readOutbound(); embeddedChannel.writeInbound(@object); }
private static void SendToChannel(GetStoreFileRequest getStoreFileRequest, EmbeddedChannel embeddedChannel) { embeddedChannel.writeOutbound(getStoreFileRequest); ByteBuf @object = embeddedChannel.readOutbound(); embeddedChannel.writeInbound(@object); }
private static void SendToChannel(PrepareStoreCopyResponse prepareStoreCopyResponse, EmbeddedChannel embeddedChannel) { embeddedChannel.writeOutbound(prepareStoreCopyResponse); ByteBuf @object = embeddedChannel.readOutbound(); embeddedChannel.writeInbound(@object); }
//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(); }
//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); }
//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); }
//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); }
//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 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 shouldRejectIfHttp() public virtual void ShouldRejectIfHttp() { // Given BoltProtocol protocol = NewBoltProtocol(1); BoltProtocolFactory handlerFactory = NewProtocolFactory(1, protocol); EmbeddedChannel channel = new EmbeddedChannel(new ProtocolHandshaker(handlerFactory, _boltChannel, _logProvider, false, true)); // When FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://hello_world:10000"); request.headers().setInt(HttpHeaderNames.CONTENT_LENGTH, 0); channel.writeInbound(request); // Then assertEquals(0, channel.outboundMessages().size()); assertFalse(channel.Active); verify(protocol, never()).install(); _logProvider.assertExactly(AssertableLogProvider.inLog(typeof(ProtocolHandshaker)).warn("Unsupported connection type: 'HTTP'. Bolt protocol only operates over a TCP connection or WebSocket.")); }
//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(); }
//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()); }
//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()); }