From 501308b6c81ebb532282d4566ac92d63f9f9be5c Mon Sep 17 00:00:00 2001 From: Decebal Suiu Date: Tue, 22 Sep 2015 15:42:39 +0300 Subject: [PATCH] fix tests after improve PluginDescriptorFinder --- .../ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java | 7 ++++++- .../fortsoft/pf4j/PropertiesPluginDescriptorFinder.java | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) 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"); + } } }