Changed exception check by JUnit API usage (#6133)
This commit is contained in:
parent
25b96faa86
commit
e3c87fc2af
|
@ -18,6 +18,7 @@ import org.junit.jupiter.api.Test;
|
|||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class SyntaxTest
|
||||
|
@ -61,17 +62,11 @@ public class SyntaxTest
|
|||
|
||||
for (String token : tokens)
|
||||
{
|
||||
try
|
||||
{
|
||||
Syntax.requireValidRFC2616Token(token, "Test Based");
|
||||
fail("RFC2616 Token [" + token + "] Should have thrown " + IllegalArgumentException.class.getName());
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
assertThat("Testing Bad RFC2616 Token [" + token + "]", e.getMessage(),
|
||||
Throwable e = assertThrows(IllegalArgumentException.class,
|
||||
() -> Syntax.requireValidRFC2616Token(token, "Test Based"));
|
||||
assertThat("Testing Bad RFC2616 Token [" + token + "]", e.getMessage(),
|
||||
allOf(containsString("Test Based"),
|
||||
containsString("RFC2616")));
|
||||
}
|
||||
containsString("RFC2616")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue