Ignore:
Timestamp:
2021-08-01T21:21:38+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #21150 - Add JUnit5 annotation for WireMockServer (patch by taylor.smock)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DefaultNameFormatterTest.java

    r17673 r18106  
    55import static com.github.tomakehurst.wiremock.client.WireMock.get;
    66import 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;
     7import static org.junit.jupiter.api.Assertions.assertEquals;
    98
    109import java.io.IOException;
     
    1615import java.util.stream.IntStream;
    1716
    18 import org.junit.Rule;
    19 import org.junit.Test;
     17import org.junit.jupiter.api.Test;
    2018import org.openstreetmap.josm.TestUtils;
    2119import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;
     
    2321import org.openstreetmap.josm.io.IllegalDataException;
    2422import org.openstreetmap.josm.io.OsmReader;
    25 import org.openstreetmap.josm.testutils.JOSMTestRules;
     23import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     24import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
     25import org.openstreetmap.josm.testutils.annotations.HTTP;
    2626import org.xml.sax.SAXException;
    2727
    28 import com.github.tomakehurst.wiremock.junit.WireMockRule;
     28import com.github.tomakehurst.wiremock.WireMockServer;
    2929
    3030import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    3333 * Unit tests of {@link DefaultNameFormatter} class.
    3434 */
    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
     39class DefaultNameFormatterTest {
    4440    /**
    4541     * HTTP mock.
    4642     */
    47     @Rule
    48     public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot()));
     43    @BasicWiremock
     44    WireMockServer wireMockServer;
    4945
    5046    /**
     
    5652    @Test
    5753    @SuppressFBWarnings(value = "ITA_INEFFICIENT_TO_ARRAY")
    58     public void testTicket9632() throws IllegalDataException, IOException, SAXException {
     54    void testTicket9632() throws IllegalDataException, IOException, SAXException {
    5955        String source = "presets/Presets_BicycleJunction-preset.xml";
    60         wireMockRule.stubFor(get(urlEqualTo("/" + source))
     56        wireMockServer.stubFor(get(urlEqualTo("/" + source))
    6157                .willReturn(aResponse()
    6258                    .withStatus(200)
    6359                    .withHeader("Content-Type", "text/xml")
    6460                    .withBodyFile(source)));
    65         TaggingPresets.addTaggingPresets(TaggingPresetReader.readAll(wireMockRule.url(source), true));
     61        TaggingPresets.addTaggingPresets(TaggingPresetReader.readAll(wireMockServer.url(source), true));
    6662
    6763        Comparator<IRelation<?>> comparator = DefaultNameFormatter.getInstance().getRelationComparator();
     
    10298     */
    10399    @Test
    104     public void testRelationName() {
     100    void testRelationName() {
    105101        assertEquals("relation (0, 0 members)",
    106102                getFormattedRelationName("X=Y"));
     
    123119     */
    124120    @Test
    125     public void testWayName() {
     121    void testWayName() {
    126122        assertEquals("\u200Ebuilding\u200E (0 nodes)\u200C", getFormattedWayName("building=yes"));
    127123        assertEquals("\u200EHouse number 123\u200E (0 nodes)\u200C",
     
    145141     */
    146142    @Test
    147     public void testFormatAsHtmlUnorderedList() {
     143    void testFormatAsHtmlUnorderedList() {
    148144        assertEquals("<ul><li>incomplete</li></ul>",
    149145                DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(new Node(1)));
     
    159155     */
    160156    @Test
    161     public void testBuildDefaultToolTip() {
     157    void testBuildDefaultToolTip() {
    162158        assertEquals("<html><strong>id</strong>=0<br>"+
    163159                           "<strong>name:en</strong>=foo<br>"+
     
    173169     */
    174170    @Test
    175     public void testRemoveBiDiCharacters() {
     171    void testRemoveBiDiCharacters() {
    176172        assertEquals("building (0 nodes)", DefaultNameFormatter.removeBiDiCharacters("\u200Ebuilding\u200E (0 nodes)\u200C"));
    177173    }
Note: See TracChangeset for help on using the changeset viewer.