use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromController.
@Test
public void testFromController() {
UriComponents uriComponents = fromController(PersonControllerImpl.class).build();
assertThat(uriComponents.toUriString(), Matchers.endsWith("/people"));
}
use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromControllerSubResource.
@Test
public void testFromControllerSubResource() {
UriComponents uriComponents = fromController(PersonControllerImpl.class).pathSegment("something").build();
assertThat(uriComponents.toUriString(), endsWith("/people/something"));
}
use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromMethodCallOnSubclass.
@Test
public void testFromMethodCallOnSubclass() {
UriComponents uriComponents = fromMethodCall(on(ExtendedController.class).myMethod(null)).build();
assertThat(uriComponents.toUriString(), startsWith("http://localhost"));
assertThat(uriComponents.toUriString(), endsWith("/extended/else"));
}
use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromMethodCallWithCustomBaseUrlViaInstance.
@Test
public void testFromMethodCallWithCustomBaseUrlViaInstance() {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("http://example.org:9090/base");
MvcUriComponentsBuilder mvcBuilder = MvcUriComponentsBuilder.relativeTo(builder);
UriComponents result = mvcBuilder.withMethodCall(on(ControllerWithMethods.class).myMethod(null)).build();
assertEquals("http://example.org:9090/base/something/else", result.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 testFromMethodCallWithTypeLevelUriVars.
@Test
public void testFromMethodCallWithTypeLevelUriVars() {
UriComponents uriComponents = fromMethodCall(on(PersonsAddressesController.class).getAddressesForCountry("DE")).buildAndExpand(15);
assertThat(uriComponents.toUriString(), endsWith("/people/15/addresses/DE"));
}
Aggregations