*/
package ro.fortsoft.pf4j;
-import com.github.zafarkhaja.semver.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ro.fortsoft.pf4j.util.StringUtils;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* This class implements the boilerplate plugin code that any {@link PluginManager}
/*
* The system version used for comparisons to the plugin requires attribute.
*/
- private Version systemVersion = Version.forIntegers(0);
+ private String systemVersion = "0.0.0";
private PluginRepository pluginRepository;
private PluginFactory pluginFactory;
private PluginLoader pluginLoader;
private boolean exactVersionAllowed = false;
+ private VersionManager versionManager;
+
/**
* The plugins root is supplied by {@code System.getProperty("pf4j.pluginsDir", "plugins")}.
*/
}
@Override
- public void setSystemVersion(Version version) {
+ public void setSystemVersion(String version) {
systemVersion = version;
}
@Override
- public Version getSystemVersion() {
+ public String getSystemVersion() {
return systemVersion;
}
pluginStateListeners.remove(listener);
}
- public Version getVersion() {
+ public String getVersion() {
String version = null;
Package pf4jPackage = PluginManager.class.getPackage();
}
}
- return (version != null) ? Version.valueOf(version) : Version.forIntegers(0);
+ return (version != null) ? version : "0.0.0";
}
protected abstract PluginRepository createPluginRepository();
protected abstract PluginLoader createPluginLoader();
+ protected abstract VersionManager createVersionManager();
+
protected PluginDescriptorFinder getPluginDescriptorFinder() {
return pluginDescriptorFinder;
}
System.setProperty("pf4j.pluginsDir", pluginsRoot.toString());
- dependencyResolver = new DependencyResolver();
-
pluginRepository = createPluginRepository();
pluginFactory = createPluginFactory();
extensionFactory = createExtensionFactory();
extensionFinder = createExtensionFinder();
pluginStatusProvider = createPluginStatusProvider();
pluginLoader = createPluginLoader();
+
+ versionManager = createVersionManager();
+ dependencyResolver = new DependencyResolver(versionManager);
}
/**
// If exact versions are not allowed in requires, rewrite to >= expression
requires = ">=" + requires;
}
- if (systemVersion.equals(Version.forIntegers(0)) || systemVersion.satisfies(requires)) {
+ if (systemVersion.equals("0.0.0") || versionManager.satisfies(requires, systemVersion)) {
return true;
}
this.exactVersionAllowed = exactVersionAllowed;
}
+ @Override
+ public VersionManager getVersionManager() {
+ return versionManager;
+ }
+
}
return new DefaultPluginLoader(this, pluginClasspath);
}
+ @Override
+ protected VersionManager createVersionManager() {
+ return new DefaultVersionManager();
+ }
+
/**
* By default if {@link DefaultPluginManager#isDevelopment()} returns true
* than a {@link DevelopmentPluginClasspath} is returned
return super.loadPluginFromPath(pluginPath);
}
+
}
--- /dev/null
+/*
+ * Copyright 2017 Decebal Suiu
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ro.fortsoft.pf4j;
+
+import com.github.zafarkhaja.semver.Version;
+
+/**
+ * Default implementation for {@link VersionManager}.
+ * This implementation uses jSemVer (a Java implementation of the SemVer Specification).
+ *
+ * @author Decebal Suiu
+ */
+public class DefaultVersionManager implements VersionManager {
+
+ @Override
+ public boolean satisfies(String constraint, String version) {
+ return Version.valueOf(version).satisfies(constraint);
+ }
+
+}
*/
package ro.fortsoft.pf4j;
-import com.github.zafarkhaja.semver.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ro.fortsoft.pf4j.util.DirectedGraph;
private static final Logger log = LoggerFactory.getLogger(DependencyResolver.class);
+ private VersionManager versionManager;
+
private DirectedGraph<String> dependenciesGraph; // the value is 'pluginId'
private DirectedGraph<String> dependentsGraph; // the value is 'pluginId'
private boolean resolved;
+ public DependencyResolver(VersionManager versionManager) {
+ this.versionManager = versionManager;
+ }
+
public Result resolve(List<PluginDescriptor> plugins) {
// create graphs
dependenciesGraph = new DirectedGraph<>();
// check dependencies versions
for (PluginDescriptor plugin : plugins) {
String pluginId = plugin.getPluginId();
- Version existingVersion = plugin.getVersion();
+ String existingVersion = plugin.getVersion();
List<String> dependents = getDependents(pluginId);
while (!dependents.isEmpty()) {
* @param existingVersion
* @return
*/
- protected boolean checkDependencyVersion(String requiredVersion, Version existingVersion) {
- return existingVersion.satisfies(requiredVersion);
+ protected boolean checkDependencyVersion(String requiredVersion, String existingVersion) {
+ return versionManager.satisfies(requiredVersion, existingVersion);
}
private void addPlugin(PluginDescriptor descriptor) {
private String dependencyId; // value is "pluginId"
private String dependentId; // value is "pluginId"
- private Version existingVersion;
+ private String existingVersion;
private String requiredVersion;
- WrongDependencyVersion(String dependencyId, String dependentId, Version existingVersion, String requiredVersion) {
+ WrongDependencyVersion(String dependencyId, String dependentId, String existingVersion, String requiredVersion) {
this.dependencyId = dependencyId;
this.dependentId = dependentId;
this.existingVersion = existingVersion;
return dependentId;
}
- public Version getExistingVersion() {
+ public String getExistingVersion() {
return existingVersion;
}
*/
package ro.fortsoft.pf4j;
-import com.github.zafarkhaja.semver.Version;
import ro.fortsoft.pf4j.util.StringUtils;
import java.nio.file.Path;
*/
public abstract class ManifestPluginDescriptorFinder implements PluginDescriptorFinder {
- @Override
+ @Override
public PluginDescriptor find(Path pluginPath) throws PluginException {
Manifest manifest = readManifest(pluginPath);
String version = attributes.getValue("Plugin-Version");
if (StringUtils.isNotEmpty(version)) {
- pluginDescriptor.setPluginVersion(createPluginVersion(version));
+ pluginDescriptor.setPluginVersion(version);
}
String provider = attributes.getValue("Plugin-Provider");
return pluginDescriptor;
}
- /**
- * Parse version to semver {@link Version} object.
- * Example : 1.1.1.RC1 -> 1.1.1-RC1.
- * This may be override to use a custom parsing to semver Version.
- * @param version given string to be the plugin version
- * @return a semver version
- */
- protected Version createPluginVersion(String version) {
- return Version.valueOf(version);
- }
-
protected PluginDescriptor createPluginDescriptorInstance() {
return new PluginDescriptor();
}
+
}
*/
package ro.fortsoft.pf4j;
-import com.github.zafarkhaja.semver.Version;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
private String pluginId;
private String pluginDescription;
private String pluginClass;
- private Version version;
+ private String version;
private String requires = "*"; // SemVer format
private String provider;
private List<PluginDependency> dependencies;
/**
* Returns the version of this plugin.
*/
- public Version getVersion() {
+ public String getVersion() {
return version;
}
return this;
}
- PluginDescriptor setPluginVersion(Version version) {
+ PluginDescriptor setPluginVersion(String version) {
this.version = version;
return this;
*/
package ro.fortsoft.pf4j;
-import com.github.zafarkhaja.semver.Version;
-
import java.nio.file.Path;
import java.util.List;
import java.util.Set;
* requires attribute. The default system version is 0.0.0 which
* disables all version checking.
*
- * @default 0.0.0
+ * @default {@code null}
* @param version
*/
- void setSystemVersion(Version version);
+ void setSystemVersion(String version);
/**
* Returns the system version.
*
- * * @return the system version
+ * @return the system version
*/
- Version getSystemVersion();
+ String getSystemVersion();
/**
* Gets the path of the folder where plugins are installed
*/
Path getPluginsRoot();
+ VersionManager getVersionManager();
+
}
*/
package ro.fortsoft.pf4j;
-import com.github.zafarkhaja.semver.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ro.fortsoft.pf4j.util.StringUtils;
private static final String DEFAULT_PROPERTIES_FILE_NAME = "plugin.properties";
- private String propertiesFileName;
+ protected String propertiesFileName;
public PropertiesPluginDescriptorFinder() {
this(DEFAULT_PROPERTIES_FILE_NAME);
String version = properties.getProperty("plugin.version");
if (StringUtils.isNotEmpty(version)) {
- pluginDescriptor.setPluginVersion(Version.valueOf(version));
+ pluginDescriptor.setPluginVersion(version);
}
String provider = properties.getProperty("plugin.provider");
protected PluginDescriptor createPluginDescriptorInstance() {
return new PluginDescriptor();
}
+
}
--- /dev/null
+/*
+ * Copyright 2017 Decebal Suiu
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ro.fortsoft.pf4j;
+
+/**
+ * Manager responsible for versions of plugins.
+ *
+ * @author Decebal Suiu
+ */
+public interface VersionManager {
+
+ /**
+ * Check if a {@code constraint} and a {@code version} match.
+ *
+ * @param constraint
+ * @param version
+ * @return
+ */
+ boolean satisfies(String constraint, String version);
+
+}
*/
package ro.fortsoft.pf4j;
-import com.github.zafarkhaja.semver.Version;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class DefaultPluginManagerTest {
+
private PluginDescriptor pd1 = null;
private DefaultPluginManager pluginManager = new DefaultPluginManager();
private PluginWrapper pw1;
public void init() throws IOException {
pd1 = new PluginDescriptor();
pd1.setPluginId("myPlugin");
- pd1.setPluginVersion(Version.valueOf("1.2.3"));
+ pd1.setPluginVersion("1.2.3");
pd1.setPluginClass("foo");
pd1.setPluginDescription("My plugin");
pd1.setDependencies("bar, baz");
// By default accept all since system version not given
assertTrue(pluginManager.isPluginValid(pw1));
- pluginManager.setSystemVersion(Version.valueOf("1.0.0"));
+ pluginManager.setSystemVersion("1.0.0");
assertFalse(pluginManager.isPluginValid(pw1));
- pluginManager.setSystemVersion(Version.valueOf("5.0.0"));
+ pluginManager.setSystemVersion("5.0.0");
assertTrue(pluginManager.isPluginValid(pw1));
- pluginManager.setSystemVersion(Version.valueOf("6.0.0"));
+ pluginManager.setSystemVersion("6.0.0");
assertTrue(pluginManager.isPluginValid(pw1));
}
// By default accept all since system version not given
assertTrue(pluginManager.isPluginValid(pw1));
- pluginManager.setSystemVersion(Version.valueOf("1.0.0"));
+ pluginManager.setSystemVersion("1.0.0");
assertFalse(pluginManager.isPluginValid(pw1));
- pluginManager.setSystemVersion(Version.valueOf("5.0.0"));
+ pluginManager.setSystemVersion("5.0.0");
assertTrue(pluginManager.isPluginValid(pw1));
- pluginManager.setSystemVersion(Version.valueOf("6.0.0"));
+ pluginManager.setSystemVersion("6.0.0");
assertFalse(pluginManager.isPluginValid(pw1));
}
public void testDefaultExactVersionAllowed() throws Exception {
assertEquals(false, pluginManager.isExactVersionAllowed());
}
+
}
--- /dev/null
+/*
+ * Copyright 2017 Decebal Suiu
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ro.fortsoft.pf4j;
+
+import com.github.zafarkhaja.semver.ParseException;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @author Decebal Suiu
+ */
+public class DefaultVersionManagerTest {
+
+ private VersionManager versionManager;
+
+ @Before
+ public void init() {
+ versionManager = new DefaultVersionManager();
+ }
+
+ @Test
+ public void satisfies() {
+ assertFalse(versionManager.satisfies(">2.0.0", "1.4.3")); // simple
+ assertTrue(versionManager.satisfies(">=1.4.0 & <1.6.0", "1.4.3")); // range
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void nullOrEmptyVersion() {
+ assertFalse(versionManager.satisfies(">2.0.0", null));
+ }
+
+ @Test(expected = ParseException.class)
+ public void invalidVersion() {
+ assertFalse(versionManager.satisfies(">2.0.0", "1.0"));
+ }
+
+}
*/
package ro.fortsoft.pf4j;
-import com.github.zafarkhaja.semver.Version;
+import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
/**
* @author Decebal Suiu
*/
public class DependencyResolverTest {
+ private DependencyResolver resolver;
+
+ @Before
+ public void init() {
+ VersionManager versionManager = new DefaultVersionManager();
+ resolver = new DependencyResolver(versionManager);
+ }
+
@Test
public void sortedPlugins() {
// create incomplete plugin descriptor (ignore some attributes)
PluginDescriptor pd2 = new PluginDescriptor()
.setPluginId("p2")
- .setPluginVersion(Version.forIntegers(0)); // needed in "checkDependencyVersion" method
+ .setPluginVersion("0.0.0"); // needed in "checkDependencyVersion" method
List<PluginDescriptor> plugins = new ArrayList<>();
plugins.add(pd1);
plugins.add(pd2);
- DependencyResolver resolver = new DependencyResolver();
DependencyResolver.Result result = resolver.resolve(plugins);
assertTrue(result.getNotFoundDependencies().isEmpty());
List<PluginDescriptor> plugins = new ArrayList<>();
plugins.add(pd1);
- DependencyResolver resolver = new DependencyResolver();
DependencyResolver.Result result = resolver.resolve(plugins);
assertFalse(result.getNotFoundDependencies().isEmpty());
public void cyclicDependencies() {
PluginDescriptor pd1 = new PluginDescriptor()
.setPluginId("p1")
- .setPluginVersion(Version.forIntegers(0))
+ .setPluginVersion("0.0.0")
.setDependencies("p2");
PluginDescriptor pd2 = new PluginDescriptor()
.setPluginId("p2")
- .setPluginVersion(Version.forIntegers(0))
+ .setPluginVersion("0.0.0")
.setDependencies("p3");
PluginDescriptor pd3 = new PluginDescriptor()
.setPluginId("p3")
- .setPluginVersion(Version.forIntegers(0))
+ .setPluginVersion("0.0.0")
.setDependencies("p1");
List<PluginDescriptor> plugins = new ArrayList<>();
plugins.add(pd2);
plugins.add(pd3);
- DependencyResolver resolver = new DependencyResolver();
DependencyResolver.Result result = resolver.resolve(plugins);
assertTrue(result.hasCyclicDependency());
PluginDescriptor pd2 = new PluginDescriptor()
.setPluginId("p2")
- .setPluginVersion(Version.forIntegers(1, 4));
+ .setPluginVersion("1.4.0");
List<PluginDescriptor> plugins = new ArrayList<>();
plugins.add(pd1);
plugins.add(pd2);
- DependencyResolver resolver = new DependencyResolver();
DependencyResolver.Result result = resolver.resolve(plugins);
assertFalse(result.getWrongVersionDependencies().isEmpty());
PluginDescriptor pd2 = new PluginDescriptor()
.setPluginId("p2")
- .setPluginVersion(Version.forIntegers(2));
+ .setPluginVersion("2.0.0");
List<PluginDescriptor> plugins = new ArrayList<>();
plugins.add(pd1);
plugins.add(pd2);
- DependencyResolver resolver = new DependencyResolver();
DependencyResolver.Result result = resolver.resolve(plugins);
assertTrue(result.getWrongVersionDependencies().isEmpty());
*/
package ro.fortsoft.pf4j;
-import com.github.zafarkhaja.semver.Version;
import org.junit.Before;
import org.junit.Test;
import ro.fortsoft.pf4j.plugin.MockPluginManager;
import static org.junit.Assert.*;
public class LoadPluginsTest {
+
private Path tmpDir;
private MockPluginManager pluginManager;
private MockZipPlugin p1;
pluginManager.loadPlugins();
pluginManager.startPlugins();
assertEquals(1, pluginManager.getPlugins().size());
- assertEquals(Version.valueOf("1.2.3"), pluginManager.getPlugin(p2.id).getDescriptor().getVersion());
+ assertEquals("1.2.3", pluginManager.getPlugin(p2.id).getDescriptor().getVersion());
assertEquals(1, pluginManager.getStartedPlugins().size());
p2.create();
pluginManager.loadPlugins();
pluginManager.startPlugin(p2.id);
assertEquals(1, pluginManager.getPlugins().size());
- assertEquals(Version.valueOf("2.0.0"), pluginManager.getPlugin(p2.id).getDescriptor().getVersion());
- assertEquals(Version.valueOf("2.0.0"), pluginManager.getStartedPlugins().get(1).getDescriptor().getVersion());
+ assertEquals("2.0.0", pluginManager.getPlugin(p2.id).getDescriptor().getVersion());
+ assertEquals("2.0.0", pluginManager.getStartedPlugins().get(1).getDescriptor().getVersion());
}
@Test
}
private class MockZipPlugin {
+
public final String id;
public final String version;
public final String filename;
Files.move(propsFile, propsInZip);
}
}
+
}
+
}
*/
package ro.fortsoft.pf4j;
-import com.github.zafarkhaja.semver.Version;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static ro.fortsoft.pf4j.util.SemVerUtils.versionMatches;
+import static org.junit.Assert.*;
/**
* @author Mario Franco
*/
public class ManifestPluginDescriptorFinderTest {
+ private VersionManager versionManager;
+
@Rule
public TemporaryFolder testFolder = new TemporaryFolder();
pluginPath = testFolder.newFolder("test-plugin-6", "classes", "META-INF").toPath();
Files.write(pluginPath.resolve("extensions.idx"), "ro.fortsoft.pf4j.demo.hello.HelloPlugin$HelloGreeting".getBytes());
Files.write(pluginPath.resolve("MANIFEST.MF"), getPlugin6Manifest(), charset);
+
+ versionManager = new DefaultVersionManager();
}
/**
assertEquals("test-plugin-1", plugin1.getPluginId());
assertEquals("Test Plugin 1", plugin1.getPluginDescription());
assertEquals("ro.fortsoft.pf4j.plugin.TestPlugin", plugin1.getPluginClass());
- assertEquals(Version.valueOf("0.0.1"), plugin1.getVersion());
+ assertEquals("0.0.1", plugin1.getVersion());
assertEquals("Decebal Suiu", plugin1.getProvider());
assertEquals(2, plugin1.getDependencies().size());
assertEquals("test-plugin-2", plugin1.getDependencies().get(0).getPluginId());
assertEquals("test-plugin-3", plugin1.getDependencies().get(1).getPluginId());
assertEquals("~1.0", plugin1.getDependencies().get(1).getPluginVersionSupport());
assertEquals("Apache-2.0", plugin1.getLicense());
- assertTrue(versionMatches(plugin1.getRequires(), "1.0.0"));
+ assertTrue(versionManager.satisfies(plugin1.getRequires(), "1.0.0"));
assertEquals("test-plugin-2", plugin2.getPluginId());
assertEquals("", plugin2.getPluginDescription());
assertEquals("ro.fortsoft.pf4j.plugin.TestPlugin", plugin2.getPluginClass());
- assertEquals(Version.valueOf("0.0.1"), plugin2.getVersion());
+ assertEquals("0.0.1", plugin2.getVersion());
assertEquals("Decebal Suiu", plugin2.getProvider());
assertEquals(0, plugin2.getDependencies().size());
- assertTrue(versionMatches(plugin2.getRequires(),"1.0.0"));
+ assertTrue(versionManager.satisfies(plugin2.getRequires(), "1.0.0"));
}
/**
*/
package ro.fortsoft.pf4j;
-import com.github.zafarkhaja.semver.Version;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.util.List;
import static org.junit.Assert.*;
-import static ro.fortsoft.pf4j.util.SemVerUtils.versionMatches;
public class PropertiesPluginDescriptorFinderTest {
+ private VersionManager versionManager;
+
@Rule
public TemporaryFolder testFolder = new TemporaryFolder();
// no plugin id
pluginPath = testFolder.newFolder("test-plugin-6").toPath();
Files.write(pluginPath.resolve("plugin.properties"), getPlugin6Properties(), charset);
+
+ versionManager = new DefaultVersionManager();
}
@Test
assertEquals("test-plugin-1", plugin1.getPluginId());
assertEquals("Test Plugin 1", plugin1.getPluginDescription());
assertEquals("ro.fortsoft.pf4j.plugin.TestPlugin", plugin1.getPluginClass());
- assertEquals(Version.valueOf("0.0.1"), plugin1.getVersion());
+ assertEquals("0.0.1", plugin1.getVersion());
assertEquals("Decebal Suiu", plugin1.getProvider());
assertEquals(2, plugin1.getDependencies().size());
assertEquals("test-plugin-2", plugin1.getDependencies().get(0).getPluginId());
assertEquals("~1.0", plugin1.getDependencies().get(1).getPluginVersionSupport());
assertEquals("Apache-2.0", plugin1.getLicense());
assertEquals(">=1", plugin1.getRequires());
- assertTrue(versionMatches(plugin1.getRequires(),"1.0.0"));
- assertFalse(versionMatches(plugin1.getRequires(), "0.1.0"));
+ assertTrue(versionManager.satisfies(plugin1.getRequires(), "1.0.0"));
+ assertFalse(versionManager.satisfies(plugin1.getRequires(), "0.1.0"));
assertEquals("test-plugin-2", plugin2.getPluginId());
assertEquals("", plugin2.getPluginDescription());
assertEquals("ro.fortsoft.pf4j.plugin.TestPlugin", plugin2.getPluginClass());
- assertEquals(Version.valueOf("0.0.1"), plugin2.getVersion());
+ assertEquals("0.0.1", plugin2.getVersion());
assertEquals("Decebal Suiu", plugin2.getProvider());
assertEquals(0, plugin2.getDependencies().size());
assertEquals("*", plugin2.getRequires()); // Default is *
- assertTrue(versionMatches(plugin2.getRequires(),"1.0.0"));
+ assertTrue(versionManager.satisfies(plugin2.getRequires(), "1.0.0"));
}
@Test(expected = PluginException.class)
return Arrays.asList(lines);
}
+
private Path getPluginsRoot() {
return testFolder.getRoot().toPath();
}
* Manager for testing
*/
public class MockPluginManager extends DefaultPluginManager {
+
private PluginDescriptorFinder finder = new DefaultPluginDescriptorFinder(new DefaultPluginClasspath());
public MockPluginManager() {
protected PluginDescriptorFinder createPluginDescriptorFinder() {
return finder;
}
+
}
import java.io.FileWriter;
import java.io.IOException;
import java.net.URI;
-import java.nio.file.*;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.Collections;
import static org.junit.Assert.*;
public class FileUtilsTest {
+
private Path zipFile;
private Path tmpDir;
private Path propsFile;
+++ /dev/null
-/*
- * Copyright 2017 Decebal Suiu
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ro.fortsoft.pf4j.util;
-
-import com.github.zafarkhaja.semver.Version;
-import com.github.zafarkhaja.semver.expr.ExpressionParser;
-
-/**
- * Utility for semantic version testing
- */
-public class SemVerUtils {
- public static boolean versionMatches(String expression, String systemVersion) {
- return ExpressionParser.newInstance().parse(expression).interpret(Version.valueOf(systemVersion));
- }
-}