From 0779d60a87f1f34da06c94ea470e5ca28ace20b2 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Wed, 10 Jan 2018 14:01:38 +0100 Subject: [PATCH] randomize the directory name and remove the exception check --- .../plugins/InstallPluginCommandTests.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java index 7a748ec7955ff..db5a6a16a9d34 100644 --- a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java +++ b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java @@ -22,6 +22,7 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import com.google.common.jimfs.Configuration; import com.google.common.jimfs.Jimfs; +import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.LuceneTestCase; import org.elasticsearch.Version; import org.elasticsearch.cli.ExitCodes; @@ -433,10 +434,12 @@ public void testMalformedUrlNotMaven() throws Exception { public void testFileNotMaven() throws Exception { Tuple env = createEnv(fs, temp); - // has two colons, so it appears similar to maven coordinates - FileNotFoundException e = expectThrows(FileNotFoundException.class, - () -> installPlugin("file:C:\\path\\to\\plugin\\does_not_exists.zip", env.v1())); - assertTrue(e.getMessage(), e.getMessage().startsWith("C:\\path\\to\\plugin\\does_not_exists.zip")); + String dir = randomAlphaOfLength(10) + ":" + randomAlphaOfLength(5) + "\\" + randomAlphaOfLength(5); + Exception e = expectThrows(Exception.class, + // has two colons, so it appears similar to maven coordinates + () -> installPlugin("file:" + dir, env.v1())); + assertFalse(e.getMessage(), e.getMessage().contains("maven.org")); + assertTrue(e.getMessage(), e.getMessage().contains(dir)); } public void testUnknownPlugin() throws Exception {