# How am I supposed to deal with test resources in an ESIntegTestCase?

**URL:** <https://discuss.elastic.co/t/how-am-i-supposed-to-deal-with-test-resources-in-an-esintegtestcase/73959>\
**Category:** Elasticsearch\
**Created:** [February 4, 2017, 8:36pm UTC](https://discuss.elastic.co/t/how-am-i-supposed-to-deal-with-test-resources-in-an-esintegtestcase/73959 "2017-02-04T20:36:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [February 4, 2017, 8:36pm UTC](https://discuss.elastic.co/t/how-am-i-supposed-to-deal-with-test-resources-in-an-esintegtestcase/73959/1 "2017-02-04T20:36:38Z")

</div>

I'm working on an Elasticsearch plugin. I'm implementing an integration test that needs to pull something off the file system. It's a rather large blob of text and I'd rather not place it inline in the code. I'm using the `esPlugin` gradle plugin. Which comes with many handy checks, including ensuring I'm not using any forbidden APIs.

The Java file i/o APIs appear to be forbidden. Instead, you're asked to use Elasticsearch's PathUtils utility class. This works fine in Intellij, however when I run the integration test from the command line (`gradle integTest`) I get a file-not-found error. It seems the root file system for Elasticsearch is not the same place where my test resource was staged. Specifically, `/build/testrun/integTest/J0/build/resources/test/model.txt`. You can see what I'm trying to do [here](https://github.com/o19s/elasticsearch-learning-to-rank/blob/faster-ranklib/src/test/java/com/o19s/es/ltr/query/LtrRanklibStoredScriptIT.java#L70).

I'm wondering what I, as an Elasticsearch plugin developer, am supposed to do to handle my own test resources. Should I

1. Use some integTest#processTestResources that will stage this for me in the temp folder? (I can't seem to find such a task)
2. Disable forbidden APIs for integTests?
3. Use some other process I'm unfamiliar with?

Any help appreciated!

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [February 4, 2017, 8:44pm UTC](https://discuss.elastic.co/t/how-am-i-supposed-to-deal-with-test-resources-in-an-esintegtestcase/73959/2 "2017-02-04T20:44:08Z")

</div>

I've also tried using the classloader to access my resources, but run into similar problems with java.io.File being disallowed.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 5, 2017, 12:23am UTC](https://discuss.elastic.co/t/how-am-i-supposed-to-deal-with-test-resources-in-an-esintegtestcase/73959/3 "2017-02-05T00:23:10Z")

</div>

Have a look at

> <https://github.com/elastic/elasticsearch/blob/master/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/TikaDocTests.java>

---

<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:** [March 5, 2017, 12:23am UTC](https://discuss.elastic.co/t/how-am-i-supposed-to-deal-with-test-resources-in-an-esintegtestcase/73959/4 "2017-03-05T00:23:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
