# How to use plugins when doing unit tests?

**URL:** <https://discuss.elastic.co/t/how-to-use-plugins-when-doing-unit-tests/3232>\
**Category:** Elasticsearch\
**Created:** [August 18, 2010, 10:14pm UTC](https://discuss.elastic.co/t/how-to-use-plugins-when-doing-unit-tests/3232 "2010-08-18T22:14:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Chang](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@John\_Chang](https://discuss.elastic.co/u/John_Chang)\
**Post date:** [August 18, 2010, 10:14pm UTC](https://discuss.elastic.co/t/how-to-use-plugins-when-doing-unit-tests/3232/1 "2010-08-18T22:14:40Z")

</div>

I start nodes locally in unit tests, such as:

```
    hostNode = NodeBuilder.nodeBuilder().loadConfigSettings(false).clusterName("test.cluster").local(true).settings(
            ImmutableSettings.settingsBuilder()
            .put("index.number_of_shards", 1)
            .put("index.number_of_replicas", 1).build()
    ).node().start();
    elasticSearchClient = hostNode.client();

```

I want to use the attachment plugin. I can get it all to work when I start the stand-alone cluster and run the code in the java client.

Can I get the attachment plugin to work with the unit tests that start the node in memory as detailed above? If so, how?

Thanks

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 19, 2010, 7:13am UTC](https://discuss.elastic.co/t/how-to-use-plugins-when-doing-unit-tests/3232/2 "2010-08-19T07:13:39Z")

</div>

You just need to have the plugin jar file and its deps in the classpath. The  
plugins are also in maven repo, for the attachment plugin, you will also  
need Tika.

-shay.banon

On Thu, Aug 19, 2010 at 1:14 AM, John Chang [jchangkihtest2@gmail.com](mailto:jchangkihtest2@gmail.com)wrote:

> I start nodes locally in unit tests, such as:
> 
> ```
> hostNode =
> 
> ```
> 
> NodeBuilder.nodeBuilder().loadConfigSettings(false).clusterName("test.cluster").local(true).settings(  
> ImmutableSettings.settingsBuilder()  
> .put("index.number\_of\_shards", 1)  
> .put("index.number\_of\_replicas", 1).build()  
> ).node().start();  
> elasticSearchClient = hostNode.client();
> 
> I want to use the attachment plugin. I can get it all to work when I start  
> the stand-alone cluster and run the code in the java client.
> 
> Can I get the attachment plugin to work with the unit tests that start the  
> node in memory as detailed above? If so, how?
> 
> ## Thanks
> 
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/How-to-use-plugins-when-doing-unit-tests-tp1215857p1215857.html](http://elasticsearch-users.115913.n3.nabble.com/How-to-use-plugins-when-doing-unit-tests-tp1215857p1215857.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:20am UTC](https://discuss.elastic.co/t/how-to-use-plugins-when-doing-unit-tests/3232/3 "2017-07-06T04:20:35Z")

</div>


