use of org.codice.solr.client.solrj.SolrClient.Listener in project ddf by codice.
the class RemoteSolrCatalogProviderTest method testAvailabilitySourceMonitor.
@Test
public void testAvailabilitySourceMonitor() throws Exception {
final SolrClient client = givenSolrClient(false);
CatalogProvider provider = new MockedRemoteSolrCatalogProvider(client);
final SourceMonitor monitor = mock(SourceMonitor.class);
assertThat(provider.isAvailable(monitor), is(false));
final ArgumentCaptor<Listener> listener = ArgumentCaptor.forClass(Listener.class);
verify(client).isAvailable(listener.capture());
verify(client).ping();
// when the underlying listener is called with not available
listener.getValue().changed(client, false);
// so should our monitor
verify(monitor).setUnavailable();
// when the underlying listener is called with available
listener.getValue().changed(client, true);
// so should our monitor
verify(monitor).setAvailable();
}
Aggregations