You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/21 11:48:18 UTC
[commons-validator] branch master updated: JUnit5 assertThrows DomainValidatorStartupTest
This is an automated email from the ASF dual-hosted git repository.
ggregory 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 aed53015 JUnit5 assertThrows DomainValidatorStartupTest
new eda1f35a Merge pull request #92 from nhojpatrick/junit5-assertThrows-DomainValidatorStartupTest
aed53015 is described below
commit aed5301503396561f3616930bca9ac8056a072cb
Author: John Patrick <14...@users.noreply.github.com>
AuthorDate: Thu Oct 15 10:07:18 2020 +0100
JUnit5 assertThrows DomainValidatorStartupTest
---
.../routines/DomainValidatorStartupTest.java | 28 +++++++++++++++-------
1 file changed, 20 insertions(+), 8 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 6b5d0e8d..aea848d9 100644
--- a/src/test/java/org/apache/commons/validator/routines/DomainValidatorStartupTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/DomainValidatorStartupTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.commons.validator.routines;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.*;
import java.util.ArrayList;
@@ -23,6 +26,7 @@ import java.util.List;
import org.apache.commons.validator.routines.DomainValidator.ArrayType;
import org.junit.Test;
+import org.junit.function.ThrowingRunnable;
import org.junit.runner.RunWith;
import org.bitstrings.test.junit.runner.ClassLoaderPerTestRunner;
@@ -34,24 +38,32 @@ import org.bitstrings.test.junit.runner.ClassLoaderPerTestRunner;
@RunWith( ClassLoaderPerTestRunner.class )
public class DomainValidatorStartupTest {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testUpdateBaseArrayCC() {
- DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_RO, new String[]{"com"});
+ final IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () ->
+ DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_RO, new String[]{"com"}));
+ assertThat(thrown.getMessage(), is(equalTo("Cannot update the table: COUNTRY_CODE_RO")));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testUpdateBaseArrayGeneric() {
- DomainValidator.updateTLDOverride(ArrayType.GENERIC_RO, new String[]{"com"});
+ final IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () ->
+ DomainValidator.updateTLDOverride(ArrayType.GENERIC_RO, new String[]{"com"}));
+ assertThat(thrown.getMessage(), is(equalTo("Cannot update the table: GENERIC_RO")));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testUpdateBaseArrayInfra() {
- DomainValidator.updateTLDOverride(ArrayType.INFRASTRUCTURE_RO, new String[]{"com"});
+ final IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () ->
+ DomainValidator.updateTLDOverride(ArrayType.INFRASTRUCTURE_RO, new String[]{"com"}));
+ assertThat(thrown.getMessage(), is(equalTo("Cannot update the table: INFRASTRUCTURE_RO")));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testUpdateBaseArrayLocal() {
- DomainValidator.updateTLDOverride(ArrayType.LOCAL_RO, new String[]{"com"});
+ final IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () ->
+ DomainValidator.updateTLDOverride(ArrayType.LOCAL_RO, new String[]{"com"}));
+ assertThat(thrown.getMessage(), is(equalTo("Cannot update the table: LOCAL_RO")));
}
@Test