From 035ef14447e88cce66aaf0a4c09fa06e2888be6e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 21 Aug 2015 20:44:30 +0200 Subject: [PATCH] Add method to load plugin from URL --- .../pterodactylus/fcp/quelaton/LoadPluginCommand.java | 1 + .../fcp/quelaton/LoadPluginCommandImpl.java | 7 +++++++ .../fcp/quelaton/DefaultFcpClientTest.java | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+) 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(); -- 2.7.4