예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void proposer_rejectAcceptShouldCarryOnPayload() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ProposerRejectAcceptShouldCarryOnPayload()
        {
            // GIVEN
            string        instanceId = "1";
            PaxosInstance instance   = new PaxosInstance(mock(typeof(PaxosInstanceStore)), new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId));
            Serializable  payload    = "myPayload";

            instance.Propose(1, new IList <java.net.URI> {
                create("http://some-guy")
            });
            instance.Ready(payload, true);
            instance.Pending();
            ProposerContext context = mock(typeof(ProposerContext));

            when(context.GetLog(any(typeof(Type)))).thenReturn(NullLog.Instance);
            when(context.GetPaxosInstance(any(typeof(Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId)))).thenReturn(instance);
            when(context.MyId).thenReturn(new Org.Neo4j.cluster.InstanceId(parseInt(instanceId)));
            TrackingMessageHolder     outgoing = new TrackingMessageHolder();
            Message <ProposerMessage> message  = to(rejectAccept, create("http://something"), new ProposerMessage.RejectAcceptState()).setHeader(INSTANCE, instanceId);

            // WHEN
            ProposerState.Proposer.handle(context, message, outgoing);

            // THEN
            verify(context).setTimeout(eq(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId)), argThat((new MessageArgumentMatcher <>()).withPayload(payload)));
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void something() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Something()
        {
            object acceptorValue = new object();
            object bookedValue   = new object();

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

            PaxosInstanceStore paxosInstanceStore = new PaxosInstanceStore();

            ProposerContext context = Mockito.mock(typeof(ProposerContext));

            when(context.GetPaxosInstance(instanceId)).thenReturn(paxosInstanceStore.GetPaxosInstance(instanceId));
            when(context.GetMinimumQuorumSize(Mockito.anyList())).thenReturn(2);

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

            paxosInstance.Propose(2001, Iterables.asList(Iterables.iterable(create("http://something1"), create("http://something2"), create("http://something3"))));

            Message message = Message.to(ProposerMessage.Promise, create("http://something1"), new ProposerMessage.PromiseState(2001, acceptorValue));

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

            MessageHolder mockHolder = mock(typeof(MessageHolder));

            ProposerState.Proposer.handle(context, message, mockHolder);
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") @Test public void proposer_promiseShouldCarryOnPayloadToPhase2Timeout() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ProposerPromiseShouldCarryOnPayloadToPhase2Timeout()
        {
            // GIVEN
            string        instanceId = "1";
            Serializable  payload    = "myPayload";
            PaxosInstance instance   = new PaxosInstance(mock(typeof(PaxosInstanceStore)), new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId));

            instance.Propose(1, new IList <java.net.URI> {
                create("http://some-guy")
            });
            instance.Value_2 = payload;               // don't blame me for making it package access.
            ProposerContext context = mock(typeof(ProposerContext));

            when(context.GetPaxosInstance(any(typeof(Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId)))).thenReturn(instance);
            when(context.GetMinimumQuorumSize(anyList())).thenReturn(1);
            TrackingMessageHolder     outgoing = new TrackingMessageHolder();
            Message <ProposerMessage> message  = to(promise, create("http://something"), new ProposerMessage.PromiseState(1, payload)).setHeader(INSTANCE, instanceId);

            // WHEN
            ProposerState.Proposer.handle(context, message, outgoing);

            // THEN
            verify(context).setTimeout(eq(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId)), argThat((new MessageArgumentMatcher <>()).withPayload(payload)));
        }