mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-09 08:40:39 +00:00
Merge branch '7.0.x'
This commit is contained in:
+11
-5
@@ -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(() ->
|
||||
|
||||
Reference in New Issue
Block a user