Merge branch '7.0.x'

This commit is contained in:
rstoyanchev
2026-08-07 10:32:13 +03:00
5 changed files with 28 additions and 11 deletions
@@ -937,11 +937,17 @@ class UriComponentsBuilderTests {
@ParameterizedTest
@EnumSource
void verifyInvalidPort(ParserType parserType) {
String url = "http://localhost:XXX/path";
assertThatIllegalArgumentException()
.isThrownBy(() -> UriComponentsBuilder.fromUriString(url, parserType).build().toUri());
assertThatIllegalArgumentException()
.isThrownBy(() -> UriComponentsBuilder.fromUriString(url, parserType).build().toUri());
assertThatIllegalArgumentException().isThrownBy(() ->
UriComponentsBuilder.fromUriString("http://localhost:XXX/path", parserType).build().toUri());
}
@ParameterizedTest // gh-37117
@EnumSource
void verifyEmptyPort(ParserType parserType) {
URI uri = UriComponentsBuilder.fromUriString("http://localhost:/path", parserType).build().toUri();
assertThat(uri.getHost()).isEqualTo("localhost");
assertThat(uri.getPort()).isEqualTo(-1);
assertThat(uri.getPath()).isEqualTo("/path");
}
@ParameterizedTest // gh-27039
@@ -196,21 +196,30 @@ 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) {
@Test
void invalidPortSet() {
UriComponents uriComponents = fromUriString("https://example.com/bar").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");
}
@Test // gh-37117
void emptyPortSet() {
UriComponents uriComponents = fromUriString("https://example.com/bar").port("").build();
assertThat(uriComponents.getPort()).isEqualTo(-1);
}
@Test
void expandEncoded() {
assertThatIllegalStateException().isThrownBy(() ->