From: David ‘Bombe’ Roden Date: Fri, 21 Aug 2015 18:48:18 +0000 (+0200) Subject: Add method to load plugin from Freenet key X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=58d74a989e1f6442fe46e126e7543a3b2ab68369;p=jFCPlib.git Add method to load plugin from Freenet key --- 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();