Search in sources :

Example 1 with PluginArtifact

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

the class PluginFileManagerTest method shouldThrowExceptionOnUploadingPluginFileWhenOperationFail.

@Test(expected = PluginException.class)
public void shouldThrowExceptionOnUploadingPluginFileWhenOperationFail() throws Exception {
    // given
    File newPluginFile = new File(source, "newpluginname.jar");
    FileUtils.touch(newPluginFile);
    PluginArtifact pluginArtifact = mock(PluginArtifact.class);
    given(pluginArtifact.getInputStream()).willReturn(new FileInputStream(newPluginFile));
    given(pluginArtifact.getName()).willReturn("");
    // when
    defaultPluginFileManager.uploadPlugin(pluginArtifact);
}
Also used : PluginArtifact(com.qcadoo.plugin.api.artifact.PluginArtifact) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 2 with PluginArtifact

use of com.qcadoo.plugin.api.artifact.PluginArtifact 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 3 with PluginArtifact

use of com.qcadoo.plugin.api.artifact.PluginArtifact 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 PluginArtifact

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

the class PluginFileManagerTest method shouldUploadPluginFile.

@Test
public void shouldUploadPluginFile() throws Exception {
    // given
    File newPluginFile = new File(source, "newpluginname.jar");
    FileUtils.touch(newPluginFile);
    PluginArtifact pluginArtifact = mock(PluginArtifact.class);
    given(pluginArtifact.getInputStream()).willReturn(new FileInputStream(newPluginFile));
    given(pluginArtifact.getName()).willReturn("uploadpluginname.jar");
    // when
    File pluginFile = defaultPluginFileManager.uploadPlugin(pluginArtifact);
    // then
    assertTrue(pluginFile.exists());
}
Also used : PluginArtifact(com.qcadoo.plugin.api.artifact.PluginArtifact) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

PluginArtifact (com.qcadoo.plugin.api.artifact.PluginArtifact)4 File (java.io.File)4 Test (org.junit.Test)4 FileInputStream (java.io.FileInputStream)3 JarPluginArtifact (com.qcadoo.plugin.api.artifact.JarPluginArtifact)2 FileUtils.writeStringToFile (org.apache.commons.io.FileUtils.writeStringToFile)2