Changeset 17332 in josm
- Timestamp:
- 2020-11-23T16:01:19+01:00 (4 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/SyncEditorLayerIndex.java
r17329 r17332 541 541 // catch reordered arguments and switches to WMS version 1.3.0 542 542 String unifyWMS(String url) { 543 String x[]= url.replaceAll("(?i)VERSION=[0-9.]+", "VERSION=x").replaceAll("(?i)SRS=", "CRS=").split("\\?");544 String a[]= x[1].split("&");543 String[] x = url.replaceAll("(?i)VERSION=[0-9.]+", "VERSION=x").replaceAll("(?i)SRS=", "CRS=").split("\\?"); 544 String[] a = x[1].split("&"); 545 545 Arrays.sort(a); 546 url = x[0]+"?"+String.join("&", a);546 url = x[0]+"?"+String.join("&", a); 547 547 return url; 548 548 } … … 579 579 580 580 if (ide.equals(idj) && Objects.equals(getType(j), getType(e))) { 581 if (getType(j).equals("wms") && unifyWMS(urle).equals(unifyWMS(urlj))) {581 if (getType(j).equals("wms") && unifyWMS(urle).equals(unifyWMS(urlj))) { 582 582 myprintln("# WMS-URL for id "+idj+" modified: "+getDescription(j)); 583 583 } else { … … 591 591 break; 592 592 } 593 Collection<String> old = ((ImageryInfo)j).getOldIds();594 if (old != null) {593 Collection<String> old = j.getOldIds(); 594 if (old != null) { 595 595 for (String oidj : old) { 596 596 if (ide.equals(oidj) && Objects.equals(getType(j), getType(e))) { 597 if (getType(j).equals("wms") && unifyWMS(urle).equals(unifyWMS(urlj))) {597 if (getType(j).equals("wms") && unifyWMS(urle).equals(unifyWMS(urlj))) { 598 598 myprintln("# WMS-URL for oldid "+idj+" modified: "+getDescription(j)); 599 599 } else { -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java
r17330 r17332 124 124 // multiple error object? prepare a HTML list 125 125 // 126 if (!errors.isEmpty() && !GraphicsEnvironment.isHeadless()) { 126 final Collection<String> items = task.getErrorMessages(); 127 if (!items.isEmpty() && !GraphicsEnvironment.isHeadless()) { 127 128 SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog( 128 129 MainApplication.getMainFrame(), 129 "<html>"+Utils.joinAsHtmlUnorderedList( task.getErrorMessages())+"</html>",130 "<html>"+Utils.joinAsHtmlUnorderedList(items)+"</html>", 130 131 tr("Errors during download"), 131 132 JOptionPane.ERROR_MESSAGE)); -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r17283 r17332 765 765 OsmPrimitive result = getPrimitiveById(primitiveId); 766 766 if (result == null && primitiveId != null) { 767 Logging. warn(tr(767 Logging.error(new IllegalStateException(tr( 768 768 "JOSM expected to find primitive [{0} {1}] in dataset but it is not there. Please report this " 769 769 + "at {2}. This is not a critical error, it should be safe to continue in your work.", 770 primitiveId.getType(), Long.toString(primitiveId.getUniqueId()), Config.getUrls().getJOSMWebsite())); 771 Logging.error(new Exception()); 770 primitiveId.getType(), Long.toString(primitiveId.getUniqueId()), Config.getUrls().getJOSMWebsite()))); 772 771 } 773 772 -
trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesWithReferrersTask.java
r16611 r17332 234 234 } 235 235 List<PrimitiveId> downloaded = new ArrayList<>(ids); 236 downloaded.removeAll(missingPrimitives); 236 if (missingPrimitives != null) { 237 downloaded.removeAll(missingPrimitives); 238 } 237 239 return downloaded; 238 240 } -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r17314 r17332 171 171 172 172 gc.anchor = GridBagConstraints.NORTHWEST; 173 gc.fill = GridBagConstraints.HORIZONTAL;173 gc.fill = HORIZONTAL; 174 174 gc.weightx = 0.0; 175 175 gc.insets = new Insets(0, 0, 0, 3); -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandler.java
r17330 r17332 6 6 import java.util.LinkedList; 7 7 import java.util.List; 8 import java.util.concurrent.ExecutionException; 9 import java.util.concurrent.TimeUnit; 10 import java.util.concurrent.TimeoutException; 8 11 import java.util.stream.Collectors; 9 12 … … 67 70 final DownloadPrimitivesWithReferrersTask task = new DownloadPrimitivesWithReferrersTask( 68 71 newLayer, ps, referrers, relationMembers, args.get("layer_name"), null); 69 MainApplication.worker.submit(task); 72 try { 73 MainApplication.worker.submit(task).get(OSM_DOWNLOAD_TIMEOUT.get(), TimeUnit.SECONDS); 74 } catch (InterruptedException | ExecutionException | TimeoutException e) { 75 Logging.error(e); 76 } 70 77 MainApplication.worker.submit(() -> { 71 78 final List<PrimitiveId> downloaded = task.getDownloadedId(); -
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r17275 r17332 480 480 481 481 /** 482 * Return WireMock server serving files under ticke rdirectory482 * Return WireMock server serving files under ticket directory 483 483 * @param ticketId Ticket numeric identifier 484 484 * @return WireMock HTTP server on dynamic port … … 493 493 494 494 /** 495 * Return WireMock server serving files under ticker directory495 * Return WireMock server 496 496 * @return WireMock HTTP server on dynamic port 497 497 */ … … 499 499 return new WireMockServer( 500 500 WireMockConfiguration.options() 501 .withRootDirectory("test/data") 501 502 .dynamicPort() 502 503 ); -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandlerTest.java
r17275 r17332 2 2 package org.openstreetmap.josm.io.remotecontrol.handler; 3 3 4 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; 5 import static com.github.tomakehurst.wiremock.client.WireMock.get; 6 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; 4 7 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 5 8 import static org.junit.jupiter.api.Assertions.assertEquals; 6 9 import static org.junit.jupiter.api.Assertions.assertThrows; 7 10 11 import org.junit.jupiter.api.Test; 8 12 import org.junit.jupiter.api.extension.RegisterExtension; 9 import org. junit.jupiter.api.Test;13 import org.openstreetmap.josm.TestUtils; 10 14 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException; 15 import org.openstreetmap.josm.spi.preferences.Config; 11 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 18 import com.github.tomakehurst.wiremock.WireMockServer; 12 19 13 20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 36 43 @Test 37 44 void testBadRequestNoParam() { 38 assertDoesNotThrow(() -> newHandler(null).handle()); 45 Exception e = assertThrows(RequestHandlerBadRequestException.class, () -> newHandler(null).handle()); 46 assertEquals("No valid object identifier has been provided", e.getMessage()); 39 47 } 40 48 … … 62 70 @Test 63 71 void testNominalRequest() { 64 assertDoesNotThrow(() -> newHandler("https://localhost?objects=foo,bar").handle()); 72 WireMockServer wiremock = TestUtils.getWireMockServer(); 73 wiremock.addStubMapping(get(urlEqualTo("/capabilities")).willReturn(aResponse().withStatusMessage("OK") 74 .withBodyFile("api/capabilities")).build()); 75 String w1 = "<way id=\"1\" version=\"1\"><nd ref=\"1\"/><nd ref=\"2\"/></way>"; 76 String n1 = "<node id=\"1\" version=\"1\"/>"; 77 String n2 = "<node id=\"2\" version=\"1\"/>"; 78 wiremock.addStubMapping(get(urlEqualTo("/0.6/ways?ways=1")).willReturn(aResponse().withStatusMessage("OK") 79 .withBody(osm(w1))).build()); 80 wiremock.addStubMapping(get(urlEqualTo("/0.6/nodes?nodes=1,2")).willReturn(aResponse().withStatusMessage("OK") 81 .withBody(osm(n1 + n2))).build()); 82 wiremock.addStubMapping(get(urlEqualTo("/0.6/way/1/full")).willReturn(aResponse().withStatusMessage("OK") 83 .withBody(osm(n1 + n2 + w1))).build()); 84 wiremock.start(); 85 Config.getPref().put("osm-server.url", wiremock.baseUrl()); 86 try { 87 assertDoesNotThrow(() -> newHandler("https://localhost?objects=n1,w1").handle()); 88 } finally { 89 wiremock.stop(); 90 } 91 } 92 93 private static String osm(String xml) { 94 return "<osm version=\"0.6\">" + xml + "</osm>"; 65 95 } 66 96 }
Note:
See TracChangeset
for help on using the changeset viewer.