summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDecebal Suiu <decebal.suiu@gmail.com>2015-09-22 15:42:39 +0300
committerDecebal Suiu <decebal.suiu@gmail.com>2015-09-22 15:42:39 +0300
commit501308b6c81ebb532282d4566ac92d63f9f9be5c (patch)
treeca7afc024ce1e45e82607a74ccd140750291a939
parentf0121fc02abe431ed49e7bbe9a8fa848c3657845 (diff)
downloadpf4j-501308b6c81ebb532282d4566ac92d63f9f9be5c.tar.gz
pf4j-501308b6c81ebb532282d4566ac92d63f9f9be5c.zip
fix tests after improve PluginDescriptorFinder
-rw-r--r--pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java7
-rw-r--r--pf4j/src/main/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinder.java8
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");
+ }
}
}