### Question:
OsgiHeaderUtil { public static String getPluginKey(Bundle bundle) { return getPluginKey( bundle.getSymbolicName(), bundle.getHeaders().get(OsgiPlugin.MAERA_PLUGIN_KEY), bundle.getHeaders().get(Constants.BUNDLE_VERSION) ); }  static String findReferredPackages(List<HostComponentRegistration> registrations); static String findReferredPackages(List<HostComponentRegistration> registrations, Map<String, String> packageVersions); static Map<String, Map<String, String>> parseHeader(String header); static String buildHeader(String key, Map<String, String> attrs); static String getPluginKey(Bundle bundle); static String getPluginKey(Manifest mf);  }### Answer:
@Test public void testGetPluginKeyBundle() { Dictionary<String, String> headers = new Hashtable<String, String>(); headers.put(Constants.BUNDLE_VERSION, "1.0"); headers.put(Constants.BUNDLE_SYMBOLICNAME, "foo"); Bundle bundle = mock(Bundle.class); when(bundle.getSymbolicName()).thenReturn("foo"); when(bundle.getHeaders()).thenReturn(headers); assertEquals("foo-1.0", OsgiHeaderUtil.getPluginKey(bundle)); headers.put(OsgiPlugin.MAERA_PLUGIN_KEY, "bar"); assertEquals("bar", OsgiHeaderUtil.getPluginKey(bundle)); }
@Test public void testGetPluginKeyManifest() { Manifest mf = new Manifest(); mf.getMainAttributes().putValue(Constants.BUNDLE_VERSION, "1.0"); mf.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, "foo"); assertEquals("foo-1.0", OsgiHeaderUtil.getPluginKey(mf)); mf.getMainAttributes().putValue(OsgiPlugin.MAERA_PLUGIN_KEY, "bar"); assertEquals("bar", OsgiHeaderUtil.getPluginKey(mf)); }