Skip to content

Commit

Permalink
Run tests through forbidden-apis.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattweber authored and jpountz committed Apr 30, 2014
1 parent 34fb5e4 commit 2663d04
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
3 changes: 3 additions & 0 deletions all-signatures.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@defaultMessage Convert to URI
java.net.URL#getPath()
java.net.URL#getFile()
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,7 @@
</bundledSignatures>
<signaturesFiles>
<signaturesFile>core-signatures.txt</signaturesFile>
<signaturesFile>all-signatures.txt</signaturesFile>
</signaturesFiles>
<signatures>${forbidden.signatures}</signatures>
</configuration>
Expand All @@ -1098,6 +1099,10 @@
<bundledSignature>jdk-unsafe</bundledSignature>
<bundledSignature>jdk-deprecated</bundledSignature>
</bundledSignatures>
<signaturesFiles>
<signaturesFile>test-signatures.txt</signaturesFile>
<signaturesFile>all-signatures.txt</signaturesFile>
</signaturesFiles>
<signatures>${forbidden.test.signatures}</signatures>
</configuration>
<phase>test-compile</phase>
Expand Down
37 changes: 21 additions & 16 deletions src/test/java/org/elasticsearch/plugin/PluginManagerTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URI;
import java.util.concurrent.TimeUnit;

import static org.elasticsearch.test.ElasticsearchIntegrationTest.*;
Expand Down Expand Up @@ -73,8 +73,8 @@ public void beforeTest() {
public void testLocalPluginInstallSingleFolder() throws Exception {
//When we have only a folder in top-level (no files either) we remove that folder while extracting
String pluginName = "plugin-test";
URL url = PluginManagerTests.class.getResource("plugin_single_folder.zip");
downloadAndExtract(pluginName, "file://" + url.getFile());
URI uri = URI.create(PluginManagerTests.class.getResource("plugin_single_folder.zip").toString());
downloadAndExtract(pluginName, "file://" + uri.getPath());

cluster().startNode(SETTINGS);

Expand All @@ -87,8 +87,8 @@ public void testLocalPluginInstallSiteFolder() throws Exception {
//When we have only a folder in top-level (no files either) but it's called _site, we make it work
//we can either remove the folder while extracting and then re-add it manually or just leave it as it is
String pluginName = "plugin-test";
URL url = PluginManagerTests.class.getResource("plugin_folder_site.zip");
downloadAndExtract(pluginName, "file://" + url.getFile());
URI uri = URI.create(PluginManagerTests.class.getResource("plugin_folder_site.zip").toString());
downloadAndExtract(pluginName, "file://" + uri.getPath());

String nodeName = cluster().startNode(SETTINGS);

Expand All @@ -100,8 +100,8 @@ public void testLocalPluginInstallSiteFolder() throws Exception {
public void testLocalPluginWithoutFolders() throws Exception {
//When we don't have folders at all in the top-level, but only files, we don't modify anything
String pluginName = "plugin-test";
URL url = PluginManagerTests.class.getResource("plugin_without_folders.zip");
downloadAndExtract(pluginName, "file://" + url.getFile());
URI uri = URI.create(PluginManagerTests.class.getResource("plugin_without_folders.zip").toString());
downloadAndExtract(pluginName, "file://" + uri.getPath());

cluster().startNode(SETTINGS);

Expand All @@ -113,8 +113,8 @@ public void testLocalPluginWithoutFolders() throws Exception {
public void testLocalPluginFolderAndFile() throws Exception {
//When we have a single top-level folder but also files in the top-level, we don't modify anything
String pluginName = "plugin-test";
URL url = PluginManagerTests.class.getResource("plugin_folder_file.zip");
downloadAndExtract(pluginName, "file://" + url.getFile());
URI uri = URI.create(PluginManagerTests.class.getResource("plugin_folder_file.zip").toString());
downloadAndExtract(pluginName, "file://" + uri.getPath());

cluster().startNode(SETTINGS);

Expand All @@ -125,8 +125,8 @@ public void testLocalPluginFolderAndFile() throws Exception {
@Test(expected = IllegalArgumentException.class)
public void testSitePluginWithSourceThrows() throws Exception {
String pluginName = "plugin-with-source";
URL url = PluginManagerTests.class.getResource("plugin_with_sourcefiles.zip");
downloadAndExtract(pluginName, "file://" + url.getFile());
URI uri = URI.create(PluginManagerTests.class.getResource("plugin_with_sourcefiles.zip").toString());
downloadAndExtract(pluginName, "file://" + uri.getPath());
}

/**
Expand Down Expand Up @@ -197,7 +197,8 @@ public void testInstallPluginNull() throws IOException {

@Test
public void testInstallPlugin() throws IOException {
PluginManager pluginManager = pluginManager("file://".concat(PluginManagerTests.class.getResource("plugin_with_classfile.zip").getFile()));
PluginManager pluginManager = pluginManager("file://".concat(
URI.create(PluginManagerTests.class.getResource("plugin_with_classfile.zip").toString()).getPath()));

pluginManager.downloadAndExtract("plugin");
File[] plugins = pluginManager.getListInstalledPlugins();
Expand All @@ -207,7 +208,8 @@ public void testInstallPlugin() throws IOException {

@Test
public void testInstallSitePlugin() throws IOException {
PluginManager pluginManager = pluginManager("file://".concat(PluginManagerTests.class.getResource("plugin_without_folders.zip").getFile()));
PluginManager pluginManager = pluginManager("file://".concat(
URI.create(PluginManagerTests.class.getResource("plugin_without_folders.zip").toString()).getPath()));

pluginManager.downloadAndExtract("plugin-site");
File[] plugins = pluginManager.getListInstalledPlugins();
Expand Down Expand Up @@ -301,13 +303,16 @@ private void deletePluginsFolder() {
@Test
public void testRemovePlugin() throws Exception {
// We want to remove plugin with plugin short name
singlePluginInstallAndRemove("plugintest", "file://".concat(PluginManagerTests.class.getResource("plugin_without_folders.zip").getFile()));
singlePluginInstallAndRemove("plugintest", "file://".concat(
URI.create(PluginManagerTests.class.getResource("plugin_without_folders.zip").toString()).getPath()));

// We want to remove plugin with groupid/artifactid/version form
singlePluginInstallAndRemove("groupid/plugintest/1.0.0", "file://".concat(PluginManagerTests.class.getResource("plugin_without_folders.zip").getFile()));
singlePluginInstallAndRemove("groupid/plugintest/1.0.0", "file://".concat(
URI.create(PluginManagerTests.class.getResource("plugin_without_folders.zip").toString()).getPath()));

// We want to remove plugin with groupid/artifactid form
singlePluginInstallAndRemove("groupid/plugintest", "file://".concat(PluginManagerTests.class.getResource("plugin_without_folders.zip").getFile()));
singlePluginInstallAndRemove("groupid/plugintest", "file://".concat(
URI.create(PluginManagerTests.class.getResource("plugin_without_folders.zip").toString()).getPath()));
}

@Test(expected = ElasticsearchIllegalArgumentException.class)
Expand Down
Empty file added test-signatures.txt
Empty file.

0 comments on commit 2663d04

Please sign in to comment.