Search in sources :

Example 6 with GoPluginDescriptor

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));
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Test(org.junit.Test)

Example 7 with GoPluginDescriptor

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);
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 8 with GoPluginDescriptor

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()));
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 9 with GoPluginDescriptor

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);
        }
    }
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)

Example 10 with GoPluginDescriptor

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);
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)

Aggregations

GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)214 Test (org.junit.jupiter.api.Test)114 Test (org.junit.Test)53 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)20 File (java.io.File)19 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)16 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)14 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)12 Capabilities (com.thoughtworks.go.plugin.domain.elastic.Capabilities)12 Before (org.junit.Before)12 AnalyticsPluginInfo (com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo)11 GoPluginBundleDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginBundleDescriptor)11 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)11 Bundle (org.osgi.framework.Bundle)10 GoPlugin (com.thoughtworks.go.plugin.api.GoPlugin)9 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)9 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)8 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)8 ArrayList (java.util.ArrayList)8 InvocationOnMock (org.mockito.invocation.InvocationOnMock)8