From: David ‘Bombe’ Roden Date: Fri, 21 Aug 2015 18:44:30 +0000 (+0200) Subject: Add method to load plugin from URL X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=035ef14447e88cce66aaf0a4c09fa06e2888be6e;p=jFCPlib.git Add method to load plugin from URL --- diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommand.java index 959f559..9e20763 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommand.java @@ -15,5 +15,6 @@ public interface LoadPluginCommand { Executable> officialFromFreenet(String pluginIdentifier); Executable> officialFromHttps(String pluginIdentifier); Executable> fromFile(String filename); + Executable> fromUrl(String url); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommandImpl.java index 209e394..bd9fbb5 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommandImpl.java @@ -63,6 +63,13 @@ public class LoadPluginCommandImpl implements LoadPluginCommand { return this::execute; } + @Override + public Executable> fromUrl(String url) { + loadPlugin.setUrlType(UrlType.URL); + loadPlugin.setPluginUrl(url); + return this::execute; + } + private ListenableFuture> execute() { return threadPool.submit(this::executeDialog); } diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 75667b3..683c25a 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -2069,6 +2069,24 @@ public class DefaultFcpClientTest { } @Test + public void fromUrl() throws ExecutionException, InterruptedException, IOException { + Future> pluginInfo = + fcpClient.loadPlugin().fromUrl("http://server.com/plugin.jar").execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "LoadPlugin", + "Identifier=" + identifier, + "PluginURL=http://server.com/plugin.jar", + "URLType=url", + "EndMessage" + )); + replyWithPluginInfo(identifier); + verifyPluginInfo(pluginInfo); + } + + @Test public void failedLoad() throws ExecutionException, InterruptedException, IOException { Future> pluginInfo = fcpClient.loadPlugin().officialFromFreenet("superPlugin").execute();