Skip to content

Commit

Permalink
Add check that plugin must specify at least site or jvm
Browse files Browse the repository at this point in the history
  • Loading branch information
rjernst committed Jul 22, 2015
1 parent 19aef2f commit 4a9b5b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/main/java/org/elasticsearch/plugins/PluginInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public static PluginInfo readFromProperties(Path dir) throws IOException {
}
boolean jvm = Boolean.parseBoolean(props.getProperty("jvm"));
boolean site = Boolean.parseBoolean(props.getProperty("site"));
if (jvm == false && site == false) {
throw new IllegalArgumentException("Plugin [" + name + "] must be at least a jvm or site plugin");
}
boolean isolated = true;
String classname = "NA";
if (jvm) {
Expand Down
14 changes: 14 additions & 0 deletions core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import static org.hamcrest.Matchers.contains;

public class PluginInfoTests extends ElasticsearchTestCase {

void writeProperties(Path pluginDir, String... stringProps) throws IOException {
assert stringProps.length % 2 == 0;
Files.createDirectories(pluginDir);
Expand Down Expand Up @@ -91,6 +92,19 @@ public void testReadFromPropertiesVersionMissing() throws Exception {
}
}

public void testReadFromPropertiesJvmAndSiteMissing() throws Exception {
Path pluginDir = createTempDir().resolve("fake-plugin");
writeProperties(pluginDir,
"description", "fake desc",
"version", "1.0");
try {
PluginInfo.readFromProperties(pluginDir);
fail("expected jvm or site exception");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("must be at least a jvm or site plugin"));
}
}

public void testReadFromPropertiesElasticsearchVersionMissing() throws Exception {
Path pluginDir = createTempDir().resolve("fake-plugin");
writeProperties(pluginDir,
Expand Down

0 comments on commit 4a9b5b4

Please sign in to comment.