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

Last change on this file was 18853, checked in by taylor.smock, 7 months ago

See #16567: Update to JUnit 5

This removes new JOSMTestRules() with no additional setup and most
JOSMFixture calls.

Removing the bare JOSMTestRules speeds up the test suite since there are two
fewer System.gc() calls per test.

  • Property svn:eol-style set to native
File size: 1.6 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.Test;
11
12/**
13 * Unit tests for class {@link Version}.
14 */
15class VersionTest {
16 /**
17 * Unit test of {@link Version#getAgentString}
18 */
19 @Test
20 void testGetAgentString() {
21 Version version = new Version();
22 version.initFromRevisionInfo(null);
23 String v = version.getAgentString(false);
24 assertTrue(v.matches("JOSM/1\\.5 \\(UNKNOWN en\\)"), v);
25 v = version.getAgentString(true);
26 assertTrue(v.matches("JOSM/1\\.5 \\(UNKNOWN en\\).*"), v);
27 }
28
29 /**
30 * Unit test of {@link Version#initFromRevisionInfo} - null case.
31 */
32 @Test
33 void testInitFromRevisionInfoNull() {
34 Version v = new Version();
35 v.initFromRevisionInfo(null);
36 assertEquals(Version.JOSM_UNKNOWN_VERSION, v.getVersion());
37 }
38
39 /**
40 * Unit test of {@link Version#initFromRevisionInfo} - local build.
41 */
42 @Test
43 void testInitFromRevisionInfoLocal() {
44 Version v = new Version();
45 v.initFromRevisionInfo(new ByteArrayInputStream(("\n" +
46 "Revision: 11885\n" +
47 "Is-Local-Build: true\n" +
48 "Build-Date: 2017-04-12 02:08:29\n"
49 ).getBytes(StandardCharsets.UTF_8)));
50 assertEquals(11885, v.getVersion());
51 assertEquals("11885", v.getVersionString());
52 assertTrue(v.isLocalBuild());
53 }
54}
Note: See TracBrowser for help on using the repository browser.