Unittest: RestFilter gets not invoked when using internal client or transportclient

I have written a RestFilter and i want to add some unit tests to test it.
But it seems that the RestFilter gets not invoked from the unittest.

[2013-10-22 17:48:54,340][INFO ][org.elasticsearch.node ] [Nocturne]
version[0.90.5], pid[9456], build[c8714e8/2013-09-17T12:50:20Z]
[2013-10-22 17:48:54,340][INFO ][org.elasticsearch.node ] [Nocturne]
initializing ...
[2013-10-22 17:48:54,346][DEBUG][org.elasticsearch.plugins.security]
Starting Security Plugin
[2013-10-22 17:48:54,351][INFO ][org.elasticsearch.plugins] [Nocturne]
loaded [elasticsearch-my-plugin], sites []
[2013-10-22 17:48:56,199][INFO ][org.elasticsearch.node ] [Nocturne]
initialized
[2013-10-22 17:48:56,200][INFO ][org.elasticsearch.node ] [Nocturne]
starting ...
[2013-10-22
17:48:56,207][DEBUG][org.elasticsearch.plugins.myplugin.service] [Nocturne]
security.configuration.index=securityconfiguration
[2013-10-22 17:48:56,349][INFO ][org.elasticsearch.transport] [Nocturne]
bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address
{inet[/1x2.xx.27.6:9300]}
[2013-10-22 17:48:59,485][INFO ][org.elasticsearch.cluster.service]
[Nocturne] new_master
[Nocturne][9Qnq2Bs3QUuFBw_0-Ompxg][inet[/1x2.xx.27.6:9300]]{http.enabled=true,
local=false}, reason: zen-disco-join (elected_as_master)
[2013-10-22 17:48:59,541][INFO ][org.elasticsearch.discovery] [Nocturne]
elasticsearch/9Qnq2Bs3QUuFBw_0-Ompxg
[2013-10-22 17:48:59,556][INFO ][org.elasticsearch.gateway] [Nocturne]
recovered [0] indices into cluster_state
[2013-10-22 17:48:59,587][INFO ][org.elasticsearch.http ] [Nocturne]
bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address
{inet[/1x2.xx.27.6:9200]}
[2013-10-22 17:48:59,587][INFO ][org.elasticsearch.node ] [Nocturne]
started

Node node =
NodeBuilder.nodeBuilder().local(false).settings(settings).node();
client = node.client();
client.prepareIndex("content","mytype").setSource(loadFile("dummy_content.json")).setRefresh(true).execute().actionGet();
<-- this normally invkoes RestFilter, but not within Junit

If i point my browser (during test is running) to localhost:9200 then the
RestFilter is invoked correctly.

I have also played around with the TransportClient, but situation is the
same.

Thanks
Hendrik

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

With Junit you are starting a Node and get a Transport Client from that node.
That means you are using Transport Layer (9300) and not REST Layer.

That's the reason your REST Filter is not applied here.

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 22 oct. 2013 à 17:56, Hendrik h.j.saly@googlemail.com a écrit :

I have written a RestFilter and i want to add some unit tests to test it.
But it seems that the RestFilter gets not invoked from the unittest.

[2013-10-22 17:48:54,340][INFO ][org.elasticsearch.node ] [Nocturne] version[0.90.5], pid[9456], build[c8714e8/2013-09-17T12:50:20Z]
[2013-10-22 17:48:54,340][INFO ][org.elasticsearch.node ] [Nocturne] initializing ...
[2013-10-22 17:48:54,346][DEBUG][org.elasticsearch.plugins.security] Starting Security Plugin
[2013-10-22 17:48:54,351][INFO ][org.elasticsearch.plugins] [Nocturne] loaded [elasticsearch-my-plugin], sites
[2013-10-22 17:48:56,199][INFO ][org.elasticsearch.node ] [Nocturne] initialized
[2013-10-22 17:48:56,200][INFO ][org.elasticsearch.node ] [Nocturne] starting ...
[2013-10-22 17:48:56,207][DEBUG][org.elasticsearch.plugins.myplugin.service] [Nocturne] security.configuration.index=securityconfiguration
[2013-10-22 17:48:56,349][INFO ][org.elasticsearch.transport] [Nocturne] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/1x2.xx.27.6:9300]}
[2013-10-22 17:48:59,485][INFO ][org.elasticsearch.cluster.service] [Nocturne] new_master [Nocturne][9Qnq2Bs3QUuFBw_0-Ompxg][inet[/1x2.xx.27.6:9300]]{http.enabled=true, local=false}, reason: zen-disco-join (elected_as_master)
[2013-10-22 17:48:59,541][INFO ][org.elasticsearch.discovery] [Nocturne] elasticsearch/9Qnq2Bs3QUuFBw_0-Ompxg
[2013-10-22 17:48:59,556][INFO ][org.elasticsearch.gateway] [Nocturne] recovered [0] indices into cluster_state
[2013-10-22 17:48:59,587][INFO ][org.elasticsearch.http ] [Nocturne] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/1x2.xx.27.6:9200]}
[2013-10-22 17:48:59,587][INFO ][org.elasticsearch.node ] [Nocturne] started

Node node = NodeBuilder.nodeBuilder().local(false).settings(settings).node();
client = node.client();
client.prepareIndex("content","mytype").setSource(loadFile("dummy_content.json")).setRefresh(true).execute().actionGet(); <-- this normally invkoes RestFilter, but not within Junit

If i point my browser (during test is running) to localhost:9200 then the RestFilter is invoked correctly.

I have also played around with the TransportClient, but situation is the same.

Thanks
Hendrik

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

thanks, and how can i use the REST layer from within a unit test?

Am Dienstag, 22. Oktober 2013 18:29:45 UTC+2 schrieb David Pilato:

With Junit you are starting a Node and get a Transport Client from that
node.
That means you are using Transport Layer (9300) and not REST Layer.

That's the reason your REST Filter is not applied here.

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 22 oct. 2013 à 17:56, Hendrik <h.j....@googlemail.com <javascript:>> a
écrit :

I have written a RestFilter and i want to add some unit tests to test it.
But it seems that the RestFilter gets not invoked from the unittest.

[2013-10-22 17:48:54,340][INFO ][org.elasticsearch.node ] [Nocturne]
version[0.90.5], pid[9456], build[c8714e8/2013-09-17T12:50:20Z]
[2013-10-22 17:48:54,340][INFO ][org.elasticsearch.node ] [Nocturne]
initializing ...
[2013-10-22 17:48:54,346][DEBUG][org.elasticsearch.plugins.security]
Starting Security Plugin
[2013-10-22 17:48:54,351][INFO ][org.elasticsearch.plugins] [Nocturne]
loaded [elasticsearch-my-plugin], sites
[2013-10-22 17:48:56,199][INFO ][org.elasticsearch.node ] [Nocturne]
initialized
[2013-10-22 17:48:56,200][INFO ][org.elasticsearch.node ] [Nocturne]
starting ...
[2013-10-22
17:48:56,207][DEBUG][org.elasticsearch.plugins.myplugin.service] [Nocturne]
security.configuration.index=securityconfiguration
[2013-10-22 17:48:56,349][INFO ][org.elasticsearch.transport] [Nocturne]
bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address
{inet[/1x2.xx.27.6:9300]}
[2013-10-22 17:48:59,485][INFO ][org.elasticsearch.cluster.service]
[Nocturne] new_master
[Nocturne][9Qnq2Bs3QUuFBw_0-Ompxg][inet[/1x2.xx.27.6:9300]]{http.enabled=true,
local=false}, reason: zen-disco-join (elected_as_master)
[2013-10-22 17:48:59,541][INFO ][org.elasticsearch.discovery] [Nocturne]
elasticsearch/9Qnq2Bs3QUuFBw_0-Ompxg
[2013-10-22 17:48:59,556][INFO ][org.elasticsearch.gateway] [Nocturne]
recovered [0] indices into cluster_state
[2013-10-22 17:48:59,587][INFO ][org.elasticsearch.http ] [Nocturne]
bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address
{inet[/1x2.xx.27.6:9200]}
[2013-10-22 17:48:59,587][INFO ][org.elasticsearch.node ] [Nocturne]
started

Node node =
NodeBuilder.nodeBuilder().local(false).settings(settings).node();
client = node.client();
client.prepareIndex("content","mytype").setSource(loadFile("dummy_content.json")).setRefresh(true).execute().actionGet();
<-- this normally invkoes RestFilter, but not within Junit

If i point my browser (during test is running) to localhost:9200 then the
RestFilter is invoked correctly.

I have also played around with the TransportClient, but situation is the
same.

Thanks
Hendrik

--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

With a REST call! :slight_smile:

I did use in the past RestTemplate: https://github.com/scrutmydocs/scrutmydocs/blob/master/src/test/java/org/scrutmydocs/webapp/itest/api/AbstractApiTest.java

I assume that you could do something easier similar to this (not tested):

    URL url = new URL( http_url );
    InputStream stream = url.openConnection().getInputStream();

And then parse the result?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 22 oct. 2013 à 18:37, Hendrik h.j.saly@googlemail.com a écrit :

thanks, and how can i use the REST layer from within a unit test?

Am Dienstag, 22. Oktober 2013 18:29:45 UTC+2 schrieb David Pilato:
With Junit you are starting a Node and get a Transport Client from that node.
That means you are using Transport Layer (9300) and not REST Layer.

That's the reason your REST Filter is not applied here.

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 22 oct. 2013 à 17:56, Hendrik h.j....@googlemail.com a écrit :

I have written a RestFilter and i want to add some unit tests to test it.
But it seems that the RestFilter gets not invoked from the unittest.

[2013-10-22 17:48:54,340][INFO ][org.elasticsearch.node ] [Nocturne] version[0.90.5], pid[9456], build[c8714e8/2013-09-17T12:50:20Z]
[2013-10-22 17:48:54,340][INFO ][org.elasticsearch.node ] [Nocturne] initializing ...
[2013-10-22 17:48:54,346][DEBUG][org.elasticsearch.plugins.security] Starting Security Plugin
[2013-10-22 17:48:54,351][INFO ][org.elasticsearch.plugins] [Nocturne] loaded [elasticsearch-my-plugin], sites
[2013-10-22 17:48:56,199][INFO ][org.elasticsearch.node ] [Nocturne] initialized
[2013-10-22 17:48:56,200][INFO ][org.elasticsearch.node ] [Nocturne] starting ...
[2013-10-22 17:48:56,207][DEBUG][org.elasticsearch.plugins.myplugin.service] [Nocturne] security.configuration.index=securityconfiguration
[2013-10-22 17:48:56,349][INFO ][org.elasticsearch.transport] [Nocturne] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/1x2.xx.27.6:9300]}
[2013-10-22 17:48:59,485][INFO ][org.elasticsearch.cluster.service] [Nocturne] new_master [Nocturne][9Qnq2Bs3QUuFBw_0-Ompxg][inet[/1x2.xx.27.6:9300]]{http.enabled=true, local=false}, reason: zen-disco-join (elected_as_master)
[2013-10-22 17:48:59,541][INFO ][org.elasticsearch.discovery] [Nocturne] elasticsearch/9Qnq2Bs3QUuFBw_0-Ompxg
[2013-10-22 17:48:59,556][INFO ][org.elasticsearch.gateway] [Nocturne] recovered [0] indices into cluster_state
[2013-10-22 17:48:59,587][INFO ][org.elasticsearch.http ] [Nocturne] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/1x2.xx.27.6:9200]}
[2013-10-22 17:48:59,587][INFO ][org.elasticsearch.node ] [Nocturne] started

Node node = NodeBuilder.nodeBuilder().local(false).settings(settings).node();
client = node.client();
client.prepareIndex("content","mytype").setSource(loadFile("dummy_content.json")).setRefresh(true).execute().actionGet(); <-- this normally invkoes RestFilter, but not within Junit

If i point my browser (during test is running) to localhost:9200 then the RestFilter is invoked correctly.

I have also played around with the TransportClient, but situation is the same.

Thanks
Hendrik

--
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 elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

ok understood, i think i will use a rest client
like GitHub - searchbox-io/Jest: Elasticsearch Java Rest Client.
thanks

Am Dienstag, 22. Oktober 2013 18:43:36 UTC+2 schrieb David Pilato:

With a REST call! :slight_smile:

I did use in the past RestTemplate:
https://github.com/scrutmydocs/scrutmydocs/blob/master/src/test/java/org/scrutmydocs/webapp/itest/api/AbstractApiTest.java

I assume that you could do something easier similar to this (not tested):

    URL url = new URL( http_url );
    InputStream stream = url.openConnection().getInputStream();

And then parse the result?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 22 oct. 2013 à 18:37, Hendrik <h.j....@googlemail.com <javascript:>> a
écrit :

thanks, and how can i use the REST layer from within a unit test?

Am Dienstag, 22. Oktober 2013 18:29:45 UTC+2 schrieb David Pilato:

With Junit you are starting a Node and get a Transport Client from that
node.
That means you are using Transport Layer (9300) and not REST Layer.

That's the reason your REST Filter is not applied here.

--
David Pilato | Technical Advocate | *Elasticsearch.comhttp://elasticsearch.com/
*
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 22 oct. 2013 à 17:56, Hendrik h.j....@googlemail.com a écrit :

I have written a RestFilter and i want to add some unit tests to test it.
But it seems that the RestFilter gets not invoked from the unittest.

[2013-10-22 17:48:54,340][INFO ][org.elasticsearch.node ] [Nocturne]
version[0.90.5], pid[9456], build[c8714e8/2013-09-17T12:50:20Z]
[2013-10-22 17:48:54,340][INFO ][org.elasticsearch.node ] [Nocturne]
initializing ...
[2013-10-22 17:48:54,346][DEBUG][org.elasticsearch.plugins.security]
Starting Security Plugin
[2013-10-22 17:48:54,351][INFO ][org.elasticsearch.plugins] [Nocturne]
loaded [elasticsearch-my-plugin], sites
[2013-10-22 17:48:56,199][INFO ][org.elasticsearch.node ] [Nocturne]
initialized
[2013-10-22 17:48:56,200][INFO ][org.elasticsearch.node ] [Nocturne]
starting ...
[2013-10-22
17:48:56,207][DEBUG][org.elasticsearch.plugins.myplugin.service] [Nocturne]
security.configuration.index=securityconfiguration
[2013-10-22 17:48:56,349][INFO ][org.elasticsearch.transport] [Nocturne]
bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address
{inet[/1x2.xx.27.6:9300]}
[2013-10-22 17:48:59,485][INFO ][org.elasticsearch.cluster.service]
[Nocturne] new_master
[Nocturne][9Qnq2Bs3QUuFBw_0-Ompxg][inet[/1x2.xx.27.6:9300]]{http.enabled=true,
local=false}, reason: zen-disco-join (elected_as_master)
[2013-10-22 17:48:59,541][INFO ][org.elasticsearch.discovery] [Nocturne]
elasticsearch/9Qnq2Bs3QUuFBw_0-Ompxg
[2013-10-22 17:48:59,556][INFO ][org.elasticsearch.gateway] [Nocturne]
recovered [0] indices into cluster_state
[2013-10-22 17:48:59,587][INFO ][org.elasticsearch.http ] [Nocturne]
bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address
{inet[/1x2.xx.27.6:9200]}
[2013-10-22 17:48:59,587][INFO ][org.elasticsearch.node ] [Nocturne]
started

Node node =
NodeBuilder.nodeBuilder().local(false).settings(settings).node();
client = node.client();
client.prepareIndex("content","mytype").setSource(loadFile("dummy_content.json")).setRefresh(true).execute().actionGet();
<-- this normally invkoes RestFilter, but not within Junit

If i point my browser (during test is running) to localhost:9200 then the
RestFilter is invoked correctly.

I have also played around with the TransportClient, but situation is the
same.

Thanks
Hendrik

--
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 elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.