Browse Source

fix tests after improve PluginDescriptorFinder

pull/72/head
Decebal Suiu 9 years ago
parent
commit
501308b6c8
  1. 7
      pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java
  2. 8
      pf4j/src/main/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinder.java

7
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");
}
}
}

8
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");
}
}
}

Loading…
Cancel
Save