From 94459bd7813c052d869ba4c1695f122a7af80350 Mon Sep 17 00:00:00 2001 From: David Pilato Date: Fri, 23 Oct 2015 15:47:37 +0200 Subject: [PATCH] Standalone runner expects path.home to be set With elasticsearch 2.0, `path.home` must be set now. Standalone Runner (test) is using elasticsearch CLI which relies on `Environment` to be set. It produces now: ``` Exception in thread "main" java.lang.IllegalStateException: path.home is not configured at org.elasticsearch.env.Environment.(Environment.java:99) at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:85) at org.elasticsearch.common.cli.CliTool.(CliTool.java:107) at org.elasticsearch.common.cli.CliTool.(CliTool.java:100) at org.elasticsearch.index.mapper.attachment.test.standalone.StandaloneRunner.(StandaloneRunner.java:170) at org.elasticsearch.index.mapper.attachment.test.standalone.StandaloneRunner.main(StandaloneRunner.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) ``` Closes #167. --- .../attachment/test/standalone/StandaloneRunner.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/index/mapper/attachment/test/standalone/StandaloneRunner.java b/src/test/java/org/elasticsearch/index/mapper/attachment/test/standalone/StandaloneRunner.java index c3ff9d4045c..ff6c5728590 100644 --- a/src/test/java/org/elasticsearch/index/mapper/attachment/test/standalone/StandaloneRunner.java +++ b/src/test/java/org/elasticsearch/index/mapper/attachment/test/standalone/StandaloneRunner.java @@ -66,6 +66,15 @@ public class StandaloneRunner extends CliTool { .cmds(TikaRunner.CMD) .build(); + static { + try { + Path tmp = Files.createTempDirectory("tika"); + System.setProperty("es.path.home", tmp.getFileName().toString()); + } catch (IOException e) { + e.printStackTrace(); + } + } + static class TikaRunner extends Command { private static final String NAME = "tika"; private final String url; @@ -113,7 +122,7 @@ public class StandaloneRunner extends CliTool { terminal.println("## Extracted text"); terminal.println("--------------------- BEGIN -----------------------"); - terminal.println("%s", doc.get(docMapper.mappers().getMapper("file").fieldType().names().indexName())); + terminal.println("%s", doc.get("file.content")); terminal.println("---------------------- END ------------------------"); terminal.println("## Metadata"); printMetadataContent(doc, AttachmentMapper.FieldNames.AUTHOR);