Changeset 17275 in josm for trunk/test/unit/org/openstreetmap/josm/data/validation/routines
- Timestamp:
- 2020-10-28T20:41:00+01:00 (5 years ago)
- 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 22 22 import static org.junit.Assert.assertNull; 23 23 import static org.junit.Assert.assertTrue; 24 import static org.junit. Assert.fail;24 import static org.junit.jupiter.api.Assertions.fail; 25 25 26 26 import java.lang.reflect.Field; … … 28 28 import java.util.Locale; 29 29 30 import org.junit. Before;31 import org.junit.Test; 30 import org.junit.jupiter.api.BeforeEach; 31 import org.junit.jupiter.api.Test; 32 32 import org.openstreetmap.josm.data.validation.routines.DomainValidator.ArrayType; 33 33 import org.openstreetmap.josm.tools.Logging; … … 38 38 * @version $Revision: 1741724 $ 39 39 */ 40 publicclass DomainValidatorTest {40 class DomainValidatorTest { 41 41 42 42 private DomainValidator validator; … … 45 45 * Setup test. 46 46 */ 47 @Before 47 @BeforeEach 48 48 public void setUp() { 49 49 validator = DomainValidator.getInstance(); … … 55 55 */ 56 56 @Test 57 publicvoid testValidDomains() {57 void testValidDomains() { 58 58 assertTrue("apache.org should validate", validator.isValid("apache.org")); 59 59 assertTrue("www.google.com should validate", validator.isValid("www.google.com")); … … 75 75 */ 76 76 @Test 77 publicvoid testInvalidDomains() {77 void testInvalidDomains() { 78 78 assertFalse("bare TLD .org shouldn't validate", validator.isValid(".org")); 79 79 assertFalse("domain name with spaces shouldn't validate", validator.isValid(" apache.org ")); … … 94 94 */ 95 95 @Test 96 publicvoid testTopLevelDomains() {96 void testTopLevelDomains() { 97 97 // infrastructure TLDs 98 98 assertTrue(".arpa should validate as iTLD", validator.isValidInfrastructureTld(".arpa")); … … 121 121 */ 122 122 @Test 123 publicvoid testAllowLocal() {123 void testAllowLocal() { 124 124 DomainValidator noLocal = DomainValidator.getInstance(false); 125 125 DomainValidator allowLocal = DomainValidator.getInstance(true); … … 147 147 */ 148 148 @Test 149 publicvoid testIDN() {149 void testIDN() { 150 150 assertTrue("b\u00fccher.ch in IDN should validate", validator.isValid("www.xn--bcher-kva.ch")); 151 151 } … … 155 155 */ 156 156 @Test 157 publicvoid testIDNJava6OrLater() {157 void testIDNJava6OrLater() { 158 158 String version = System.getProperty("java.version"); 159 159 if (version.compareTo("1.6") < 0) { … … 171 171 */ 172 172 @Test 173 publicvoid testRFC2396domainlabel() { // use fixed valid TLD173 void testRFC2396domainlabel() { // use fixed valid TLD 174 174 assertTrue("a.ch should validate", validator.isValid("a.ch")); 175 175 assertTrue("9.ch should validate", validator.isValid("9.ch")); … … 185 185 */ 186 186 @Test 187 publicvoid testRFC2396toplabel() {187 void testRFC2396toplabel() { 188 188 // These tests use non-existent TLDs so currently need to use a package protected method 189 189 assertTrue("a.c (alpha) should validate", validator.isValidDomainSyntax("a.c")); … … 203 203 */ 204 204 @Test 205 publicvoid testDomainNoDots() {205 void testDomainNoDots() { 206 206 assertTrue("a (alpha) should validate", validator.isValidDomainSyntax("a")); 207 207 assertTrue("9 (alphanum) should validate", validator.isValidDomainSyntax("9")); … … 217 217 */ 218 218 @Test 219 publicvoid testValidator297() {219 void testValidator297() { 220 220 assertTrue("xn--d1abbgf6aiiy.xn--p1ai should validate", validator.isValid("xn--d1abbgf6aiiy.xn--p1ai")); // This uses a valid TLD 221 221 } … … 226 226 */ 227 227 @Test 228 publicvoid testValidator306() {228 void testValidator306() { 229 229 final String longString = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789A"; 230 230 assertEquals(63, longString.length()); // 26 * 2 + 11 … … 251 251 */ 252 252 @Test 253 publicvoid testUnicodeToASCII() {253 void testUnicodeToASCII() { 254 254 String[] asciidots = { 255 255 "", … … 289 289 */ 290 290 @Test 291 publicvoid test_INFRASTRUCTURE_TLDS_sortedAndLowerCase() throws Exception {291 void test_INFRASTRUCTURE_TLDS_sortedAndLowerCase() throws Exception { 292 292 final boolean sorted = isSortedLowerCase("INFRASTRUCTURE_TLDS"); 293 293 assertTrue(sorted); … … 299 299 */ 300 300 @Test 301 publicvoid test_COUNTRY_CODE_TLDS_sortedAndLowerCase() throws Exception {301 void test_COUNTRY_CODE_TLDS_sortedAndLowerCase() throws Exception { 302 302 final boolean sorted = isSortedLowerCase("COUNTRY_CODE_TLDS"); 303 303 assertTrue(sorted); … … 309 309 */ 310 310 @Test 311 publicvoid test_GENERIC_TLDS_sortedAndLowerCase() throws Exception {311 void test_GENERIC_TLDS_sortedAndLowerCase() throws Exception { 312 312 final boolean sorted = isSortedLowerCase("GENERIC_TLDS"); 313 313 assertTrue(sorted); … … 319 319 */ 320 320 @Test 321 publicvoid test_LOCAL_TLDS_sortedAndLowerCase() throws Exception {321 void test_LOCAL_TLDS_sortedAndLowerCase() throws Exception { 322 322 final boolean sorted = isSortedLowerCase("LOCAL_TLDS"); 323 323 assertTrue(sorted); … … 328 328 */ 329 329 @Test 330 publicvoid testEnumIsPublic() {330 void testEnumIsPublic() { 331 331 assertTrue(Modifier.isPublic(DomainValidator.ArrayType.class.getModifiers())); 332 332 } … … 336 336 */ 337 337 @Test 338 publicvoid testUpdateBaseArrays() {338 void testUpdateBaseArrays() { 339 339 try { 340 340 DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_RO, new String[]{"com"}); … … 371 371 */ 372 372 @Test 373 publicvoid testGetArray() {373 void testGetArray() { 374 374 assertNotNull(DomainValidator.getTLDEntries(ArrayType.COUNTRY_CODE_MINUS)); 375 375 assertNotNull(DomainValidator.getTLDEntries(ArrayType.COUNTRY_CODE_PLUS)); … … 386 386 */ 387 387 @Test 388 publicvoid testUpdateCountryCode() {388 void testUpdateCountryCode() { 389 389 assertFalse(validator.isValidCountryCodeTld("com")); // cannot be valid 390 390 DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_PLUS, new String[]{"com"}); … … 404 404 */ 405 405 @Test 406 publicvoid testUpdateGeneric() {406 void testUpdateGeneric() { 407 407 assertFalse(validator.isValidGenericTld("ch")); // cannot be valid 408 408 DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, new String[]{"ch"}); … … 422 422 */ 423 423 @Test 424 publicvoid testCannotUpdate() {424 void testCannotUpdate() { 425 425 DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, new String[]{"ch"}); // OK 426 426 DomainValidator dv = DomainValidator.getInstance(); … … 484 484 */ 485 485 @Test 486 publicvoid testValidatorName() {486 void testValidatorName() { 487 487 assertNull(DomainValidator.getInstance().getValidatorName()); 488 488 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java
r16765 r17275 47 47 import java.util.regex.Pattern; 48 48 49 import org.junit. Rule;50 import org.junit.Test; 49 import org.junit.jupiter.api.extension.RegisterExtension; 50 import org.junit.jupiter.api.Test; 51 51 import org.openstreetmap.josm.testutils.JOSMTestRules; 52 52 import org.openstreetmap.josm.tools.Logging; … … 59 59 * @version $Revision: 1723861 $ 60 60 */ 61 publicclass DomainValidatorTestIT {61 class DomainValidatorTestIT { 62 62 63 63 /** 64 64 * Setup rule 65 65 */ 66 @R ule66 @RegisterExtension 67 67 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 68 68 public JOSMTestRules test = new JOSMTestRules().https(); … … 75 75 */ 76 76 @Test 77 publicvoid testIanaTldList() throws Exception {77 void testIanaTldList() throws Exception { 78 78 // Check the arrays first as this affects later checks 79 79 // Doing this here makes it easier when updating the lists -
trunk/test/unit/org/openstreetmap/josm/data/validation/routines/EmailValidatorTest.java
r10378 r17275 21 21 import static org.junit.Assert.assertTrue; 22 22 23 import org.junit. Before;24 import org.junit. Ignore;25 import org.junit.Test; 23 import org.junit.jupiter.api.BeforeEach; 24 import org.junit.jupiter.api.Disabled; 25 import org.junit.jupiter.api.Test; 26 26 27 27 /** … … 31 31 * @version $Revision: 1741724 $ 32 32 */ 33 publicclass EmailValidatorTest {33 class EmailValidatorTest { 34 34 35 35 /** … … 49 49 * Setup 50 50 */ 51 @Before 51 @BeforeEach 52 52 public void setUp() { 53 53 validator = EmailValidator.getInstance(); … … 58 58 */ 59 59 @Test 60 publicvoid testEmail() {60 void testEmail() { 61 61 assertTrue(validator.isValid("jsmith@apache.org")); 62 62 assertFalse(validator.isValid(null)); … … 67 67 */ 68 68 @Test 69 publicvoid testEmailWithNumericAddress() {69 void testEmailWithNumericAddress() { 70 70 assertTrue(validator.isValid("someone@[216.109.118.76]")); 71 71 assertTrue(validator.isValid("someone@yahoo.com")); … … 76 76 */ 77 77 @Test 78 publicvoid testEmailExtension() {78 void testEmailExtension() { 79 79 assertTrue(validator.isValid("jsmith@apache.org")); 80 80 … … 99 99 */ 100 100 @Test 101 publicvoid testEmailWithDash() {101 void testEmailWithDash() { 102 102 assertTrue(validator.isValid("andy.noble@data-workshop.com")); 103 103 … … 114 114 */ 115 115 @Test 116 publicvoid testEmailWithDotEnd() {116 void testEmailWithDotEnd() { 117 117 assertFalse(validator.isValid("andy.noble@data-workshop.com.")); 118 118 } … … 123 123 */ 124 124 @Test 125 publicvoid testEmailWithBogusCharacter() {125 void testEmailWithBogusCharacter() { 126 126 127 127 assertFalse(validator.isValid("andy.noble@\u008fdata-workshop.com")); … … 148 148 */ 149 149 @Test 150 publicvoid testVALIDATOR_315() {150 void testVALIDATOR_315() { 151 151 assertFalse(validator.isValid("me@at&t.net")); 152 152 assertTrue(validator.isValid("me@att.net")); // Make sure TLD is not the cause of the failure … … 157 157 */ 158 158 @Test 159 publicvoid testVALIDATOR_278() {159 void testVALIDATOR_278() { 160 160 assertFalse(validator.isValid("someone@-test.com")); // hostname starts with dash/hyphen 161 161 assertFalse(validator.isValid("someone@test-.com")); // hostname ends with dash/hyphen … … 166 166 */ 167 167 @Test 168 publicvoid testValidator235() {168 void testValidator235() { 169 169 String version = System.getProperty("java.version"); 170 170 if (version.compareTo("1.6") < 0) { … … 184 184 */ 185 185 @Test 186 publicvoid testEmailWithCommas() {186 void testEmailWithCommas() { 187 187 assertFalse(validator.isValid("joeblow@apa,che.org")); 188 188 … … 196 196 */ 197 197 @Test 198 publicvoid testEmailWithSpaces() {198 void testEmailWithSpaces() { 199 199 assertFalse(validator.isValid("joeblow @apache.org")); // TODO - this should be valid? 200 200 … … 215 215 */ 216 216 @Test 217 publicvoid testEmailWithControlChars() {217 void testEmailWithControlChars() { 218 218 for (char c = 0; c < 32; c++) { 219 219 assertFalse("Test control char " + ((int) c), validator.isValid("foo" + c + "bar@domain.com")); … … 227 227 */ 228 228 @Test 229 publicvoid testEmailLocalhost() {229 void testEmailLocalhost() { 230 230 // Check the default is not to allow 231 231 EmailValidator noLocal = EmailValidator.getInstance(false); … … 258 258 */ 259 259 @Test 260 publicvoid testEmailWithSlashes() {260 void testEmailWithSlashes() { 261 261 assertTrue( 262 262 "/ and ! valid in username", … … 278 278 */ 279 279 @Test 280 publicvoid testEmailUserName() {280 void testEmailUserName() { 281 281 282 282 assertTrue(validator.isValid("joe1blow@apache.org")); … … 490 490 * The real solution is to fix the email parsing. 491 491 */ 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 publicvoid 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() { 495 495 for (int index = 0; index < testEmailFromPerl.length; index++) { 496 496 String item = testEmailFromPerl[index].item; … … 507 507 */ 508 508 @Test 509 publicvoid testValidator293() {509 void testValidator293() { 510 510 assertTrue(validator.isValid("abc-@abc.com")); 511 511 assertTrue(validator.isValid("abc_@abc.com")); … … 519 519 */ 520 520 @Test 521 publicvoid testValidator365() {521 void testValidator365() { 522 522 assertFalse(validator.isValid( 523 523 "Loremipsumdolorsitametconsecteturadipiscingelit.Nullavitaeligulamattisrhoncusnuncegestasmattisleo."+ … … 554 554 */ 555 555 @Test 556 publicvoid testEmailAtTLD() {556 void testEmailAtTLD() { 557 557 EmailValidator val = EmailValidator.getInstance(false, true); 558 558 assertTrue(val.isValid("test@com")); … … 563 563 */ 564 564 @Test 565 publicvoid testValidator359() {565 void testValidator359() { 566 566 EmailValidator val = EmailValidator.getInstance(false, true); 567 567 assertFalse(val.isValid("test@.com")); … … 572 572 */ 573 573 @Test 574 publicvoid testValidator374() {574 void testValidator374() { 575 575 assertTrue(validator.isValid("abc@school.school")); 576 576 } … … 580 580 */ 581 581 @Test 582 publicvoid testValidatorName() {582 void testValidatorName() { 583 583 assertEquals("Email validator", EmailValidator.getInstance().getValidatorName()); 584 584 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/routines/InetAddressValidatorTest.java
r10378 r17275 15 15 * limitations under the License. 16 16 */ 17 18 17 package org.openstreetmap.josm.data.validation.routines; 19 18 … … 22 21 import static org.junit.Assert.assertTrue; 23 22 24 import org.junit. Before;25 import org.junit.Test; 23 import org.junit.jupiter.api.BeforeEach; 24 import org.junit.jupiter.api.Test; 26 25 27 26 /** … … 30 29 * @version $Revision: 1741724 $ 31 30 */ 32 publicclass InetAddressValidatorTest {31 class InetAddressValidatorTest { 33 32 34 33 private InetAddressValidator validator; … … 37 36 * Setup 38 37 */ 39 @Before 38 @BeforeEach 40 39 public void setUp() { 41 40 validator = new InetAddressValidator(); … … 46 45 */ 47 46 @Test 48 publicvoid testInetAddressesFromTheWild() {47 void testInetAddressesFromTheWild() { 49 48 // CHECKSTYLE.OFF: SingleSpaceSeparator 50 49 assertTrue("www.apache.org IP should be valid", validator.isValid("140.211.11.130")); … … 59 58 */ 60 59 @Test 61 publicvoid testVALIDATOR_335() {60 void testVALIDATOR_335() { 62 61 assertTrue("2001:0438:FFFE:0000:0000:0000:0000:0A35 should be valid", 63 62 validator.isValid("2001:0438:FFFE:0000:0000:0000:0000:0A35")); … … 68 67 */ 69 68 @Test 70 publicvoid testInetAddressesByClass() {69 void testInetAddressesByClass() { 71 70 // CHECKSTYLE.OFF: SingleSpaceSeparator 72 71 assertTrue("class A IP should be valid", validator.isValid("24.25.231.12")); … … 91 90 */ 92 91 @Test 93 publicvoid testReservedInetAddresses() {92 void testReservedInetAddresses() { 94 93 assertTrue("localhost IP should be valid", validator.isValid("127.0.0.1")); 95 94 assertTrue("broadcast IP should be valid", validator.isValid("255.255.255.255")); … … 100 99 */ 101 100 @Test 102 publicvoid testBrokenInetAddresses() {101 void testBrokenInetAddresses() { 103 102 // CHECKSTYLE.OFF: SingleSpaceSeparator 104 103 assertFalse("IP with characters should be invalid", validator.isValid("124.14.32.abc")); … … 119 118 */ 120 119 @Test 121 publicvoid testIPv6() {120 void testIPv6() { 122 121 // The original Perl script contained a lot of duplicate tests. 123 122 // I removed the duplicates I noticed, but there may be more. … … 627 626 */ 628 627 @Test 629 publicvoid testValidatorName() {628 void testValidatorName() { 630 629 assertNull(new InetAddressValidator().getValidatorName()); 631 630 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/routines/RegexValidatorTest.java
r12620 r17275 21 21 import static org.junit.Assert.assertNull; 22 22 import static org.junit.Assert.assertTrue; 23 import static org.junit. Assert.fail;23 import static org.junit.jupiter.api.Assertions.fail; 24 24 25 25 import java.util.Arrays; 26 26 import java.util.regex.PatternSyntaxException; 27 27 28 import org.junit.Test; 28 import org.junit.jupiter.api.Test; 29 29 import org.openstreetmap.josm.tools.Logging; 30 30 … … 35 35 * @since Validator 1.4 36 36 */ 37 publicclass RegexValidatorTest {37 class RegexValidatorTest { 38 38 39 39 private static final String REGEX = "^([abc]*)(?:\\-)([DEF]*)(?:\\-)([123]*)$"; … … 55 55 */ 56 56 @Test 57 publicvoid testSingle() {57 void testSingle() { 58 58 RegexValidator sensitive = new RegexValidator(REGEX); 59 59 RegexValidator insensitive = new RegexValidator(REGEX, false); … … 84 84 */ 85 85 @Test 86 publicvoid testMultipleSensitive() {86 void testMultipleSensitive() { 87 87 88 88 // ------------ Set up Sensitive Validators … … 126 126 */ 127 127 @Test 128 publicvoid testMultipleInsensitive() {128 void testMultipleInsensitive() { 129 129 130 130 // ------------ Set up In-sensitive Validators … … 168 168 */ 169 169 @Test 170 publicvoid testNullValue() {170 void testNullValue() { 171 171 RegexValidator validator = new RegexValidator(REGEX); 172 172 assertFalse("Instance isValid()", validator.isValid(null)); … … 181 181 */ 182 182 @Test 183 publicvoid testMissingRegex() {183 void testMissingRegex() { 184 184 185 185 // Single Regular Expression - null … … 238 238 */ 239 239 @Test 240 publicvoid testExceptions() {240 void testExceptions() { 241 241 String invalidRegex = "^([abCD12]*$"; 242 242 try { … … 252 252 */ 253 253 @Test 254 publicvoid testToString() {254 void testToString() { 255 255 RegexValidator single = new RegexValidator(REGEX); 256 256 assertEquals("Single", "RegexValidator{" + REGEX + "}", single.toString()); … … 264 264 */ 265 265 @Test 266 publicvoid testValidatorName() {266 void testValidatorName() { 267 267 assertNull(new RegexValidator(".*").getValidatorName()); 268 268 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/routines/UrlValidatorTest.java
r11621 r17275 21 21 import static org.junit.Assert.assertTrue; 22 22 23 import org.junit. Before;24 import org.junit.Test; 23 import org.junit.jupiter.api.BeforeEach; 24 import org.junit.jupiter.api.Test; 25 25 26 26 /** … … 29 29 * @version $Revision: 1741724 $ 30 30 */ 31 publicclass UrlValidatorTest {31 class UrlValidatorTest { 32 32 33 33 private static final boolean printStatus = false; … … 37 37 * Setup 38 38 */ 39 @Before 39 @BeforeEach 40 40 public void setUp() { 41 41 for (int index = 0; index < testPartsIndex.length - 1; index++) { … … 140 140 */ 141 141 @Test 142 publicvoid testValidator202() {142 void testValidator202() { 143 143 String[] schemes = {"http", "https"}; 144 144 UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.NO_FRAGMENTS); … … 151 151 */ 152 152 @Test 153 publicvoid testValidator204() {153 void testValidator204() { 154 154 String[] schemes = {"http", "https"}; 155 155 UrlValidator urlValidator = new UrlValidator(schemes); … … 161 161 */ 162 162 @Test 163 publicvoid testValidator218() {163 void testValidator218() { 164 164 UrlValidator validator = new UrlValidator(UrlValidator.ALLOW_2_SLASHES); 165 165 assertTrue("parentheses should be valid in URLs", … … 171 171 */ 172 172 @Test 173 publicvoid testValidator235() {173 void testValidator235() { 174 174 String version = System.getProperty("java.version"); 175 175 if (version.compareTo("1.6") < 0) { … … 190 190 */ 191 191 @Test 192 publicvoid testValidator248() {192 void testValidator248() { 193 193 RegexValidator regex = new RegexValidator(new String[] {"localhost", ".*\\.my-testing"}); 194 194 UrlValidator validator = new UrlValidator(regex, 0); … … 224 224 */ 225 225 @Test 226 publicvoid testValidator288() {226 void testValidator288() { 227 227 UrlValidator validator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS); 228 228 … … 262 262 */ 263 263 @Test 264 publicvoid testValidator276() {264 void testValidator276() { 265 265 // file:// isn't allowed by default 266 266 UrlValidator validator = new UrlValidator(); … … 319 319 */ 320 320 @Test 321 publicvoid testValidator309() {321 void testValidator309() { 322 322 UrlValidator urlValidator = new UrlValidator(); 323 323 assertTrue(urlValidator.isValid("http://sample.ondemand.com/")); … … 334 334 */ 335 335 @Test 336 publicvoid testValidator339() {336 void testValidator339() { 337 337 UrlValidator urlValidator = new UrlValidator(); 338 338 assertTrue(urlValidator.isValid("http://www.cnn.com/WORLD/?hpt=sitenav")); // without … … 347 347 */ 348 348 @Test 349 publicvoid testValidator339IDN() {349 void testValidator339IDN() { 350 350 UrlValidator urlValidator = new UrlValidator(); 351 351 assertTrue(urlValidator.isValid("http://президент.рф/WORLD/?hpt=sitenav")); // without … … 360 360 */ 361 361 @Test 362 publicvoid testValidator342() {362 void testValidator342() { 363 363 UrlValidator urlValidator = new UrlValidator(); 364 364 assertTrue(urlValidator.isValid("http://example.rocks/"));
Note:
See TracChangeset
for help on using the changeset viewer.