コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testToSlaveSlaveIsAvailable()
        public virtual void TestToSlaveSlaveIsAvailable()
        {
            // CASE 1: It is me that that is available as slave - cool, go to SLAVE
            HighAvailabilityMemberState newState = TO_SLAVE.slaveIsAvailable(_context, _myId, SampleUri);

            assertEquals(SLAVE, newState);

            // CASE 2: It is someone else that completed the switch - ignore, continue
            HighAvailabilityMemberState newStateCase2 = TO_SLAVE.slaveIsAvailable(_context, new InstanceId(2), SampleUri);

            assertEquals(TO_SLAVE, newStateCase2);
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testToSlaveMasterIsElected()
        public virtual void TestToSlaveMasterIsElected()
        {
            // CASE 1: Got MasterIsElected for me - should switch to TO_MASTER
            HighAvailabilityMemberState newState = TO_SLAVE.masterIsElected(_context, _myId);

            assertEquals(TO_MASTER, newState);

            // CASE 2: Got MasterIsElected for someone else - should switch to PENDING
            HighAvailabilityMemberState newStateCase2 = TO_SLAVE.masterIsElected(_context, new InstanceId(2));

            assertEquals(PENDING, newStateCase2);
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testToSlaveMasterIsAvailable()
        public virtual void TestToSlaveMasterIsAvailable()
        {
            // CASE 1: Got MasterIsAvailable for me - should fail, i am currently trying to become slave
            HighAvailabilityMemberState illegal = TO_SLAVE.masterIsAvailable(_context, _myId, SampleUri);

            assertEquals(ILLEGAL, illegal);

            // CASE 2: Got MasterIsAvailable for someone else who is already the master - should continue switching
            InstanceId currentMaster = new InstanceId(2);

            when(_context.ElectedMasterId).thenReturn(currentMaster);
            HighAvailabilityMemberState newState = TO_SLAVE.masterIsAvailable(_context, currentMaster, SampleUri);

            assertEquals(TO_SLAVE, newState);

            // CASE 3: Got MasterIsAvailable for someone else who is not the master - should fail
            InstanceId instanceId = new InstanceId(3);
            HighAvailabilityMemberState moreIllegal = TO_SLAVE.masterIsAvailable(_context, instanceId, SampleUri);

            assertEquals(ILLEGAL, moreIllegal);
        }