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);
}
}
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());
}
Aggregations