From e3c87fc2afa64264446e7ce338944d379c31f5cf Mon Sep 17 00:00:00 2001 From: Guilherme Amaral <40870111+gvma@users.noreply.github.com> Date: Mon, 5 Apr 2021 19:51:50 -0300 Subject: [PATCH] Changed exception check by JUnit API usage (#6133) --- .../java/org/eclipse/jetty/http/SyntaxTest.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/SyntaxTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/SyntaxTest.java index a31995cbd24..7e944e38f55 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/SyntaxTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/SyntaxTest.java @@ -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"))); } }