ACS-953 Unable to upgrade from ACS-7.0-M1 or ACS-7.0-M2 to ACS-7.0-A12 (#183)

* ACS-953 Unable to upgrade from ACS-7.0-M1 or ACS-7.0-M2 to ACS-7.0-A12

Now that we create internal releases of the form M.m.r-M9 (milestone), M.m.r-A9 (alpha) and M.m.r-RC9 (release candidate) during development and testing, we need to ensure we can upgrade from any of these to any other, as they may occur in any order and also to the final external release M.m.r. We also will allow a change from the final release back to an internal one for regression testing. The code within ModuleComponentHelper which calls this method, checks if it is the same version (0) and then if it is downgrading (> 0), so if they share the same M.m.r part matches AND is one of these formats, we return <0.
This commit is contained in:
Alan Davis
2020-11-30 19:54:21 +00:00
committed by GitHub
parent 73c875eac9
commit ea4e18d347
4 changed files with 180 additions and 31 deletions

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2017 Alfresco Software Limited
* Copyright (C) 2005 - 2020 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -79,6 +79,7 @@ import org.junit.runners.Suite;
org.alfresco.service.cmr.calendar.CalendarRecurrenceHelperTest.class,
org.alfresco.service.cmr.calendar.CalendarTimezoneHelperTest.class,
org.alfresco.tools.RenameUserTest.class,
org.alfresco.util.VersionNumberTest.class,
org.alfresco.util.FileNameValidatorTest.class,
org.alfresco.util.HttpClientHelperTest.class,
org.alfresco.util.JSONtoFmModelTest.class,

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2020 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -230,4 +230,87 @@ public class ModuleVersionNumberTest extends TestCase
ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
return (ModuleVersionNumber) objectInputStream.readObject();
}
// Tests that we can strip the suffixes such as "-M2", "-A12" or "-RC2" from versions "7.0.0-M2", "6.2.2-A12", "7.0.1-RC2"
// The main version may contain 3 or 4 digit parts.
public void testGetVersionWithoutSuffix()
{
for (String[] pair: new String[][]
{{null, "1.2"},
{"1.2.3", "1.2.3"},
{"1.2.3.4", "1.2.3.4"},
{null, "1.2.3.4.5"},
{"1.2.3", "1.2.3-M4"},
{"1.2.3.4", "1.2.3.4-A56"},
{"1.2.3", "1.2.3-RC456"},
{"11.22.33.44", "11.22.33.44-A5"},
{null, "1.2.3-456"},
{null, "1.2.3-X12"},
{null, "1.2.5-A6-A6"},
{null, "1.2.3.4.5-A6"},
{null, "1.2-M3"},
{null, "1.2.3-RCA-45"},
{null, "1.2.3-AM4"},
{null, "1.2.3-A56A"},
})
{
String expected = pair[0];
String value = pair[1];
ModuleVersionNumber version = new ModuleVersionNumber(value);
String actual = version.getVersionWithoutSuffix();
assertEquals(expected, actual);
}
}
public void testInternalVersionsAreUpgrades()
{
for (String[] pair: new String[][]
// same base version with an optional special suffix (-A9, -M9, -RC9)
{{"upgrade", "7.0.0-A10", "7.0.0"},
{"upgrade", "7.0.0", "7.0.0-A11"},
{"upgrade", "7.0.0-A10", "7.0.0-A12"},
{"upgrade", "7.0.0-A13", "7.0.0-M1"},
{"upgrade", "7.0.0-A13", "7.0.0-RC1"},
// Just the same version
{"same", "7.0.0", "7.0.0"},
{"same", "7.0.0-A14", "7.0.0-A14"},
// Normal versions using standard maven compare
{"downgrade", "7.0.0", "6.2.3"},
{"upgrade", "6.2.3", "7.0.0"},
// standard maven compare - note sure these even make sense as these are not maven format versions!
{"upgrade", "7.0.0-A15", "7.0.0-1234"},
{"downgrade", "7.0.0-1234", "7.0.0-M2"},
{"downgrade", "7.0.0-Rubbish1", "7.0.0-M3"},
{"upgrade", "7.0.0-A16", "7.0.0-Rubbish2"}
})
{
String expected = pair[0];
String value1 = pair[1];
String value2 = pair[2];
ModuleVersionNumber thisVersion = new ModuleVersionNumber(value1);
ModuleVersionNumber thatVersion = new ModuleVersionNumber(value2);
int actual = thisVersion.compareTo(thatVersion);
if ("downgrade".equals(expected))
{
assertTrue("Expected "+thisVersion+" to be a downgrade "+thatVersion+" ("+actual+")", actual > 0);
}
else if ("same".equals(expected))
{
assertTrue("Expected "+thisVersion+" to be the same base version as "+thatVersion+" ("+actual+")", actual == 0);
}
else if ("upgrade".equals(expected))
{
assertTrue("Expected "+thisVersion+" to be an upgrade from "+thatVersion+" ("+actual+")", actual < 0);
}
}
}
}