use of org.springframework.web.util.UriComponentsBuilder in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method fromControllerWithCustomBaseUrlViaStaticCall.
@Test
public void fromControllerWithCustomBaseUrlViaStaticCall() {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("https://example.org:9090/base");
UriComponents uriComponents = fromController(builder, PersonControllerImpl.class).build();
assertThat(uriComponents.toString()).isEqualTo("https://example.org:9090/base/people");
assertThat(builder.toUriString()).isEqualTo("https://example.org:9090/base");
}
use of org.springframework.web.util.UriComponentsBuilder in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method fromMethodCallWithCustomBaseUrlViaInstance.
@Test
public void fromMethodCallWithCustomBaseUrlViaInstance() {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("https://example.org:9090/base");
MvcUriComponentsBuilder mvcBuilder = relativeTo(builder);
UriComponents result = mvcBuilder.withMethodCall(on(ControllerWithMethods.class).myMethod(null)).build();
assertThat(result.toString()).isEqualTo("https://example.org:9090/base/something/else");
assertThat(builder.toUriString()).isEqualTo("https://example.org:9090/base");
}
use of org.springframework.web.util.UriComponentsBuilder in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method fromMappingNameWithCustomBaseUrl.
@Test
public void fromMappingNameWithCustomBaseUrl() {
initWebApplicationContext(WebConfig.class);
UriComponentsBuilder baseUrl = UriComponentsBuilder.fromUriString("https://example.org:9999/base");
MvcUriComponentsBuilder mvcBuilder = relativeTo(baseUrl);
String url = mvcBuilder.withMappingName("PAC#getAddressesForCountry").arg(0, "DE").buildAndExpand(123);
assertThat(url).isEqualTo("https://example.org:9999/base/people/123/addresses/DE");
}
use of org.springframework.web.util.UriComponentsBuilder in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method fromMethodNameWithCustomBaseUrlViaInstance.
@Test
public void fromMethodNameWithCustomBaseUrlViaInstance() {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("https://example.org:9090/base");
MvcUriComponentsBuilder mvcBuilder = relativeTo(builder);
UriComponents uriComponents = mvcBuilder.withMethodName(ControllerWithMethods.class, "methodWithPathVariable", "1").build();
assertThat(uriComponents.toString()).isEqualTo("https://example.org:9090/base/something/1/foo");
assertThat(builder.toUriString()).isEqualTo("https://example.org:9090/base");
}
use of org.springframework.web.util.UriComponentsBuilder in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method fromMethodCallWithCustomBaseUrlViaStaticCall.
@Test
public void fromMethodCallWithCustomBaseUrlViaStaticCall() {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("https://example.org:9090/base");
UriComponents uriComponents = fromMethodCall(builder, on(ControllerWithMethods.class).myMethod(null)).build();
assertThat(uriComponents.toString()).isEqualTo("https://example.org:9090/base/something/else");
assertThat(builder.toUriString()).isEqualTo("https://example.org:9090/base");
}
Aggregations