From: Decebal Suiu Date: Tue, 22 Sep 2015 12:42:39 +0000 (+0300) Subject: fix tests after improve PluginDescriptorFinder X-Git-Tag: release-0.11.0~8^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F72%2Fhead;p=pf4j.git fix tests after improve PluginDescriptorFinder --- diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java index eed54bd..55b0059 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java @@ -100,7 +100,9 @@ public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder { pluginDescriptor.setPluginClass(clazz); String version = attributes.getValue("Plugin-Version"); - pluginDescriptor.setPluginVersion(Version.valueOf(version)); + if (StringUtils.isNotEmpty(version)) { + pluginDescriptor.setPluginVersion(Version.valueOf(version)); + } String provider = attributes.getValue("Plugin-Provider"); pluginDescriptor.setProvider(provider); @@ -122,6 +124,9 @@ public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder { if (StringUtils.isEmpty(pluginDescriptor.getPluginClass())) { throw new PluginException("Plugin-Class cannot be empty"); } + if (pluginDescriptor.getVersion() == null) { + throw new PluginException("Plugin-Version cannot be empty"); + } } } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinder.java index a6d35c9..a0703e8 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinder.java @@ -96,7 +96,9 @@ public class PropertiesPluginDescriptorFinder implements PluginDescriptorFinder pluginDescriptor.setPluginClass(clazz); String version = properties.getProperty("plugin.version"); - pluginDescriptor.setPluginVersion(Version.valueOf(version)); + if (StringUtils.isNotEmpty(version)) { + pluginDescriptor.setPluginVersion(Version.valueOf(version)); + } String provider = properties.getProperty("plugin.provider"); pluginDescriptor.setProvider(provider); @@ -110,11 +112,13 @@ public class PropertiesPluginDescriptorFinder implements PluginDescriptorFinder protected void validatePluginDescriptor(PluginDescriptor pluginDescriptor) throws PluginException { if (StringUtils.isEmpty(pluginDescriptor.getPluginId())) { throw new PluginException("plugin.id cannot be empty"); - } if (StringUtils.isEmpty(pluginDescriptor.getPluginClass())) { throw new PluginException("plugin.class cannot be empty"); } + if (pluginDescriptor.getVersion() == null) { + throw new PluginException("plugin.version cannot be empty"); + } } }