Add method to load plugin from URL
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 21 Aug 2015 18:44:30 +0000 (20:44 +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 959f559..9e20763 100644 (file)
@@ -15,5 +15,6 @@ public interface LoadPluginCommand {
        Executable<Optional<PluginInfo>> officialFromFreenet(String pluginIdentifier);
        Executable<Optional<PluginInfo>> officialFromHttps(String pluginIdentifier);
        Executable<Optional<PluginInfo>> fromFile(String filename);
+       Executable<Optional<PluginInfo>> fromUrl(String url);
 
 }
index 209e394..bd9fbb5 100644 (file)
@@ -63,6 +63,13 @@ public class LoadPluginCommandImpl implements LoadPluginCommand {
                return this::execute;
        }
 
+       @Override
+       public Executable<Optional<PluginInfo>> fromUrl(String url) {
+               loadPlugin.setUrlType(UrlType.URL);
+               loadPlugin.setPluginUrl(url);
+               return this::execute;
+       }
+
        private ListenableFuture<Optional<PluginInfo>> execute() {
                return threadPool.submit(this::executeDialog);
        }
index 75667b3..683c25a 100644 (file)
@@ -2069,6 +2069,24 @@ public class DefaultFcpClientTest {
                }
 
                @Test
+               public void fromUrl() throws ExecutionException, InterruptedException, IOException {
+                       Future<Optional<PluginInfo>> pluginInfo =
+                               fcpClient.loadPlugin().fromUrl("http://server.com/plugin.jar").execute();
+                       connectNode();
+                       List<String> 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<Optional<PluginInfo>> pluginInfo =
                                fcpClient.loadPlugin().officialFromFreenet("superPlugin").execute();