diff --git a/src/main/java/org/wikipedia/WikipediaApp.java b/src/main/java/org/wikipedia/WikipediaApp.java
index c7512a83..0f2b82cc 100644
--- a/src/main/java/org/wikipedia/WikipediaApp.java
+++ b/src/main/java/org/wikipedia/WikipediaApp.java
@@ -54,6 +54,9 @@
public final class WikipediaApp {
+ /** The base URL for WIWOSM **/
+ public static final String WIWOSM_APP = "https://wiwosm.toolforge.org";
+
private static final XPath X_PATH = XPath.getInstance();
private static final String STRING_URI_PIPE = Utils.encodeUrl("|");
@@ -222,7 +225,7 @@ public void updateWIWOSMStatus(List entries) {
}
Map status = new HashMap<>();
if (!entries.isEmpty()) {
- final String url = "https://wiwosm.toolforge.org/osmjson/getGeoJSON.php?action=check&lang=" + wikipediaLang;
+ final String url = WIWOSM_APP + "/osmjson/getGeoJSON.php?action=check&lang=" + wikipediaLang;
try {
final String articles = entries.stream().map(i -> i.article).collect(Collectors.joining(","));
final String requestBody = "articles=" + Utils.encodeUrl(articles);
diff --git a/test/unit/org/wikipedia/WikipediaAppTest.java b/test/unit/org/wikipedia/WikipediaAppTest.java
index 2e4326fc..708b19f6 100644
--- a/test/unit/org/wikipedia/WikipediaAppTest.java
+++ b/test/unit/org/wikipedia/WikipediaAppTest.java
@@ -9,6 +9,9 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -21,14 +24,36 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.condition.DisabledIf;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.testutils.annotations.I18n;
+import org.openstreetmap.josm.tools.HttpClient;
+import org.openstreetmap.josm.tools.Logging;
import org.wikipedia.data.WikidataEntry;
import org.wikipedia.data.WikipediaEntry;
@Timeout(20)
@I18n
class WikipediaAppTest {
+ private static Boolean wiwosmup;
+
+ static synchronized boolean isWiwosmDown() throws MalformedURLException {
+ if (wiwosmup == null) {
+ final HttpClient client = HttpClient.create(URI.create(WikipediaApp.WIWOSM_APP).toURL());
+ try {
+ final HttpClient.Response response = client.connect();
+ // We only care if there are server error responses, as far as whether the server is up.
+ wiwosmup = (response.getResponseCode() < 500);
+ } catch (IOException e) {
+ Logging.trace(e);
+ wiwosmup = false;
+ } finally {
+ client.disconnect();
+ }
+ }
+ return !wiwosmup;
+ }
+
@Test
void testMediawikiLocale() {
assertThat(WikipediaApp.getMediawikiLocale(Locale.GERMANY), is("de-de"));
@@ -154,6 +179,7 @@ void testGetLabelForWikidataInvalidId() {
assertThrows(RuntimeException.class, () -> WikipediaApp.getLabelForWikidata("Qxyz", Locale.ENGLISH));
}
+ @DisabledIf(value = "isWiwosmDown", disabledReason = "The WIWOSM server is down")
@Test
void testWIWOSMStatus() {
final WikipediaEntry entry1 = new WikipediaEntry("en", "Vienna");