Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogQueryOnFailureEvenIfFasterThanThreshold()
        public virtual void ShouldLogQueryOnFailureEvenIfFasterThanThreshold()
        {
            // 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);
            Exception             failure     = new Exception();

            // when
            _clock.forward(1, TimeUnit.MILLISECONDS);
            queryLogger.Failure(query, failure);

            // then
            logProvider.AssertExactly(inLog(this.GetType()).error(@is("1 ms: " + SessionConnectionDetails(_session_1, "TestUser") + " - MATCH (n) RETURN n - {}"), sameInstance(failure)));
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogQueryParametersOnFailure()
        public virtual void ShouldLogQueryParametersOnFailure()
        {
            // 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"));
            Exception             failure     = new Exception();

            // when
            _clock.forward(1, TimeUnit.MILLISECONDS);
            queryLogger.Failure(query, failure);

            // then
            logProvider.AssertExactly(inLog(this.GetType()).error(@is("1 ms: " + SessionConnectionDetails(_session_1, "TestUser") + " - MATCH (n) WHERE n.age IN {ages} RETURN n - {ages: [41, 42, 43]} - {}"), sameInstance(failure)));
        }
Esempio n. 3
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)));
        }