Tatu Saloranta | 5ff8a2d | 2011-12-23 21:52:24 -0800 | [diff] [blame] | 1 | package com.fasterxml.jackson.core.util; |
| 2 | |
| 3 | import com.fasterxml.jackson.core.Version; |
Ben Gertzfield | 769c94d | 2013-01-04 11:27:21 -0800 | [diff] [blame] | 4 | import com.fasterxml.jackson.core.json.PackageVersion; |
Tatu Saloranta | 68d79dd | 2013-01-10 21:13:46 -0800 | [diff] [blame] | 5 | import com.fasterxml.jackson.core.json.UTF8JsonGenerator; |
Tatu Saloranta | 5ff8a2d | 2011-12-23 21:52:24 -0800 | [diff] [blame] | 6 | |
Tatu Saloranta | 7317dc9 | 2014-09-24 20:07:10 -0700 | [diff] [blame] | 7 | public class TestVersionUtil extends com.fasterxml.jackson.core.BaseTest |
Tatu Saloranta | 5ff8a2d | 2011-12-23 21:52:24 -0800 | [diff] [blame] | 8 | { |
| 9 | public void testVersionPartParsing() |
| 10 | { |
| 11 | assertEquals(13, VersionUtil.parseVersionPart("13")); |
| 12 | assertEquals(27, VersionUtil.parseVersionPart("27.8")); |
| 13 | assertEquals(0, VersionUtil.parseVersionPart("-3")); |
| 14 | } |
| 15 | |
| 16 | public void testVersionParsing() |
| 17 | { |
Tatu Saloranta | 5b2aff3 | 2012-01-17 09:04:51 -0800 | [diff] [blame] | 18 | assertEquals(new Version(1, 2, 15, "foo", "group", "artifact"), |
| 19 | VersionUtil.parseVersion("1.2.15-foo", "group", "artifact")); |
Tatu Saloranta | 5ff8a2d | 2011-12-23 21:52:24 -0800 | [diff] [blame] | 20 | } |
James Roper | 7877499 | 2012-01-03 20:43:57 +0100 | [diff] [blame] | 21 | |
Cowtowncoder | 88c296c | 2015-05-27 12:08:24 -0700 | [diff] [blame] | 22 | @SuppressWarnings("deprecation") |
James Roper | 7877499 | 2012-01-03 20:43:57 +0100 | [diff] [blame] | 23 | public void testMavenVersionParsing() { |
| 24 | assertEquals(new Version(1, 2, 3, "SNAPSHOT", "foo.bar", "foo-bar"), |
| 25 | VersionUtil.mavenVersionFor(TestVersionUtil.class.getClassLoader(), "foo.bar", "foo-bar")); |
| 26 | } |
Ben Gertzfield | 769c94d | 2013-01-04 11:27:21 -0800 | [diff] [blame] | 27 | |
| 28 | public void testPackageVersionMatches() { |
Tatu Saloranta | 68d79dd | 2013-01-10 21:13:46 -0800 | [diff] [blame] | 29 | assertEquals(PackageVersion.VERSION, VersionUtil.versionFor(UTF8JsonGenerator.class)); |
Ben Gertzfield | 769c94d | 2013-01-04 11:27:21 -0800 | [diff] [blame] | 30 | } |
Sammy Chu | 18ad3bc | 2016-01-26 11:58:58 +0800 | [diff] [blame] | 31 | |
Tatu Saloranta | b52647c | 2016-01-25 20:04:39 -0800 | [diff] [blame^] | 32 | // [core#248]: make sure not to return `null` but `Version.unknownVersion()` |
Sammy Chu | 18ad3bc | 2016-01-26 11:58:58 +0800 | [diff] [blame] | 33 | public void testVersionForUnknownVersion() { |
| 34 | // expecting return version.unknownVersion() instead of null |
| 35 | assertEquals(Version.unknownVersion(), VersionUtil.versionFor(TestVersionUtil.class)); |
| 36 | } |
Tatu Saloranta | 5ff8a2d | 2011-12-23 21:52:24 -0800 | [diff] [blame] | 37 | } |