Changeset 16834 in josm
- Timestamp:
- 2020-08-03T20:23:44+02:00 (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Tag2Link.java
r16780 r16834 23 23 24 24 import org.openstreetmap.josm.data.osm.OsmUtils; 25 import org.openstreetmap.josm.data.preferences.ListProperty; 26 import org.openstreetmap.josm.io.CachedFile; 25 27 26 28 /** … … 54 56 .collect(Collectors.joining("|")); 55 57 58 static final ListProperty PREF_SOURCE = new ListProperty("tag2link.source", 59 Collections.singletonList("resource://META-INF/resources/webjars/tag2link/2020.7.15/index.json")); 60 56 61 private Tag2Link() { 57 62 // private constructor for utility class … … 77 82 try { 78 83 wikidataRules.clear(); 79 initializeFromResources(); 84 for (String source : PREF_SOURCE.get()) { 85 initializeFromResources(new CachedFile(source)); 86 } 80 87 } catch (Exception e) { 81 88 Logging.error("Failed to initialize tag2link rules"); … … 87 94 * Initializes the tag2link rules from the resources. 88 95 * 96 * @param resource the source 89 97 * @throws IOException in case of I/O error 90 98 */ 91 private static void initializeFromResources() throws IOException { 92 final String resource = "META-INF/resources/webjars/tag2link/2020.7.15/index.json"; 99 private static void initializeFromResources(CachedFile resource) throws IOException { 93 100 final JsonArray rules; 94 try (InputStream inputStream = Tag2Link.class.getClassLoader().getResourceAsStream(resource);101 try (InputStream inputStream = resource.getInputStream(); 95 102 JsonReader jsonReader = Json.createReader(inputStream)) { 96 103 rules = jsonReader.readArray(); -
trunk/test/unit/org/openstreetmap/josm/tools/Tag2LinkTest.java
r16774 r16834 7 7 8 8 import org.junit.Assert; 9 import org.junit.Rule; 9 10 import org.junit.Test; 11 import org.openstreetmap.josm.testutils.JOSMTestRules; 12 13 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 10 14 11 15 /** … … 23 27 Assert.assertEquals(Arrays.asList(expected), links); 24 28 } 29 30 /** 31 * Setup test. 32 */ 33 @Rule 34 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 35 public JOSMTestRules test = new JOSMTestRules().preferences(); 25 36 26 37 /**
Note:
See TracChangeset
for help on using the changeset viewer.