Search in sources :

Example 1 with ConfigurationResponseState

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());
}
Also used : InstanceId(org.neo4j.cluster.InstanceId) TrackingMessageHolder(org.neo4j.cluster.com.message.TrackingMessageHolder) URI(java.net.URI) ConfigurationResponseState(org.neo4j.cluster.protocol.cluster.ClusterMessage.ConfigurationResponseState) Test(org.junit.Test)

Aggregations

URI (java.net.URI)1 Test (org.junit.Test)1 InstanceId (org.neo4j.cluster.InstanceId)1 TrackingMessageHolder (org.neo4j.cluster.com.message.TrackingMessageHolder)1 ConfigurationResponseState (org.neo4j.cluster.protocol.cluster.ClusterMessage.ConfigurationResponseState)1