use of com.datastax.oss.driver.internal.core.channel.EventCallback in project java-driver by datastax.
the class ControlConnectionEventsTest method should_process_topology_change_events.
@Test
public void should_process_topology_change_events() {
// Given
DriverChannel channel1 = newMockDriverChannel(1);
ArgumentCaptor<DriverChannelOptions> optionsCaptor = ArgumentCaptor.forClass(DriverChannelOptions.class);
when(channelFactory.connect(eq(node1), optionsCaptor.capture())).thenReturn(CompletableFuture.completedFuture(channel1));
controlConnection.init(true, false, false);
await().until(() -> optionsCaptor.getValue() != null);
EventCallback callback = optionsCaptor.getValue().eventCallback;
TopologyChangeEvent event = new TopologyChangeEvent(ProtocolConstants.TopologyChangeType.NEW_NODE, ADDRESS1);
// When
callback.onEvent(event);
// Then
verify(eventBus).fire(TopologyEvent.suggestAdded(ADDRESS1));
}
use of com.datastax.oss.driver.internal.core.channel.EventCallback in project java-driver by datastax.
the class ControlConnectionEventsTest method should_process_schema_change_events.
@Test
public void should_process_schema_change_events() {
// Given
DriverChannel channel1 = newMockDriverChannel(1);
ArgumentCaptor<DriverChannelOptions> optionsCaptor = ArgumentCaptor.forClass(DriverChannelOptions.class);
when(channelFactory.connect(eq(node1), optionsCaptor.capture())).thenReturn(CompletableFuture.completedFuture(channel1));
controlConnection.init(false, false, false);
await().until(() -> optionsCaptor.getValue() != null);
EventCallback callback = optionsCaptor.getValue().eventCallback;
SchemaChangeEvent event = new SchemaChangeEvent(ProtocolConstants.SchemaChangeType.CREATED, ProtocolConstants.SchemaChangeTarget.FUNCTION, "ks", "fn", ImmutableList.of("text", "text"));
// When
callback.onEvent(event);
// Then
verify(metadataManager).refreshSchema("ks", false, false);
}
use of com.datastax.oss.driver.internal.core.channel.EventCallback in project java-driver by datastax.
the class ControlConnectionEventsTest method should_process_status_change_events.
@Test
public void should_process_status_change_events() {
// Given
DriverChannel channel1 = newMockDriverChannel(1);
ArgumentCaptor<DriverChannelOptions> optionsCaptor = ArgumentCaptor.forClass(DriverChannelOptions.class);
when(channelFactory.connect(eq(node1), optionsCaptor.capture())).thenReturn(CompletableFuture.completedFuture(channel1));
controlConnection.init(true, false, false);
await().until(() -> optionsCaptor.getValue() != null);
EventCallback callback = optionsCaptor.getValue().eventCallback;
StatusChangeEvent event = new StatusChangeEvent(ProtocolConstants.StatusChangeType.UP, ADDRESS1);
// When
callback.onEvent(event);
// Then
verify(eventBus).fire(TopologyEvent.suggestUp(ADDRESS1));
}
Aggregations