use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginBundleDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFrameworkTest method shouldSkipUninstallIfPluginIsPreviouslyUninstalled.
@Test
void shouldSkipUninstallIfPluginIsPreviouslyUninstalled() throws BundleException {
GoPluginBundleDescriptor pluginDescriptor = mock(GoPluginBundleDescriptor.class);
when(pluginDescriptor.bundle()).thenReturn(bundle);
when(bundle.getState()).thenReturn(Bundle.UNINSTALLED);
spy.unloadPlugin(pluginDescriptor);
verify(bundle, never()).start();
verify(bundle, never()).uninstall();
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginBundleDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFrameworkTest method shouldUnloadAPlugin.
@Test
void shouldUnloadAPlugin() throws BundleException {
GoPluginBundleDescriptor pluginDescriptor = mock(GoPluginBundleDescriptor.class);
when(pluginDescriptor.bundle()).thenReturn(bundle);
spy.unloadPlugin(pluginDescriptor);
verify(bundle, atLeastOnce()).stop();
verify(bundle, atLeastOnce()).uninstall();
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginBundleDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFrameworkTest method shouldNotFailToUnloadAPluginWhoseBundleIsNull.
@Test
void shouldNotFailToUnloadAPluginWhoseBundleIsNull() {
GoPluginBundleDescriptor pluginDescriptor = mock(GoPluginBundleDescriptor.class);
when(pluginDescriptor.bundle()).thenReturn(null);
try {
spy.unloadPlugin(pluginDescriptor);
} catch (Exception e) {
fail("Should not have thrown an exception");
}
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginBundleDescriptor in project gocd by gocd.
the class PackageLevelClassWithPublicInnerClass method installBundleFoundInDirectory.
private Bundle installBundleFoundInDirectory(File bundleWithActivator) {
final GoPluginDescriptor pluginDescriptor = GoPluginDescriptor.builder().id(GO_TEST_DUMMY_SYMBOLIC_NAME).version("1").bundleLocation(bundleWithActivator).isBundledPlugin(true).build();
GoPluginBundleDescriptor bundleDescriptor = new GoPluginBundleDescriptor(pluginDescriptor);
registry.fakeRegistrationOfPlugin(pluginDescriptor);
return framework.loadPlugin(bundleDescriptor);
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginBundleDescriptor in project gocd by gocd.
the class PluginsZip method create.
public void create() {
checkFilesAccessibility(bundledPlugins, externalPlugins);
reset();
MessageDigest md5Digest = DigestUtils.getMd5Digest();
try (ZipOutputStream zos = new ZipOutputStream(new DigestOutputStream(new BufferedOutputStream(new FileOutputStream(destZipFile)), md5Digest))) {
for (GoPluginBundleDescriptor agentPlugins : agentPlugins()) {
String zipEntryPrefix = "external/";
if (agentPlugins.isBundledPlugin()) {
zipEntryPrefix = "bundled/";
}
zos.putNextEntry(new ZipEntry(zipEntryPrefix + new File(agentPlugins.bundleJARFileLocation()).getName()));
Files.copy(new File(agentPlugins.bundleJARFileLocation()).toPath(), zos);
zos.closeEntry();
}
} catch (Exception e) {
LOG.error("Could not create zip of plugins for agent to download.", e);
}
md5DigestOfPlugins = Hex.encodeHexString(md5Digest.digest());
}
Aggregations