use of com.qcadoo.plugin.api.Version in project qcadoo by qcadoo.
the class PluginDependencyInformationTest method shouldReturnTrueWhenVersionIsNotSattisfied.
@Test
public void shouldReturnTrueWhenVersionIsNotSattisfied() throws Exception {
// given
Version v1 = new Version("0.9");
Version v2 = new Version("2.3");
Version v3 = new Version("1.2.09");
Version v4 = new Version("3.0.1");
Version v5 = new Version("3.0.2");
// when
boolean res1 = dependencyInformation1.contains(v1);
boolean res2 = dependencyInformation2.contains(v2);
boolean res3 = dependencyInformation3.contains(v3);
boolean res4 = dependencyInformation4.contains(v4);
boolean res5 = dependencyInformation5.contains(v5);
// then
Assert.assertFalse(res1);
Assert.assertFalse(res2);
Assert.assertFalse(res3);
Assert.assertFalse(res4);
Assert.assertFalse(res5);
}
use of com.qcadoo.plugin.api.Version in project qcadoo by qcadoo.
the class DefaultPluginAccessor method init.
public void init() {
LOG.info("Plugin Framework initialization");
long time = System.currentTimeMillis();
pluginStateResolver.setPluginAccessor(this);
Set<InternalPlugin> enabledPluginsFromDescriptor = pluginDescriptorParser.loadPlugins();
Set<QcadooPluginPlugin> pluginsFromDatabase = pluginDao.list();
for (InternalPlugin plugin : enabledPluginsFromDescriptor) {
QcadooPluginPlugin existingPlugin = null;
for (QcadooPluginPlugin databasePlugin : pluginsFromDatabase) {
if (plugin.getIdentifier().equals(databasePlugin.getIdentifier())) {
existingPlugin = databasePlugin;
break;
}
}
if (existingPlugin == null) {
plugin.changeStateTo(PluginState.ENABLING);
} else {
plugin.changeStateTo(PluginState.valueOf(existingPlugin.getState()));
}
if (existingPlugin == null || plugin.compareVersion(new Version(existingPlugin.getVersion())) > 0) {
pluginDao.save(plugin);
} else if (plugin.compareVersion(new Version(existingPlugin.getVersion())) < 0) {
throw new IllegalStateException("Unsupported operation: downgrade, for plugin: " + plugin.getIdentifier());
}
LOG.info("Registering plugin " + plugin);
plugins.put(plugin.getIdentifier(), plugin);
}
for (QcadooPluginPlugin databasePlugin : pluginsFromDatabase) {
if (databasePlugin.getState().equals(PluginState.TEMPORARY.toString())) {
continue;
}
Plugin existingPlugin = null;
for (Plugin plugin : enabledPluginsFromDescriptor) {
if (databasePlugin.getIdentifier().equals(plugin.getIdentifier())) {
existingPlugin = plugin;
break;
}
}
if (existingPlugin == null) {
pluginDao.delete(databasePlugin);
}
}
Set<InternalPlugin> temporaryPlugins = pluginDescriptorParser.getTemporaryPlugins();
for (InternalPlugin plugin : temporaryPlugins) {
plugins.put(plugin.getIdentifier(), plugin);
}
LOG.info("Plugin Framework initialized in " + (System.currentTimeMillis() - time) + "ms");
}
use of com.qcadoo.plugin.api.Version in project qcadoo by qcadoo.
the class PluginIntegrationTest method shouldUpdateTemporaryPlugin.
@Test
public void shouldUpdateTemporaryPlugin() throws Exception {
// given
JarPluginArtifact artifact = new JarPluginArtifact(new File("src/test/resources/com/qcadoo/plugin/integration/plugin4.jar"));
JarPluginArtifact artifact2 = new JarPluginArtifact(new File("src/test/resources/com/qcadoo/plugin/integration/plugin4.1.jar"));
pluginManager.installPlugin(artifact);
// when
PluginOperationResult result = pluginManager.installPlugin(artifact2);
// then
assertTrue(result.isSuccess());
assertFalse(result.isRestartNeccessary());
assertNotNull(pluginAccessor.getPlugin("plugin4"));
assertTrue(pluginAccessor.getPlugin("plugin4").hasState(PluginState.TEMPORARY));
assertEquals(new Version("1.2.4"), pluginAccessor.getPlugin("plugin4").getVersion());
}
Aggregations