コード例 #1
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 - ")));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogDatabasePanicEvent()
        public virtual void ShouldLogDatabasePanicEvent()
        {
            // GIVEN
            AssertableLogProvider logProvider    = new AssertableLogProvider();
            DatabaseHealth        databaseHealth = new DatabaseHealth(mock(typeof(DatabasePanicEventGenerator)), logProvider.GetLog(typeof(DatabaseHealth)));

            databaseHealth.Healed();

            // WHEN
            string    message   = "Listen everybody... panic!";
            Exception exception = new Exception(message);

            databaseHealth.Panic(exception);

            // THEN
            logProvider.AssertAtLeastOnce(inLog(typeof(DatabaseHealth)).error(@is("Database panic: The database has encountered a critical error, " + "and needs to be restarted. Please see database logs for more details."), sameInstance(exception)));
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SetUp()
        {
            _log = new AssertableLogProvider();
            SecurityLog securityLog = new SecurityLog(_log.getLog(this.GetType()));

            AuthProcedures             = new TestUserManagementProcedures();
            AuthProcedures.graph       = mock(typeof(GraphDatabaseAPI));
            AuthProcedures.securityLog = securityLog;

            _generalUserManager = UserManager;
            EnterpriseSecurityContext adminContext = new EnterpriseSecurityContext(new MockAuthSubject("admin"), [email protected]_Static.Full, Collections.emptySet(), true);

            _matsContext = new EnterpriseSecurityContext(new MockAuthSubject("mats"), [email protected]_Static.None, Collections.emptySet(), false);

            Subject = adminContext;
            _log.clear();
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogFirstHeartbeatAfterTimeout()
        public virtual void ShouldLogFirstHeartbeatAfterTimeout()
        {
            // given
            InstanceId           instanceId    = new InstanceId(1);
            InstanceId           otherInstance = new InstanceId(2);
            ClusterConfiguration configuration = new ClusterConfiguration("whatever", NullLogProvider.Instance, "cluster://1", "cluster://2");

            configuration.Members[otherInstance] = URI.create("cluster://2");
            AssertableLogProvider internalLog     = new AssertableLogProvider(true);
            TimeoutStrategy       timeoutStrategy = mock(typeof(TimeoutStrategy));
            Timeouts timeouts = new Timeouts(timeoutStrategy);

            Config config = mock(typeof(Config));

            when(config.Get(ClusterSettings.max_acceptors)).thenReturn(10);

            MultiPaxosContext context = new MultiPaxosContext(instanceId, iterable(new ElectionRole("coordinator")), configuration, mock(typeof(Executor)), internalLog, mock(typeof(ObjectInputStreamFactory)), mock(typeof(ObjectOutputStreamFactory)), mock(typeof(AcceptorInstanceStore)), timeouts, mock(typeof(ElectionCredentialsProvider)), config);

            StateMachines stateMachines = new StateMachines(internalLog, mock(typeof(StateMachines.Monitor)), mock(typeof(MessageSource)), mock(typeof(MessageSender)), timeouts, mock(typeof(DelayedDirectExecutor)), ThreadStart.run, instanceId);

            stateMachines.AddStateMachine(new StateMachine(context.HeartbeatContext, typeof(HeartbeatMessage), HeartbeatState.Start, internalLog));

            timeouts.Tick(0);
            when(timeoutStrategy.TimeoutFor(any(typeof(Message)))).thenReturn(5L);

            // when
            stateMachines.Process(Message.@internal(HeartbeatMessage.Join));
            stateMachines.Process(Message.@internal(HeartbeatMessage.IAmAlive, new HeartbeatMessage.IAmAliveState(otherInstance)).setHeader(Message.HEADER_CREATED_BY, otherInstance.ToString()));
            for (int i = 1; i <= 15; i++)
            {
                timeouts.Tick(i);
            }

            // then
            verify(timeoutStrategy, times(3)).timeoutTriggered(argThat(new MessageArgumentMatcher <>()
                                                                       .onMessageType(HeartbeatMessage.TimedOut)));
            internalLog.AssertExactly(inLog(typeof(HeartbeatState)).debug("Received timed out for server 2"), inLog(typeof(HeartbeatContext)).info("1(me) is now suspecting 2"), inLog(typeof(HeartbeatState)).debug("Received timed out for server 2"), inLog(typeof(HeartbeatState)).debug("Received timed out for server 2"));
            internalLog.Clear();

            // when
            stateMachines.Process(Message.@internal(HeartbeatMessage.IAmAlive, new HeartbeatMessage.IAmAliveState(otherInstance)).setHeader(Message.HEADER_CREATED_BY, otherInstance.ToString()));

            // then
            internalLog.AssertExactly(inLog(typeof(HeartbeatState)).debug("Received i_am_alive[2] after missing 3 (15ms)"));
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void upgradeShouldGiveProgressMonitorProgressMessages() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UpgradeShouldGiveProgressMonitorProgressMessages()
        {
            // Given
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fileSystem);
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);

            // When
            AssertableLogProvider logProvider = new AssertableLogProvider();

            NewUpgrader(upgradableDatabase, pageCache, _allowMigrateConfig, new VisibleMigrationProgressMonitor(logProvider.GetLog("test"))).migrateIfNeeded(_databaseLayout);

            // Then
            AssertableLogProvider.MessageMatcher messageMatcher = logProvider.RawMessageMatcher();
            messageMatcher.AssertContains("Store files");
            messageMatcher.AssertContains("Indexes");
            messageMatcher.AssertContains("Counts store");
            messageMatcher.AssertContains("Successfully finished");
        }
コード例 #6
0
//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()
        {
            _logProvider = new AssertableLogProvider(true);
            ApplicationProtocolRepository applicationProtocolRepository = new ApplicationProtocolRepository(Org.Neo4j.causalclustering.protocol.Protocol_ApplicationProtocols.values(), _parameters.applicationSupportedProtocol);
            ModifierProtocolRepository    modifierProtocolRepository    = new ModifierProtocolRepository(Protocol_ModifierProtocols.values(), _parameters.modifierSupportedProtocols);

            NettyPipelineBuilderFactory serverPipelineBuilderFactory = new NettyPipelineBuilderFactory(VoidPipelineWrapperFactory.VOID_WRAPPER);
            NettyPipelineBuilderFactory clientPipelineBuilderFactory = new NettyPipelineBuilderFactory(VoidPipelineWrapperFactory.VOID_WRAPPER);

            _server = new Server(serverPipelineBuilderFactory);
            _server.start(applicationProtocolRepository, modifierProtocolRepository, _logProvider);

            Config config = Config.builder().withSetting(CausalClusteringSettings.handshake_timeout, TIMEOUT_SECONDS + "s").build();

            _client = new Client(applicationProtocolRepository, modifierProtocolRepository, clientPipelineBuilderFactory, config, _logProvider);

            _client.connect(_server.port());
        }
コード例 #7
0
//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()
        {
            _master = mock(typeof(Master));
            _databaseAvailabilityGuard = new DatabaseAvailabilityGuard(DEFAULT_DATABASE_NAME, Clocks.fakeClock(), Instance);

            _lockManager = new CommunityLockManger(Config.defaults(), Clocks.systemClock());
            _local       = spy(_lockManager.newClient());
            _logProvider = new AssertableLogProvider();

            LockResult lockResultOk = new LockResult(LockStatus.OkLocked);
            TransactionStreamResponse <LockResult> responseOk = new TransactionStreamResponse <LockResult>(lockResultOk, null, Org.Neo4j.com.TransactionStream_Fields.Empty, Org.Neo4j.com.ResourceReleaser_Fields.NoOp);

            WhenMasterAcquireShared().thenReturn(responseOk);

            WhenMasterAcquireExclusive().thenReturn(responseOk);

            _client = new SlaveLocksClient(_master, _local, _lockManager, mock(typeof(RequestContextFactory)), _databaseAvailabilityGuard, _logProvider);
        }
コード例 #8
0
ファイル: RecoveryCleanupIT.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void scanStoreMustLogCrashPointerCleanupDuringRecovery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ScanStoreMustLogCrashPointerCleanupDuringRecovery()
        {
            // given
            DirtyDatabase();

            // when
            AssertableLogProvider logProvider = new AssertableLogProvider(true);

            _factory.UserLogProvider     = logProvider;
            _factory.InternalLogProvider = logProvider;
            StartDatabase().shutdown();

            // then
            logProvider.RawMessageMatcher().assertContains("Label index cleanup job registered");
            logProvider.RawMessageMatcher().assertContains("Label index cleanup job started");
            logProvider.RawMessageMatcher().assertContains(Matchers.stringContainsInOrder(Iterables.asIterable("Label index cleanup job finished", "Number of pages visited", "Number of cleaned crashed pointers", "Time spent")));
            logProvider.RawMessageMatcher().assertContains("Label index cleanup job closed");
        }
コード例 #9
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)));
        }
コード例 #10
0
ファイル: IndexPopulationIT.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shutdownDatabaseDuringIndexPopulations()
        public virtual void ShutdownDatabaseDuringIndexPopulations()
        {
            AssertableLogProvider assertableLogProvider = new AssertableLogProvider(true);
            File   storeDir                 = Directory.directory("shutdownDbTest");
            Label  testLabel                = Label.label("testLabel");
            string propertyName             = "testProperty";
            GraphDatabaseService shutDownDb = (new TestGraphDatabaseFactory()).setInternalLogProvider(assertableLogProvider).newEmbeddedDatabase(storeDir);

            PrePopulateDatabase(shutDownDb, testLabel, propertyName);

            using (Transaction transaction = shutDownDb.BeginTx())
            {
                shutDownDb.Schema().indexFor(testLabel).on(propertyName).create();
                transaction.Success();
            }
            shutDownDb.Shutdown();
            assertableLogProvider.AssertNone(AssertableLogProvider.inLog(typeof(IndexPopulationJob)).anyError());
        }
コード例 #11
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)));
        }
コード例 #12
0
ファイル: ErrorReporterTest.cs プロジェクト: Neo4Net/Neo4Net
//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();
                }
            }
        }
コード例 #13
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)));
        }
コード例 #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotLogConnectionResetErrors() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotLogConnectionResetErrors()
        {
            // Given
            AssertableLogProvider logProvider = new AssertableLogProvider();
            HouseKeeper           keeper      = new HouseKeeper(null, logProvider.GetLog(typeof(HouseKeeper)));
            Channel channel = mock(typeof(Channel));

            when(channel.ToString()).thenReturn("[some channel info]");
            ChannelHandlerContext ctx = mock(typeof(ChannelHandlerContext));

            when(ctx.channel()).thenReturn(channel);
            when(ctx.executor()).thenReturn(mock(typeof(EventExecutor)));
            IOException connResetError = new IOException("Connection reset by peer");

            // When
            keeper.ExceptionCaught(ctx, connResetError);

            // Then
            logProvider.AssertExactly(AssertableLogProvider.inLog(typeof(HouseKeeper)).warn("Fatal error occurred when handling a client connection, " + "remote peer unexpectedly closed connection: %s", channel));
        }
コード例 #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogJobFailure() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogJobFailure()
        {
            // Given
            CreateNode(map(_name, "irrelephant"), _first);
            AssertableLogProvider logProvider = new AssertableLogProvider();
            FlippableIndexProxy   index       = mock(typeof(FlippableIndexProxy));
            IndexPopulator        populator   = spy(IndexPopulator(false));
            IndexPopulationJob    job         = NewIndexPopulationJob(populator, index, _indexStoreView, logProvider, EntityType.NODE, IndexDescriptor(_first, _name, false));

            Exception failure = new System.InvalidOperationException("not successful");

            doThrow(failure).when(populator).create();

            // When
            job.Run();

            // Then
            AssertableLogProvider.LogMatcherBuilder match = inLog(typeof(IndexPopulationJob));
            logProvider.AssertAtLeastOnce(match.error(@is("Failed to populate index: [:FIRST(name)]"), sameInstance(failure)));
        }
コード例 #16
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());
        }
コード例 #17
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]}")));
        }
コード例 #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void failingJobShouldLogAndStopConnection() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FailingJobShouldLogAndStopConnection()
        {
            AtomicBoolean  stopped    = new AtomicBoolean();
            string         id         = System.Guid.randomUUID().ToString();
            BoltConnection connection = NewConnection(id);

            doThrow(new Exception("some unexpected error")).when(connection).processNextBatch();
            doAnswer(inv => stopped.getAndSet(true)).when(connection).stop();

            _boltScheduler.start();
            _boltScheduler.created(connection);
            _boltScheduler.enqueued(connection, Jobs.noop());

            Predicates.await(() => stopped.get(), 1, MINUTES);

            assertFalse(_boltScheduler.isActive(connection));
            verify(connection).processNextBatch();
            verify(connection).stop();

            _logProvider.assertExactly(AssertableLogProvider.inLog(containsString(typeof(BoltServer).Assembly.GetName().Name)).error(containsString("Unexpected error during job scheduling for session"), matchesExceptionMessage(containsString("some unexpected error"))));
        }
コード例 #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogAndExcludeMembersWithMissingAttributes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogAndExcludeMembersWithMissingAttributes()
        {
            // given
            int              numMembers       = 4;
            ISet <Member>    hazelcastMembers = new HashSet <Member>();
            IList <MemberId> coreMembers      = new List <MemberId>();

            System.Func <int, Dictionary <string, string> > generator = i =>
            {
                Dictionary <string, string> settings = _defaultSettingsGenerator.apply(i);
                settings.remove(CausalClusteringSettings.transaction_advertised_address.name());
                settings.remove(CausalClusteringSettings.raft_advertised_address.name());
                return(settings);
            };

            IList <Config> configs = GenerateConfigs(numMembers, generator);

            for (int i = 0; i < configs.Count; i++)
            {
                MemberId memberId = new MemberId(System.Guid.randomUUID());
                coreMembers.Add(memberId);
                Config c = configs[i];
                IDictionary <string, object> attributes = buildMemberAttributesForCore(memberId, c).Attributes;
                if (i == 2)
                {
                    attributes.Remove(HazelcastClusterTopology.RAFT_SERVER);
                }
                hazelcastMembers.Add(new MemberImpl(new Address("localhost", i), null, attributes, false));
            }

            // when
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log log = logProvider.getLog(this.GetType());
            IDictionary <MemberId, CoreServerInfo> map = toCoreMemberMap(hazelcastMembers, log, _hzInstance);

            // then
            assertThat(map.Keys, hasItems(coreMembers[0], coreMembers[1], coreMembers[3]));
            assertThat(map.Keys, not(hasItems(coreMembers[2])));
            logProvider.FormattedMessageMatcher().assertContains("Missing member attribute");
        }
コード例 #20
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)));
        }
コード例 #21
0
ファイル: ErrorReporterTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void databaseErrorShouldLogFullMessageInDebugLogAndHelpfulPointerInUserLog()
        public virtual void DatabaseErrorShouldLogFullMessageInDebugLogAndHelpfulPointerInUserLog()
        {
            // given
            AssertableLogProvider userLog     = new AssertableLogProvider();
            AssertableLogProvider internalLog = new AssertableLogProvider();
            ErrorReporter         reporter    = NewErrorReporter(userLog, internalLog);

            Neo4jError error = Neo4jError.fatalFrom(new TestDatabaseError());

            System.Guid reference = error.Reference();

            // when
            reporter.Report(error);

            // then
            userLog.RawMessageMatcher().assertContains("Client triggered an unexpected error");
            userLog.RawMessageMatcher().assertContains(reference.ToString());
            userLog.RawMessageMatcher().assertContains("Database error");

            internalLog.RawMessageMatcher().assertContains(reference.ToString());
            internalLog.RawMessageMatcher().assertContains("Database error");
        }
コード例 #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogHelpfullyWhenPluginJarIsCorrupt() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogHelpfullyWhenPluginJarIsCorrupt()
        {
            // given
            URL theJar = CreateJarFor(typeof(ClassWithOneProcedure), typeof(ClassWithAnotherProcedure), typeof(ClassWithNoProcedureAtAll));

            CorruptJar(theJar);

            AssertableLogProvider logProvider = new AssertableLogProvider(true);

            ProcedureJarLoader jarloader = new ProcedureJarLoader(new ReflectiveProcedureCompiler(new TypeMappers(), new ComponentRegistry(), RegistryWithUnsafeAPI(), _log, ProcedureConfig()), logProvider.GetLog(typeof(ProcedureJarLoader)));

            // when
            try
            {
                jarloader.LoadProceduresFromDir(ParentDir(theJar));
                fail("Should have logged and thrown exception.");
            }
            catch (ZipException)
            {
                // then
                logProvider.InternalToStringMessageMatcher().assertContains(escapeJava(string.Format("Plugin jar file: {0} corrupted.", (new File(theJar.toURI())).toPath())));
            }
        }
コード例 #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogRuntime()
        public virtual void ShouldLogRuntime()
        {
            // given
            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());
            Config         config = Config.defaults();

            config.Augment(GraphDatabaseSettings.log_queries_parameter_logging_enabled, "true");
            config.Augment(GraphDatabaseSettings.log_queries_runtime_logging_enabled, "true");
            QueryLogger queryLogger = queryLogger(logProvider, config);

            // when
            _clock.forward(11, TimeUnit.MILLISECONDS);
            query.CompilationCompleted(new CompilerInfo("magic", "quantum", Collections.emptyList()), null);
            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]} - runtime=quantum")));
        }
コード例 #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWorkOnPathsWithSpaces() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWorkOnPathsWithSpaces()
        {
            // given
            File fileWithSpacesInName = Tmpdir.newFile((new Random()).Next() + "  some spaces in the filename" + ".jar");
            URL  theJar = (new JarBuilder()).CreateJarFor(fileWithSpacesInName, typeof(ClassWithOneProcedure));

            CorruptJar(theJar);

            AssertableLogProvider logProvider = new AssertableLogProvider(true);

            ProcedureJarLoader jarloader = new ProcedureJarLoader(new ReflectiveProcedureCompiler(new TypeMappers(), new ComponentRegistry(), RegistryWithUnsafeAPI(), _log, ProcedureConfig()), logProvider.GetLog(typeof(ProcedureJarLoader)));

            // when
            try
            {
                jarloader.LoadProceduresFromDir(ParentDir(theJar));
                fail("Should have logged and thrown exception.");
            }
            catch (ZipException)
            {
                // then
                logProvider.InternalToStringMessageMatcher().assertContains(escapeJava(string.Format("Plugin jar file: {0} corrupted.", fileWithSpacesInName.toPath())));
            }
        }
コード例 #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportFailureWhenAllThreadsInThreadPoolAreBusy() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReportFailureWhenAllThreadsInThreadPoolAreBusy()
        {
            // it's enough to get the bolt state machine into streaming mode to have
            // the thread sticked to the connection, causing all the available threads
            // to be busy (logically)
            _connection1 = EnterStreaming();
            _connection2 = EnterStreaming();

            try
            {
                _connection3 = ConnectAndPerformBoltHandshake(NewConnection());

                _connection3.send(Util.chunk(new InitMessage("TestClient/1.1", emptyMap())));
                assertThat(_connection3, Util.eventuallyReceives(msgFailure(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.NoThreadsAvailable, "There are no available threads to serve this request at the moment")));

                _userLogProvider.rawMessageMatcher().assertContains("since there are no available threads to serve it at the moment. You can retry at a later time");
                _internalLogProvider.assertAtLeastOnce(AssertableLogProvider.inLog(startsWith(typeof(BoltConnection).Assembly.GetName().Name)).error(containsString("since there are no available threads to serve it at the moment. You can retry at a later time"), isA(typeof(RejectedExecutionException))));
            }
            finally
            {
                ExitStreaming(_connection1);
                ExitStreaming(_connection2);
            }
        }
コード例 #26
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)));
        }
コード例 #27
0
//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()
        {
            _logProvider = new AssertableLogProvider();
            _logger      = new CappedLogger(_logProvider.getLog(typeof(CappedLogger)));
        }
コード例 #28
0
//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()
        {
            _storeDir    = TestDirectory.storeDir();
            _logProvider = new AssertableLogProvider();
            _database    = (new TestGraphDatabaseFactory()).setInternalLogProvider(_logProvider).newEmbeddedDatabase(_storeDir);
        }