### Question:
OsgiPluginFactory implements PluginFactory { public String canCreate(PluginArtifact pluginArtifact) throws PluginParseException { Validate.notNull(pluginArtifact, "The plugin artifact is required"); String pluginKey = null; InputStream descriptorStream = null; try { descriptorStream = pluginArtifact.getResourceAsStream(pluginDescriptorFileName); if (descriptorStream != null) { final DescriptorParser descriptorParser = descriptorParserFactory.getInstance(descriptorStream, applicationKeys.toArray(new String[applicationKeys.size()])); if (descriptorParser.getPluginsVersion() == 2) { pluginKey = descriptorParser.getKey(); } } } finally { IOUtils.closeQuietly(descriptorStream); } return pluginKey; } OsgiPluginFactory(String pluginDescriptorFileName, String applicationKey, OsgiPersistentCache persistentCache, OsgiContainerManager osgi, PluginEventManager pluginEventManager);  OsgiPluginFactory(String pluginDescriptorFileName, Set<String> applicationKeys, OsgiPersistentCache persistentCache, OsgiContainerManager osgi, PluginEventManager pluginEventManager); String canCreate(PluginArtifact pluginArtifact); Plugin create(DeploymentUnit deploymentUnit, ModuleDescriptorFactory moduleDescriptorFactory); Plugin create(PluginArtifact pluginArtifact, ModuleDescriptorFactory moduleDescriptorFactory);  }### Answer:
@Test public void testCanLoadNoXml() throws PluginParseException, IOException { final File plugin = new PluginJarBuilder("loadwithxml").build(); final String key = factory.canCreate(new JarPluginArtifact(plugin)); assertNull(key); }
@Test public void testCanLoadWithXml() throws PluginParseException, IOException { final File plugin = new PluginJarBuilder("loadwithxml").addPluginInformation("foo.bar", "", "1.0").build(); final String key = factory.canCreate(new JarPluginArtifact(plugin)); assertEquals("foo.bar", key); }