source: josm/trunk/test/unit/org/openstreetmap/josm/data/VersionTest.java@ 14219

Last change on this file since 14219 was 11899, checked in by Don-vip, 7 years ago

fix #14646 - extra space in JOSM user agent since r11889 (regression)

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertTrue;
6
7import java.io.ByteArrayInputStream;
8import java.nio.charset.StandardCharsets;
9
10import org.junit.BeforeClass;
11import org.junit.Test;
12import org.openstreetmap.josm.JOSMFixture;
13
14/**
15 * Unit tests for class {@link Version}.
16 */
17public class VersionTest {
18
19 /**
20 * Setup test.
21 */
22 @BeforeClass
23 public static void setUpBeforeClass() {
24 JOSMFixture.createUnitTestFixture().init();
25 }
26
27 /**
28 * Unit test of {@link Version#getAgentString}
29 */
30 @Test
31 public void testGetAgentString() {
32 String v = Version.getInstance().getAgentString(false);
33 assertTrue(v, v.matches("JOSM/1\\.5 \\([1-9][0-9]* SVN en\\)"));
34 v = Version.getInstance().getAgentString(true);
35 assertTrue(v, v.matches("JOSM/1\\.5 \\([1-9][0-9]* SVN en\\).*"));
36 }
37
38 /**
39 * Unit test of {@link Version#initFromRevisionInfo} - null case.
40 */
41 @Test
42 public void testInitFromRevisionInfoNull() {
43 Version v = new Version();
44 v.initFromRevisionInfo(null);
45 assertEquals(Version.JOSM_UNKNOWN_VERSION, v.getVersion());
46 }
47
48 /**
49 * Unit test of {@link Version#initFromRevisionInfo} - local build.
50 */
51 @Test
52 public void testInitFromRevisionInfoLocal() {
53 Version v = new Version();
54 v.initFromRevisionInfo(new ByteArrayInputStream(("\n" +
55 "Revision: 11885\n" +
56 "Is-Local-Build: true\n" +
57 "Build-Date: 2017-04-12 02:08:29\n"
58 ).getBytes(StandardCharsets.UTF_8)));
59 assertEquals(11885, v.getVersion());
60 assertEquals("11885", v.getVersionString());
61 assertTrue(v.isLocalBuild());
62 }
63}
Note: See TracBrowser for help on using the repository browser.