@Test public void testPendingMasterIsElected() { // CASE 1: Got MasterIsElected for me - should switch to TO_MASTER HighAvailabilityMemberState newState = PENDING.masterIsElected(context, myId); assertEquals(TO_MASTER, newState); // CASE 2: Got MasterIsElected for someone else - should remain to PENDING HighAvailabilityMemberState newStateCase2 = PENDING.masterIsElected(context, new InstanceId(2)); assertEquals(PENDING, newStateCase2); }
@Test public void testPendingSlaveIsAvailable() { // CASE 1: Got SlaveIsAvailable for me - should not happen, that's what TO_SLAVE exists for try { PENDING.slaveIsAvailable(context, myId, SampleUri); fail("Should not accept SlaveIsAvailable for myself from PENDING"); } catch (RuntimeException e) { // marvellous } // CASE 2: Got SlaveIsAvailable for someone else - it's ok, remain in PENDING HighAvailabilityMemberState newState = PENDING.slaveIsAvailable(context, new InstanceId(2), SampleUri); assertEquals(PENDING, newState); }
@Test public void testPendingMasterIsAvailable() { // CASE 1: Got MasterIsAvailable for me - should not happen try { PENDING.masterIsAvailable(context, myId, SampleUri); fail("Should not accept MasterIsAvailable for myself from PENDING"); } catch (RuntimeException e) { // marvellous } // CASE 2: Got MasterIsAvailable for someone else - should transition to TO_SLAVE // TODO test correct info is passed through to context HighAvailabilityMemberState newState = PENDING.masterIsAvailable(context, new InstanceId(2), SampleUri); assertEquals(TO_SLAVE, newState); }