예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSlaveMasterIsAvailable()
        public virtual void TestSlaveMasterIsAvailable()
        {
            // CASE 1: It is me who is available as master - i don't think so
            HighAvailabilityMemberState illegal = SLAVE.masterIsAvailable(_context, _myId, SampleUri);

            assertEquals(ILLEGAL, illegal);

            // CASE 2: It is someone else that is available as master and is not the master now - missed the election, fail
            InstanceId masterInstanceId = new InstanceId(2);

            when(_context.ElectedMasterId).thenReturn(masterInstanceId);
            HighAvailabilityMemberState moreIllegal = SLAVE.masterIsAvailable(_context, new InstanceId(3), SampleUri);

            assertEquals(ILLEGAL, moreIllegal);

            // CASE 3: It is the same master as now - it's ok, stay calm and carry on
            HighAvailabilityMemberState newState = SLAVE.masterIsAvailable(_context, masterInstanceId, SampleUri);

            assertEquals(SLAVE, newState);
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSlaveMasterIsElected()
        public virtual void TestSlaveMasterIsElected()
        {
            // CASE 1: It is me that got elected master - should switch to TO_MASTER
            HighAvailabilityMemberState newState = SLAVE.masterIsElected(_context, _myId);

            assertEquals(TO_MASTER, newState);

            InstanceId masterInstanceId = new InstanceId(2);

            when(_context.ElectedMasterId).thenReturn(masterInstanceId);
            // CASE 2: It is someone else that got elected master - should switch to PENDING
            HighAvailabilityMemberState newStateCase2 = SLAVE.masterIsElected(_context, new InstanceId(3));

            assertEquals(PENDING, newStateCase2);

            // CASE 3: It is the current master that got elected again - ignore
            HighAvailabilityMemberState newStateCase3 = SLAVE.masterIsElected(_context, masterInstanceId);

            assertEquals(SLAVE, newStateCase3);
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSlaveSlaveIsAvailable()
        public virtual void TestSlaveSlaveIsAvailable()
        {
            // CASE 1 and only - always remain in SLAVE
            assertEquals(SLAVE, SLAVE.slaveIsAvailable(mock(typeof(HighAvailabilityMemberContext)), mock(typeof(InstanceId)), SampleUri));
        }