Changed exception check by JUnit API usage (#6133)

This commit is contained in:
Guilherme Amaral 2021-04-05 19:51:50 -03:00 committed by GitHub
parent 25b96faa86
commit e3c87fc2af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 10 deletions

View File

@ -18,6 +18,7 @@ import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.fail;
public class SyntaxTest public class SyntaxTest
@ -61,19 +62,13 @@ public class SyntaxTest
for (String token : tokens) for (String token : tokens)
{ {
try Throwable e = assertThrows(IllegalArgumentException.class,
{ () -> Syntax.requireValidRFC2616Token(token, "Test Based"));
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(), assertThat("Testing Bad RFC2616 Token [" + token + "]", e.getMessage(),
allOf(containsString("Test Based"), allOf(containsString("Test Based"),
containsString("RFC2616"))); containsString("RFC2616")));
} }
} }
}
@Test @Test
public void testRequireValidRFC6265CookieValueGood() public void testRequireValidRFC6265CookieValueGood()