//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(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest(name = "V{0}") @ValueSource(longs = {org.neo4j.bolt.v1.BoltProtocolV1.VERSION, org.neo4j.bolt.v2.BoltProtocolV2.VERSION, org.neo4j.bolt.v3.BoltProtocolV3.VERSION}) void shouldCreateBoltProtocol(long protocolVersion) throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldCreateBoltProtocol(long protocolVersion) { EmbeddedChannel channel = new EmbeddedChannel(); BoltChannel boltChannel = new BoltChannel("bolt-1", "bolt", channel); BoltStateMachineFactory stateMachineFactory = mock(typeof(BoltStateMachineFactory)); BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); when(stateMachineFactory.NewStateMachine(protocolVersion, boltChannel)).thenReturn(stateMachine); BoltConnectionFactory connectionFactory = mock(typeof(BoltConnectionFactory)); BoltConnection connection = mock(typeof(BoltConnection)); when(connectionFactory.NewConnection(boltChannel, stateMachine)).thenReturn(connection); BoltProtocolFactory factory = new DefaultBoltProtocolFactory(connectionFactory, stateMachineFactory, NullLogService.Instance); BoltProtocol protocol = factory(protocolVersion, boltChannel); protocol.Install(); // handler with correct version is created assertEquals(protocolVersion, protocol.Version()); // it uses the expected worker verify(connectionFactory).newConnection(eq(boltChannel), any(typeof(BoltStateMachine))); // and halts this same worker when closed verify(connection, never()).stop(); channel.close(); verify(connection).stop(); channel.finishAndReleaseAll(); }
public static void SendToChannel <E>(E e, EmbeddedChannel embeddedChannel) { embeddedChannel.writeOutbound(e); 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); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { _channel = new EmbeddedChannel(); _log = mock(typeof(Log)); _connection = mock(typeof(BoltConnection)); when(_connection.id()).thenReturn(_channel.id().asLongText()); when(_connection.channel()).thenReturn(_channel); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldInstallTransportSelectionHandler() internal virtual void ShouldInstallTransportSelectionHandler() { SocketTransport socketTransport = NewSocketTransport(NetworkConnectionTracker.NO_OP, NO_THROTTLE); EmbeddedChannel channel = new EmbeddedChannel(socketTransport.ChannelInitializer()); TransportSelectionHandler handler = channel.pipeline().get(typeof(TransportSelectionHandler)); assertNotNull(handler); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @After public void cleanUp() public virtual void CleanUp() { if (_outbound != null) { _outbound.close(); } if (_inbound != null) { _inbound.close(); } _outbound = _inbound = null; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { Dependencies dependencies = new Dependencies(); dependencies.SatisfyDependency(_checkPointer); StoreCopyCheckPointMutex storeCopyCheckPointMutex = new StoreCopyCheckPointMutex(); when(_neoStoreDataSource.StoreCopyCheckPointMutex).thenReturn(storeCopyCheckPointMutex); when(_neoStoreDataSource.DependencyResolver).thenReturn(dependencies); PrepareStoreCopyRequestHandler subject = CreateHandler(); _embeddedChannel = new EmbeddedChannel(subject); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldManageThrottlersInChannelInitializer() internal virtual void ShouldManageThrottlersInChannelInitializer() { TransportThrottleGroup throttleGroup = mock(typeof(TransportThrottleGroup)); SocketTransport socketTransport = NewSocketTransport(NetworkConnectionTracker.NO_OP, throttleGroup); EmbeddedChannel channel = new EmbeddedChannel(socketTransport.ChannelInitializer()); verify(throttleGroup).install(channel); verify(throttleGroup, never()).uninstall(channel); channel.close(); verify(throttleGroup).uninstall(channel); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldManageChannelsInChannelInitializer() internal virtual void ShouldManageChannelsInChannelInitializer() { NetworkConnectionTracker connectionTracker = mock(typeof(NetworkConnectionTracker)); SocketTransport socketTransport = NewSocketTransport(connectionTracker, NO_THROTTLE); EmbeddedChannel channel = new EmbeddedChannel(socketTransport.ChannelInitializer()); ArgumentCaptor <TrackedNetworkConnection> captor = ArgumentCaptor.forClass(typeof(TrackedNetworkConnection)); verify(connectionTracker).add(captor.capture()); verify(connectionTracker, never()).remove(any()); channel.close(); verify(connectionTracker).remove(captor.Value); }
//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 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 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 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 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 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: @Before public void setupChannels() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SetupChannels() { _outbound = new EmbeddedChannel(); _inbound = new EmbeddedChannel(); if (RaftProtocol == 2) { (new RaftProtocolClientInstallerV2(new NettyPipelineBuilderFactory(VoidPipelineWrapperFactory.VOID_WRAPPER), Collections.emptyList(), FormattedLogProvider.toOutputStream(System.out))).install(_outbound); (new RaftProtocolServerInstallerV2(_handler, new NettyPipelineBuilderFactory(VoidPipelineWrapperFactory.VOID_WRAPPER), Collections.emptyList(), FormattedLogProvider.toOutputStream(System.out))).install(_inbound); } else if (RaftProtocol == 1) { (new RaftProtocolClientInstallerV1(new NettyPipelineBuilderFactory(VoidPipelineWrapperFactory.VOID_WRAPPER), Collections.emptyList(), FormattedLogProvider.toOutputStream(System.out))).install(_outbound); (new RaftProtocolServerInstallerV1(_handler, new NettyPipelineBuilderFactory(VoidPipelineWrapperFactory.VOID_WRAPPER), Collections.emptyList(), FormattedLogProvider.toOutputStream(System.out))).install(_inbound); } else { throw new System.ArgumentException("Unknown raft protocol " + RaftProtocol); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @SuppressWarnings("deprecation") void shouldExposeClientConnectionInfo() internal virtual void ShouldExposeClientConnectionInfo() { EmbeddedChannel channel = new EmbeddedChannel(); BoltChannel boltChannel = new BoltChannel("bolt-42", "my-bolt", channel); ClientConnectionInfo info1 = boltChannel.Info(); assertEquals("bolt-42", info1.ConnectionId()); assertEquals("bolt", info1.Protocol()); assertEquals(SocketAddress.format(channel.remoteAddress()), info1.ClientAddress()); boltChannel.UpdateUser("Tom", "my-driver"); ClientConnectionInfo info2 = boltChannel.Info(); assertEquals("bolt-42", info2.ConnectionId()); assertEquals("bolt", info2.Protocol()); assertEquals(SocketAddress.format(channel.remoteAddress()), info2.ClientAddress()); assertThat(info2.AsConnectionDetails(), containsString("Tom")); assertThat(info2.AsConnectionDetails(), containsString("my-driver")); }
//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: @Before public void setup() public virtual void Setup() { _channel = new EmbeddedChannel(new RaftMessageEncoder(serializer), new RaftMessageDecoder(serializer, Clock.systemUTC())); }
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: @Before public void setup() public virtual void Setup() { _embeddedChannel = new EmbeddedChannel(new PrepareStoreCopyResponse.Encoder(), new PrepareStoreCopyResponse.Decoder()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { EmbeddedChannel = new EmbeddedChannel(new GetStoreFileRequest.Encoder(), new GetStoreFileRequest.Decoder()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { _embeddedChannel = new EmbeddedChannel(new GetIndexFilesRequest.Encoder(), new GetIndexFilesRequest.Decoder()); }
private static void SendToChannel(GetIndexFilesRequest expectedIndexSnapshotRequest, EmbeddedChannel embeddedChannel) { embeddedChannel.writeOutbound(expectedIndexSnapshotRequest); 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: @Before public void setup() public virtual void Setup() { EmbeddedChannel = new EmbeddedChannel(new PrepareStoreCopyRequestEncoder(), new PrepareStoreCopyRequestDecoder()); }