-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[MNG-7559] Fix version comparison (master 4.0.x branch) #929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,13 +46,16 @@ private Comparable newComparable(String version) { | |
| } | ||
|
|
||
| private static final String[] VERSIONS_QUALIFIER = { | ||
| "1-abc", | ||
sultan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "1-alpha2snapshot", | ||
| "1-alpha2", | ||
| "1-alpha-123", | ||
| "1-beta-2", | ||
| "1-beta123", | ||
| "1-def", | ||
| "1-m2", | ||
| "1-m11", | ||
| "1-pom-1", | ||
| "1-rc", | ||
| "1-cr2", | ||
| "1-rc123", | ||
|
|
@@ -61,18 +64,15 @@ private Comparable newComparable(String version) { | |
| "1-sp", | ||
| "1-sp2", | ||
| "1-sp123", | ||
| "1-abc", | ||
| "1-def", | ||
| "1-pom-1", | ||
| "1-1-snapshot", | ||
| "1-1", | ||
| "1-2", | ||
| "1-123" | ||
| }; | ||
|
|
||
| private static final String[] VERSIONS_NUMBER = { | ||
| "2.0", "2.0.a", "2-1", "2.0.2", "2.0.123", "2.1.0", "2.1-a", "2.1b", "2.1-c", "2.1-1", "2.1.0.1", "2.2", | ||
| "2.123", "11.a2", "11.a11", "11.b2", "11.b11", "11.m2", "11.m11", "11", "11.a", "11b", "11c", "11m" | ||
| "2.0.a", "2.0", "2-1", "2.0.2", "2.0.123", "2.1-a", "2.1b", "2.1-c", "2.1.0", "2.1-1", "2.1.0.1", "2.2", | ||
| "2.123", "11.a", "11.a2", "11.a11", "11b", "11.b2", "11.b11", "11c", "11m", "11.m2", "11.m11", "11" | ||
| }; | ||
|
|
||
| private void checkVersionsOrder(String[] versions) { | ||
|
|
@@ -202,7 +202,7 @@ public void testVersionComparing() { | |
|
|
||
| checkVersionsOrder("2.0-1", "2.0.1"); | ||
| checkVersionsOrder("2.0.1-klm", "2.0.1-lmn"); | ||
| checkVersionsOrder("2.0.1", "2.0.1-xyz"); | ||
| checkVersionsOrder("2.0.1-xyz", "2.0.1"); // now 2.0.1-xyz < 2.0.1 as of MNG-7559 | ||
|
|
||
| checkVersionsOrder("2.0.1", "2.0.1-123"); | ||
| checkVersionsOrder("2.0.1-xyz", "2.0.1-123"); | ||
|
|
@@ -217,13 +217,9 @@ public void testVersionComparing() { | |
| */ | ||
| @Test | ||
| public void testMng5568() { | ||
| String a = "6.1.0"; | ||
| String b = "6.1.0rc3"; | ||
| String c = "6.1H.5-beta"; // this is the unusual version string, with 'H' in the middle | ||
|
|
||
| checkVersionsOrder(b, a); // classical | ||
| checkVersionsOrder(b, c); // now b < c, but before MNG-5568, we had b > c | ||
| checkVersionsOrder(a, c); | ||
| checkVersionsOrder("6.1H.5-beta", "6.1.0rc3"); // now H < RC as of MNG-7559 | ||
| checkVersionsOrder("6.1.0rc3", "6.1.0"); // classical | ||
| checkVersionsOrder("6.1H.5-beta", "6.1.0"); // transitivity | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -347,6 +343,23 @@ public void testReuse() { | |
| assertEquals(c1, c2, "reused instance should be equivalent to new instance"); | ||
| } | ||
|
|
||
| /** | ||
| * Test <a href="https://issues.apache.org/jira/browse/MNG-7559">MNG-7559</a> edge cases | ||
| * -pfd < final, ga, release | ||
| * 2.0.1.MR < 2.0.1 | ||
| * 9.4.1.jre16 > 9.4.1.jre16-preview | ||
| */ | ||
| @Test | ||
| public void testMng7559() { | ||
| // checking general cases | ||
| checkVersionsOrder(new String[] {"ab", "alpha", "beta", "cd", "ea", "milestone", "mr", "pfd", "preview", "RC"}); | ||
| // checking identified issues respect the general case | ||
| checkVersionsOrder("2.3-pfd", "2.3"); | ||
sultan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| checkVersionsOrder("2.0.1.MR", "2.0.1"); | ||
| checkVersionsOrder("9.4.1.jre16-preview", "9.4.1.jre16"); | ||
sultan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| checkVersionsOrder("1-sp-1", "1-ga-1"); // proving website documentation right. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also there is no change here, this is weird, isn't? I mean a service pack comes after
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i agree with you but the website documentation says otherwise. this is an edge case that may need a separate PR to fix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the test
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think the number are already taken into account but a unit test for them will not hurt i'll have to amend the code; meanwhile there should be a talk -maybe i should join the mailing list- about what the future yields between Maven and SemVer |
||
| } | ||
|
|
||
| /** | ||
| * Test <a href="https://issues.apache.org/jira/browse/MNG-7644">MNG-7644</a> edge cases | ||
| * 1.0.0.RC1 < 1.0.0-RC2 and more generally: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.