use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method fromMethodNameWithOptionalNamedParam.
// gh-22656
@Test
public void fromMethodNameWithOptionalNamedParam() {
UriComponents uriComponents = fromMethodName(ControllerWithMethods.class, "methodWithOptionalNamedParam", Optional.of("foo")).build();
assertThat(uriComponents.toUriString()).isEqualTo("http://localhost/something/optional-param-with-name?search=foo");
}
use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method fromMethodNameTwoPathVariables.
@Test
public void fromMethodNameTwoPathVariables() {
UriComponents uriComponents = fromMethodName(ControllerWithMethods.class, "methodWithTwoPathVariables", 1, "2009-10-31").build();
assertThat(uriComponents.getPath()).isEqualTo("/something/1/foo/2009-10-31");
}
use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method fromMethodNameTypeLevelPathVariableWithoutArgumentValue.
// SPR-11391
@Test
public void fromMethodNameTypeLevelPathVariableWithoutArgumentValue() {
UriComponents uriComponents = fromMethodName(UserContactController.class, "showCreate", 123).build();
assertThat(uriComponents.getPath()).isEqualTo("/user/123/contacts/create");
}
use of org.springframework.web.util.UriComponents 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.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method usesForwardedHostAsHostIfHeaderIsSet.
@Test
public void usesForwardedHostAsHostIfHeaderIsSet() throws Exception {
this.request.setScheme("https");
this.request.addHeader("X-Forwarded-Host", "somethingDifferent");
adaptRequestFromForwardedHeaders();
UriComponents uriComponents = fromController(PersonControllerImpl.class).build();
assertThat(uriComponents.toUriString()).startsWith("https://somethingDifferent");
}
Aggregations