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

Last change on this file since 17442 was 17275, checked in by Don-vip, 3 years ago

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

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