Polishing in UriComponentsTests

See gh-37117
This commit is contained in:
rstoyanchev
2026-08-07 10:25:12 +03:00
parent 7f1966f5f5
commit 70ca103b22
@@ -196,16 +196,20 @@ class UriComponentsTests {
@ParameterizedTest // gh-28521
@EnumSource
void invalidPort(ParserType parserType) {
void invalidPortParsed(ParserType parserType) {
assertThatExceptionOfType(InvalidUrlException.class)
.isThrownBy(() -> fromUriString("https://example.com:XXX/bar", parserType));
assertExceptionsForInvalidPort(fromUriString("https://example.com/bar", parserType).port("XXX").build());
}
private void assertExceptionsForInvalidPort(UriComponents uriComponents) {
@ParameterizedTest
@EnumSource
void invalidPortSet(ParserType parserType) {
UriComponents uriComponents = fromUriString("https://example.com/bar", parserType).port("XXX").build();
assertThatIllegalStateException()
.isThrownBy(uriComponents::getPort)
.withMessage("The port must be an integer: XXX");
assertThatIllegalStateException()
.isThrownBy(uriComponents::toUri)
.withMessage("The port must be an integer: XXX");