use of org.neo4j.cluster.protocol.cluster.ClusterMessage.ConfigurationResponseState in project neo4j by neo4j.
the class ClusterStateTest method joinDeniedResponseShouldContainRespondersConfiguration.
@Test
public void joinDeniedResponseShouldContainRespondersConfiguration() throws Throwable {
// GIVEN
ClusterContext context = mock(ClusterContext.class);
Map<InstanceId, URI> existingMembers = members(1, 2);
when(context.isCurrentlyAlive(any(InstanceId.class))).thenReturn(true);
when(context.getMembers()).thenReturn(existingMembers);
when(context.getConfiguration()).thenReturn(clusterConfiguration(existingMembers));
when(context.getLog(any(Class.class))).thenReturn(NullLog.getInstance());
TrackingMessageHolder outgoing = new TrackingMessageHolder();
Message<ClusterMessage> message = to(configurationRequest, uri(1), configuration(2)).setHeader(Message.FROM, uri(2).toString());
// WHEN an instance responds to a join request, responding that the joining instance cannot join
ClusterState.entered.handle(context, message, outgoing);
// THEN assert that the responding instance sends its configuration along with the response
Message<ClusterMessage> response = outgoing.single();
assertTrue(response.getPayload() instanceof ConfigurationResponseState);
ConfigurationResponseState responseState = response.getPayload();
assertEquals(existingMembers, responseState.getMembers());
}
Aggregations