Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogFailedRule()
        public virtual void ShouldLogFailedRule()
        {
            AssertableLogProvider logProvider = new AssertableLogProvider();
            PreFlightTasks        check       = new PreFlightTasks(logProvider, WithOneFailingRule);

            check.Run();

            logProvider.AssertExactly(inLog(typeof(PreFlightTasks)).error("blah blah"));
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrottle()
        public virtual void ShouldThrottle()
        {
            // Given
            AssertableLogProvider logProvider = new AssertableLogProvider(true);

            StateTransitionLogger stateLogger = new StateTransitionLogger(logProvider, new AtomicBroadcastSerializer(new ObjectStreamFactory(), new ObjectStreamFactory()));

            // When
            stateLogger.StateTransition(new StateTransition(entered, Message.@internal(join), joining));
            stateLogger.StateTransition(new StateTransition(entered, Message.@internal(join), joining));
            stateLogger.StateTransition(new StateTransition(joining, Message.@internal(join), entered));
            stateLogger.StateTransition(new StateTransition(entered, Message.@internal(join), joining));

            // Then
            logProvider.AssertExactly(inLog(entered.GetType()).debug("ClusterState: entered-[join]->joining"), inLog(joining.GetType()).debug("ClusterState: joining-[join]->entered"), inLog(entered.GetType()).debug("ClusterState: entered-[join]->joining"));
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOnlyLogLearnMissOnce()
        public virtual void ShouldOnlyLogLearnMissOnce()
        {
            // 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();
            LearnerContextImpl    ctx         = new LearnerContextImpl(new InstanceId(1), mock(typeof(CommonContextState)), logProvider, mock(typeof(Timeouts)), mock(typeof(PaxosInstanceStore)), mock(typeof(AcceptorInstanceStore)), mock(typeof(ObjectInputStreamFactory)), mock(typeof(ObjectOutputStreamFactory)), mock(typeof(HeartbeatContextImpl)));

            // When
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(1L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(1L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(2L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(2L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(1L));

            // Then
            logProvider.AssertExactly(inLog(typeof(LearnerState)).warn(containsString("Did not have learned value for Paxos instance 1.")), inLog(typeof(LearnerState)).warn(containsString("Did not have learned value for Paxos instance 2.")), inLog(typeof(LearnerState)).warn(containsString("Did not have learned value for Paxos instance 1.")));
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogWhenLoggingThreadStarts()
        public virtual void ShouldLogWhenLoggingThreadStarts()
        {
            // given
            AssertableLogProvider logs    = new AssertableLogProvider();
            AsyncLogging          logging = new AsyncLogging(logs.GetLog("meta"));

            // when
            (new AsyncLogProvider(logging.EventSender(), logs)).getLog("test").info("hello");

            // then
            logs.AssertNoLoggingOccurred();

            // when
            logging.Start();
            logging.Stop();

            // then
            logs.AssertExactly(inLog("test").info(endsWith("hello")));
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogMessages()
        public virtual void ShouldLogMessages()
        {
            // given
            AssertableLogProvider logs    = new AssertableLogProvider();
            AsyncLogging          logging = new AsyncLogging(logs.GetLog("meta"));

            // when
            logging.Start();
            try
            {
                (new AsyncLogProvider(logging.EventSender(), logs)).getLog("test").info("hello");
            }
            finally
            {
                logging.Stop();
            }
            // then
            logs.AssertExactly(inLog("test").info(endsWith("hello")));
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void transactionsShouldBeEvictedWhenUnusedLongerThanTimeout() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TransactionsShouldBeEvictedWhenUnusedLongerThanTimeout()
        {
            // Given
            FakeClock                 clock       = Clocks.fakeClock();
            AssertableLogProvider     logProvider = new AssertableLogProvider();
            TransactionHandleRegistry registry    = new TransactionHandleRegistry(clock, 0, logProvider);
            TransactionHandle         oldTx       = mock(typeof(TransactionHandle));
            TransactionHandle         newTx       = mock(typeof(TransactionHandle));
            TransactionHandle         handle      = mock(typeof(TransactionHandle));

            long txId1 = registry.Begin(handle);
            long txId2 = registry.Begin(handle);

            // And given one transaction was stored one minute ago, and another was stored just now
            registry.Release(txId1, oldTx);
            clock.Forward(1, TimeUnit.MINUTES);
            registry.Release(txId2, newTx);

            // When
            registry.RollbackSuspendedTransactionsIdleSince(clock.Millis() - 1000);

            // Then
            assertThat(registry.Acquire(txId2), equalTo(newTx));

            // And then the other should have been evicted
            try
            {
                registry.Acquire(txId1);
                fail("Should have thrown exception");
            }
            catch (InvalidTransactionId)
            {
                // ok
            }

            logProvider.AssertExactly(inLog(typeof(TransactionHandleRegistry)).info("Transaction with id 1 has been automatically rolled " + "back due to transaction timeout."));
        }