Hi,

In my topology, I have a bolt that reads and writes to Solr. Everything
works well. The connection to solr is created in the prepare method, which
ensures that the solr client does not need to be serializable.

The problem I have is around unit testing the topology. In this process, I
mock the solr client (SolrJ) using Mockito and inject the resulting mock
class into the bolt. Something along the line of:

SolrClient client=mock(SolrClient);
mySolrBolt.setSolrClient(client);

Unfortunately, this doesn't work. I get NotSerializableException because
the Solr client is of course not serializable. My topology unit tests is
heavily inspired from testBasicTopology implemented in TestingApiDemo.


My question is: what is the recommended way to unit test topologies with
such bolts?

Thanks,
Max.

Reply via email to