|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2012-2020 the original author or authors. |
|
|
|
|
* Copyright 2012-2023 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -378,7 +378,15 @@ public class MvcUriComponentsBuilderTests {
@@ -378,7 +378,15 @@ public class MvcUriComponentsBuilderTests {
|
|
|
|
|
assertThat(uriComponents.encode().toUri().toString()).isEqualTo("http://localhost/hotels/42/bookings/21"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-16710
|
|
|
|
|
@Test // SPR-16710
|
|
|
|
|
public void fromMethodCallWithCharSequenceReturnType() { |
|
|
|
|
UriComponents uriComponents = fromMethodCall( |
|
|
|
|
on(BookingControllerWithCharSequence.class).getBooking(21L)).buildAndExpand(42); |
|
|
|
|
|
|
|
|
|
assertThat(uriComponents.encode().toUri().toString()).isEqualTo("http://localhost/hotels/42/bookings/21"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-16710
|
|
|
|
|
public void fromMethodCallWithStringReturnType() { |
|
|
|
|
assertThatIllegalStateException().isThrownBy(() -> { |
|
|
|
|
UriComponents uriComponents = fromMethodCall( |
|
|
|
|
@ -397,7 +405,6 @@ public class MvcUriComponentsBuilderTests {
@@ -397,7 +405,6 @@ public class MvcUriComponentsBuilderTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromMappingNamePlain() { |
|
|
|
|
|
|
|
|
|
initWebApplicationContext(WebConfig.class); |
|
|
|
|
|
|
|
|
|
this.request.setServerName("example.org"); |
|
|
|
|
@ -411,7 +418,6 @@ public class MvcUriComponentsBuilderTests {
@@ -411,7 +418,6 @@ public class MvcUriComponentsBuilderTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromMappingNameWithCustomBaseUrl() { |
|
|
|
|
|
|
|
|
|
initWebApplicationContext(WebConfig.class); |
|
|
|
|
|
|
|
|
|
UriComponentsBuilder baseUrl = UriComponentsBuilder.fromUriString("https://example.org:9999/base"); |
|
|
|
|
@ -420,9 +426,8 @@ public class MvcUriComponentsBuilderTests {
@@ -420,9 +426,8 @@ public class MvcUriComponentsBuilderTests {
|
|
|
|
|
assertThat(url).isEqualTo("https://example.org:9999/base/people/123/addresses/DE"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-17027
|
|
|
|
|
@Test // SPR-17027
|
|
|
|
|
public void fromMappingNameWithEncoding() { |
|
|
|
|
|
|
|
|
|
initWebApplicationContext(WebConfig.class); |
|
|
|
|
|
|
|
|
|
this.request.setServerName("example.org"); |
|
|
|
|
@ -436,7 +441,6 @@ public class MvcUriComponentsBuilderTests {
@@ -436,7 +441,6 @@ public class MvcUriComponentsBuilderTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromMappingNameWithPathWithoutLeadingSlash() { |
|
|
|
|
|
|
|
|
|
initWebApplicationContext(PathWithoutLeadingSlashConfig.class); |
|
|
|
|
|
|
|
|
|
this.request.setServerName("example.org"); |
|
|
|
|
@ -450,7 +454,6 @@ public class MvcUriComponentsBuilderTests {
@@ -450,7 +454,6 @@ public class MvcUriComponentsBuilderTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromControllerWithPrefix() { |
|
|
|
|
|
|
|
|
|
initWebApplicationContext(PathPrefixWebConfig.class); |
|
|
|
|
|
|
|
|
|
this.request.setScheme("https"); |
|
|
|
|
@ -463,7 +466,6 @@ public class MvcUriComponentsBuilderTests {
@@ -463,7 +466,6 @@ public class MvcUriComponentsBuilderTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromMethodWithPrefix() { |
|
|
|
|
|
|
|
|
|
initWebApplicationContext(PathPrefixWebConfig.class); |
|
|
|
|
|
|
|
|
|
this.request.setScheme("https"); |
|
|
|
|
@ -691,6 +693,17 @@ public class MvcUriComponentsBuilderTests {
@@ -691,6 +693,17 @@ public class MvcUriComponentsBuilderTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
|
@RequestMapping("/hotels/{hotel}") |
|
|
|
|
static class BookingControllerWithCharSequence { |
|
|
|
|
|
|
|
|
|
@GetMapping("/bookings/{booking}") |
|
|
|
|
public CharSequence getBooking(@PathVariable Long booking) { |
|
|
|
|
return "url"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
|
@RequestMapping("/hotels/{hotel}") |
|
|
|
|
static class BookingControllerWithString { |
|
|
|
|
|