Skip to content

Commit 734e4b8

Browse files
committed
Add unit tests for apply() method handling empty and slash-prefixed URIs
- Added tests for RootUriTemplateHandler.apply() covering: - URIs starting with '/' - Empty string - Blank string - Absolute URLs - Relative paths - Ensures apply() behaves as expected in all edge cases Signed-off-by: Hyunwoo Gu <realization0327@gmail.com>
1 parent 73984c6 commit 734e4b8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

module/spring-boot-restclient/src/test/java/org/springframework/boot/restclient/RootUriBuilderFactoryTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* Tests for {@link RootUriBuilderFactory}.
3333
*
3434
* @author Scott Frederick
35+
* @author Hyunwoo Gu
3536
*/
3637
class RootUriBuilderFactoryTests {
3738

@@ -43,4 +44,12 @@ void uriStringPrefixesRoot() throws URISyntaxException {
4344
assertThat(builder.build()).isEqualTo(new URI("https://example.com/hello"));
4445
}
4546

47+
@Test
48+
void uriStringWhenEmptyShouldReturnRoot() throws URISyntaxException {
49+
UriBuilderFactory builderFactory = new RootUriBuilderFactory("https://example.com",
50+
mock(UriTemplateHandler.class));
51+
UriBuilder builder = builderFactory.uriString("");
52+
assertThat(builder.build()).isEqualTo(new URI("https://example.com"));
53+
}
54+
4655
}

0 commit comments

Comments
 (0)