예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldKeepAtMostGivenNumberOfInstances()
        public virtual void ShouldKeepAtMostGivenNumberOfInstances()
        {
            // Given
            const int          instancesToKeep = 10;
            PaxosInstanceStore theStore        = new PaxosInstanceStore(instancesToKeep);

            // Keeps the first instance inserted, which is the first to be removed
            PaxosInstance firstInstance = null;

            // When
            for (int i = 0; i < instancesToKeep + 1; i++)
            {
                InstanceId    currentInstanceId = new InstanceId(i);
                PaxosInstance currentInstance   = theStore.GetPaxosInstance(currentInstanceId);
                theStore.Delivered(currentInstance.Id);
                if (firstInstance == null)
                {
                    firstInstance = currentInstance;
                }
            }

            // Then
            // The first instance must have been removed now
            PaxosInstance toTest = theStore.GetPaxosInstance(firstInstance.Id);

            assertNotSame(firstInstance, toTest);
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnSameObjectWhenAskedById()
        public virtual void ShouldReturnSameObjectWhenAskedById()
        {
            // Given
            PaxosInstanceStore theStore          = new PaxosInstanceStore();
            InstanceId         currentInstanceId = new InstanceId(1);

            // When
            PaxosInstance currentInstance = theStore.GetPaxosInstance(currentInstanceId);

            // Then
            assertSame(currentInstance, theStore.GetPaxosInstance(currentInstanceId));
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void leaveShouldClearStoredInstances()
        public virtual void LeaveShouldClearStoredInstances()
        {
            // Given
            PaxosInstanceStore theStore          = new PaxosInstanceStore();
            InstanceId         currentInstanceId = new InstanceId(1);

            // When
            PaxosInstance currentInstance = theStore.GetPaxosInstance(currentInstanceId);

            theStore.Leave();

            // Then
            assertNotSame(currentInstance, theStore.GetPaxosInstance(currentInstanceId));
        }
예제 #4
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);
        }