### Question:
OsgiPluginXmlDescriptorParser extends XmlDescriptorParser { @Override protected ModuleDescriptor<?> createModuleDescriptor(final Plugin plugin, final Element element, final ModuleDescriptorFactory moduleDescriptorFactory) throws PluginParseException { final ModuleDescriptor<?> descriptor = super.createModuleDescriptor(plugin, element, moduleDescriptorFactory); final String key = (descriptor != null ? descriptor.getKey() : element.attributeValue("key")); ((OsgiPlugin) plugin).addModuleDescriptorElement(key, element); return descriptor; } OsgiPluginXmlDescriptorParser(final InputStream source, final String... applicationKeys);   }### Answer:
@Test public void testCreateModuleDescriptor() throws PluginParseException, IllegalAccessException, ClassNotFoundException, InstantiationException { OsgiPluginXmlDescriptorParser parser = new OsgiPluginXmlDescriptorParser(new ByteArrayInputStream("<foo/>".getBytes())); ModuleDescriptor desc = mock(ModuleDescriptor.class); when(desc.getKey()).thenReturn("foo"); ModuleDescriptorFactory factory = mock(ModuleDescriptorFactory.class); when(factory.getModuleDescriptor("foo")).thenReturn(desc); OsgiPlugin plugin = mock(OsgiPlugin.class); Element fooElement = new DefaultElement("foo"); fooElement.addAttribute("key", "bob"); assertNotNull(parser.createModuleDescriptor(plugin, fooElement, factory)); verify(plugin).addModuleDescriptorElement("foo", fooElement); }