Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRespectThreshold()
        public virtual void ShouldRespectThreshold()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider();
            AssertableLogProvider logProvider = new AssertableLogProvider();
            ExecutingQuery        query       = query(_session_1, "TestUser", QUERY_1);
            ConfiguredQueryLogger queryLogger = queryLogger(logProvider);

            // when
            _clock.forward(9, TimeUnit.MILLISECONDS);
            queryLogger.Success(query);

            // then
            logProvider.AssertNoLoggingOccurred();

            // and when
            ExecutingQuery query2 = query(_session_2, "TestUser2", QUERY_2);

            _thresholdInMillis = 5;
            queryLogger        = queryLogger(logProvider);          // Rebuild queryLogger, like the DynamicQueryLogger would.
            _clock.forward(9, TimeUnit.MILLISECONDS);
            queryLogger.Success(query2);

            // then
            string expectedSessionString = SessionConnectionDetails(_session_2, "TestUser2");

            logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 9L, expectedSessionString, QUERY_2)));
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotLogExceptionsWhenEvenLoopIsShuttingDown() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotLogExceptionsWhenEvenLoopIsShuttingDown()
        {
            AssertableLogProvider logProvider = new AssertableLogProvider();
            BoltConnection        connection  = mock(typeof(BoltConnection));
            HouseKeeper           houseKeeper = new HouseKeeper(connection, logProvider.GetLog(typeof(HouseKeeper)));
            Bootstrap             bootstrap   = NewBootstrap(houseKeeper);

            try
            {
                using (ServerSocket serverSocket = new ServerSocket(0))
                {
                    ChannelFuture future  = bootstrap.connect("localhost", serverSocket.LocalPort).sync();
                    Channel       channel = future.channel();

                    // write some messages without flushing
                    for (int i = 0; i < 100; i++)
                    {
                        // use void promise which should redirect all write errors back to the pipeline and the HouseKeeper
                        channel.write(writeUtf8(channel.alloc(), "Hello"), channel.voidPromise());
                    }

                    // stop the even loop to make all pending writes fail
                    bootstrap.config().group().shutdownGracefully();
                    // await for the channel to be closed by the HouseKeeper
                    channel.closeFuture().sync();
                }
            }
            finally
            {
                // make sure event loop group is always terminated
                bootstrap.config().group().shutdownGracefully().sync();
            }

            logProvider.AssertNoLoggingOccurred();
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void onlyDatabaseErrorsAreLogged()
        public virtual void OnlyDatabaseErrorsAreLogged()
        {
            AssertableLogProvider userLog     = new AssertableLogProvider();
            AssertableLogProvider internalLog = new AssertableLogProvider();
            ErrorReporter         reporter    = NewErrorReporter(userLog, internalLog);

            foreach (Org.Neo4j.Kernel.Api.Exceptions.Status_Classification classification in Enum.GetValues(typeof(Org.Neo4j.Kernel.Api.Exceptions.Status_Classification)))
            {
                if (classification != Org.Neo4j.Kernel.Api.Exceptions.Status_Classification.DatabaseError)
                {
                    Org.Neo4j.Kernel.Api.Exceptions.Status_Code code = NewStatusCode(classification);
                    Neo4jError error = Neo4jError.from(() => code, "Database error");
                    reporter.Report(error);

                    userLog.AssertNoLoggingOccurred();
                    internalLog.AssertNoLoggingOccurred();
                }
            }
        }
Exemple #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @MethodSource("parameters") void shouldLogAsynchronously(Invocation invocation, Level level, Style style)
        internal virtual void ShouldLogAsynchronously(Invocation invocation, Level level, Style style)
        {
            // given
            AssertableLogProvider logging = new AssertableLogProvider();
            Log            log            = logging.getLog(this.GetType());
            DeferredSender events         = new DeferredSender();
            AsyncLog       asyncLog       = new AsyncLog(events, log);

            // when
            log(invocation.decorate(asyncLog), level, style);
            // then
            logging.AssertNoLoggingOccurred();

            // when
            events.Process();
            // then
            MatcherBuilder matcherBuilder = new MatcherBuilder(inLog(this.GetType()));

            log(matcherBuilder, level, style);
            logging.AssertExactly(matcherBuilder.Matcher());
        }