source: josm/trunk/test/unit/org/openstreetmap/josm/io/UrlPatternsTest.java

Last change on this file was 18690, checked in by taylor.smock, 13 months ago

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.

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.junit.jupiter.api.Assertions.assertTrue;
5
6import java.util.Arrays;
7import java.util.List;
8import java.util.regex.Pattern;
9
10import org.junit.jupiter.api.Test;
11import org.openstreetmap.josm.TestUtils;
12
13/**
14 * Unit tests of {@link UrlPatterns}.
15 */
16class UrlPatternsTest {
17
18 private static final List<Class<? extends Enum<?>>> patterns = Arrays.asList(
19 UrlPatterns.GeoJsonUrlPattern.class,
20 UrlPatterns.GpxUrlPattern.class,
21 UrlPatterns.NoteUrlPattern.class,
22 UrlPatterns.OsmChangeUrlPattern.class,
23 UrlPatterns.OsmUrlPattern.class);
24
25 /**
26 * Unit test of {@link UrlPatterns} enums.
27 */
28 @Test
29 void testUrlPatternEnums() {
30 patterns.forEach(TestUtils::superficialEnumCodeCoverage);
31 }
32
33 /**
34 * Unit test of {@link UrlPatterns} syntax validity.
35 */
36 @Test
37 void testUrlPatterns() {
38 assertTrue(patterns.stream().flatMap(c -> Arrays.stream(c.getEnumConstants())).map(t -> ((UrlPattern) t).pattern())
39 .map(Pattern::compile).findAny().isPresent());
40 }
41}
Note: See TracBrowser for help on using the repository browser.