Java Code Examples for org.springframework.web.util.UriComponents

The following examples show how to use org.springframework.web.util.UriComponents. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: jakduk-api   Source File: AuthUtils.java    License: MIT License 6 votes vote down vote up
/**
 * 회원 프로필 이미지 URL을 생성한다.
 *
 * @param sizeType size 타입
 * @param id UserImage의 ID
 */
public String generateUserPictureUrl(Constants.IMAGE_SIZE_TYPE sizeType, String id) {

    if (StringUtils.isBlank(id))
        return null;

    String urlPathUserPicture = null;

    switch (sizeType) {
        case LARGE:
            urlPathUserPicture = jakdukProperties.getApiUrlPath().getUserPictureLarge();
            break;
        case SMALL:
            urlPathUserPicture = jakdukProperties.getApiUrlPath().getUserPictureSmall();
            break;
    }

    UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(jakdukProperties.getApiServerUrl())
            .path("/{urlPathGallery}/{id}")
            .buildAndExpand(urlPathUserPicture, id);

    return uriComponents.toUriString();
}
 
Example 2
private void mockManifestRestTemplateCall(Map<String, Object> mapToReturn, String registryHost,
		String registryPort, String repository, String tag) {

	UriComponents manifestUriComponents = UriComponentsBuilder.newInstance()
			.scheme("https")
			.host(registryHost)
			.port(StringUtils.hasText(registryPort) ? registryPort : null)
			.path("v2/{repository}/manifests/{tag}")
			.build().expand(repository, tag);


	when(mockRestTemplate.exchange(
			eq(manifestUriComponents.toUri()),
			eq(HttpMethod.GET),
			any(HttpEntity.class),
			eq(Map.class))).thenReturn(new ResponseEntity<>(mapToReturn, HttpStatus.OK));
}
 
Example 3
Source Project: levelup-java-examples   Source File: ConstructBuildURI.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void construct_uri_queryparmeter_spring () {
	
	UriComponents uriComponents =
	        UriComponentsBuilder.newInstance()
	            .scheme("http")
	            .host("www.leveluplunch.com")
	            .path("/{lanuage}/{type}/")
	            .queryParam("test", "a", "b")
	            .build()
	            .expand("java", "examples")
	            .encode();
	
	assertEquals("http://www.leveluplunch.com/java/examples/?test=a&test=b", 
			uriComponents.toUriString());
}
 
Example 4
Source Project: wallride   Source File: ArticleSearchController.java    License: Apache License 2.0 6 votes vote down vote up
@RequestMapping(method = RequestMethod.GET)
public String search(
        @PathVariable String language,
        @Validated @ModelAttribute("form") ArticleSearchForm form,
        BindingResult result,
        @PageableDefault(50) Pageable pageable,
        Model model,
        HttpServletRequest servletRequest) throws UnsupportedEncodingException {
    Page<Article> articles = articleService.getArticles(form.toArticleSearchRequest(), pageable);

    model.addAttribute("articles", articles);
    model.addAttribute("pageable", pageable);
    model.addAttribute("pagination", new Pagination<>(articles, servletRequest));

    UriComponents uriComponents = ServletUriComponentsBuilder
            .fromRequest(servletRequest)
            .queryParams(ControllerUtils.convertBeanForQueryParams(form, conversionService))
            .build();
    if (!StringUtils.isEmpty(uriComponents.getQuery())) {
        model.addAttribute("query", URLDecoder.decode(uriComponents.getQuery(), "UTF-8"));
    }

    return "article/index";
}
 
Example 5
@Test
public void fromRequestWithForwardedHostAndPort() throws Exception {
	MockHttpServletRequest request = new MockHttpServletRequest();
	request.setScheme("http");
	request.setServerName("localhost");
	request.setServerPort(80);
	request.setRequestURI("/mvc-showcase");
	request.addHeader("X-Forwarded-Proto", "https");
	request.addHeader("X-Forwarded-Host", "84.198.58.199");
	request.addHeader("X-Forwarded-Port", "443");

	HttpServletRequest requestToUse = adaptFromForwardedHeaders(request);
	UriComponents result =  ServletUriComponentsBuilder.fromRequest(requestToUse).build();

	assertEquals("https://84.198.58.199/mvc-showcase", result.toString());
}
 
Example 6
Source Project: Spring-Boot-2-Fundamentals   Source File: MottoController.java    License: MIT License 6 votes vote down vote up
/** Append to list of mottos, but only if the motto is unique */
@PostMapping
public ResponseEntity<Message> uniqueAppend(@RequestBody Message message, UriComponentsBuilder uriBuilder) {
    // Careful, this lookup is O(n)
    if (motto.contains(message)) {
        return ResponseEntity.status(HttpStatus.CONFLICT).build();
    } else {
        motto.add(message);

        UriComponents location = MvcUriComponentsBuilder
                .fromMethodCall(on(MottoController.class).retrieveById(motto.size()))
                .build();
        return ResponseEntity
                .created(location.toUri())
                .header("X-Copyright", "Packt 2018")
                .body(new Message("Accepted #" + motto.size()));
    }
}
 
Example 7
/**
 * Initialize a builder with a scheme, host,and port (but not path and query).
 */
private static ServletUriComponentsBuilder initFromRequest(HttpServletRequest request) {
	HttpRequest httpRequest = new ServletServerHttpRequest(request);
	UriComponents uriComponents = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
	String scheme = uriComponents.getScheme();
	String host = uriComponents.getHost();
	int port = uriComponents.getPort();

	ServletUriComponentsBuilder builder = new ServletUriComponentsBuilder();
	builder.scheme(scheme);
	builder.host(host);
	if (("http".equals(scheme) && port != 80) || ("https".equals(scheme) && port != 443)) {
		builder.port(port);
	}
	return builder;
}
 
Example 8
Source Project: wallride   Source File: CustomFieldSearchController.java    License: Apache License 2.0 6 votes vote down vote up
@RequestMapping(method = RequestMethod.GET)
public String search(
        @PathVariable String language,
        @Validated @ModelAttribute("form") CustomFieldSearchForm form,
        BindingResult result,
        @PageableDefault(50) Pageable pageable,
        Model model,
        HttpServletRequest servletRequest) throws UnsupportedEncodingException {
    Page<CustomField> customFields = customfieldService.getCustomFields(form.toCustomFieldSearchRequest(), pageable);

    model.addAttribute("customFields", customFields);
    model.addAttribute("pageable", pageable);
    model.addAttribute("pagination", new Pagination<>(customFields, servletRequest));

    UriComponents uriComponents = ServletUriComponentsBuilder
            .fromRequest(servletRequest)
            .queryParams(ControllerUtils.convertBeanForQueryParams(form, conversionService))
            .build();
    if (!StringUtils.isEmpty(uriComponents.getQuery())) {
        model.addAttribute("query", URLDecoder.decode(uriComponents.getQuery(), "UTF-8"));
    }

    return "customfield/index";
}
 
Example 9
Source Project: FastBootWeixin   Source File: WxApiMethodInfo.java    License: Apache License 2.0 6 votes vote down vote up
private UriComponents applyContributors(UriComponentsBuilder builder, Method method, Object... args) {
    CompositeUriComponentsContributor contributor = defaultUriComponentsContributor;
    int paramCount = method.getParameterTypes().length;
    int argCount = args.length;
    if (paramCount != argCount) {
        throw new IllegalArgumentException("方法参数量为" + paramCount + " 与真实参数量不匹配,真实参数量为" + argCount);
    }
    final Map<String, Object> uriVars = new HashMap<>(8);
    for (int i = 0; i < paramCount; i++) {
        MethodParameter param = new SynthesizingMethodParameter(method, i);
        param.initParameterNameDiscovery(parameterNameDiscoverer);
        contributor.contributeMethodArgument(param, args[i], builder, uriVars);
    }
    // We may not have all URI var values, expand only what we have
    return builder.build().expand(name -> uriVars.containsKey(name) ? uriVars.get(name) : UriComponents.UriTemplateVariables.SKIP_VALUE);
}
 
Example 10
/**
 * Initialize a builder with a scheme, host,and port (but not path and query).
 */
private static ServletUriComponentsBuilder initFromRequest(HttpServletRequest request) {
	HttpRequest httpRequest = new ServletServerHttpRequest(request);
	UriComponents uriComponents = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
	String scheme = uriComponents.getScheme();
	String host = uriComponents.getHost();
	int port = uriComponents.getPort();

	ServletUriComponentsBuilder builder = new ServletUriComponentsBuilder();
	builder.scheme(scheme);
	builder.host(host);
	if (("http".equals(scheme) && port != 80) || ("https".equals(scheme) && port != 443)) {
		builder.port(port);
	}
	return builder;
}
 
Example 11
@Test
void toEntityFileValueValid() throws ParseException {
  String generatedId = "id";
  String downloadUriAsString = "http://somedownloaduri";
  ServletUriComponentsBuilder mockBuilder = mock(ServletUriComponentsBuilder.class);
  UriComponents downloadUri = mock(UriComponents.class);
  FileMeta fileMeta = mock(FileMeta.class);

  Attribute fileAttr = when(mock(Attribute.class).getName()).thenReturn("fileAttr").getMock();
  when(fileAttr.getDataType()).thenReturn(FILE);
  when(idGenerator.generateId()).thenReturn(generatedId);
  when(fileMetaFactory.create(generatedId)).thenReturn(fileMeta);
  when(mockBuilder.replacePath(anyString())).thenReturn(mockBuilder);
  when(mockBuilder.replaceQuery(null)).thenReturn(mockBuilder);
  when(downloadUri.toUriString()).thenReturn(downloadUriAsString);
  when(mockBuilder.build()).thenReturn(downloadUri);
  when(servletUriComponentsBuilderFactory.fromCurrentRequest()).thenReturn(mockBuilder);

  byte[] content = {'a', 'b'};
  MockMultipartFile mockMultipartFile =
      new MockMultipartFile("name", "fileName", "contentType", content);

  assertEquals(fileMeta, restService.toEntityValue(fileAttr, mockMultipartFile, null));
}
 
Example 12
Source Project: spring4-understanding   Source File: RedirectView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Convert model to request parameters and redirect to the given URL.
 * @see #appendQueryProperties
 * @see #sendRedirect
 */
@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
		HttpServletResponse response) throws IOException {

	String targetUrl = createTargetUrl(model, request);
	targetUrl = updateTargetUrl(targetUrl, model, request, response);

	FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
	if (!CollectionUtils.isEmpty(flashMap)) {
		UriComponents uriComponents = UriComponentsBuilder.fromUriString(targetUrl).build();
		flashMap.setTargetRequestPath(uriComponents.getPath());
		flashMap.addTargetRequestParams(uriComponents.getQueryParams());
		FlashMapManager flashMapManager = RequestContextUtils.getFlashMapManager(request);
		if (flashMapManager == null) {
			throw new IllegalStateException("FlashMapManager not found despite output FlashMap having been set");
		}
		flashMapManager.saveOutputFlashMap(flashMap, request, response);
	}

	sendRedirect(request, response, targetUrl, this.http10Compatible);
}
 
Example 13
Source Project: WeBASE-Node-Manager   Source File: HttpRequestTools.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * convert map to query params
 * ex: uri:permission,
 *     params: (groupId, 1) (address, 0x01)
 *
 * result: permission?groupId=1&address=0x01
 */
public static String getQueryUri(String uriHead, Map<String, String> map) {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();

    for (Map.Entry<String, String> entry : map.entrySet()) {
        params.add(entry.getKey(), entry.getValue());
    }

    UriComponents uriComponents = UriComponentsBuilder.newInstance()
            .queryParams(params).build();

    return uriHead + uriComponents.toString();
}
 
Example 14
Source Project: molgenis   Source File: UriUtils.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private static UriComponents createEntitiesUriComponents(
    ServletUriComponentsBuilder builder,
    String entityTypeId,
    String idAttributeName,
    Collection<String> entityIds) {
  builder = builder.cloneBuilder();
  builder.path(ApiNamespace.API_PATH);
  builder.pathSegment(RestControllerV2.API_VERSION, entityTypeId);
  builder.queryParam("q", createEntitiesUriQuery(idAttributeName, entityIds));
  return builder.build();
}
 
Example 15
@Test
public void requestAuthorizationCodeGrantWhenValidAuthorizationResponseThenDisplayIndexPage() throws Exception {
	HtmlPage page = this.webClient.getPage("/");

	ClientRegistration clientRegistration = this.clientRegistrationRepository.findByRegistrationId("github");

	HtmlAnchor clientAnchorElement = this.getClientAnchorElement(page, clientRegistration);
	assertThat(clientAnchorElement).isNotNull();

	WebResponse response = this.followLinkDisableRedirects(clientAnchorElement);

	UriComponents authorizeRequestUriComponents = UriComponentsBuilder.fromUri(
		URI.create(response.getResponseHeaderValue("Location"))).build();

	Map<String, String> params = authorizeRequestUriComponents.getQueryParams().toSingleValueMap();
	String code = "auth-code";
	String state = URLDecoder.decode(params.get(OAuth2ParameterNames.STATE), "UTF-8");
	String redirectUri = URLDecoder.decode(params.get(OAuth2ParameterNames.REDIRECT_URI), "UTF-8");

	String authorizationResponseUri =
		UriComponentsBuilder.fromHttpUrl(redirectUri)
			.queryParam(OAuth2ParameterNames.CODE, code)
			.queryParam(OAuth2ParameterNames.STATE, state)
			.build().encode().toUriString();

	page = this.webClient.getPage(new URL(authorizationResponseUri));
	this.assertIndexPage(page);
}
 
Example 16
Source Project: java-technology-stack   Source File: HtmlUnitRequestBuilder.java    License: MIT License 5 votes vote down vote up
public MockHttpServletRequest buildRequest(ServletContext servletContext) {
	Charset charset = getCharset();
	String httpMethod = this.webRequest.getHttpMethod().name();
	UriComponents uriComponents = uriComponents();
	String path = uriComponents.getPath();

	MockHttpServletRequest request = new HtmlUnitMockHttpServletRequest(
			servletContext, httpMethod, (path != null ? path : ""));
	parent(request, this.parentBuilder);
	String host = uriComponents.getHost();
	request.setServerName(host != null ? host : "");  // needs to be first for additional headers
	authType(request);
	request.setCharacterEncoding(charset.name());
	content(request, charset);
	contextPath(request, uriComponents);
	contentType(request);
	cookies(request);
	headers(request);
	locales(request);
	servletPath(uriComponents, request);
	params(request, uriComponents);
	ports(uriComponents, request);
	request.setProtocol("HTTP/1.1");
	request.setQueryString(uriComponents.getQuery());
	String scheme = uriComponents.getScheme();
	request.setScheme(scheme != null ? scheme : "");
	request.setPathInfo(null);

	return postProcess(request);
}
 
Example 17
Source Project: molgenis   Source File: UriUtils.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private static UriComponents createEntityCollectionUriComponents(
    ServletUriComponentsBuilder builder, String entityTypeId) {
  builder = builder.cloneBuilder();
  builder.path(ApiNamespace.API_PATH);
  builder.pathSegment(RestControllerV2.API_VERSION, entityTypeId);
  return builder.build();
}
 
Example 18
@Test
public void fromMethodCallWithTypeLevelUriVars() {
	UriComponents uriComponents = fromMethodCall(
			on(PersonsAddressesController.class).getAddressesForCountry("DE")).buildAndExpand(15);

	assertThat(uriComponents.toUriString(), endsWith("/people/15/addresses/DE"));
}
 
Example 19
@Override
public HttpHeaders getAuthorizationHeaders(ContainerImage containerImage, RegistryConfiguration registryConfiguration) {

	Assert.isTrue(registryConfiguration.getAuthorizationType() == this.getType(),
			"Incorrect authorization type: " + registryConfiguration.getAuthorizationType());

	Assert.notNull(containerImage, "Valid containerImageName is required!");
	String imageRepository = containerImage.getRepository();
	Assert.hasText(imageRepository, "Valid repository name (e.g. namespace/repository-name without the tag)" +
			" is required for the authorization");

	final HttpHeaders requestHttpHeaders = new HttpHeaders();
	if (StringUtils.hasText(registryConfiguration.getUser()) && StringUtils.hasText(registryConfiguration.getSecret())) {
		// Use basic authentication to obtain the authorization token.
		// Usually the public docker hub authorization service doesn't require authentication for image pull requests.
		requestHttpHeaders.setBasicAuth(registryConfiguration.getUser(), registryConfiguration.getSecret());
	}

	String registryAuthUri = registryConfiguration.getExtra().containsKey(DOCKER_REGISTRY_AUTH_URI_KEY) ?
			registryConfiguration.getExtra().get(DOCKER_REGISTRY_AUTH_URI_KEY) : DEFAULT_DOCKER_REGISTRY_AUTH_URI;
	UriComponents uriComponents = UriComponentsBuilder.newInstance()
			.fromHttpUrl(registryAuthUri).build().expand(imageRepository);

	ResponseEntity<Map> authorization = this.getRestTemplate(registryConfiguration)
			.exchange(uriComponents.toUri(), HttpMethod.GET, new HttpEntity<>(requestHttpHeaders), Map.class);

	Map<String, String> authorizationBody = (Map<String, String>) authorization.getBody();

	final HttpHeaders responseHttpHeaders = new HttpHeaders();
	responseHttpHeaders.setBearerAuth(authorizationBody.get(TOKEN_KEY));
	return responseHttpHeaders;
}
 
Example 20
@Test // SPR-16650
public void fromRequestWithForwardedPrefix() throws Exception {
	this.request.addHeader("X-Forwarded-Prefix", "/prefix");
	this.request.setContextPath("/mvc-showcase");
	this.request.setRequestURI("/mvc-showcase/bar");

	HttpServletRequest requestToUse = adaptFromForwardedHeaders(this.request);
	UriComponents result =  ServletUriComponentsBuilder.fromRequest(requestToUse).build();

	assertEquals("http://localhost/prefix/bar", result.toUriString());
}
 
Example 21
@Test
public void create_URI_from_http_request () {
	
	MockHttpServletRequest request = new MockHttpServletRequest();
	
	UriComponents ucb =
	        ServletUriComponentsBuilder
		        .fromContextPath(request)
		        .path("/examples/java")
		        .build();

	URI uri = ucb.toUri();
	
	assertEquals("http://localhost/examples/java", uri.toString());
}
 
Example 22
@Test
public void fromMethodNameTypeLevelPathVariable() {
	this.request.setContextPath("/myapp");
	UriComponents uriComponents = fromMethodName(
			PersonsAddressesController.class, "getAddressesForCountry", "DE").buildAndExpand("1");

	assertThat(uriComponents.toUriString(), is("http://localhost/myapp/people/1/addresses/DE"));
}
 
Example 23
@Test
public void fromMethodNameTypeLevelPathVariable() {
	this.request.setContextPath("/myapp");
	UriComponents uriComponents = fromMethodName(
			PersonsAddressesController.class, "getAddressesForCountry", "DE").buildAndExpand("1");

	assertThat(uriComponents.toUriString(), is("http://localhost/myapp/people/1/addresses/DE"));
}
 
Example 24
Source Project: vics   Source File: VoterTest.java    License: MIT License 5 votes vote down vote up
@Test
public void returnsTheElectorsWhenSearchingByAttributes() throws Exception {
    when(sessionService.extractUserFromPrincipal(any(Principal.class)))
            .thenReturn(Try.success(earlsdon()));
    pafApiStub.willSearchVoters("CV46PL", "McCall", "E05001221");

    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add("surname", "McCall");
    params.add("postcode", "CV46PL");
    params.add("wardCode", "E05001221");
    UriComponents uriComponents = UriComponentsBuilder.fromPath("/elector")
            .queryParams(params)
            .build();

    String url = uriComponents.toUriString();

    mockMvc.perform(get(url)
            .accept(APPLICATION_JSON))
            .andDo(print())
            .andExpect(status().isOk())
            .andExpect(jsonPath("$[0].full_name", is("McCall, John B")))
            .andExpect(jsonPath("$[0].first_name", is("John B")))
            .andExpect(jsonPath("$[0].surname", is("McCall")))
            .andExpect(jsonPath("$[0].ern", is("E050097474-LFF-305-0")))
            .andExpect(jsonPath("$[0].address.postcode", is("CV4 6PL")))
            .andExpect(jsonPath("$[0].address.line_1", is("Grange Farm House")))
            .andExpect(jsonPath("$[0].address.line_2", is("Crompton Lane")))
            .andExpect(jsonPath("$[0].address.post_town", is("Coventry")));
}
 
Example 25
@Test
public void fromMethodNameWithCustomBaseUrlViaStaticCall() {
	UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("https://example.org:9090/base");
	UriComponents uriComponents = fromMethodName(builder, ControllerWithMethods.class,
			"methodWithPathVariable", "1").build();

	assertEquals("https://example.org:9090/base/something/1/foo", uriComponents.toString());
	assertEquals("https://example.org:9090/base", builder.toUriString());
}
 
Example 26
Source Project: mirrorgate   Source File: SlackServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public SlackDTO getToken(final String team, final String clientId, final String clientSecret, final String code) {
    final UriComponents uri = UriComponentsBuilder.newInstance()
        .scheme("https")
        .host(team + ".slack.com")
        .path("/api/oauth.access")
        .queryParam("client_id", clientId)
        .queryParam("client_secret", clientSecret)
        .queryParam("code", code)
        .build()
        .encode();

    return restTemplate.getForObject(uri.toUriString(), SlackDTO.class);
}
 
Example 27
Source Project: netty-cookbook   Source File: ServletNettyChannelHandler.java    License: Apache License 2.0 5 votes vote down vote up
private MockHttpServletRequest createHttpServletRequest(FullHttpRequest fullHttpReq) {
	UriComponents uriComponents = UriComponentsBuilder.fromUriString(fullHttpReq.getUri()).build();

	MockHttpServletRequest servletRequest = new MockHttpServletRequest(this.servletContext);
	servletRequest.setRequestURI(uriComponents.getPath());
	servletRequest.setPathInfo(uriComponents.getPath());
	servletRequest.setMethod(fullHttpReq.getMethod().name());
	servletRequest.setCharacterEncoding(UTF_8);

	if (uriComponents.getScheme() != null) {
		servletRequest.setScheme(uriComponents.getScheme());
	}
	if (uriComponents.getHost() != null) {
		servletRequest.setServerName(uriComponents.getHost());
	}
	if (uriComponents.getPort() != -1) {
		servletRequest.setServerPort(uriComponents.getPort());
	}
	
	copyHttpHeaders(fullHttpReq, servletRequest);
	copyHttpBodyData(fullHttpReq, servletRequest);
	
	copyQueryParams(uriComponents, servletRequest);
	copyToServletCookie(fullHttpReq, servletRequest);
	
	return servletRequest;
}
 
Example 28
@Test  // gh-22656
public void fromMethodNameWithOptionalNamedParam() {
	UriComponents uriComponents = fromMethodName(ControllerWithMethods.class,
			"methodWithOptionalNamedParam", Optional.of("foo")).build();

	assertThat(uriComponents.toUriString(),
			is("http://localhost/something/optional-param-with-name?search=foo"));
}
 
Example 29
@Test
public void fromMethodNameWithCustomBaseUrlViaInstance() {
	UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("http://example.org:9090/base");
	MvcUriComponentsBuilder mvcBuilder = relativeTo(builder);
	UriComponents uriComponents = mvcBuilder.withMethodName(ControllerWithMethods.class,
			"methodWithPathVariable", "1").build();

	assertEquals("http://example.org:9090/base/something/1/foo", uriComponents.toString());
	assertEquals("http://example.org:9090/base", builder.toUriString());
}
 
Example 30
@Test
public void fromMethodCallOnSubclass() {
	UriComponents uriComponents = fromMethodCall(on(ExtendedController.class).myMethod(null)).build();

	assertThat(uriComponents.toUriString(), startsWith("http://localhost"));
	assertThat(uriComponents.toUriString(), endsWith("/extended/else"));
}