Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldKeepTrackOfDifferentSessions()
        public virtual void ShouldKeepTrackOfDifferentSessions()
        {
            // 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        query1      = Query(_session_1, "TestUser1", QUERY_1);

            _clock.forward(1, TimeUnit.MILLISECONDS);
            ExecutingQuery query2 = Query(_session_2, "TestUser2", QUERY_2);

            _clock.forward(1, TimeUnit.MILLISECONDS);
            ExecutingQuery query3 = Query(_session_3, "TestUser3", QUERY_3);

            ConfiguredQueryLogger queryLogger = queryLogger(logProvider);

            // when
            _clock.forward(1, TimeUnit.MILLISECONDS);
            _clock.forward(1, TimeUnit.MILLISECONDS);
            _clock.forward(7, TimeUnit.MILLISECONDS);
            queryLogger.Success(query3);
            _clock.forward(7, TimeUnit.MILLISECONDS);
            queryLogger.Success(query2);
            _clock.forward(7, TimeUnit.MILLISECONDS);
            queryLogger.Success(query1);

            // then
            string expectedSession1String = SessionConnectionDetails(_session_1, "TestUser1");
            string expectedSession2String = SessionConnectionDetails(_session_2, "TestUser2");

            logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 17L, expectedSession2String, QUERY_2)), inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 25L, expectedSession1String, QUERY_1)));
        }
Example #2
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)));
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogUserName()
        public virtual void ShouldLogUserName()
        {
            // 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();
            ConfiguredQueryLogger queryLogger = queryLogger(logProvider);

            // when
            ExecutingQuery query = query(_session_1, "TestUser", QUERY_1);

            _clock.forward(10, TimeUnit.MILLISECONDS);
            queryLogger.Success(query);

            ExecutingQuery anotherQuery = query(_session_1, "AnotherUser", QUERY_1);

            _clock.forward(10, TimeUnit.MILLISECONDS);
            queryLogger.Success(anotherQuery);

            // then
            logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 10L, SessionConnectionDetails(_session_1, "TestUser"), QUERY_1)), inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 10L, SessionConnectionDetails(_session_1, "AnotherUser"), QUERY_1)));
        }
Example #4
0
        private void RunAndCheck(string inputQuery, string outputQuery, IDictionary <string, object> @params, string paramsString)
        {
//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();
            ConfiguredQueryLogger queryLogger = queryLogger(logProvider, Config.defaults(GraphDatabaseSettings.log_queries_parameter_logging_enabled, "true"));

            // when
            ExecutingQuery query = query(_session_1, "neo", inputQuery, @params, emptyMap());

            _clock.forward(10, TimeUnit.MILLISECONDS);
            queryLogger.Success(query);

            // then
            logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {%s} - {}", 10L, SessionConnectionDetails(_session_1, "neo"), outputQuery, paramsString)));
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToLogAllocatedBytes()
        public virtual void ShouldBeAbleToLogAllocatedBytes()
        {
            // 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();
            ConfiguredQueryLogger queryLogger = queryLogger(logProvider, Config.defaults(GraphDatabaseSettings.log_queries_allocation_logging_enabled, "true"));
            ExecutingQuery        query       = query(_session_1, "TestUser", QUERY_1);

            // when
            _clock.forward(17, TimeUnit.MILLISECONDS);
            HeapAllocation.add(4096);
            queryLogger.Success(query);

            // then
            logProvider.AssertExactly(inLog(this.GetType()).info(containsString("ms: 4096 B - ")));
        }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogQuerySlowerThanThreshold()
        public virtual void ShouldLogQuerySlowerThanThreshold()
        {
            // 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(11, TimeUnit.MILLISECONDS);
            queryLogger.Success(query);

            // then
            string expectedSessionString = SessionConnectionDetails(_session_1, "TestUser");

            logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 11L, expectedSessionString, QUERY_1)));
        }
Example #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogQueryParameters()
        public virtual void ShouldLogQueryParameters()
        {
            // 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();
            IDictionary <string, object> @params     = new Dictionary <string, object>();

            @params["ages"] = Arrays.asList(41, 42, 43);
            ExecutingQuery        query       = query(_session_1, "TestUser", QUERY_4, @params, emptyMap());
            ConfiguredQueryLogger queryLogger = queryLogger(logProvider, Config.defaults(GraphDatabaseSettings.log_queries_parameter_logging_enabled, "true"));

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

            // then
            string expectedSessionString = SessionConnectionDetails(_session_1, "TestUser");

            logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - %s - {}", 11L, expectedSessionString, QUERY_4, "{ages: " + "[41, 42, 43]}")));
        }
Example #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogMetaData()
        public virtual void ShouldLogMetaData()
        {
            // 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();
            ConfiguredQueryLogger queryLogger = queryLogger(logProvider);

            // when
            ExecutingQuery query = query(_session_1, "TestUser", QUERY_1, emptyMap(), map("User", "UltiMate"));

            _clock.forward(10, TimeUnit.MILLISECONDS);
            queryLogger.Success(query);

            ExecutingQuery anotherQuery = query(_session_1, "AnotherUser", QUERY_1, emptyMap(), map("Place", "Town"));

            _clock.forward(10, TimeUnit.MILLISECONDS);
            Exception error = new Exception();

            queryLogger.Failure(anotherQuery, error);

            // then
            logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {User: '******'}", 10L, SessionConnectionDetails(_session_1, "TestUser"), QUERY_1)), inLog(this.GetType()).error(equalTo(format("%d ms: %s - %s - {Place: 'Town'}", 10L, SessionConnectionDetails(_session_1, "AnotherUser"), QUERY_1)), sameInstance(error)));
        }