Search in sources :

Example 1 with GoPluginFrameworkException

use of com.thoughtworks.go.plugin.infra.GoPluginFrameworkException in project gocd by gocd.

the class PackageMaterialMetadataLoader method fetchRepositoryAndPackageMetaData.

void fetchRepositoryAndPackageMetaData(GoPluginDescriptor pluginDescriptor) {
    try {
        RepositoryConfiguration repositoryConfiguration = packageRepositoryExtension.getRepositoryConfiguration(pluginDescriptor.id());
        com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration packageConfiguration = packageRepositoryExtension.getPackageConfiguration(pluginDescriptor.id());
        if (repositoryConfiguration == null) {
            throw new RuntimeException(format("Plugin[%s] returned null repository configuration", pluginDescriptor.id()));
        }
        if (packageConfiguration == null) {
            throw new RuntimeException(format("Plugin[%s] returned null package configuration", pluginDescriptor.id()));
        }
        repositoryMetadataStore.addMetadataFor(pluginDescriptor.id(), new PackageConfigurations(repositoryConfiguration));
        packageMetadataStore.addMetadataFor(pluginDescriptor.id(), new PackageConfigurations(packageConfiguration));
    } catch (GoPluginFrameworkException e) {
        LOGGER.error(format("Failed to fetch package metadata for plugin : %s", pluginDescriptor.id()), e);
    }
}
Also used : GoPluginFrameworkException(com.thoughtworks.go.plugin.infra.GoPluginFrameworkException) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)

Example 2 with GoPluginFrameworkException

use of com.thoughtworks.go.plugin.infra.GoPluginFrameworkException in project gocd by gocd.

the class DefaultPluginJarChangeListenerTest method shouldNotThrowExceptionIfThePluginImplementsDescriptorAwareIsNotAvailable.

@Test
public void shouldNotThrowExceptionIfThePluginImplementsDescriptorAwareIsNotAvailable() throws Exception {
    String pluginJarFileName = "descriptor-aware-test-plugin.jar";
    File pluginJarFile = new File(PLUGIN_DIR, pluginJarFileName);
    copyPluginToTheDirectory(PLUGIN_DIR, pluginJarFileName);
    GoPluginDescriptor descriptor = new GoPluginDescriptor("some.old.id", "1.0", new GoPluginDescriptor.About(null, null, null, null, null, null), null, new File(pluginJarFileName), false);
    when(systemEnvironment.getOperatingSystemFamilyName()).thenReturn("Windows");
    when(goPluginDescriptorBuilder.build(pluginJarFile, true)).thenReturn(descriptor);
    when(osgiFramework.hasReferenceFor(PluginDescriptorAware.class, descriptor.id())).thenReturn(false);
    doThrow(new GoPluginFrameworkException("Failed to find service reference")).when(osgiFramework).doOnAllForPlugin(eq(PluginDescriptorAware.class), eq(descriptor.id()), Matchers.<Action<PluginDescriptorAware>>anyObject());
    listener = new DefaultPluginJarChangeListener(registry, osgiManifestGenerator, osgiFramework, goPluginDescriptorBuilder, systemEnvironment);
    listener.pluginJarAdded(new PluginFileDetails(pluginJarFile, true));
    verify(registry, times(1)).loadPlugin(descriptor);
    verify(osgiFramework, times(1)).loadPlugin(descriptor);
    verify(osgiFramework, times(1)).hasReferenceFor(PluginDescriptorAware.class, descriptor.id());
    verify(osgiFramework, never()).doOnAllForPlugin(eq(PluginDescriptorAware.class), eq(descriptor.id()), Matchers.<Action<PluginDescriptorAware>>anyObject());
}
Also used : PluginDescriptorAware(com.thoughtworks.go.plugin.api.info.PluginDescriptorAware) PluginFileDetails(com.thoughtworks.go.plugin.infra.monitor.PluginFileDetails) GoPluginFrameworkException(com.thoughtworks.go.plugin.infra.GoPluginFrameworkException) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) File(java.io.File) Test(org.junit.Test)

Aggregations

GoPluginFrameworkException (com.thoughtworks.go.plugin.infra.GoPluginFrameworkException)2 PluginDescriptorAware (com.thoughtworks.go.plugin.api.info.PluginDescriptorAware)1 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)1 PluginFileDetails (com.thoughtworks.go.plugin.infra.monitor.PluginFileDetails)1 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)1 File (java.io.File)1 Test (org.junit.Test)1