diff --git a/framework/build.gradle b/framework/build.gradle index 1c817f545f0..331fb09228f 100644 --- a/framework/build.gradle +++ b/framework/build.gradle @@ -83,7 +83,9 @@ dependencies { compileOnly group: 'javax.portlet', name: 'portlet-api', version: '3.0.1' compile "io.vavr:vavr:0.9.2" - compile group: 'org.pf4j', name: 'pf4j', version: '2.5.0' + compile group: 'org.pf4j', name: 'pf4j', version: '3.10.0',{ + exclude group: 'org.slf4j' + } testImplementation group: 'org.springframework', name: 'spring-test', version: '5.2.0.RELEASE' testImplementation group: 'org.springframework', name: 'spring-web', version: '5.2.0.RELEASE' diff --git a/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java b/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java index 8ff8167f52e..058ad136a51 100644 --- a/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java +++ b/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java @@ -1,14 +1,25 @@ package org.tron.common.logsfilter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + import org.junit.Assert; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.tron.common.logsfilter.trigger.BlockLogTrigger; import org.tron.common.logsfilter.trigger.TransactionLogTrigger; public class EventLoaderTest { + @ClassRule + public static final TemporaryFolder temporaryFolder = new TemporaryFolder(); + @Test public void launchNativeQueue() { EventPluginConfig config = new EventPluginConfig(); @@ -31,6 +42,29 @@ public void launchNativeQueue() { EventPluginLoader.getInstance().stopPlugin(); } + @Test + public void testPluginManager() throws IOException { + EventPluginConfig config = new EventPluginConfig(); + config.setUseNativeQueue(false); + config.setPluginPath(temporaryFolder.newFolder() + "/testPlugin.zip"); + createPluginInPath(config.getPluginPath()); + Assert.assertThrows(Exception.class, () -> EventPluginLoader.getInstance().start(config)); + } + + private void createPluginInPath(String pluginPath) { + String fileName = "../testPlugin.zip"; + try (ZipOutputStream zipOutputStream = new ZipOutputStream( + Files.newOutputStream(Paths.get(pluginPath)))) { + ZipEntry zipEntry = new ZipEntry(fileName); + zipOutputStream.putNextEntry(zipEntry); + zipOutputStream.write("".getBytes()); + zipOutputStream.closeEntry(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Test public void testBlockLogTrigger() { BlockLogTrigger blt = new BlockLogTrigger();