use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromMethodNamePathVariable.
@Test
public void testFromMethodNamePathVariable() throws Exception {
UriComponents uriComponents = fromMethodName(ControllerWithMethods.class, "methodWithPathVariable", new Object[] { "1" }).build();
assertThat(uriComponents.toUriString(), is("http://localhost/something/1/foo"));
}
use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method usesForwardedHostAsHostIfHeaderIsSet.
@Test
public void usesForwardedHostAsHostIfHeaderIsSet() {
this.request.addHeader("X-Forwarded-Host", "somethingDifferent");
UriComponents uriComponents = fromController(PersonControllerImpl.class).build();
assertThat(uriComponents.toUriString(), startsWith("http://somethingDifferent"));
}
use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromControllerNotMapped.
@Test
public void testFromControllerNotMapped() {
UriComponents uriComponents = fromController(UnmappedController.class).build();
assertThat(uriComponents.toUriString(), is("http://localhost/"));
}
use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromMethodNameWithCustomBaseUrlViaInstance.
@Test
public void testFromMethodNameWithCustomBaseUrlViaInstance() throws Exception {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("http://example.org:9090/base");
MvcUriComponentsBuilder mvcBuilder = MvcUriComponentsBuilder.relativeTo(builder);
UriComponents uriComponents = mvcBuilder.withMethodName(ControllerWithMethods.class, "methodWithPathVariable", new Object[] { "1" }).build();
assertEquals("http://example.org:9090/base/something/1/foo", uriComponents.toString());
assertEquals("http://example.org:9090/base", builder.toUriString());
}
use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method fromMethodNameWithBridgedMethod.
// SPR-12977
@Test
public void fromMethodNameWithBridgedMethod() throws Exception {
UriComponents uriComponents = fromMethodName(PersonCrudController.class, "get", (long) 42).build();
assertThat(uriComponents.toUriString(), is("http://localhost/42"));
}
Aggregations