Sharing connection junit and code under test

I'm trying to connect to the "junit" embedded node in my code under test.

Normally the code under test makes a getNodeClient to 9300 to join the
cluster.
But I guess that's not an option with the embedded local(true) node.
So what is the answer?

One option is to write the original code (under test) to accept a client as
a parameter eg m(Client client, )
And that would work but would require significant refactoring of existing
code.

What do other people do?

Just to be clear, say I have a black box piece of code under test Class C
with method m()

I start up my unit test and create a node and create a client

Node node = nodeBuilder().local(true).node()
node.start()
client = node.client()

Now I call m()

and somewhere else m calls es.writeRecord()
which does a client = getClient() // get NodeClient
but the two servers are separate and distinct.

Any way around this other than as I suggest : refactoring all code
interfaces to pass in the client to be used?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8cc197ba-68a9-4b93-9685-d652551b3731%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Okay so here's the answer

Maybe my question wasn't clear.

I find the documentation isn't clear;;

Anyway to "create" a node in one thread :

Node node = nodeBuilder().local(true).node();
Client client = node.client();

But then to connect to it in a separate thread from code that knows nothing
about this client, just make sure the clustername is the same

and then :

Node node = nodeBuilder().*local(true).*client(true).node();
Client client = node.client();

That fixes the problem.

On Monday, September 29, 2014 10:28:00 AM UTC+1, eune...@gmail.com wrote:

I'm trying to connect to the "junit" embedded node in my code under test.

Normally the code under test makes a getNodeClient to 9300 to join the
cluster.
But I guess that's not an option with the embedded local(true) node.
So what is the answer?

One option is to write the original code (under test) to accept a client
as a parameter eg m(Client client, )
And that would work but would require significant refactoring of existing
code.

What do other people do?

Just to be clear, say I have a black box piece of code under test Class C
with method m()

I start up my unit test and create a node and create a client

Node node = nodeBuilder().local(true).node()
node.start()
client = node.client()

Now I call m()

and somewhere else m calls es.writeRecord()
which does a client = getClient() // get NodeClient
but the two servers are separate and distinct.

Any way around this other than as I suggest : refactoring all code
interfaces to pass in the client to be used?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d2ca075b-0caf-4e4d-a573-bc4526f596de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.