Search in sources :

Example 1 with Listener

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();
}
Also used : Listener(org.codice.solr.client.solrj.SolrClient.Listener) SolrClient(org.codice.solr.client.solrj.SolrClient) CatalogProvider(ddf.catalog.source.CatalogProvider) SourceMonitor(ddf.catalog.source.SourceMonitor) Test(org.junit.Test)

Aggregations

CatalogProvider (ddf.catalog.source.CatalogProvider)1 SourceMonitor (ddf.catalog.source.SourceMonitor)1 SolrClient (org.codice.solr.client.solrj.SolrClient)1 Listener (org.codice.solr.client.solrj.SolrClient.Listener)1 Test (org.junit.Test)1