Run tests through forbidden-apis.

This commit is contained in:
Matt Weber 2014-04-27 13:45:20 -07:00 committed by Adrien Grand
parent 34fb5e48e2
commit 2663d04a96
4 changed files with 29 additions and 16 deletions

3
all-signatures.txt Normal file
View File

@ -0,0 +1,3 @@
@defaultMessage Convert to URI
java.net.URL#getPath()
java.net.URL#getFile()

View File

@ -1077,6 +1077,7 @@
</bundledSignatures> </bundledSignatures>
<signaturesFiles> <signaturesFiles>
<signaturesFile>core-signatures.txt</signaturesFile> <signaturesFile>core-signatures.txt</signaturesFile>
<signaturesFile>all-signatures.txt</signaturesFile>
</signaturesFiles> </signaturesFiles>
<signatures>${forbidden.signatures}</signatures> <signatures>${forbidden.signatures}</signatures>
</configuration> </configuration>
@ -1098,6 +1099,10 @@
<bundledSignature>jdk-unsafe</bundledSignature> <bundledSignature>jdk-unsafe</bundledSignature>
<bundledSignature>jdk-deprecated</bundledSignature> <bundledSignature>jdk-deprecated</bundledSignature>
</bundledSignatures> </bundledSignatures>
<signaturesFiles>
<signaturesFile>test-signatures.txt</signaturesFile>
<signaturesFile>all-signatures.txt</signaturesFile>
</signaturesFiles>
<signatures>${forbidden.test.signatures}</signatures> <signatures>${forbidden.test.signatures}</signatures>
</configuration> </configuration>
<phase>test-compile</phase> <phase>test-compile</phase>

View File

@ -43,7 +43,7 @@ import org.junit.Test;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URI;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static org.elasticsearch.test.ElasticsearchIntegrationTest.*; import static org.elasticsearch.test.ElasticsearchIntegrationTest.*;
@ -73,8 +73,8 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
public void testLocalPluginInstallSingleFolder() throws Exception { public void testLocalPluginInstallSingleFolder() throws Exception {
//When we have only a folder in top-level (no files either) we remove that folder while extracting //When we have only a folder in top-level (no files either) we remove that folder while extracting
String pluginName = "plugin-test"; String pluginName = "plugin-test";
URL url = PluginManagerTests.class.getResource("plugin_single_folder.zip"); URI uri = URI.create(PluginManagerTests.class.getResource("plugin_single_folder.zip").toString());
downloadAndExtract(pluginName, "file://" + url.getFile()); downloadAndExtract(pluginName, "file://" + uri.getPath());
cluster().startNode(SETTINGS); cluster().startNode(SETTINGS);
@ -87,8 +87,8 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
//When we have only a folder in top-level (no files either) but it's called _site, we make it work //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 //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"; String pluginName = "plugin-test";
URL url = PluginManagerTests.class.getResource("plugin_folder_site.zip"); URI uri = URI.create(PluginManagerTests.class.getResource("plugin_folder_site.zip").toString());
downloadAndExtract(pluginName, "file://" + url.getFile()); downloadAndExtract(pluginName, "file://" + uri.getPath());
String nodeName = cluster().startNode(SETTINGS); String nodeName = cluster().startNode(SETTINGS);
@ -100,8 +100,8 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
public void testLocalPluginWithoutFolders() 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 //When we don't have folders at all in the top-level, but only files, we don't modify anything
String pluginName = "plugin-test"; String pluginName = "plugin-test";
URL url = PluginManagerTests.class.getResource("plugin_without_folders.zip"); URI uri = URI.create(PluginManagerTests.class.getResource("plugin_without_folders.zip").toString());
downloadAndExtract(pluginName, "file://" + url.getFile()); downloadAndExtract(pluginName, "file://" + uri.getPath());
cluster().startNode(SETTINGS); cluster().startNode(SETTINGS);
@ -113,8 +113,8 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
public void testLocalPluginFolderAndFile() 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 //When we have a single top-level folder but also files in the top-level, we don't modify anything
String pluginName = "plugin-test"; String pluginName = "plugin-test";
URL url = PluginManagerTests.class.getResource("plugin_folder_file.zip"); URI uri = URI.create(PluginManagerTests.class.getResource("plugin_folder_file.zip").toString());
downloadAndExtract(pluginName, "file://" + url.getFile()); downloadAndExtract(pluginName, "file://" + uri.getPath());
cluster().startNode(SETTINGS); cluster().startNode(SETTINGS);
@ -125,8 +125,8 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testSitePluginWithSourceThrows() throws Exception { public void testSitePluginWithSourceThrows() throws Exception {
String pluginName = "plugin-with-source"; String pluginName = "plugin-with-source";
URL url = PluginManagerTests.class.getResource("plugin_with_sourcefiles.zip"); URI uri = URI.create(PluginManagerTests.class.getResource("plugin_with_sourcefiles.zip").toString());
downloadAndExtract(pluginName, "file://" + url.getFile()); downloadAndExtract(pluginName, "file://" + uri.getPath());
} }
/** /**
@ -197,7 +197,8 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
@Test @Test
public void testInstallPlugin() throws IOException { 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"); pluginManager.downloadAndExtract("plugin");
File[] plugins = pluginManager.getListInstalledPlugins(); File[] plugins = pluginManager.getListInstalledPlugins();
@ -207,7 +208,8 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
@Test @Test
public void testInstallSitePlugin() throws IOException { 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"); pluginManager.downloadAndExtract("plugin-site");
File[] plugins = pluginManager.getListInstalledPlugins(); File[] plugins = pluginManager.getListInstalledPlugins();
@ -301,13 +303,16 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
@Test @Test
public void testRemovePlugin() throws Exception { public void testRemovePlugin() throws Exception {
// We want to remove plugin with plugin short name // 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 // 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 // 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) @Test(expected = ElasticsearchIllegalArgumentException.class)

0
test-signatures.txt Normal file
View File