use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class PluginServiceTest method shouldFetchPluginInfoForTheSpecifiedId.
@Test
public void shouldFetchPluginInfoForTheSpecifiedId() {
GoPluginDescriptor.About about = new GoPluginDescriptor.About("asdfasdf", "1.0", null, null, null, null);
PluginInfo pluginInfo = new PluginInfo(new GoPluginDescriptor("github.pr", "1.0", about, null, null, false), null, null, null, null);
when(builder.pluginInfoFor("github.pr")).thenReturn(pluginInfo);
assertThat(pluginService.pluginInfo("github.pr"), is(pluginInfo));
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFrameworkTest method shouldNotUnloadBundleForAnUnloadedInvalidPlugin.
@Test
public void shouldNotUnloadBundleForAnUnloadedInvalidPlugin() throws BundleException {
GoPluginDescriptor pluginDescriptor = mock(GoPluginDescriptor.class);
when(pluginDescriptor.bundle()).thenReturn(null);
spy.unloadPlugin(pluginDescriptor);
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class MultipleExtensionPluginWithPluginManagerIntegrationTest method shouldProvideDescriptorToMultipleExtensionsImplementingThePluginDescriptorAwareInterface.
@Test
public void shouldProvideDescriptorToMultipleExtensionsImplementingThePluginDescriptorAwareInterface() throws Exception {
GoPluginDescriptor plugin = pluginManager.getPluginDescriptorFor(PLUGIN_ID);
assertThat(plugin.id(), is(PLUGIN_ID));
assertThat(plugin.bundleSymbolicName(), is(PLUGIN_ID));
assertThat(plugin.bundleClassPath(), is("lib/go-plugin-activator.jar,."));
assertThat(plugin.bundleActivator(), is(DefaultGoPluginActivator.class.getCanonicalName()));
assertThat(plugin.isInvalid(), is(false));
//property set by the plugin in the setPluginDescriptor method.
assertThat(System.getProperty(PLUGIN_DESC_PROPERTY_SET_BY_PLUGIN_EXT_1), is(plugin.toString()));
assertThat(System.getProperty(PLUGIN_DESC_PROPERTY_SET_BY_PLUGIN_EXT_2), is(plugin.toString()));
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFramework method doOnAllWithExceptionHandling.
@Override
public <T> void doOnAllWithExceptionHandling(Class<T> serviceReferenceClass, Action<T> actionToDoOnEachRegisteredServiceWhichMatches, ExceptionHandler<T> handler) {
if (framework == null) {
LOGGER.warn("[Plugin Framework] Plugins are not enabled, so cannot do an action on all implementations of " + serviceReferenceClass);
return;
}
BundleContext bundleContext = framework.getBundleContext();
Collection<ServiceReference<T>> matchingServiceReferences;
try {
matchingServiceReferences = bundleContext.getServiceReferences(serviceReferenceClass, null);
} catch (InvalidSyntaxException e) {
throw new RuntimeException(e);
}
for (ServiceReference<T> currentServiceReference : matchingServiceReferences) {
T service = bundleContext.getService(currentServiceReference);
GoPluginDescriptor descriptor = getDescriptorFor(currentServiceReference);
try {
actionToDoOnEachRegisteredServiceWhichMatches.execute(service, descriptor);
} catch (Throwable t) {
handler.handleException(service, t);
}
}
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class DefaultPluginJarChangeListener method pluginJarAdded.
@Override
public void pluginJarAdded(PluginFileDetails pluginFileDetails) {
GoPluginDescriptor descriptor = goPluginDescriptorBuilder.build(pluginFileDetails.file(), pluginFileDetails.isBundledPlugin());
GoPluginDescriptor existingDescriptor = registry.getPluginByIdOrFileName(descriptor.id(), descriptor.fileName());
validateIfExternalPluginRemovingBundledPlugin(descriptor, existingDescriptor);
validatePluginCompatibilityWithCurrentOS(descriptor);
addPlugin(pluginFileDetails, descriptor);
}
Aggregations