Changeset 17275 in josm for trunk/test/performance/org


Ignore:
Timestamp:
2020-10-28T20:41:00+01:00 (4 years ago)
Author:
Don-vip
Message:

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

Location:
trunk/test/performance/org/openstreetmap/josm
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/performance/org/openstreetmap/josm/data/osm/KeyValuePerformanceTest.java

    r16913 r17275  
    22package org.openstreetmap.josm.data.osm;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertNotSame;
    7 import static org.junit.Assert.assertSame;
    8 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNotSame;
     7import static org.junit.jupiter.api.Assertions.assertSame;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99
    1010import java.security.SecureRandom;
    1111import java.util.ArrayList;
    1212import java.util.Random;
     13import java.util.concurrent.TimeUnit;
    1314
    1415import org.apache.commons.lang3.RandomStringUtils;
    1516import org.junit.Before;
    16 import org.junit.Rule;
    17 import org.junit.Test;
    18 import org.junit.rules.Timeout;
     17import org.junit.jupiter.api.Test;
     18import org.junit.jupiter.api.Timeout;
     19import org.junit.jupiter.api.extension.RegisterExtension;
    1920import org.openstreetmap.josm.PerformanceTestUtils;
    2021import org.openstreetmap.josm.PerformanceTestUtils.PerformanceTestTimer;
     
    2829 * @author Michael Zangl
    2930 */
    30 public class KeyValuePerformanceTest {
     31@Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     32class KeyValuePerformanceTest {
    3133    private static final int PUT_RUNS = 10000;
    3234    private static final int GET_RUNS = 100000;
     
    3840
    3941    /**
    40      * Global timeout applied to all test methods.
    41      */
    42     @Rule
    43     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    44     public Timeout globalTimeout = Timeout.seconds(15*60);
    45 
    46     /**
    4742     * Prepare the test.
    4843     */
    49     @Rule
     44    @RegisterExtension
    5045    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    5146    public JOSMTestRules test = new JOSMTestRules().projection();
     
    5651    @Test
    5752    @SuppressFBWarnings(value = "DM_STRING_CTOR", justification = "test Strings that are interned and those that are not")
    58     public void testMeasureStringEqualsIntern() {
     53    void testMeasureStringEqualsIntern() {
    5954        String str1Interned = "string1";
    6055        String str1InternedB = "string1";
     
    134129     */
    135130    @Test
    136     public void testKeyValuePut() {
     131    void testKeyValuePut() {
    137132        for (double tagNodeRatio : TAG_NODE_RATIOS) {
    138133            int nodeCount = (int) (PUT_RUNS / tagNodeRatio);
     
    158153    @Test
    159154    @SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT")
    160     public void testKeyValueGet() {
     155    void testKeyValueGet() {
    161156        for (double tagNodeRatio : TAG_NODE_RATIOS) {
    162157            KeyValueDataGenerator generator = OsmDataGenerator.getKeyValue(tagNodeRatio);
     
    179174     */
    180175    @Test
    181     public void testKeyValueGetKeys() {
     176    void testKeyValueGetKeys() {
    182177        for (double tagNodeRatio : TAG_NODE_RATIOS) {
    183178            KeyValueDataGenerator generator = OsmDataGenerator.getKeyValue(tagNodeRatio);
     
    202197    @Test
    203198    @SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT")
    204     public void testKeyValueGetKeysGet() {
     199    void testKeyValueGetKeysGet() {
    205200        for (double tagNodeRatio : TAG_NODE_RATIOS) {
    206201            KeyValueDataGenerator generator = OsmDataGenerator.getKeyValue(tagNodeRatio);
  • trunk/test/performance/org/openstreetmap/josm/data/osm/RoundingPerformanceTest.java

    r10758 r17275  
    22package org.openstreetmap.josm.data.osm;
    33
    4 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertTrue;
    55
    6 import org.junit.Test;
     6import org.junit.jupiter.api.Test;
    77import org.openstreetmap.josm.data.coor.LatLon;
    88import org.openstreetmap.josm.data.coor.LatLonTest;
     
    1313 * Checks that rounding of coordinates is not too slow.
    1414 */
    15 public class RoundingPerformanceTest {
     15class RoundingPerformanceTest {
    1616
    1717    private static double oldRoundToOsmPrecision(double value) {
     
    2525    @Test
    2626    @SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT")
    27     public void testRounding() {
     27    void testRounding() {
    2828        final int n = 1000000;
    2929        long start = System.nanoTime();
  • trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRendererPerformanceTestParent.java

    r16006 r17275  
    1111import java.nio.file.Files;
    1212import java.nio.file.Paths;
     13import java.util.concurrent.TimeUnit;
    1314
    1415import javax.imageio.ImageIO;
    1516
    16 import org.junit.Rule;
    17 import org.junit.Test;
    18 import org.junit.rules.Timeout;
     17import org.junit.jupiter.api.Test;
     18import org.junit.jupiter.api.Timeout;
    1919import org.openstreetmap.josm.JOSMFixture;
    2020import org.openstreetmap.josm.data.Bounds;
     
    3030 * Abstract superclass of {@code StyledMapRendererPerformanceTest} and {@code WireframeMapRendererPerformanceTest}.
    3131 */
    32 public abstract class AbstractMapRendererPerformanceTestParent {
     32@Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     33abstract class AbstractMapRendererPerformanceTestParent {
    3334
    3435    private static final int IMG_WIDTH = 1400;
     
    4546    private static DataSet dsOverpass;
    4647    private static DataSet dsCity;
    47 
    48     /**
    49      * Global timeout applied to all test methods.
    50      */
    51     @Rule
    52     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    53     public Timeout globalTimeout = Timeout.seconds(15*60);
    5448
    5549    protected static void load() throws Exception {
     
    112106
    113107    @Test
    114     public void testRestriction() throws Exception {
     108    void testRestriction() throws Exception {
    115109        test(700, dsRestriction, new Bounds(51.12, 14.147472381591795, 51.128, 14.162492752075195));
    116110    }
    117111
    118112    @Test
    119     public void testRestrictionSmall() throws Exception {
     113    void testRestrictionSmall() throws Exception {
    120114        test(1500, dsRestriction, new Bounds(51.125, 14.147, 51.128, 14.152));
    121115    }
    122116
    123117    @Test
    124     public void testMultipolygon() throws Exception {
     118    void testMultipolygon() throws Exception {
    125119        test(400, dsMultipolygon, new Bounds(60, -180, 85, -122));
    126120    }
    127121
    128122    @Test
    129     public void testMultipolygonSmall() throws Exception {
     123    void testMultipolygonSmall() throws Exception {
    130124        test(850, dsMultipolygon, new Bounds(-90, -180, 90, 180));
    131125    }
     
    135129     * Complex polygon (Lake Ontario) with small download area.
    136130     */
    137     public void testOverpassDownload() throws Exception {
     131    void testOverpassDownload() throws Exception {
    138132        test(20, dsOverpass, new Bounds(43.4510496, -76.536684, 43.4643202, -76.4954853));
    139133    }
    140134
    141135    @Test
    142     public void testCity() throws Exception {
     136    void testCity() throws Exception {
    143137        test(50, dsCity, new Bounds(53.51, 13.20, 53.59, 13.34));
    144138    }
    145139
    146140    @Test
    147     public void testCitySmall() throws Exception {
     141    void testCitySmall() throws Exception {
    148142        test(70, dsCity, new Bounds(52, 11, 55, 14));
    149143    }
    150144
    151145    @Test
    152     public void testCityPart1() throws Exception {
     146    void testCityPart1() throws Exception {
    153147        test(250, dsCity, new Bounds(53.56, 13.25, 53.57, 13.26));
    154148    }
    155149
    156150    @Test
    157     public void testCityPart2() throws Exception {
     151    void testCityPart2() throws Exception {
    158152        test(200, dsCity, new Bounds(53.55, 13.29, 53.57, 13.30));
    159153    }
    160154
    161155    @Test
    162     public void testCitySmallPart2() throws Exception {
     156    void testCitySmallPart2() throws Exception {
    163157        test(200, dsCity, new Bounds(53.56, 13.295, 53.57, 13.30));
    164158    }
  • trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java

    r10907 r17275  
    77import javax.imageio.ImageIO;
    88
    9 import org.junit.AfterClass;
    10 import org.junit.BeforeClass;
     9import org.junit.jupiter.api.AfterAll;
     10import org.junit.jupiter.api.BeforeAll;
    1111import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
    1212
     
    1616 * Performance test of {@code StyledMapRenderer}.
    1717 */
    18 public class StyledMapRendererPerformanceTest extends AbstractMapRendererPerformanceTestParent {
     18class StyledMapRendererPerformanceTest extends AbstractMapRendererPerformanceTestParent {
    1919
    20     @BeforeClass
     20    @BeforeAll
    2121    public static void load() throws Exception {
    2222        AbstractMapRendererPerformanceTestParent.load();
     
    2525    }
    2626
    27     @AfterClass
     27    @AfterAll
    2828    public static void clean() throws Exception {
    2929        AbstractMapRendererPerformanceTestParent.clean();
  • trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRendererPerformanceTest.java

    r10907 r17275  
    22package org.openstreetmap.josm.data.osm.visitor.paint;
    33
    4 import org.junit.AfterClass;
    5 import org.junit.BeforeClass;
     4import org.junit.jupiter.api.AfterAll;
     5import org.junit.jupiter.api.BeforeAll;
    66
    77/**
    88 * Performance test of {@code WireframeMapRenderer}.
    99 */
    10 public class WireframeMapRendererPerformanceTest extends AbstractMapRendererPerformanceTestParent {
     10class WireframeMapRendererPerformanceTest extends AbstractMapRendererPerformanceTestParent {
    1111
    12     @BeforeClass
     12    @BeforeAll
    1313    public static void load() throws Exception {
    1414        AbstractMapRendererPerformanceTestParent.load();
    1515    }
    1616
    17     @AfterClass
     17    @AfterAll
    1818    public static void clean() throws Exception {
    1919        AbstractMapRendererPerformanceTestParent.clean();
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java

    r16822 r17275  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint;
     3
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    35
    46import java.awt.Color;
     
    2022import javax.imageio.ImageIO;
    2123
    22 import org.junit.AfterClass;
    2324import org.junit.Assert;
    24 import org.junit.BeforeClass;
    25 import org.junit.Rule;
    26 import org.junit.Test;
     25import org.junit.jupiter.api.AfterAll;
     26import org.junit.jupiter.api.BeforeAll;
     27import org.junit.jupiter.api.Test;
     28import org.junit.jupiter.api.extension.RegisterExtension;
    2729import org.openstreetmap.josm.JOSMFixture;
    2830import org.openstreetmap.josm.PerformanceTestUtils;
     
    4951import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    5052
    51 import static org.junit.Assert.assertEquals;
    52 
    5353/**
    5454 * Performance test of map renderer.
     
    8787     * Setup tests
    8888     */
    89     @Rule
     89    @RegisterExtension
    9090    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    9191    public JOSMTestRules josmTestRules = new JOSMTestRules().main().projection().preferences().timeout(15 * 60 * 1000);
     
    9595     * @throws Exception if any error occurs
    9696     */
    97     @BeforeClass
     97    @BeforeAll
    9898    public static void load() throws Exception {
    9999        JOSMFixture.createPerformanceTestFixture().init(true);
     
    179179     * Cleanup test environment.
    180180     */
    181     @AfterClass
     181    @AfterAll
    182182    public static void cleanUp() {
    183183        setFilterStyleActive(false);
     
    283283     */
    284284    @Test
    285     public void testPerformanceGenerate() throws IOException {
     285    void testPerformanceGenerate() throws IOException {
    286286        setFilterStyleActive(false);
    287287        PerformanceTester test = new PerformanceTester();
     
    322322     */
    323323    @Test
    324     public void testPerformanceDrawFeatures() throws IOException {
     324    void testPerformanceDrawFeatures() throws IOException {
    325325        testDrawFeature(null);
    326326        for (Feature f : Feature.values()) {
     
    352352    }
    353353
    354     public static class BenchmarkData extends CapturingBenchmark {
     354    static class BenchmarkData extends CapturingBenchmark {
    355355
    356356        private List<StyleRecord> allStyleElems;
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSConditionPerformanceTest.java

    r10837 r17275  
    44import java.util.EnumSet;
    55
    6 import org.junit.Test;
     6import org.junit.jupiter.api.Test;
    77import org.openstreetmap.josm.PerformanceTestUtils;
    88import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.Op;
     
    1212 * @author Michael Zangl
    1313 */
    14 public class MapCSSConditionPerformanceTest {
     14class MapCSSConditionPerformanceTest {
    1515    /**
    1616     * Test the performance of all OP entries.
    1717     */
    1818    @Test
    19     public void testAllOps() {
     19    void testAllOps() {
    2020        // The JIT does some really heavy optimisations if it notices that other values are not used.
    2121        // If we want to simulate a real scenario, we need to invoke every op several times to let the compiler
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.java

    r16006 r17275  
    22package org.openstreetmap.josm.gui.mappaint.mapcss;
    33
    4 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.fail;
    55
    66import java.awt.Graphics2D;
     
    1010import java.util.Collection;
    1111
    12 import org.junit.BeforeClass;
    13 import org.junit.Test;
     12import org.junit.jupiter.api.Test;
     13import org.junit.jupiter.api.BeforeAll;
    1414import org.openstreetmap.josm.JOSMFixture;
    1515import org.openstreetmap.josm.data.Bounds;
     
    2929 *
    3030 */
    31 public class MapCSSPerformanceTest {
     31class MapCSSPerformanceTest {
    3232
    3333    /* ------------------------ configuration section  ---------------------------- */
     
    5656     * Setup test.
    5757     */
    58     @BeforeClass
     58    @BeforeAll
    5959    public static void createJOSMFixture() {
    6060        JOSMFixture.createPerformanceTestFixture().init(true);
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSourceFilterTest.java

    r16913 r17275  
    22package org.openstreetmap.josm.gui.mappaint.mapcss;
    33
    4 import org.junit.BeforeClass;
    5 import org.junit.Rule;
    6 import org.junit.Test;
    7 import org.junit.rules.Timeout;
     4import java.util.concurrent.TimeUnit;
     5
     6import org.junit.jupiter.api.BeforeAll;
     7import org.junit.jupiter.api.Test;
     8import org.junit.jupiter.api.Timeout;
    89import org.openstreetmap.josm.JOSMFixture;
    910import org.openstreetmap.josm.PerformanceTestUtils;
     
    1314import org.openstreetmap.josm.gui.mappaint.MultiCascade;
    1415
    15 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    16 
    1716/**
    1817 * Tests how fast {@link MapCSSStyleSource} finds the right style candidates for one object.
    1918 * @author Michael Zangl
    2019 */
    21 public class MapCSSStyleSourceFilterTest {
     20@Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     21class MapCSSStyleSourceFilterTest {
    2222
    2323    private static final int TEST_RULE_COUNT = 10000;
     
    8282
    8383    /**
    84      * Global timeout applied to all test methods.
    85      */
    86     @Rule
    87     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    88     public Timeout globalTimeout = Timeout.seconds(15*60);
    89 
    90     /**
    9184     * Prepare the test.
    9285     */
    93     @BeforeClass
     86    @BeforeAll
    9487    public static void createJOSMFixture() {
    9588        JOSMFixture.createPerformanceTestFixture().init(true);
     
    10093     */
    10194    @Test
    102     public void testKeyValueRules() {
     95    void testKeyValueRules() {
    10396        KeyValueDataGenerator data = OsmDataGenerator.getKeyValue();
    10497        data.generateDataSet();
     
    111104     */
    112105    @Test
    113     public void testKeyOnlyRules() {
     106    void testKeyOnlyRules() {
    114107        KeyValueDataGenerator data = OsmDataGenerator.getKeyValue();
    115108        data.generateDataSet();
     
    122115     */
    123116    @Test
    124     public void testRegularExpressionRules() {
     117    void testRegularExpressionRules() {
    125118        KeyValueDataGenerator data = OsmDataGenerator.getKeyValue();
    126119        data.generateDataSet();
     
    133126     */
    134127    @Test
    135     public void testIsTrueRules() {
     128    void testIsTrueRules() {
    136129        KeyValueDataGenerator data = OsmDataGenerator.getKeyValue();
    137130        data.generateDataSet();
  • trunk/test/performance/org/openstreetmap/josm/io/OsmReaderPerformanceTest.java

    r16913 r17275  
    22package org.openstreetmap.josm.io;
    33
    4 import static org.junit.Assert.assertNotNull;
     4import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    66import java.io.ByteArrayInputStream;
     
    1010import java.io.IOException;
    1111import java.io.InputStream;
     12import java.util.concurrent.TimeUnit;
    1213
    13 import org.junit.BeforeClass;
    14 import org.junit.Rule;
    15 import org.junit.Test;
    16 import org.junit.rules.Timeout;
     14import org.junit.jupiter.api.BeforeAll;
     15import org.junit.jupiter.api.Test;
     16import org.junit.jupiter.api.Timeout;
    1717import org.openstreetmap.josm.JOSMFixture;
    1818import org.openstreetmap.josm.PerformanceTestUtils;
    1919import org.openstreetmap.josm.PerformanceTestUtils.PerformanceTestTimer;
    2020import org.openstreetmap.josm.data.osm.DataSet;
    21 
    22 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2321
    2422/**
     
    2927 * @author Michael Zangl
    3028 */
    31 public class OsmReaderPerformanceTest {
     29@Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     30class OsmReaderPerformanceTest {
    3231    private static final int TIMES = 4;
    3332    private static final String DATA_FILE = "nodist/data/neubrandenburg.osm.bz2";
    3433
    3534    /**
    36      * Global timeout applied to all test methods.
    37      */
    38     @Rule
    39     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public Timeout globalTimeout = Timeout.seconds(15*60);
    41 
    42     /**
    4335     * Prepare the test.
    4436     */
    45     @BeforeClass
     37    @BeforeAll
    4638    public static void createJOSMFixture() {
    4739        JOSMFixture.createPerformanceTestFixture().init(true);
     
    5345     */
    5446    @Test
    55     public void testCompressed() throws Exception {
     47    void testCompressed() throws Exception {
    5648        runTest("compressed (.osm.bz2)", false);
    5749    }
     
    6254     */
    6355    @Test
    64     public void testPlain() throws Exception {
     56    void testPlain() throws Exception {
    6557        runTest(".osm-file", true);
    6658    }
Note: See TracChangeset for help on using the changeset viewer.