Search in sources :

Example 1 with JarPluginArtifact

use of com.qcadoo.plugin.api.artifact.JarPluginArtifact in project qcadoo by qcadoo.

the class JarPluginArtifactTest method shouldHaveFileName.

@Test
public void shouldHaveFileName() throws Exception {
    // given
    File file = folder.newFile("plugin.jar");
    // when
    PluginArtifact pluginArtifact = new JarPluginArtifact(file);
    // then
    assertEquals("plugin.jar", pluginArtifact.getName());
}
Also used : JarPluginArtifact(com.qcadoo.plugin.api.artifact.JarPluginArtifact) JarPluginArtifact(com.qcadoo.plugin.api.artifact.JarPluginArtifact) PluginArtifact(com.qcadoo.plugin.api.artifact.PluginArtifact) FileUtils.writeStringToFile(org.apache.commons.io.FileUtils.writeStringToFile) File(java.io.File) Test(org.junit.Test)

Example 2 with JarPluginArtifact

use of com.qcadoo.plugin.api.artifact.JarPluginArtifact in project qcadoo by qcadoo.

the class JarPluginArtifactTest method shouldThrowAnExceptionIfFileNotExist.

@Test(expected = IllegalStateException.class)
public void shouldThrowAnExceptionIfFileNotExist() throws Exception {
    // given
    File file = new File("xxxx");
    // when
    new JarPluginArtifact(file);
}
Also used : JarPluginArtifact(com.qcadoo.plugin.api.artifact.JarPluginArtifact) FileUtils.writeStringToFile(org.apache.commons.io.FileUtils.writeStringToFile) File(java.io.File) Test(org.junit.Test)

Example 3 with JarPluginArtifact

use of com.qcadoo.plugin.api.artifact.JarPluginArtifact in project qcadoo by qcadoo.

the class JarPluginArtifactTest method shouldHaveFileInputStream.

@Test
public void shouldHaveFileInputStream() throws Exception {
    // given
    File file = folder.newFile("plugin.jar");
    writeStringToFile(file, "content");
    // when
    PluginArtifact pluginArtifact = new JarPluginArtifact(file);
    // then
    Assert.assertTrue(contentEquals(new FileInputStream(file), pluginArtifact.getInputStream()));
}
Also used : JarPluginArtifact(com.qcadoo.plugin.api.artifact.JarPluginArtifact) JarPluginArtifact(com.qcadoo.plugin.api.artifact.JarPluginArtifact) PluginArtifact(com.qcadoo.plugin.api.artifact.PluginArtifact) FileUtils.writeStringToFile(org.apache.commons.io.FileUtils.writeStringToFile) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 4 with JarPluginArtifact

use of com.qcadoo.plugin.api.artifact.JarPluginArtifact in project qcadoo by qcadoo.

the class PluginIntegrationTest method shouldUpdateEnabledPlugin.

@Test
public void shouldUpdateEnabledPlugin() 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);
    pluginManager.enablePlugin("plugin4");
    ((InternalPlugin) pluginAccessor.getPlugin("plugin4")).changeStateTo(PluginState.ENABLED);
    // when
    PluginOperationResult result = pluginManager.installPlugin(artifact2);
    // then
    assertTrue(result.isSuccess());
    assertTrue(result.isRestartNeccessary());
    assertNotNull(pluginAccessor.getPlugin("plugin4"));
    assertTrue(pluginAccessor.getPlugin("plugin4").hasState(PluginState.ENABLING));
    assertEquals(new Version("1.2.4"), pluginAccessor.getPlugin("plugin4").getVersion());
}
Also used : InternalPlugin(com.qcadoo.plugin.internal.api.InternalPlugin) JarPluginArtifact(com.qcadoo.plugin.api.artifact.JarPluginArtifact) Version(com.qcadoo.plugin.api.Version) PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) File(java.io.File) Test(org.junit.Test)

Example 5 with JarPluginArtifact

use of com.qcadoo.plugin.api.artifact.JarPluginArtifact in project qcadoo by qcadoo.

the class PluginIntegrationTest method shouldUninstallPlugin.

@Test
public void shouldUninstallPlugin() throws Exception {
    // given
    JarPluginArtifact artifact = new JarPluginArtifact(new File("src/test/resources/com/qcadoo/plugin/integration/plugin4.jar"));
    pluginManager.installPlugin(artifact);
    pluginManager.enablePlugin("plugin4");
    // when
    PluginOperationResult result = pluginManager.uninstallPlugin("plugin4");
    // then
    assertTrue(result.isSuccess());
    assertTrue(result.isRestartNeccessary());
    assertNull(pluginAccessor.getPlugin("plugin4"));
}
Also used : JarPluginArtifact(com.qcadoo.plugin.api.artifact.JarPluginArtifact) PluginOperationResult(com.qcadoo.plugin.api.PluginOperationResult) File(java.io.File) Test(org.junit.Test)

Aggregations

JarPluginArtifact (com.qcadoo.plugin.api.artifact.JarPluginArtifact)10 File (java.io.File)10 Test (org.junit.Test)10 PluginOperationResult (com.qcadoo.plugin.api.PluginOperationResult)7 Version (com.qcadoo.plugin.api.Version)3 FileUtils.writeStringToFile (org.apache.commons.io.FileUtils.writeStringToFile)3 PluginArtifact (com.qcadoo.plugin.api.artifact.PluginArtifact)2 InternalPlugin (com.qcadoo.plugin.internal.api.InternalPlugin)1 FileInputStream (java.io.FileInputStream)1