Changeset 11899 in josm


Ignore:
Timestamp:
2017-04-13T22:40:03+02:00 (3 months ago)
Author:
Don-vip
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Version.java

    r11889 r11899  
    178178        int v = getVersion();
    179179        String s = (v == JOSM_UNKNOWN_VERSION) ? "UNKNOWN" : Integer.toString(v);
    180         if (buildName != null) {
     180        if (buildName != null && !buildName.isEmpty()) {
    181181            s += ' ' + buildName;
    182182        }
  • trunk/test/unit/org/openstreetmap/josm/data/VersionTest.java

    r10300 r11899  
    22package org.openstreetmap.josm.data;
    33
     4import static org.junit.Assert.assertEquals;
    45import static org.junit.Assert.assertTrue;
     6
     7import java.io.ByteArrayInputStream;
     8import java.nio.charset.StandardCharsets;
    59
    610import org.junit.BeforeClass;
     
    2731    public void testGetAgentString() {
    2832        String v = Version.getInstance().getAgentString(false);
    29         assertTrue(v.startsWith("JOSM/1.5 ("));
    30         assertTrue(v.endsWith(" en)"));
     33        assertTrue(v, v.matches("JOSM/1\\.5 \\([1-9][0-9]* SVN en\\)"));
    3134        v = Version.getInstance().getAgentString(true);
    32         assertTrue(v.startsWith("JOSM/1.5 ("));
    33         assertTrue(v.contains(" en) "));
     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());
    3462    }
    3563}
Note: See TracChangeset for help on using the changeset viewer.