Browse Source

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>
pull/48364/head
Hyunwoo Gu 2 months ago
parent
commit
734e4b8cdc
  1. 9
      module/spring-boot-restclient/src/test/java/org/springframework/boot/restclient/RootUriBuilderFactoryTests.java

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

@ -32,6 +32,7 @@ import static org.mockito.Mockito.mock; @@ -32,6 +32,7 @@ import static org.mockito.Mockito.mock;
* Tests for {@link RootUriBuilderFactory}.
*
* @author Scott Frederick
* @author Hyunwoo Gu
*/
class RootUriBuilderFactoryTests {
@ -43,4 +44,12 @@ class RootUriBuilderFactoryTests { @@ -43,4 +44,12 @@ class RootUriBuilderFactoryTests {
assertThat(builder.build()).isEqualTo(new URI("https://example.com/hello"));
}
@Test
void uriStringWhenEmptyShouldReturnRoot() throws URISyntaxException {
UriBuilderFactory builderFactory = new RootUriBuilderFactory("https://example.com",
mock(UriTemplateHandler.class));
UriBuilder builder = builderFactory.uriString("");
assertThat(builder.build()).isEqualTo(new URI("https://example.com"));
}
}

Loading…
Cancel
Save