mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
added unit test for plugin updates
This commit is contained in:
@@ -77,6 +77,9 @@ import javax.xml.bind.JAXBException;
|
||||
public final class PluginProcessor
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final String INSTALLEDNAME_FORMAT = "%s.%03d";
|
||||
|
||||
/** Field description */
|
||||
private static final String DIRECTORY_CLASSES = "classes";
|
||||
|
||||
@@ -640,7 +643,23 @@ public final class PluginProcessor
|
||||
Files.createDirectories(installedDirectory);
|
||||
}
|
||||
|
||||
Files.move(archive, installedDirectory.resolve(archive.getFileName()));
|
||||
Path installed = null;
|
||||
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
String name = String.format(INSTALLEDNAME_FORMAT, archive.getFileName(), i);
|
||||
|
||||
installed = installedDirectory.resolve(name);
|
||||
|
||||
if (!Files.exists(installed))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("move installed archive to {}", installed);
|
||||
|
||||
Files.move(archive, installed);
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
@@ -92,6 +92,16 @@ public class PluginProcessorTest
|
||||
new PluginResource("sonia/scm/plugin/scm-e-plugin.smp", "scm-e-plugin.smp",
|
||||
"sonia.scm.plugins:scm-e-plugin:1.0.0-SNAPSHOT");
|
||||
|
||||
/** Field description */
|
||||
private static final PluginResource PLUGIN_F_1_0_0 =
|
||||
new PluginResource("sonia/scm/plugin/scm-f-plugin-1.0.0.smp",
|
||||
"scm-f-plugin.smp", "sonia.scm.plugins:scm-f-plugin:1.0.0");
|
||||
|
||||
/** Field description */
|
||||
private static final PluginResource PLUGIN_F_1_0_1 =
|
||||
new PluginResource("sonia/scm/plugin/scm-f-plugin-1.0.1.smp",
|
||||
"scm-f-plugin.smp", "sonia.scm.plugins:scm-f-plugin:1.0.1");
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -247,6 +257,25 @@ public class PluginProcessorTest
|
||||
assertThat(Resources.toString(url, Charsets.UTF_8), is("hello"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test
|
||||
public void testUpdate() throws IOException
|
||||
{
|
||||
copySmp(PLUGIN_F_1_0_0);
|
||||
|
||||
PluginWrapper plugin = collectAndGetFirst();
|
||||
|
||||
assertThat(plugin.getId(), is(PLUGIN_F_1_0_0.id));
|
||||
copySmp(PLUGIN_F_1_0_1);
|
||||
plugin = collectAndGetFirst();
|
||||
assertThat(plugin.getId(), is(PLUGIN_F_1_0_1.id));
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user