use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilder method fromMethodInternal.
private static UriComponentsBuilder fromMethodInternal(UriComponentsBuilder baseUrl, Class<?> controllerType, Method method, Object... args) {
baseUrl = getBaseUrlToUse(baseUrl);
String typePath = getTypeRequestMapping(controllerType);
String methodPath = getMethodRequestMapping(method);
String path = pathMatcher.combine(typePath, methodPath);
baseUrl.path(path);
UriComponents uriComponents = applyContributors(baseUrl, method, args);
return UriComponentsBuilder.newInstance().uriComponents(uriComponents);
}
use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromControllerWithCustomBaseUrlViaStaticCall.
@Test
public void testFromControllerWithCustomBaseUrlViaStaticCall() {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("http://example.org:9090/base");
UriComponents uriComponents = fromController(builder, PersonControllerImpl.class).build();
assertEquals("http://example.org:9090/base/people", 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 testFromControllerTwoTypeLevelMappings.
@Test
public void testFromControllerTwoTypeLevelMappings() {
UriComponents uriComponents = fromController(InvalidController.class).build();
assertThat(uriComponents.toUriString(), is("http://localhost/persons"));
}
use of org.springframework.web.util.UriComponents in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromMethodNameNotMapped.
@Test
public void testFromMethodNameNotMapped() throws Exception {
UriComponents uriComponents = fromMethodName(UnmappedController.class, "unmappedMethod").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 testFromMethodCallWithCustomBaseUrlViaStaticCall.
@Test
public void testFromMethodCallWithCustomBaseUrlViaStaticCall() {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("http://example.org:9090/base");
UriComponents uriComponents = fromMethodCall(builder, on(ControllerWithMethods.class).myMethod(null)).build();
assertEquals("http://example.org:9090/base/something/else", uriComponents.toString());
assertEquals("http://example.org:9090/base", builder.toUriString());
}
Aggregations