Skip to content

Commit

Permalink
Merge pull request #32 from jglick/majorVersion
Browse files Browse the repository at this point in the history
Documenting counterintuitive behavior of `DefaultArtifactVersion.majorVersion` with `.` separator
  • Loading branch information
jglick authored Jan 13, 2022
2 parents f1ed0e9 + db7d2a1 commit 4e30093
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/java/hudson/util/VersionNumberTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.hamcrest.CoreMatchers;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -138,6 +139,17 @@ public void backportJep229() {
assertOrderAlsoInMaven("99.v1234deadbeef", "99.5.vabcd1234abcd", "99.10.vabcd1234abcd", "100.vdead9876beef");
}

@Issue("https://github.com/jenkinsci/incrementals-tools/issues/29")
@Test
public void majorVersion() {
assertOrderAlsoInMaven("1.1", "391.ve4a_38c1b_cf4b_");
// Weird but TBD if this matters in practice:
assertEquals(0, new DefaultArtifactVersion("391.ve4a_38c1b_cf4b_").getMajorVersion());
// More natural behavior of majorVersion:
assertOrderAlsoInMaven("1.1", "200.vabcd1234abcd", "391-ve4a_38c1b_cf4b_");
assertEquals(391, new DefaultArtifactVersion("391-ve4a_38c1b_cf4b_").getMajorVersion());
}

@Test
public void testOrEqualTo() {
assertTrue(new VersionNumber("1.8").isNewerThanOrEqualTo(new VersionNumber("1.8")));
Expand Down

0 comments on commit 4e30093

Please sign in to comment.