Ignore:
Timestamp:
2020-10-28T20:41:00+01:00 (5 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/unit/org/openstreetmap/josm/data/validation/routines
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTest.java

    r12620 r17275  
    2222import static org.junit.Assert.assertNull;
    2323import static org.junit.Assert.assertTrue;
    24 import static org.junit.Assert.fail;
     24import static org.junit.jupiter.api.Assertions.fail;
    2525
    2626import java.lang.reflect.Field;
     
    2828import java.util.Locale;
    2929
    30 import org.junit.Before;
    31 import org.junit.Test;
     30import org.junit.jupiter.api.BeforeEach;
     31import org.junit.jupiter.api.Test;
    3232import org.openstreetmap.josm.data.validation.routines.DomainValidator.ArrayType;
    3333import org.openstreetmap.josm.tools.Logging;
     
    3838 * @version $Revision: 1741724 $
    3939 */
    40 public class DomainValidatorTest {
     40class DomainValidatorTest {
    4141
    4242    private DomainValidator validator;
     
    4545     * Setup test.
    4646     */
    47     @Before
     47    @BeforeEach
    4848    public void setUp() {
    4949        validator = DomainValidator.getInstance();
     
    5555     */
    5656    @Test
    57     public void testValidDomains() {
     57    void testValidDomains() {
    5858        assertTrue("apache.org should validate", validator.isValid("apache.org"));
    5959        assertTrue("www.google.com should validate", validator.isValid("www.google.com"));
     
    7575     */
    7676    @Test
    77     public void testInvalidDomains() {
     77    void testInvalidDomains() {
    7878        assertFalse("bare TLD .org shouldn't validate", validator.isValid(".org"));
    7979        assertFalse("domain name with spaces shouldn't validate", validator.isValid(" apache.org "));
     
    9494     */
    9595    @Test
    96     public void testTopLevelDomains() {
     96    void testTopLevelDomains() {
    9797        // infrastructure TLDs
    9898        assertTrue(".arpa should validate as iTLD", validator.isValidInfrastructureTld(".arpa"));
     
    121121     */
    122122    @Test
    123     public void testAllowLocal() {
     123    void testAllowLocal() {
    124124       DomainValidator noLocal = DomainValidator.getInstance(false);
    125125       DomainValidator allowLocal = DomainValidator.getInstance(true);
     
    147147     */
    148148    @Test
    149     public void testIDN() {
     149    void testIDN() {
    150150       assertTrue("b\u00fccher.ch in IDN should validate", validator.isValid("www.xn--bcher-kva.ch"));
    151151    }
     
    155155     */
    156156    @Test
    157     public void testIDNJava6OrLater() {
     157    void testIDNJava6OrLater() {
    158158        String version = System.getProperty("java.version");
    159159        if (version.compareTo("1.6") < 0) {
     
    171171     */
    172172    @Test
    173     public void testRFC2396domainlabel() { // use fixed valid TLD
     173    void testRFC2396domainlabel() { // use fixed valid TLD
    174174        assertTrue("a.ch should validate", validator.isValid("a.ch"));
    175175        assertTrue("9.ch should validate", validator.isValid("9.ch"));
     
    185185     */
    186186    @Test
    187     public void testRFC2396toplabel() {
     187    void testRFC2396toplabel() {
    188188        // These tests use non-existent TLDs so currently need to use a package protected method
    189189        assertTrue("a.c (alpha) should validate", validator.isValidDomainSyntax("a.c"));
     
    203203     */
    204204    @Test
    205     public void testDomainNoDots() {
     205    void testDomainNoDots() {
    206206        assertTrue("a (alpha) should validate", validator.isValidDomainSyntax("a"));
    207207        assertTrue("9 (alphanum) should validate", validator.isValidDomainSyntax("9"));
     
    217217     */
    218218    @Test
    219     public void testValidator297() {
     219    void testValidator297() {
    220220        assertTrue("xn--d1abbgf6aiiy.xn--p1ai should validate", validator.isValid("xn--d1abbgf6aiiy.xn--p1ai")); // This uses a valid TLD
    221221     }
     
    226226     */
    227227    @Test
    228     public void testValidator306() {
     228    void testValidator306() {
    229229        final String longString = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789A";
    230230        assertEquals(63, longString.length()); // 26 * 2 + 11
     
    251251     */
    252252    @Test
    253     public void testUnicodeToASCII() {
     253    void testUnicodeToASCII() {
    254254        String[] asciidots = {
    255255                "",
     
    289289     */
    290290    @Test
    291     public void test_INFRASTRUCTURE_TLDS_sortedAndLowerCase() throws Exception {
     291    void test_INFRASTRUCTURE_TLDS_sortedAndLowerCase() throws Exception {
    292292        final boolean sorted = isSortedLowerCase("INFRASTRUCTURE_TLDS");
    293293        assertTrue(sorted);
     
    299299     */
    300300    @Test
    301     public void test_COUNTRY_CODE_TLDS_sortedAndLowerCase() throws Exception {
     301    void test_COUNTRY_CODE_TLDS_sortedAndLowerCase() throws Exception {
    302302        final boolean sorted = isSortedLowerCase("COUNTRY_CODE_TLDS");
    303303        assertTrue(sorted);
     
    309309     */
    310310    @Test
    311     public void test_GENERIC_TLDS_sortedAndLowerCase() throws Exception {
     311    void test_GENERIC_TLDS_sortedAndLowerCase() throws Exception {
    312312        final boolean sorted = isSortedLowerCase("GENERIC_TLDS");
    313313        assertTrue(sorted);
     
    319319     */
    320320    @Test
    321     public void test_LOCAL_TLDS_sortedAndLowerCase() throws Exception {
     321    void test_LOCAL_TLDS_sortedAndLowerCase() throws Exception {
    322322        final boolean sorted = isSortedLowerCase("LOCAL_TLDS");
    323323        assertTrue(sorted);
     
    328328     */
    329329    @Test
    330     public void testEnumIsPublic() {
     330    void testEnumIsPublic() {
    331331        assertTrue(Modifier.isPublic(DomainValidator.ArrayType.class.getModifiers()));
    332332    }
     
    336336     */
    337337    @Test
    338     public void testUpdateBaseArrays() {
     338    void testUpdateBaseArrays() {
    339339        try {
    340340            DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_RO, new String[]{"com"});
     
    371371     */
    372372    @Test
    373     public void testGetArray() {
     373    void testGetArray() {
    374374        assertNotNull(DomainValidator.getTLDEntries(ArrayType.COUNTRY_CODE_MINUS));
    375375        assertNotNull(DomainValidator.getTLDEntries(ArrayType.COUNTRY_CODE_PLUS));
     
    386386     */
    387387    @Test
    388     public void testUpdateCountryCode() {
     388    void testUpdateCountryCode() {
    389389        assertFalse(validator.isValidCountryCodeTld("com")); // cannot be valid
    390390        DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_PLUS, new String[]{"com"});
     
    404404     */
    405405    @Test
    406     public void testUpdateGeneric() {
     406    void testUpdateGeneric() {
    407407        assertFalse(validator.isValidGenericTld("ch")); // cannot be valid
    408408        DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, new String[]{"ch"});
     
    422422     */
    423423    @Test
    424     public void testCannotUpdate() {
     424    void testCannotUpdate() {
    425425        DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, new String[]{"ch"}); // OK
    426426        DomainValidator dv = DomainValidator.getInstance();
     
    484484     */
    485485    @Test
    486     public void testValidatorName() {
     486    void testValidatorName() {
    487487        assertNull(DomainValidator.getInstance().getValidatorName());
    488488    }
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java

    r16765 r17275  
    4747import java.util.regex.Pattern;
    4848
    49 import org.junit.Rule;
    50 import org.junit.Test;
     49import org.junit.jupiter.api.extension.RegisterExtension;
     50import org.junit.jupiter.api.Test;
    5151import org.openstreetmap.josm.testutils.JOSMTestRules;
    5252import org.openstreetmap.josm.tools.Logging;
     
    5959 * @version $Revision: 1723861 $
    6060 */
    61 public class DomainValidatorTestIT {
     61class DomainValidatorTestIT {
    6262
    6363    /**
    6464     * Setup rule
    6565     */
    66     @Rule
     66    @RegisterExtension
    6767    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    6868    public JOSMTestRules test = new JOSMTestRules().https();
     
    7575     */
    7676    @Test
    77     public void testIanaTldList() throws Exception {
     77    void testIanaTldList() throws Exception {
    7878        // Check the arrays first as this affects later checks
    7979        // Doing this here makes it easier when updating the lists
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/EmailValidatorTest.java

    r10378 r17275  
    2121import static org.junit.Assert.assertTrue;
    2222
    23 import org.junit.Before;
    24 import org.junit.Ignore;
    25 import org.junit.Test;
     23import org.junit.jupiter.api.BeforeEach;
     24import org.junit.jupiter.api.Disabled;
     25import org.junit.jupiter.api.Test;
    2626
    2727/**
     
    3131 * @version $Revision: 1741724 $
    3232 */
    33 public class EmailValidatorTest {
     33class EmailValidatorTest {
    3434
    3535    /**
     
    4949     * Setup
    5050     */
    51     @Before
     51    @BeforeEach
    5252    public void setUp() {
    5353        validator = EmailValidator.getInstance();
     
    5858     */
    5959    @Test
    60     public void testEmail() {
     60    void testEmail() {
    6161        assertTrue(validator.isValid("jsmith@apache.org"));
    6262        assertFalse(validator.isValid(null));
     
    6767     */
    6868    @Test
    69     public void testEmailWithNumericAddress() {
     69    void testEmailWithNumericAddress() {
    7070        assertTrue(validator.isValid("someone@[216.109.118.76]"));
    7171        assertTrue(validator.isValid("someone@yahoo.com"));
     
    7676     */
    7777    @Test
    78     public void testEmailExtension() {
     78    void testEmailExtension() {
    7979        assertTrue(validator.isValid("jsmith@apache.org"));
    8080
     
    9999     */
    100100    @Test
    101     public void testEmailWithDash() {
     101    void testEmailWithDash() {
    102102        assertTrue(validator.isValid("andy.noble@data-workshop.com"));
    103103
     
    114114     */
    115115    @Test
    116     public void testEmailWithDotEnd() {
     116    void testEmailWithDotEnd() {
    117117        assertFalse(validator.isValid("andy.noble@data-workshop.com."));
    118118    }
     
    123123     */
    124124    @Test
    125     public void testEmailWithBogusCharacter() {
     125    void testEmailWithBogusCharacter() {
    126126
    127127        assertFalse(validator.isValid("andy.noble@\u008fdata-workshop.com"));
     
    148148     */
    149149    @Test
    150     public void testVALIDATOR_315() {
     150    void testVALIDATOR_315() {
    151151        assertFalse(validator.isValid("me@at&t.net"));
    152152        assertTrue(validator.isValid("me@att.net")); // Make sure TLD is not the cause of the failure
     
    157157     */
    158158    @Test
    159     public void testVALIDATOR_278() {
     159    void testVALIDATOR_278() {
    160160        assertFalse(validator.isValid("someone@-test.com")); // hostname starts with dash/hyphen
    161161        assertFalse(validator.isValid("someone@test-.com")); // hostname ends with dash/hyphen
     
    166166     */
    167167    @Test
    168     public void testValidator235() {
     168    void testValidator235() {
    169169        String version = System.getProperty("java.version");
    170170        if (version.compareTo("1.6") < 0) {
     
    184184     */
    185185    @Test
    186     public void testEmailWithCommas() {
     186    void testEmailWithCommas() {
    187187        assertFalse(validator.isValid("joeblow@apa,che.org"));
    188188
     
    196196     */
    197197    @Test
    198     public void testEmailWithSpaces() {
     198    void testEmailWithSpaces() {
    199199        assertFalse(validator.isValid("joeblow @apache.org")); // TODO - this should be valid?
    200200
     
    215215     */
    216216    @Test
    217     public void testEmailWithControlChars() {
     217    void testEmailWithControlChars() {
    218218        for (char c = 0; c < 32; c++) {
    219219            assertFalse("Test control char " + ((int) c), validator.isValid("foo" + c + "bar@domain.com"));
     
    227227     */
    228228    @Test
    229     public void testEmailLocalhost() {
     229    void testEmailLocalhost() {
    230230       // Check the default is not to allow
    231231       EmailValidator noLocal = EmailValidator.getInstance(false);
     
    258258     */
    259259    @Test
    260     public void testEmailWithSlashes() {
     260    void testEmailWithSlashes() {
    261261       assertTrue(
    262262             "/ and ! valid in username",
     
    278278     */
    279279    @Test
    280     public void testEmailUserName() {
     280    void testEmailUserName() {
    281281
    282282        assertTrue(validator.isValid("joe1blow@apache.org"));
     
    490490     * The real solution is to fix the email parsing.
    491491     */
    492     @Ignore("This test fails so disable it for 1.1.4 release. The real solution is to fix the email parsing")
    493     @Test
    494     public void testEmailFromPerl() {
     492    @Disabled("This test fails so disable it for 1.1.4 release. The real solution is to fix the email parsing")
     493    @Test
     494    void testEmailFromPerl() {
    495495        for (int index = 0; index < testEmailFromPerl.length; index++) {
    496496            String item = testEmailFromPerl[index].item;
     
    507507     */
    508508    @Test
    509     public void testValidator293() {
     509    void testValidator293() {
    510510        assertTrue(validator.isValid("abc-@abc.com"));
    511511        assertTrue(validator.isValid("abc_@abc.com"));
     
    519519     */
    520520    @Test
    521     public void testValidator365() {
     521    void testValidator365() {
    522522        assertFalse(validator.isValid(
    523523                "Loremipsumdolorsitametconsecteturadipiscingelit.Nullavitaeligulamattisrhoncusnuncegestasmattisleo."+
     
    554554     */
    555555    @Test
    556     public void testEmailAtTLD() {
     556    void testEmailAtTLD() {
    557557        EmailValidator val = EmailValidator.getInstance(false, true);
    558558        assertTrue(val.isValid("test@com"));
     
    563563     */
    564564    @Test
    565     public void testValidator359() {
     565    void testValidator359() {
    566566        EmailValidator val = EmailValidator.getInstance(false, true);
    567567        assertFalse(val.isValid("test@.com"));
     
    572572     */
    573573    @Test
    574     public void testValidator374() {
     574    void testValidator374() {
    575575        assertTrue(validator.isValid("abc@school.school"));
    576576    }
     
    580580     */
    581581    @Test
    582     public void testValidatorName() {
     582    void testValidatorName() {
    583583        assertEquals("Email validator", EmailValidator.getInstance().getValidatorName());
    584584    }
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/InetAddressValidatorTest.java

    r10378 r17275  
    1515 * limitations under the License.
    1616 */
    17 
    1817package org.openstreetmap.josm.data.validation.routines;
    1918
     
    2221import static org.junit.Assert.assertTrue;
    2322
    24 import org.junit.Before;
    25 import org.junit.Test;
     23import org.junit.jupiter.api.BeforeEach;
     24import org.junit.jupiter.api.Test;
    2625
    2726/**
     
    3029 * @version $Revision: 1741724 $
    3130 */
    32 public class InetAddressValidatorTest {
     31class InetAddressValidatorTest {
    3332
    3433    private InetAddressValidator validator;
     
    3736     * Setup
    3837     */
    39     @Before
     38    @BeforeEach
    4039    public void setUp() {
    4140        validator = new InetAddressValidator();
     
    4645     */
    4746    @Test
    48     public void testInetAddressesFromTheWild() {
     47    void testInetAddressesFromTheWild() {
    4948        // CHECKSTYLE.OFF: SingleSpaceSeparator
    5049        assertTrue("www.apache.org IP should be valid",   validator.isValid("140.211.11.130"));
     
    5958     */
    6059    @Test
    61     public void testVALIDATOR_335() {
     60    void testVALIDATOR_335() {
    6261        assertTrue("2001:0438:FFFE:0000:0000:0000:0000:0A35 should be valid",
    6362                validator.isValid("2001:0438:FFFE:0000:0000:0000:0000:0A35"));
     
    6867     */
    6968    @Test
    70     public void testInetAddressesByClass() {
     69    void testInetAddressesByClass() {
    7170        // CHECKSTYLE.OFF: SingleSpaceSeparator
    7271        assertTrue("class A IP should be valid",            validator.isValid("24.25.231.12"));
     
    9190     */
    9291    @Test
    93     public void testReservedInetAddresses() {
     92    void testReservedInetAddresses() {
    9493        assertTrue("localhost IP should be valid", validator.isValid("127.0.0.1"));
    9594        assertTrue("broadcast IP should be valid", validator.isValid("255.255.255.255"));
     
    10099     */
    101100    @Test
    102     public void testBrokenInetAddresses() {
     101    void testBrokenInetAddresses() {
    103102        // CHECKSTYLE.OFF: SingleSpaceSeparator
    104103        assertFalse("IP with characters should be invalid",     validator.isValid("124.14.32.abc"));
     
    119118     */
    120119    @Test
    121     public void testIPv6() {
     120    void testIPv6() {
    122121        // The original Perl script contained a lot of duplicate tests.
    123122        // I removed the duplicates I noticed, but there may be more.
     
    627626     */
    628627    @Test
    629     public void testValidatorName() {
     628    void testValidatorName() {
    630629        assertNull(new InetAddressValidator().getValidatorName());
    631630    }
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/RegexValidatorTest.java

    r12620 r17275  
    2121import static org.junit.Assert.assertNull;
    2222import static org.junit.Assert.assertTrue;
    23 import static org.junit.Assert.fail;
     23import static org.junit.jupiter.api.Assertions.fail;
    2424
    2525import java.util.Arrays;
    2626import java.util.regex.PatternSyntaxException;
    2727
    28 import org.junit.Test;
     28import org.junit.jupiter.api.Test;
    2929import org.openstreetmap.josm.tools.Logging;
    3030
     
    3535 * @since Validator 1.4
    3636 */
    37 public class RegexValidatorTest {
     37class RegexValidatorTest {
    3838
    3939    private static final String REGEX = "^([abc]*)(?:\\-)([DEF]*)(?:\\-)([123]*)$";
     
    5555     */
    5656    @Test
    57     public void testSingle() {
     57    void testSingle() {
    5858        RegexValidator sensitive   = new RegexValidator(REGEX);
    5959        RegexValidator insensitive = new RegexValidator(REGEX, false);
     
    8484     */
    8585    @Test
    86     public void testMultipleSensitive() {
     86    void testMultipleSensitive() {
    8787
    8888        // ------------ Set up Sensitive Validators
     
    126126     */
    127127    @Test
    128     public void testMultipleInsensitive() {
     128    void testMultipleInsensitive() {
    129129
    130130        // ------------ Set up In-sensitive Validators
     
    168168     */
    169169    @Test
    170     public void testNullValue() {
     170    void testNullValue() {
    171171        RegexValidator validator = new RegexValidator(REGEX);
    172172        assertFalse("Instance isValid()", validator.isValid(null));
     
    181181     */
    182182    @Test
    183     public void testMissingRegex() {
     183    void testMissingRegex() {
    184184
    185185        // Single Regular Expression - null
     
    238238     */
    239239    @Test
    240     public void testExceptions() {
     240    void testExceptions() {
    241241        String invalidRegex = "^([abCD12]*$";
    242242        try {
     
    252252     */
    253253    @Test
    254     public void testToString() {
     254    void testToString() {
    255255        RegexValidator single = new RegexValidator(REGEX);
    256256        assertEquals("Single", "RegexValidator{" + REGEX + "}", single.toString());
     
    264264     */
    265265    @Test
    266     public void testValidatorName() {
     266    void testValidatorName() {
    267267        assertNull(new RegexValidator(".*").getValidatorName());
    268268    }
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/UrlValidatorTest.java

    r11621 r17275  
    2121import static org.junit.Assert.assertTrue;
    2222
    23 import org.junit.Before;
    24 import org.junit.Test;
     23import org.junit.jupiter.api.BeforeEach;
     24import org.junit.jupiter.api.Test;
    2525
    2626/**
     
    2929 * @version $Revision: 1741724 $
    3030 */
    31 public class UrlValidatorTest {
     31class UrlValidatorTest {
    3232
    3333   private static final boolean printStatus = false;
     
    3737    * Setup
    3838    */
    39    @Before
     39   @BeforeEach
    4040   public void setUp() {
    4141      for (int index = 0; index < testPartsIndex.length - 1; index++) {
     
    140140     */
    141141    @Test
    142     public void testValidator202() {
     142    void testValidator202() {
    143143        String[] schemes = {"http", "https"};
    144144        UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.NO_FRAGMENTS);
     
    151151     */
    152152    @Test
    153     public void testValidator204() {
     153    void testValidator204() {
    154154        String[] schemes = {"http", "https"};
    155155        UrlValidator urlValidator = new UrlValidator(schemes);
     
    161161     */
    162162    @Test
    163     public void testValidator218() {
     163    void testValidator218() {
    164164        UrlValidator validator = new UrlValidator(UrlValidator.ALLOW_2_SLASHES);
    165165        assertTrue("parentheses should be valid in URLs",
     
    171171     */
    172172    @Test
    173     public void testValidator235() {
     173    void testValidator235() {
    174174        String version = System.getProperty("java.version");
    175175        if (version.compareTo("1.6") < 0) {
     
    190190     */
    191191    @Test
    192     public void testValidator248() {
     192    void testValidator248() {
    193193        RegexValidator regex = new RegexValidator(new String[] {"localhost", ".*\\.my-testing"});
    194194        UrlValidator validator = new UrlValidator(regex, 0);
     
    224224     */
    225225    @Test
    226     public void testValidator288() {
     226    void testValidator288() {
    227227        UrlValidator validator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);
    228228
     
    262262     */
    263263    @Test
    264     public void testValidator276() {
     264    void testValidator276() {
    265265        // file:// isn't allowed by default
    266266        UrlValidator validator = new UrlValidator();
     
    319319     */
    320320    @Test
    321     public void testValidator309() {
     321    void testValidator309() {
    322322        UrlValidator urlValidator = new UrlValidator();
    323323        assertTrue(urlValidator.isValid("http://sample.ondemand.com/"));
     
    334334     */
    335335    @Test
    336     public void testValidator339() {
     336    void testValidator339() {
    337337        UrlValidator urlValidator = new UrlValidator();
    338338        assertTrue(urlValidator.isValid("http://www.cnn.com/WORLD/?hpt=sitenav")); // without
     
    347347     */
    348348    @Test
    349     public void testValidator339IDN() {
     349    void testValidator339IDN() {
    350350        UrlValidator urlValidator = new UrlValidator();
    351351        assertTrue(urlValidator.isValid("http://президент.рф/WORLD/?hpt=sitenav")); // without
     
    360360     */
    361361    @Test
    362     public void testValidator342() {
     362    void testValidator342() {
    363363        UrlValidator urlValidator = new UrlValidator();
    364364        assertTrue(urlValidator.isValid("http://example.rocks/"));
Note: See TracChangeset for help on using the changeset viewer.