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


Ignore:
Timestamp:
2023-03-13T21:59:27+01:00 (21 months ago)
Author:
taylor.smock
Message:

See #16567: Convert all assertion calls to JUnit 5 (patch by gaben, modified)

The modifications are as follows:

  • Merge DomainValidatorTest.testIDN and DomainValidatorTest.testIDNJava6OrLater
  • Update some tests to use @ParameterizedTest (DomainValidatorTest)
  • Replace various exception blocks with assertThrows. These typically looked like
        try {
            // Something that should throw an exception here
            fail("An exception should have been thrown");
        } catch (Exception e) {
            // Verify the exception matches expectations here
        }
    
  • Replace assertTrue(val instanceof Clazz) with assertInstanceOf
  • Replace JUnit 4 @Suite with JUnit 5 @Suite

Both the original patch and the modified patch fix various lint issues.

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

Legend:

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

    r17275 r18690  
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    5 import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertNotEquals;
    66import static org.junit.jupiter.api.Assertions.assertNotSame;
    77import static org.junit.jupiter.api.Assertions.assertSame;
     
    1414
    1515import org.apache.commons.lang3.RandomStringUtils;
    16 import org.junit.Before;
     16import org.junit.jupiter.api.BeforeEach;
    1717import org.junit.jupiter.api.Test;
    1818import org.junit.jupiter.api.Timeout;
     
    2929 * @author Michael Zangl
    3030 */
    31 @Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     31@Timeout(value = 15, unit = TimeUnit.MINUTES)
    3232class KeyValuePerformanceTest {
    3333    private static final int PUT_RUNS = 10000;
     
    9696        timer = PerformanceTestUtils.startTimer("str1.equals(str2) = fails (without intern)");
    9797        for (int i = 0; i < STRING_INTERN_TESTS; i++) {
    98             assertFalse(str1.equals(str2));
     98            assertNotEquals(str1, str2);
    9999        }
    100100        timer.done();
     
    116116     * Generate an array of test strings.
    117117     */
    118     @Before
     118    @BeforeEach
    119119    public void generateTestStrings() {
    120120        testStrings.clear();
  • trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRendererPerformanceTestParent.java

    r17615 r18690  
    3131 * Abstract superclass of {@code StyledMapRendererPerformanceTest} and {@code WireframeMapRendererPerformanceTest}.
    3232 */
    33 @Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     33@Timeout(value = 15, unit = TimeUnit.MINUTES)
    3434abstract class AbstractMapRendererPerformanceTestParent {
    3535
     
    7979        try (InputStream fisR = Files.newInputStream(Paths.get("nodist/data/restriction.osm"));
    8080             InputStream fisM = Files.newInputStream(Paths.get("nodist/data/multipolygon.osm"));
    81              InputStream fisO = Compression.getUncompressedFileInputStream(new File("nodist/data/overpass-download.osm.bz2"));) {
     81             InputStream fisO = Compression.getUncompressedFileInputStream(new File("nodist/data/overpass-download.osm.bz2"))) {
    8282            dsRestriction = OsmReader.parseDataSet(fisR, NullProgressMonitor.INSTANCE);
    8383            dsMultipolygon = OsmReader.parseDataSet(fisM, NullProgressMonitor.INSTANCE);
     
    125125    }
    126126
    127     @Test
    128127    /**
    129128     * Complex polygon (Lake Ontario) with small download area.
    130129     */
     130    @Test
    131131    void testOverpassDownload() throws Exception {
    132132        test(20, dsOverpass, new Bounds(43.4510496, -76.536684, 43.4643202, -76.4954853));
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java

    r17615 r18690  
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    57
    68import java.awt.Color;
     
    2123import javax.imageio.ImageIO;
    2224
    23 import org.junit.Assert;
    2425import org.junit.jupiter.api.AfterAll;
    2526import org.junit.jupiter.api.BeforeAll;
     
    125126        List<StyleSource> sources = MapPaintStyles.getStyles().getStyleSources();
    126127        filterStyleIdx = sources.indexOf(filterStyle);
    127         Assert.assertEquals(2, filterStyleIdx);
    128 
    129         Assert.assertEquals(Feature.values().length, filterStyle.settings.size());
     128        assertEquals(2, filterStyleIdx);
     129
     130        assertEquals(Feature.values().length, filterStyle.settings.size());
    130131        for (StyleSetting set : filterStyle.settings) {
    131132            BooleanStyleSetting bset = (BooleanStyleSetting) set;
     
    139140                }
    140141            }
    141             Assert.assertTrue(prefKey, found);
     142            assertTrue(found, prefKey);
    142143        }
    143144
     
    151152            }
    152153        }
    153         Assert.assertNotNull(defaultStyle);
     154        assertNotNull(defaultStyle);
    154155
    155156        for (StyleSetting set : defaultStyle.settings) {
     
    161162            }
    162163        }
    163         Assert.assertNotNull(hideIconsSetting);
     164        assertNotNull(hideIconsSetting);
    164165        hideIconsSetting.setValue(false);
    165166        MapPaintStyleLoader.reloadStyles(defaultStyleIdx);
     
    209210            if (checkScale) {
    210211                int lvl = Selector.GeneralSelector.scale2level(nc.getDist100Pixel());
    211                 Assert.assertEquals(17, lvl);
     212                assertEquals(17, lvl);
    212213            }
    213214
     
    360361
    361362        public void dumpTimes() {
    362             System.out.print(String.format("gen. %4d, sort %4d, draw %4d%n", getGenerateTime(), getSortTime(), getDrawTime()));
     363            System.out.printf("gen. %4d, sort %4d, draw %4d%n", getGenerateTime(), getSortTime(), getDrawTime());
    363364        }
    364365
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSourceFilterTest.java

    r17275 r18690  
    1818 * @author Michael Zangl
    1919 */
    20 @Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     20@Timeout(value = 15, unit = TimeUnit.MINUTES)
    2121class MapCSSStyleSourceFilterTest {
    2222
     
    7171
    7272        private void addRule(String selector) {
    73             sb.append(selector + " {}\n");
     73            sb.append(selector).append(" {}\n");
    7474        }
    7575
  • trunk/test/performance/org/openstreetmap/josm/io/OsmReaderPerformanceTest.java

    r17615 r18690  
    1010import java.io.IOException;
    1111import java.io.InputStream;
     12import java.nio.file.Files;
    1213import java.util.concurrent.TimeUnit;
    1314
     
    2728 * @author Michael Zangl
    2829 */
    29 @Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     30@Timeout(value = 15, unit = TimeUnit.MINUTES)
    3031class OsmReaderPerformanceTest {
    3132    private static final int TIMES = 4;
     
    7374    private InputStream loadFile(boolean decompressBeforeRead) throws IOException {
    7475        File file = new File(PerformanceTestUtils.DATA_FILE);
    75         try (InputStream is = decompressBeforeRead ? Compression.getUncompressedFileInputStream(file) : new FileInputStream(file)) {
     76        try (InputStream is = decompressBeforeRead ? Compression.getUncompressedFileInputStream(file) : Files.newInputStream(file.toPath())) {
    7677            ByteArrayOutputStream temporary = new ByteArrayOutputStream();
    7778            byte[] readBuffer = new byte[4096];
  • trunk/test/performance/org/openstreetmap/josm/io/OsmWriterPerformanceTest.java

    r17848 r18690  
    2020 * For this, we use the neubrandenburg-file, which is a good real world example of an OSM file.
    2121 */
    22 @Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     22@Timeout(value = 15, unit = TimeUnit.MINUTES)
    2323class OsmWriterPerformanceTest {
    2424    private static final int TIMES = 4;
Note: See TracChangeset for help on using the changeset viewer.