Changeset 18106 in josm for trunk/test/unit/org/openstreetmap/josm/data/osm/DefaultNameFormatterTest.java
- Timestamp:
- 2021-08-01T21:21:38+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/osm/DefaultNameFormatterTest.java
r17673 r18106 5 5 import static com.github.tomakehurst.wiremock.client.WireMock.get; 6 6 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; 7 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; 8 import static org.junit.Assert.assertEquals; 7 import static org.junit.jupiter.api.Assertions.assertEquals; 9 8 10 9 import java.io.IOException; … … 16 15 import java.util.stream.IntStream; 17 16 18 import org.junit.Rule; 19 import org.junit.Test; 17 import org.junit.jupiter.api.Test; 20 18 import org.openstreetmap.josm.TestUtils; 21 19 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader; … … 23 21 import org.openstreetmap.josm.io.IllegalDataException; 24 22 import org.openstreetmap.josm.io.OsmReader; 25 import org.openstreetmap.josm.testutils.JOSMTestRules; 23 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 24 import org.openstreetmap.josm.testutils.annotations.BasicWiremock; 25 import org.openstreetmap.josm.testutils.annotations.HTTP; 26 26 import org.xml.sax.SAXException; 27 27 28 import com.github.tomakehurst.wiremock. junit.WireMockRule;28 import com.github.tomakehurst.wiremock.WireMockServer; 29 29 30 30 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 33 33 * Unit tests of {@link DefaultNameFormatter} class. 34 34 */ 35 public class DefaultNameFormatterTest { 36 37 /** 38 * Setup test. 39 */ 40 @Rule 41 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 42 public JOSMTestRules test = new JOSMTestRules(); 43 35 // Preferences are needed for OSM primitives 36 @BasicPreferences 37 @BasicWiremock 38 @HTTP 39 class DefaultNameFormatterTest { 44 40 /** 45 41 * HTTP mock. 46 42 */ 47 @ Rule48 publicWireMockRulewireMockRule = new WireMockRule(options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot()));43 @BasicWiremock 44 WireMockServer wireMockServer; 49 45 50 46 /** … … 56 52 @Test 57 53 @SuppressFBWarnings(value = "ITA_INEFFICIENT_TO_ARRAY") 58 publicvoid testTicket9632() throws IllegalDataException, IOException, SAXException {54 void testTicket9632() throws IllegalDataException, IOException, SAXException { 59 55 String source = "presets/Presets_BicycleJunction-preset.xml"; 60 wireMock Rule.stubFor(get(urlEqualTo("/" + source))56 wireMockServer.stubFor(get(urlEqualTo("/" + source)) 61 57 .willReturn(aResponse() 62 58 .withStatus(200) 63 59 .withHeader("Content-Type", "text/xml") 64 60 .withBodyFile(source))); 65 TaggingPresets.addTaggingPresets(TaggingPresetReader.readAll(wireMock Rule.url(source), true));61 TaggingPresets.addTaggingPresets(TaggingPresetReader.readAll(wireMockServer.url(source), true)); 66 62 67 63 Comparator<IRelation<?>> comparator = DefaultNameFormatter.getInstance().getRelationComparator(); … … 102 98 */ 103 99 @Test 104 publicvoid testRelationName() {100 void testRelationName() { 105 101 assertEquals("relation (0, 0 members)", 106 102 getFormattedRelationName("X=Y")); … … 123 119 */ 124 120 @Test 125 publicvoid testWayName() {121 void testWayName() { 126 122 assertEquals("\u200Ebuilding\u200E (0 nodes)\u200C", getFormattedWayName("building=yes")); 127 123 assertEquals("\u200EHouse number 123\u200E (0 nodes)\u200C", … … 145 141 */ 146 142 @Test 147 publicvoid testFormatAsHtmlUnorderedList() {143 void testFormatAsHtmlUnorderedList() { 148 144 assertEquals("<ul><li>incomplete</li></ul>", 149 145 DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(new Node(1))); … … 159 155 */ 160 156 @Test 161 publicvoid testBuildDefaultToolTip() {157 void testBuildDefaultToolTip() { 162 158 assertEquals("<html><strong>id</strong>=0<br>"+ 163 159 "<strong>name:en</strong>=foo<br>"+ … … 173 169 */ 174 170 @Test 175 publicvoid testRemoveBiDiCharacters() {171 void testRemoveBiDiCharacters() { 176 172 assertEquals("building (0 nodes)", DefaultNameFormatter.removeBiDiCharacters("\u200Ebuilding\u200E (0 nodes)\u200C")); 177 173 }
Note:
See TracChangeset
for help on using the changeset viewer.
