From 58d74a989e1f6442fe46e126e7543a3b2ab68369 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:48:18 +0200 Subject: [PATCH] Add method to load plugin from Freenet key --- .../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 9e20763..317f64e 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommand.java @@ -14,6 +14,7 @@ public interface LoadPluginCommand { LoadPluginCommand addToConfig(); Executable> officialFromFreenet(String pluginIdentifier); Executable> officialFromHttps(String pluginIdentifier); + Executable> fromFreenet(String key); 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 bd9fbb5..bd5acd7 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommandImpl.java @@ -57,6 +57,13 @@ public class LoadPluginCommandImpl implements LoadPluginCommand { } @Override + public Executable> fromFreenet(String key) { + loadPlugin.setUrlType(UrlType.FREENET); + loadPlugin.setPluginUrl(key); + return this::execute; + } + + @Override public Executable> fromFile(String filename) { loadPlugin.setUrlType(UrlType.FILE); loadPlugin.setPluginUrl(filename); diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 9a99864..b2f48dd 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -2087,6 +2087,24 @@ public class DefaultFcpClientTest { } @Test + public void fromFreenet() throws ExecutionException, InterruptedException, IOException { + Future> pluginInfo = + fcpClient.loadPlugin().fromFreenet("KSK@plugin.jar").execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "LoadPlugin", + "Identifier=" + identifier, + "PluginURL=KSK@plugin.jar", + "URLType=freenet", + "EndMessage" + )); + replyWithPluginInfo(identifier); + verifyPluginInfo(pluginInfo); + } + + @Test public void failedLoad() throws ExecutionException, InterruptedException, IOException { Future> pluginInfo = fcpClient.loadPlugin().officialFromFreenet("superPlugin").execute(); -- 2.7.4