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);
}
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());
}
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()));
}
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());
}
Aggregations