Skip to content

Commit

Permalink
Fix HA test after mocking cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ragadeeshu committed May 3, 2018
1 parent 3bff680 commit b782b7d
Showing 1 changed file with 6 additions and 5 deletions.
Expand Up @@ -141,9 +141,10 @@ public void shouldClearSlavesWhenNewMasterElected()
new ClusterMember( INSTANCE_ID ).availableAs( SLAVE, HA_URI, StoreId.DEFAULT ) ) );

SlaveFactory slaveFactory = mock( SlaveFactory.class );
Slave slave = mock( Slave.class );
Slave slave1 = mock( Slave.class );
Slave slave2 = mock( Slave.class );
when( slaveFactory.newSlave( any( LifeSupport.class ), any( ClusterMember.class ), any( String.class ), any( Integer.class ) ) )
.thenReturn( slave, slave );
.thenReturn( slave1, slave2 );

HighAvailabilitySlaves slaves = new HighAvailabilitySlaves( clusterMembers, cluster, slaveFactory, new
HostnamePort( "localhost", 0 ) );
Expand All @@ -153,14 +154,14 @@ public void shouldClearSlavesWhenNewMasterElected()
verify( cluster ).addClusterListener( listener.capture() );

// when
Slave slave1 = slaves.getSlaves().iterator().next();
Slave actualSlave1 = slaves.getSlaves().iterator().next();

listener.getValue().elected( ClusterConfiguration.COORDINATOR, INSTANCE_ID, CLUSTER_URI );

Slave slave2 = slaves.getSlaves().iterator().next();
Slave actualSlave2 = slaves.getSlaves().iterator().next();

// then
assertThat( slave2, not( sameInstance( slave1 ) ) );
assertThat( actualSlave2, not( sameInstance( actualSlave1 ) ) );
}

@Test
Expand Down

0 comments on commit b782b7d

Please sign in to comment.