Jörg,

Thanks for your response. I see that in your example you create the Node 
and get the client in the buildNode() method used by the tests..But my 
requirement is different.

I want to be able to start a test elastic search server and make my code in 
the app (not the test) use this server to give me the client..

For Example:

Lets say this is how my code is organised

-src package
   -  class ElasticSearchExtension { Client getClient() {  return new 
TransportClient().addTransportAddress(new 
InetSocketTransportAddress(config.get("host"), config.get("port"))); } }
-tests package
   -  class ElasticSearchExtensionTest {  testGetClient() { } }

Now in my ElasticSearchExtensionTest, I want to be able to start up a test 
elastic server and tell the getClient() in ElasticSearchExtension  to use 
the test server and give me the client...I don't want to get the client 
directly in ElasticSearchExtensionTest.

Also, thanks for your note. But we instantiate the client only once per 
module using Akka's Extensions and Bootable implementations.

Thanks,
SD

On Thursday, February 13, 2014 10:48:20 AM UTC-6, Jörg Prante wrote:
>
> The NodeBuilder can start an embedded Elasticsearch cluster, this is 
> exactly what you want for unit tests with a TransportClient.
>
> To see how this works, you can also consult my elasticsearch-support tests 
> which I stole from the original Elasticearch test code:
>
>
> https://github.com/jprante/elasticsearch-support/blob/master/src/test/java/org/xbib/elasticsearch/support/AbstractNodeTest.java
>
> Note, is is rather bad practice to issue a "new TransportClient()" each 
> time you want a client instance. Create just a singleton TransportClient 
> and pass this instance around. At instantiation, the TransportClient starts 
> the full discovery and cluster rendevzous, which takes a loooong time.
>
> Jörg
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/9305fe60-9ef7-48e0-a6bd-82d7a788bb6d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to