You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2020/07/25 16:46:42 UTC
[commons-validator] branch master updated: Convert to Junit4
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-validator.git
The following commit(s) were added to refs/heads/master by this push:
new 77d7036 Convert to Junit4
77d7036 is described below
commit 77d7036ec8e8a76467985285ada364988afa4628
Author: Sebb <se...@apache.org>
AuthorDate: Sat Jul 25 17:46:34 2020 +0100
Convert to Junit4
---
.../routines/DomainValidatorStartupTest.java | 58 +++++++++++-----------
1 file changed, 28 insertions(+), 30 deletions(-)
diff --git a/src/test/java/org/apache/commons/validator/routines/DomainValidatorStartupTest.java b/src/test/java/org/apache/commons/validator/routines/DomainValidatorStartupTest.java
index 0ab16bf..37306b7 100644
--- a/src/test/java/org/apache/commons/validator/routines/DomainValidatorStartupTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/DomainValidatorStartupTest.java
@@ -16,53 +16,48 @@
*/
package org.apache.commons.validator.routines;
-import org.apache.commons.validator.routines.DomainValidator.ArrayType;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.apache.commons.validator.routines.DomainValidator.ArrayType;
+import org.junit.Before;
+import org.junit.Test;
/**
* Startup Tests for the DomainValidator.
*
* @version $Revision$
*/
-public class DomainValidatorStartupTest extends TestCase {
+public class DomainValidatorStartupTest {
private DomainValidator validator;
- @Override
+ @Before
public void setUp() {
validator = DomainValidator.getInstance();
DomainValidator.clearTLDOverrides(); // N.B. this clears the inUse flag, allowing overrides
}
- public void testUpdateBaseArrays() {
- try {
- DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_RO, new String[]{"com"});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- // expected
- }
- try {
- DomainValidator.updateTLDOverride(ArrayType.GENERIC_RO, new String[]{"com"});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- // expected
- }
- try {
- DomainValidator.updateTLDOverride(ArrayType.INFRASTRUCTURE_RO, new String[]{"com"});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- // expected
- }
- try {
- DomainValidator.updateTLDOverride(ArrayType.LOCAL_RO, new String[]{"com"});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- // expected
- }
+ @Test(expected = IllegalArgumentException.class)
+ public void testUpdateBaseArrayCC() {
+ DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_RO, new String[]{"com"});
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testUpdateBaseArrayGeneric() {
+ DomainValidator.updateTLDOverride(ArrayType.GENERIC_RO, new String[]{"com"});
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testUpdateBaseArrayInfra() {
+ DomainValidator.updateTLDOverride(ArrayType.INFRASTRUCTURE_RO, new String[]{"com"});
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testUpdateBaseArrayLocal() {
+ DomainValidator.updateTLDOverride(ArrayType.LOCAL_RO, new String[]{"com"});
}
+ @Test
public void testUpdateCountryCode() {
assertFalse(validator.isValidCountryCodeTld("com")); // cannot be valid
DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_PLUS, new String[]{"com"});
@@ -77,6 +72,7 @@ public class DomainValidatorStartupTest extends TestCase {
assertTrue(validator.isValidCountryCodeTld("ch"));
}
+ @Test
public void testUpdateGeneric() {
assertFalse(validator.isValidGenericTld("ch")); // cannot be valid
DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, new String[]{"ch"});
@@ -91,6 +87,7 @@ public class DomainValidatorStartupTest extends TestCase {
assertTrue(validator.isValidGenericTld("com"));
}
+ @Test
public void testVALIDATOR_412() {
assertFalse(validator.isValidGenericTld("local"));
assertFalse(validator.isValid("abc.local"));
@@ -103,6 +100,7 @@ public class DomainValidatorStartupTest extends TestCase {
assertTrue(validator.isValid("abc.pvt"));
}
+ @Test
public void testCannotUpdate() {
DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, new String[]{"ch"}); // OK
DomainValidator dv = DomainValidator.getInstance();