use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFrameworkIntegrationTest method shouldNotifyListenersWhenPluginUnLoaded.
@Test
public void shouldNotifyListenersWhenPluginUnLoaded() {
PluginChangeListener pluginChangeListener = mock(PluginChangeListener.class);
pluginOSGiFramework.addPluginChangeListener(pluginChangeListener);
GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(null, null, null, null, descriptorBundleDir, true);
Bundle bundle = pluginOSGiFramework.loadPlugin(pluginDescriptor);
pluginDescriptor.setBundle(bundle);
pluginOSGiFramework.unloadPlugin(pluginDescriptor);
verify(pluginChangeListener).pluginUnLoaded(pluginDescriptor);
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFrameworkIntegrationTest method shouldUnloadALoadedPlugin.
@Test
public void shouldUnloadALoadedPlugin() throws Exception {
GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(null, null, null, null, descriptorBundleDir, true);
Bundle bundle = pluginOSGiFramework.loadPlugin(pluginDescriptor);
BundleContext context = bundle.getBundleContext();
ServiceReference<?>[] allServiceReferences = context.getServiceReferences(GoPlugin.class.getCanonicalName(), null);
assertThat(allServiceReferences.length, is(1));
GoPlugin service = (GoPlugin) context.getService(allServiceReferences[0]);
assertThat("@Load should have been called", getIntField(service, "loadCalled"), is(1));
pluginDescriptor.setBundle(bundle);
pluginOSGiFramework.unloadPlugin(pluginDescriptor);
assertThat(bundle.getState(), is(Bundle.UNINSTALLED));
assertThat("@UnLoad should have been called", getIntField(service, "unloadCalled"), is(1));
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFrameworkIntegrationTest method shouldNotifyListenersWhenPluginLoaded.
@Test
public void shouldNotifyListenersWhenPluginLoaded() {
PluginChangeListener pluginChangeListener = mock(PluginChangeListener.class);
pluginOSGiFramework.addPluginChangeListener(pluginChangeListener);
GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(null, null, null, null, descriptorBundleDir, true);
pluginOSGiFramework.loadPlugin(pluginDescriptor);
verify(pluginChangeListener).pluginLoaded(pluginDescriptor);
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFrameworkIntegrationTest method shouldLoadAValidGoPluginOSGiBundle.
@Test
public void shouldLoadAValidGoPluginOSGiBundle() throws Exception {
Bundle bundle = pluginOSGiFramework.loadPlugin(new GoPluginDescriptor(null, null, null, null, descriptorBundleDir, true));
assertThat(bundle.getState(), is(Bundle.ACTIVE));
BundleContext context = bundle.getBundleContext();
ServiceReference<?>[] allServiceReferences = context.getServiceReferences(GoPlugin.class.getCanonicalName(), null);
assertThat(allServiceReferences.length, is(1));
try {
GoPlugin service = (GoPlugin) context.getService(allServiceReferences[0]);
service.pluginIdentifier();
assertThat("@Load should have been called", getIntField(service, "loadCalled"), is(1));
} catch (Exception e) {
fail(String.format("pluginIdentifier should have been called. Exception: %s", e.getMessage()));
}
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class FelixGoPluginOSGiFrameworkIntegrationTest method shouldPassInCorrectDescriptorToAction.
@Test
public void shouldPassInCorrectDescriptorToAction() {
final GoPluginDescriptor descriptor = new GoPluginDescriptor("testplugin.descriptorValidator", null, null, null, descriptorBundleDir, true);
Bundle bundle = pluginOSGiFramework.loadPlugin(descriptor);
registry.loadPlugin(descriptor);
assertThat(bundle.getState(), is(Bundle.ACTIVE));
ActionWithReturn<GoPlugin, Object> action = new ActionWithReturn<GoPlugin, Object>() {
@Override
public Object execute(GoPlugin plugin, GoPluginDescriptor pluginDescriptor) {
assertThat(pluginDescriptor, is(descriptor));
plugin.pluginIdentifier();
return null;
}
};
pluginOSGiFramework.doOn(GoPlugin.class, "testplugin.descriptorValidator", "notification", action);
}
Aggregations