Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void ifProposingWithClosedInstanceThenRetryWithNextInstance() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void IfProposingWithClosedInstanceThenRetryWithNextInstance()
        {
            ProposerContext context = Mockito.mock(typeof(ProposerContext));

            when(context.GetLog(any(typeof(Type)))).thenReturn(NullLog.Instance);

            Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId instanceId = new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(42);
            PaxosInstanceStore paxosInstanceStore = new PaxosInstanceStore();

            // The instance is closed
            PaxosInstance paxosInstance = new PaxosInstance(paxosInstanceStore, instanceId); // the instance

            paxosInstance.Closed(instanceId, "1/15#");                                       // is closed for that conversation, not really important
            when(context.UnbookInstance(instanceId)).thenReturn(Message.@internal(ProposerMessage.Accepted, "the closed payload"));

            when(context.GetPaxosInstance(instanceId)).thenReturn(paxosInstance);                     // required for

            // But in the meantime it was reused and has now (of course) timed out
            string  theTimedoutPayload = "the timed out payload";
            Message message            = Message.@internal(ProposerMessage.Phase1Timeout, theTimedoutPayload);

            message.setHeader(Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId.INSTANCE, instanceId.ToString());

            // Handle it
            MessageHolder mockHolder = mock(typeof(MessageHolder));

            ProposerState.Proposer.handle(context, message, mockHolder);

            // Verify it was resent as a propose with the same value
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: verify(mockHolder, times(1)).offer(org.mockito.ArgumentMatchers.argThat<org.neo4j.cluster.com.message.Message<? extends org.neo4j.cluster.com.message.MessageType>>(new org.neo4j.cluster.protocol.MessageArgumentMatcher().onMessageType(ProposerMessage.propose).withPayload(theTimedoutPayload)));
            verify(mockHolder, times(1)).offer(ArgumentMatchers.argThat <Message <MessageType> >((new MessageArgumentMatcher()).onMessageType(ProposerMessage.Propose).withPayload(theTimedoutPayload)));
            verify(context, times(1)).unbookInstance(instanceId);
        }
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 shouldIgnoreSuspicionsForOurselves() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldIgnoreSuspicionsForOurselves()
        {
            // Given
            InstanceId           instanceId    = new InstanceId(1);
            HeartbeatState       heartbeat     = HeartbeatState.Heartbeat;
            ClusterConfiguration configuration = new ClusterConfiguration("whatever", NullLogProvider.Instance, "cluster://1", "cluster://2");

            configuration.Joined(instanceId, URI.create("cluster://1"));
            configuration.Joined(new InstanceId(2), URI.create("cluster://2"));

            Config config = mock(typeof(Config));

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

            MultiPaxosContext context = new MultiPaxosContext(instanceId, iterable(new ElectionRole("coordinator")), configuration, Mockito.mock(typeof(Executor)), NullLogProvider.Instance, Mockito.mock(typeof(ObjectInputStreamFactory)), Mockito.mock(typeof(ObjectOutputStreamFactory)), Mockito.mock(typeof(AcceptorInstanceStore)), Mockito.mock(typeof(Timeouts)), mock(typeof(ElectionCredentialsProvider)), config);

            HeartbeatContext heartbeatContext = context.HeartbeatContext;
            Message          received         = Message.@internal(HeartbeatMessage.Suspicions, new HeartbeatMessage.SuspicionsState(asSet(iterable(instanceId))));

            received.setHeader(Message.HEADER_FROM, "cluster://2").SetHeader(Message.HEADER_INSTANCE_ID, "2");

            // When
            heartbeat.handle(heartbeatContext, received, mock(typeof(MessageHolder)));

            // Then
            assertThat(heartbeatContext.GetSuspicionsOf(instanceId).Count, equalTo(0));
        }
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 delayedVoteFromPreviousElectionMustNotCauseCurrentElectionToComplete() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DelayedVoteFromPreviousElectionMustNotCauseCurrentElectionToComplete()
        {
            // Given
            ElectionContext context = mock(typeof(ElectionContext));
            MessageHolder   holder  = mock(typeof(MessageHolder));

            when(context.GetLog(Mockito.any())).thenReturn(NullLog.Instance);

            const string role = "master";
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.cluster.InstanceId voter = new org.neo4j.cluster.InstanceId(2);
            InstanceId voter = new InstanceId(2);

            ElectionCredentials       voteCredentialComparable = mock(typeof(ElectionCredentials));
            Message <ElectionMessage> vote = Message.@internal(voted, new ElectionMessage.VersionedVotedData(role, voter, voteCredentialComparable, 4));

            when(context.Voted(role, voter, voteCredentialComparable, 4)).thenReturn(false);

            // When
            election.handle(context, vote, holder);

            verify(context).getLog(ArgumentMatchers.any());
            verify(context).voted(role, voter, voteCredentialComparable, 4);

            // Then
            verifyNoMoreInteractions(context, holder);
        }
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 shouldAlwaysAddItsInstanceIdToOutgoingMessages()
        public virtual void ShouldAlwaysAddItsInstanceIdToOutgoingMessages()
        {
            InstanceId me = new InstanceId(42);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<org.neo4j.cluster.com.message.Message> sentOut = new java.util.LinkedList<>();
            IList <Message> sentOut = new LinkedList <Message>();

            /*
             * Lots of setup required. Must have a sender that keeps messages so we can see what the machine sent out.
             * We must have the StateMachines actually delegate the incoming message and retrieve the generated outgoing.
             * That means we need an actual StateMachine with a registered MessageType. And most of those are void
             * methods, which means lots of Answer objects.
             */
            // Given
            MessageSender sender = mock(typeof(MessageSender));

            // The sender, which adds messages outgoing to the list above.
            doAnswer(invocation =>
            {
                ((IList <Org.Neo4j.cluster.com.message.Message>)sentOut).AddRange(invocation.getArgument(0));
                return(null);
            }).when(sender).process(ArgumentMatchers.any <IList <Message <? extends MessageType> > >());

            StateMachines stateMachines = new StateMachines(NullLogProvider.Instance, mock(typeof(StateMachines.Monitor)), mock(typeof(MessageSource)), sender, mock(typeof(Timeouts)), mock(typeof(DelayedDirectExecutor)), ThreadStart.run, me);

            // The state machine, which has a TestMessage message type and simply adds a HEADER_TO header to the messages it
            // is handed to handle.
            StateMachine machine = mock(typeof(StateMachine));

            when(machine.MessageType).then((Answer <object>)invocation => typeof(TestMessage));
            doAnswer(invocation =>
            {
                Message message      = invocation.getArgument(0);
                MessageHolder holder = invocation.getArgument(1);
                message.setHeader(Message.HEADER_TO, "to://neverland");
                holder.offer(message);
                return(null);
            }).when(machine).handle(any(typeof(Message)), any(typeof(MessageHolder)));
            stateMachines.AddStateMachine(machine);

            // When
            stateMachines.Process(Message.@internal(TestMessage.Message1));

            // Then
            assertEquals("StateMachines should not make up messages from thin air", 1, sentOut.Count);
            Message sent = sentOut[0];

            assertTrue("StateMachines should add the instance-id header", sent.hasHeader(Message.HEADER_INSTANCE_ID));
            assertEquals("StateMachines should add instance-id header that has the correct value", me.ToString(), sent.getHeader(Message.HEADER_INSTANCE_ID));
        }
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 testElectionFromDemoteIsRejectedIfNoQuorum() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestElectionFromDemoteIsRejectedIfNoQuorum()
        {
            ElectionContext context            = mock(typeof(ElectionContext));
            ClusterContext  clusterContextMock = mock(typeof(ClusterContext));

            when(context.ElectionOk()).thenReturn(false);
            when(clusterContextMock.GetLog(ArgumentMatchers.any())).thenReturn(NullLog.Instance);
            when(context.GetLog(ArgumentMatchers.any())).thenReturn(NullLog.Instance);

            MessageHolder holder = mock(typeof(MessageHolder));

            election.handle(context, Message.@internal(demote), holder);

            verifyZeroInteractions(holder);
        }
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 electionShouldRemainLocalIfStartedBySingleInstanceWhichIsTheRoleHolder() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ElectionShouldRemainLocalIfStartedBySingleInstanceWhichIsTheRoleHolder()
        {
            /*
             * Ensures that when an instance is alone in the cluster, elections for roles that it holds do not set
             * timeouts or try to reach other instances.
             */

            // Given
            ElectionContext context            = mock(typeof(ElectionContext));
            ClusterContext  clusterContextMock = mock(typeof(ClusterContext));

            when(clusterContextMock.GetLog(ArgumentMatchers.any())).thenReturn(NullLog.Instance);
            MessageHolder holder = mock(typeof(MessageHolder));

            // These mean the election can proceed normally, by us
            when(context.ElectionOk()).thenReturn(true);
            when(context.InCluster).thenReturn(true);
            when(context.Elector).thenReturn(true);

            // Like it says on the box, we are the only instance
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.cluster.InstanceId myInstanceId = new org.neo4j.cluster.InstanceId(1);
            InstanceId myInstanceId = new InstanceId(1);
            IDictionary <InstanceId, URI> members = new Dictionary <InstanceId, URI>();

            members[myInstanceId] = URI.create("ha://me");
            when(context.Members).thenReturn(members);

            // Any role would do, just make sure we have it
            const string role = "master";
            ElectionContext_VoteRequest voteRequest = new ElectionContext_VoteRequest(role, 13);

            when(context.PossibleRoles).thenReturn(Collections.singletonList(new ElectionRole(role)));
            when(context.GetElected(role)).thenReturn(myInstanceId);
            when(context.VoteRequestForRole(new ElectionRole(role))).thenReturn(voteRequest);

            // Required for logging
            when(context.GetLog(Mockito.any())).thenReturn(NullLog.Instance);

            // When
            election.handle(context, Message.@internal(performRoleElections), holder);

            // Then
            // Make sure that we asked ourselves to vote for that role and that no timer was set
            verify(holder, times(1)).offer(ArgumentMatchers.argThat(new MessageArgumentMatcher <ElectionMessage>()
                                                                    .onMessageType(ElectionMessage.Vote).withPayload(voteRequest)));
            verify(context, never()).setTimeout(ArgumentMatchers.any(), ArgumentMatchers.any());
        }
Exemplo n.º 7
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.º 8
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)"));
        }
Exemplo n.º 9
0
        internal virtual object Invoke(StateMachine stateMachine, System.Reflection.MethodInfo method, object arg)
        {
            if (method.Name.Equals("toString"))
            {
                return(_me.ToString());
            }

            if (method.Name.Equals("equals"))
            {
                return((( StateMachineProxyHandler )Proxy.getInvocationHandler(arg)).StateMachineProxyFactory.me.Equals(_me));
            }

            string conversationId = _conversations.NextConversationId;

            try
            {
                MessageType typeAsEnum = ( MessageType )Enum.valueOf(stateMachine.MessageType, method.Name);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.cluster.com.message.Message<?> message = org.neo4j.cluster.com.message.Message.internal(typeAsEnum, arg);
                Message <object> message = Message.@internal(typeAsEnum, arg);
                if (_me != null)
                {
                    message.SetHeader(Message.HEADER_CONVERSATION_ID, conversationId).setHeader(Message.HEADER_CREATED_BY, _me.ToString());
                }

                if (method.ReturnType.Equals(Void.TYPE))
                {
                    _stateMachines.process(message);
                    return(null);
                }
                else
                {
                    ResponseFuture future = new ResponseFuture(conversationId, typeAsEnum, _responseFutureMap);
                    _responseFutureMap[conversationId] = future;
                    _log.debug("Added response future for conversation id %s", conversationId);
                    _stateMachines.process(message);

                    return(future);
                }
            }
            catch (System.ArgumentException)
            {
                throw new System.InvalidOperationException("No state machine can handle the method " + method.Name);
            }
        }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void equalsShouldBeLogicalAndNotExact() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void EqualsShouldBeLogicalAndNotExact()
        {
            // Given
            ProverTimeouts timeouts1 = new ProverTimeouts(new URI("http://asd"));
            ProverTimeouts timeouts2 = new ProverTimeouts(new URI("http://asd"));

            timeouts1.SetTimeout("a", Message.@internal(ProposerMessage.join));
            timeouts1.SetTimeout("b", Message.@internal(ProposerMessage.join));
            timeouts1.SetTimeout("c", Message.@internal(ProposerMessage.join));

            timeouts2.SetTimeout("b", Message.@internal(ProposerMessage.join));
            timeouts2.SetTimeout("c", Message.@internal(ProposerMessage.join));

            // When
            timeouts1.CancelTimeout("a");

            // Then
            assertEquals(timeouts1, timeouts2);
        }
Exemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAddInstanceIdHeaderInCatchUpMessages() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAddInstanceIdHeaderInCatchUpMessages()
        {
            // Given
            InstanceId           instanceId    = new InstanceId(1);
            HeartbeatState       heartbeat     = HeartbeatState.Heartbeat;
            ClusterConfiguration configuration = new ClusterConfiguration("whatever", NullLogProvider.Instance, "cluster://1", "cluster://2");

            configuration.Joined(instanceId, URI.create("cluster://1"));
            InstanceId otherInstance = new InstanceId(2);

            configuration.Joined(otherInstance, URI.create("cluster://2"));

            Config config = mock(typeof(Config));

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

            MultiPaxosContext context = new MultiPaxosContext(instanceId, iterable(new ElectionRole("coordinator")), configuration, Mockito.mock(typeof(Executor)), NullLogProvider.Instance, Mockito.mock(typeof(ObjectInputStreamFactory)), Mockito.mock(typeof(ObjectOutputStreamFactory)), Mockito.mock(typeof(AcceptorInstanceStore)), Mockito.mock(typeof(Timeouts)), mock(typeof(ElectionCredentialsProvider)), config);

            int lastDeliveredInstanceId = 100;

            context.LearnerContext.LastDeliveredInstanceId = lastDeliveredInstanceId;
            // This gap will trigger the catchUp message that we'll test against
            lastDeliveredInstanceId += 20;

            HeartbeatContext heartbeatContext = context.HeartbeatContext;
            Message          received         = Message.@internal(HeartbeatMessage.IAmAlive, new HeartbeatMessage.IAmAliveState(otherInstance));

            received.setHeader(Message.HEADER_FROM, "cluster://2").SetHeader(Message.HEADER_INSTANCE_ID, "2").setHeader("last-learned", Convert.ToString(lastDeliveredInstanceId));

            // When
            MessageHolder holder = mock(typeof(MessageHolder));

            heartbeat.handle(heartbeatContext, received, holder);

            // Then
            verify(holder, times(1)).offer(ArgumentMatchers.argThat(new MessageArgumentMatcher <LearnerMessage>()
                                                                    .onMessageType(LearnerMessage.catchUp).withHeader(Message.HEADER_INSTANCE_ID, "2")));
        }
Exemplo n.º 12
0
        public override bool Process <T1>(Message <T1> message) where T1 : Org.Neo4j.cluster.com.message.MessageType
        {
            if (!message.Internal && !message.MessageType.Equals(HeartbeatMessage.IAmAlive))
            {
                try
                {
                    string to = message.GetHeader(Message.HEADER_TO);

                    InstanceId serverId = _clusterContext.Configuration.getIdForUri(new URI(to));

                    if (!_clusterContext.isMe(serverId))
                    {
                        _outgoing.offer(Message.@internal(HeartbeatMessage.ResetSendHeartbeat, serverId));
                    }
                }
                catch (URISyntaxException e)
                {
                    Console.WriteLine(e.ToString());
                    Console.Write(e.StackTrace);
                }
            }
            return(true);
        }
Exemplo n.º 13
0
 public override void JoinedCluster(InstanceId member, URI atUri)
 {
     _outgoing.offer(Message.@internal(HeartbeatMessage.ResetSendHeartbeat, member));
 }
Exemplo n.º 14
0
        public override bool Process <T1>(Message <T1> message) where T1 : Org.Neo4j.cluster.com.message.MessageType
        {
            if (!message.Internal && !message.MessageType.Equals(HeartbeatMessage.IAmAlive) && !message.MessageType.Equals(HeartbeatMessage.Suspicions))
            {
                // We assume the HEADER_FROM header always exists.
                string from = message.GetHeader(Message.HEADER_FROM);
                if (!from.Equals(message.GetHeader(Message.HEADER_TO)))
                {
                    InstanceId theId;
                    if (message.HasHeader(Message.HEADER_INSTANCE_ID))
                    {
                        // HEADER_INSTANCE_ID is there since after 1.9.6
                        theId = new InstanceId(int.Parse(message.GetHeader(Message.HEADER_INSTANCE_ID)));
                    }
                    else
                    {
                        theId = _clusterContext.Configuration.getIdForUri(URI.create(from));
                    }

                    if (theId != null && _clusterContext.Configuration.Members.ContainsKey(theId) && !_clusterContext.isMe(theId))
                    {
                        Message <HeartbeatMessage> heartbeatMessage = message.CopyHeadersTo(Message.@internal(HeartbeatMessage.IAmAlive, new HeartbeatMessage.IAmAliveState(theId)), Message.HEADER_FROM, Message.HEADER_INSTANCE_ID);
                        _output.offer(heartbeatMessage);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void timeoutMakesElectionBeForgotten() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TimeoutMakesElectionBeForgotten()
        {
            // Given
            string coordinatorRole = "coordinator";

            ElectionContext context = mock(typeof(ElectionContext));

            when(context.GetLog(Mockito.any())).thenReturn(NullLog.Instance);

            MessageHolder holder = mock(typeof(MessageHolder));

            Message <ElectionMessage> timeout = Message.timeout(ElectionMessage.ElectionTimeout, Message.@internal(performRoleElections), new ElectionState.ElectionTimeoutData(coordinatorRole, null));

            // When
            election.handle(context, timeout, holder);

            // Then
            verify(context, times(1)).forgetElection(coordinatorRole);
        }