Changeset 19651 in josm for trunk/test
- Timestamp:
- 2026-10-22T16:46:16+02:00 (11 days ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
test/unit/org/openstreetmap/josm/data/preferences/JosmUrlsTest.java (modified) (1 diff)
-
test/unit/org/openstreetmap/josm/io/OsmApiTest.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 25 25 target 26 26 failed.png 27 dependency-reduced-pom.xml
-
- Property svn:ignore
-
trunk/test/unit/org/openstreetmap/josm/data/preferences/JosmUrlsTest.java
r18870 r19651 20 20 assertEquals("https://api06.dev.openstreetmap.org/user", Config.getUrls().getBaseUserUrl()); 21 21 } 22 23 /** 24 * An API URL entered with a trailing slash must give the same web site URLs as one without, so that 25 * "History (web)" and the other links to the server are built from the web site and not from the API path. 26 */ 27 @Test 28 void testApiUrlWithTrailingSlash() { 29 Config.getPref().put("osm-server.url", "https://api06.dev.openstreetmap.org/api/"); 30 assertEquals("https://api06.dev.openstreetmap.org", Config.getUrls().getOSMWebsiteDependingOnSelectedApi()); 31 assertEquals("https://api06.dev.openstreetmap.org", Config.getUrls().getBaseBrowseUrl()); 32 assertEquals("https://api06.dev.openstreetmap.org/user", Config.getUrls().getBaseUserUrl()); 33 } 34 35 /** 36 * The default API URL is recognized even when it is entered with a trailing slash, so the links point to 37 * the OSM web site rather than to the API host. 38 */ 39 @Test 40 void testDefaultApiUrlWithTrailingSlash() { 41 Config.getPref().put("osm-server.url", Config.getUrls().getDefaultOsmApiUrl() + '/'); 42 assertEquals(Config.getUrls().getOSMWebsite(), Config.getUrls().getOSMWebsiteDependingOnSelectedApi()); 43 } 22 44 } -
trunk/test/unit/org/openstreetmap/josm/io/OsmApiTest.java
r18853 r19651 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNull; 6 import static org.junit.jupiter.api.Assertions.assertSame; 5 7 6 8 import java.io.ByteArrayInputStream; … … 11 13 import org.openstreetmap.josm.data.osm.User; 12 14 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 15 import org.openstreetmap.josm.spi.preferences.Config; 16 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 13 17 14 18 /** 15 19 * Unit tests of {@link OsmApi} class. 16 20 */ 21 @BasicPreferences 22 @org.openstreetmap.josm.testutils.annotations.OsmApi 17 23 class OsmApiTest { 18 24 /** … … 37 43 assertEquals(User.getAnonymous(), cs2.getUser()); 38 44 } 45 46 /** 47 * Unit test of {@link OsmApi#normalizeApiUrl}: white space and trailing slashes are removed. 48 */ 49 @Test 50 void testNormalizeApiUrl() { 51 assertEquals("https://example.com/api", OsmApi.normalizeApiUrl("https://example.com/api")); 52 assertEquals("https://example.com/api", OsmApi.normalizeApiUrl("https://example.com/api/")); 53 assertEquals("https://example.com/api", OsmApi.normalizeApiUrl("https://example.com/api///")); 54 assertEquals("https://example.com/api", OsmApi.normalizeApiUrl(" https://example.com/api/\t")); 55 assertEquals("https://example.com", OsmApi.normalizeApiUrl("https://example.com/")); 56 assertEquals("", OsmApi.normalizeApiUrl(" ")); 57 assertNull(OsmApi.normalizeApiUrl(null)); 58 // the slashes of the scheme must not be eaten 59 assertEquals("https://", OsmApi.normalizeApiUrl("https://")); 60 } 61 62 /** 63 * A URL which only differs by a trailing slash is the same API, and is stored without the slash. 64 */ 65 @Test 66 void testGetOsmApiIgnoresTrailingSlash() { 67 OsmApi api = OsmApi.getOsmApi("https://example.com/api/"); 68 assertEquals("https://example.com/api", api.getServerUrl()); 69 assertSame(api, OsmApi.getOsmApi("https://example.com/api")); 70 assertSame(api, OsmApi.getOsmApi(" https://example.com/api// ")); 71 } 72 73 /** 74 * An API URL stored with a trailing slash is used without it, so that code comparing it to a known URL or 75 * deriving another URL from it works. Non-regression test for the OAuth and "History (web)" breakage. 76 */ 77 @Test 78 void testTrailingSlashInPreference() { 79 Config.getPref().put("osm-server.url", "https://example.com/api/"); 80 assertEquals("https://example.com/api", OsmApi.getOsmApi().getServerUrl()); 81 assertEquals("https://example.com/api/", OsmApi.getOsmApi().getBaseUrl()); 82 } 39 83 }
Note:
See TracChangeset
for help on using the changeset viewer.
