# \[ANN\] Java annotations for JUnit testing with elasticsearch

**URL:** <https://discuss.elastic.co/t/ann-java-annotations-for-junit-testing-with-elasticsearch/7950>\
**Category:** Elasticsearch\
**Created:** [June 2, 2012, 9:25pm UTC](https://discuss.elastic.co/t/ann-java-annotations-for-junit-testing-with-elasticsearch/7950 "2012-06-02T21:25:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanguy1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy1/32/1749_2.png) [@Tanguy1](https://discuss.elastic.co/u/Tanguy1)\
**Post date:** [June 2, 2012, 9:25pm UTC](https://discuss.elastic.co/t/ann-java-annotations-for-junit-testing-with-elasticsearch/7950/1 "2012-06-02T21:25:28Z")

</div>

Hi all,

I've put on GitHub a small project that can be helpful for those who need  
to do JUNIT tests with elasticsearch. It helps to instantiate nodes and  
clients and take care of index and mappings creation in a less programmatic  
manner than usual.

This is how it looks like:

@RunWith(ElasticsearchRunner.class)  
public class MyTest {  
@ElasticsearchClient  
Client client;  
@Test  
@ElasticsearchIndex(indexName = "library",  
mappings = {  
@ElasticsearchMapping(typeName = "book",  
properties = {  
@ElasticsearchMappingField(name = "title", store = Store.Yes, type =  
Types.String),  
@ElasticsearchMappingField(name = "author", store = Store.Yes, type =  
Types.String)  
})  
})  
public void myFirstTestMethod(){  
... test stuff...  
}  
}

More documentation and source code can be found on GitHub project page:

> **[tlrx/elasticsearch-test](https://github.com/tlrx/elasticsearch-test)**
>
> elasticsearch-test, a framework that makes elasticsearch unit testing a breeze.

In the hope that it may be useful,

Regards,

-- Tanguy  
@tlrx

---

<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:** [June 3, 2012, 9:46am UTC](https://discuss.elastic.co/t/ann-java-annotations-for-junit-testing-with-elasticsearch/7950/2 "2012-06-03T09:46:01Z")

</div>

Great stuff, can you add it to the clients and integrations page?

On Sat, Jun 2, 2012 at 11:25 PM, Tanguy [tlrx.dev@gmail.com](mailto:tlrx.dev@gmail.com) wrote:

> Hi all,
> 
> I've put on GitHub a small project that can be helpful for those who need  
> to do JUNIT tests with elasticsearch. It helps to instantiate nodes and  
> clients and take care of index and mappings creation in a less programmatic  
> manner than usual.
> 
> This is how it looks like:
> 
> @RunWith(ElasticsearchRunner.class)  
> public class MyTest {  
> @ElasticsearchClient  
> Client client;  
> @Test  
> @ElasticsearchIndex(indexName = "library",  
> mappings = {  
> @ElasticsearchMapping(typeName = "book",  
> properties = {  
> @ElasticsearchMappingField(name = "title", store = Store.Yes, type =  
> Types.String),  
> @ElasticsearchMappingField(name = "author", store = Store.Yes, type =  
> Types.String)  
> })  
> })  
> public void myFirstTestMethod(){  
> ... test stuff...  
> }  
> }
> 
> More documentation and source code can be found on GitHub project page:  
> [GitHub - tlrx/elasticsearch-test: elasticsearch-test, a framework that makes elasticsearch unit testing a breeze.](https://github.com/tlrx/elasticsearch-test)
> 
> In the hope that it may be useful,
> 
> Regards,
> 
> -- Tanguy  
> @tlrx

---

<div class="post-metadata">

**Author:** ![Tanguy1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy1/32/1749_2.png) [@Tanguy1](https://discuss.elastic.co/u/Tanguy1)\
**Post date:** [June 3, 2012, 12:56pm UTC](https://discuss.elastic.co/t/ann-java-annotations-for-junit-testing-with-elasticsearch/7950/3 "2012-06-03T12:56:27Z")

</div>

Thanks Shay,

It's done:  
[https://github.com/elasticsearch/elasticsearch.github.com/pull/194](https://github.com/elasticsearch/elasticsearch.github.com/pull/194)

-- Tanguy  
@tlrx

Le dimanche 3 juin 2012 11:46:01 UTC+2, kimchy a écrit :

> Great stuff, can you add it to the clients and integrations page?
> 
> On Sat, Jun 2, 2012 at 11:25 PM, Tanguy [tlrx.dev@gmail.com](mailto:tlrx.dev@gmail.com) wrote:
> 
> > Hi all,
> > 
> > I've put on GitHub a small project that can be helpful for those who need  
> > to do JUNIT tests with elasticsearch. It helps to instantiate nodes and  
> > clients and take care of index and mappings creation in a less programmatic  
> > manner than usual.
> > 
> > This is how it looks like:
> > 
> > @RunWith(ElasticsearchRunner.class)  
> > public class MyTest {  
> > @ElasticsearchClient  
> > Client client;  
> > @Test  
> > @ElasticsearchIndex(indexName = "library",  
> > mappings = {  
> > @ElasticsearchMapping(typeName = "book",  
> > properties = {  
> > @ElasticsearchMappingField(name = "title", store = Store.Yes, type =  
> > Types.String),  
> > @ElasticsearchMappingField(name = "author", store = Store.Yes, type =  
> > Types.String)  
> > })  
> > })  
> > public void myFirstTestMethod(){  
> > ... test stuff...  
> > }  
> > }
> > 
> > More documentation and source code can be found on GitHub project page:  
> > [GitHub - tlrx/elasticsearch-test: elasticsearch-test, a framework that makes elasticsearch unit testing a breeze.](https://github.com/tlrx/elasticsearch-test)
> > 
> > In the hope that it may be useful,
> > 
> > Regards,
> > 
> > -- Tanguy  
> > @tlrx

---

<div class="post-metadata">

**Author:** ![Tanguy1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy1/32/1749_2.png) [@Tanguy1](https://discuss.elastic.co/u/Tanguy1)\
**Post date:** [June 28, 2012, 6:03pm UTC](https://discuss.elastic.co/t/ann-java-annotations-for-junit-testing-with-elasticsearch/7950/4 "2012-06-28T18:03:54Z")

</div>

Hi,

Just updated to 0.0.3, now with settings, analyzers and bulk requests:  
[https://github.com/tlrx/elasticsearch-test/blob/master/src/test/java/fr/tlrx/elasticsearch/test/annotations/ElasticsearchBulkRequestAnnotationTest.java](https://github.com/tlrx/elasticsearch-test/blob/master/src/test/java/fr/tlrx/elasticsearch/test/annotations/ElasticsearchBulkRequestAnnotationTest.java)

Issues, PR and feedback are welcome :o)

-- Tanguy  
@tlrx

Le samedi 2 juin 2012 23:25:28 UTC+2, Tanguy a écrit :

> Hi all,
> 
> I've put on GitHub a small project that can be helpful for those who need  
> to do JUNIT tests with elasticsearch. It helps to instantiate nodes and  
> clients and take care of index and mappings creation in a less programmatic  
> manner than usual.
> 
> This is how it looks like:
> 
> @RunWith(ElasticsearchRunner.class)  
> public class MyTest {  
> @ElasticsearchClient  
> Client client;  
> @Test  
> @ElasticsearchIndex(indexName = "library",  
> mappings = {  
> @ElasticsearchMapping(typeName = "book",  
> properties = {  
> @ElasticsearchMappingField(name = "title", store = Store.Yes, type =  
> Types.String),  
> @ElasticsearchMappingField(name = "author", store = Store.Yes, type =  
> Types.String)  
> })  
> })  
> public void myFirstTestMethod(){  
> ... test stuff...  
> }  
> }
> 
> More documentation and source code can be found on GitHub project page:  
> [GitHub - tlrx/elasticsearch-test: elasticsearch-test, a framework that makes elasticsearch unit testing a breeze.](https://github.com/tlrx/elasticsearch-test)
> 
> In the hope that it may be useful,
> 
> Regards,
> 
> -- Tanguy  
> @tlrx

---

<div class="post-metadata">

**Author:** ![Tanguy1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy1/32/1749_2.png) [@Tanguy1](https://discuss.elastic.co/u/Tanguy1)\
**Post date:** [November 7, 2012, 9:39am UTC](https://discuss.elastic.co/t/ann-java-annotations-for-junit-testing-with-elasticsearch/7950/5 "2012-11-07T09:39:16Z")

</div>

Hi,

Just to let you know - version 0.0.5 of this test library for JUnit &  
Elasticsearch has been released on OSS maven repositories.

> **[tlrx/elasticsearch-test](https://github.com/tlrx/elasticsearch-test)**
>
> elasticsearch-test, a framework that makes elasticsearch unit testing a breeze.

  
[https://oss.sonatype.org/content/repositories/releases/com/github/tlrx/](https://oss.sonatype.org/content/repositories/releases/com/github/tlrx/)

I (and other folks) use it on production and it works well. I hope it will  
be helpful for other people as well :o)

-- Tanguy  
Twitter: @tlrx

> **[tlrx (Tanguy Leroux)](https://github.com/tlrx/)**
>
> tlrx has 22 repositories available. Follow their code on GitHub.

--

---

<div class="post-metadata">

**Author:** ![kazoompa\_3](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@kazoompa\_3](https://discuss.elastic.co/u/kazoompa_3)\
**Post date:** [December 22, 2014, 9:13pm UTC](https://discuss.elastic.co/t/ann-java-annotations-for-junit-testing-with-elasticsearch/7950/6 "2014-12-22T21:13:41Z")

</div>

HI Tanguy,

Is this library still maintained for the newer versions of ES, for example  
1.4.0?

Thanks,  
Ramin

On Wednesday, November 7, 2012 4:39:16 AM UTC-5, Tanguy wrote:

> Hi,
> 
> Just to let you know - version 0.0.5 of this test library for JUnit &  
> Elasticsearch has been released on OSS maven repositories.  
> [GitHub - tlrx/elasticsearch-test: elasticsearch-test, a framework that makes elasticsearch unit testing a breeze.](https://github.com/tlrx/elasticsearch-test)  
> [Central Repository: com/github/tlrx](https://oss.sonatype.org/content/repositories/releases/com/github/tlrx/)
> 
> I (and other folks) use it on production and it works well. I hope it will  
> be helpful for other people as well :o)
> 
> -- Tanguy  
> Twitter: @tlrx  
> [tlrx (Tanguy Leroux) · GitHub](https://github.com/tlrx/)

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5098ba86-5c72-4bc2-98b1-3d77b1168d6f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5098ba86-5c72-4bc2-98b1-3d77b1168d6f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:42am UTC](https://discuss.elastic.co/t/ann-java-annotations-for-junit-testing-with-elasticsearch/7950/7 "2017-07-06T00:42:15Z")

</div>


