org.pf4j.Plugin Java Examples
The following examples show how to use
org.pf4j.Plugin.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Pf4jServiceLoaderIntegrationTestable.java From exonum-java-binding with Apache License 2.0 | 6 votes |
@Test void cannotLoadIfPluginFailedToStart() throws IOException { String pluginId = PLUGIN_ID; Class<? extends Plugin> evilPlugin = EvilPluginFailingToStart.class; anArtifact() .setPluginId(pluginId) .addClass(evilPlugin) .setManifestEntry("Plugin-Class", evilPlugin.getName()) .writeTo(artifactLocation); // Try to load the service Exception e = assertThrows(ServiceLoadingException.class, () -> serviceLoader.loadService(artifactLocation)); assertThat(e).hasMessageContaining("Failed to start the plugin"); // Check the definition is inaccessible ServiceArtifactId serviceId = ServiceArtifactId.parseFrom(pluginId); assertThat(serviceLoader.findService(serviceId)).isEmpty(); // Check it is unloaded if failed to start verifyUnloaded(pluginId); }