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 a1582e05 JUnit5 assertThrows EmailValidatorTest
new e46bd350 Merge pull request #93 from
nhojpatrick/junit5-assertThrows-EmailValidatorTest
a1582e05 is described below
commit a1582e05df5b07487fec16557de463375eb43b85
Author: John Patrick <[email protected]>
AuthorDate: Thu Oct 15 10:07:55 2020 +0100
JUnit5 assertThrows EmailValidatorTest
---
.../validator/routines/EmailValidatorTest.java | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git
a/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java
b/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java
index 19ab97be..e55e1c56 100644
---
a/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java
+++
b/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.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;
@@ -25,6 +28,7 @@ import org.apache.commons.validator.ResultPair;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
+import org.junit.function.ThrowingRunnable;
/**
* Performs Validation Test for e-mail validations.
@@ -565,21 +569,27 @@ public class EmailValidatorTest {
assertTrue(validator.isValid("[email protected]"));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testValidator473_1() { // reject null DomainValidator
- new EmailValidator(false, false, null);
+ final IllegalArgumentException thrown =
assertThrows(IllegalArgumentException.class, () ->
+ new EmailValidator(false, false, null));
+ assertThat(thrown.getMessage(), is(equalTo("DomainValidator cannot be
null")));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testValidator473_2() { // reject null DomainValidator with
mismatched allowLocal
final List<DomainValidator.Item> items = new ArrayList<>();
- new EmailValidator(false, false, DomainValidator.getInstance(true,
items));
+ final IllegalArgumentException thrown =
assertThrows(IllegalArgumentException.class, () ->
+ new EmailValidator(false, false,
DomainValidator.getInstance(true, items)));
+ assertThat(thrown.getMessage(), is(equalTo("DomainValidator must agree
with allowLocal setting")));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testValidator473_3() { // reject null DomainValidator with
mismatched allowLocal
final List<DomainValidator.Item> items = new ArrayList<>();
- new EmailValidator(true, false, DomainValidator.getInstance(false,
items));
+ final IllegalArgumentException thrown =
assertThrows(IllegalArgumentException.class, () ->
+ new EmailValidator(true, false,
DomainValidator.getInstance(false, items)));
+ assertThat(thrown.getMessage(), is(equalTo("DomainValidator must agree
with allowLocal setting")));
}
@Test