Add method to load plugin from Freenet key
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 21 Aug 2015 18:48:18 +0000 (20:48 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 21 Aug 2015 18:48:27 +0000 (20:48 +0200)
src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommand.java
src/main/java/net/pterodactylus/fcp/quelaton/LoadPluginCommandImpl.java
src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java

index 9e20763..317f64e 100644 (file)
@@ -14,6 +14,7 @@ public interface LoadPluginCommand {
        LoadPluginCommand addToConfig();
        Executable<Optional<PluginInfo>> officialFromFreenet(String pluginIdentifier);
        Executable<Optional<PluginInfo>> officialFromHttps(String pluginIdentifier);
+       Executable<Optional<PluginInfo>> fromFreenet(String key);
        Executable<Optional<PluginInfo>> fromFile(String filename);
        Executable<Optional<PluginInfo>> fromUrl(String url);
 
index bd9fbb5..bd5acd7 100644 (file)
@@ -57,6 +57,13 @@ public class LoadPluginCommandImpl implements LoadPluginCommand {
        }
 
        @Override
+       public Executable<Optional<PluginInfo>> fromFreenet(String key) {
+               loadPlugin.setUrlType(UrlType.FREENET);
+               loadPlugin.setPluginUrl(key);
+               return this::execute;
+       }
+
+       @Override
        public Executable<Optional<PluginInfo>> fromFile(String filename) {
                loadPlugin.setUrlType(UrlType.FILE);
                loadPlugin.setPluginUrl(filename);
index 9a99864..b2f48dd 100644 (file)
@@ -2087,6 +2087,24 @@ public class DefaultFcpClientTest {
                }
 
                @Test
+               public void fromFreenet() throws ExecutionException, InterruptedException, IOException {
+                       Future<Optional<PluginInfo>> pluginInfo =
+                               fcpClient.loadPlugin().fromFreenet("KSK@plugin.jar").execute();
+                       connectNode();
+                       List<String> 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<Optional<PluginInfo>> pluginInfo =
                                fcpClient.loadPlugin().officialFromFreenet("superPlugin").execute();