Esempio n. 1
0
//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: @Test public void shouldLogConnectionResetErrorsAtWarningLevelAndClosesContext() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogConnectionResetErrorsAtWarningLevelAndClosesContext()
        {
            // Given
            ChannelHandlerContext     context = ChannelHandlerContextMock();
            AssertableLogProvider     logging = new AssertableLogProvider();
            TransportSelectionHandler handler = new TransportSelectionHandler(null, null, false, false, logging, null);

            IOException connResetError = new IOException("Connection reset by peer");

            // When
            handler.ExceptionCaught(context, connResetError);

            // Then
            verify(context).close();
            logging.AssertExactly(inLog(typeof(TransportSelectionHandler)).warn("Fatal error occurred when initialising pipeline, " + "remote peer unexpectedly closed connection: %s", context.channel()));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogOnUnexpectedExceptionsAndClosesContext() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogOnUnexpectedExceptionsAndClosesContext()
        {
            // Given
            ChannelHandlerContext     context = ChannelHandlerContextMock();
            AssertableLogProvider     logging = new AssertableLogProvider();
            TransportSelectionHandler handler = new TransportSelectionHandler(null, null, false, false, logging, null);

            // When
            Exception cause = new Exception("Oh no!");

            handler.ExceptionCaught(context, cause);

            // Then
            verify(context).close();
            logging.AssertExactly(inLog(typeof(TransportSelectionHandler)).error(equalTo("Fatal error occurred when initialising pipeline: " + context.channel()), sameInstance(cause)));
        }
Esempio n. 4
0
            public override void initChannel(Channel ch)
            {
                ch.config().Allocator = PooledByteBufAllocator.DEFAULT;

                BoltChannel boltChannel = outerInstance.newBoltChannel(ch);

                _outerInstance.connectionTracker.add(boltChannel);
                ch.closeFuture().addListener(future => _outerInstance.connectionTracker.remove(boltChannel));

                // install throttles
                _outerInstance.throttleGroup.install(ch);

                // add a close listener that will uninstall throttles
                ch.closeFuture().addListener(future => _outerInstance.throttleGroup.uninstall(ch));

                TransportSelectionHandler transportSelectionHandler = new TransportSelectionHandler(boltChannel, _outerInstance.sslCtx, _outerInstance.encryptionRequired, false, _outerInstance.logging, _outerInstance.boltProtocolFactory);

                ch.pipeline().addLast(transportSelectionHandler);
            }