Merge branch '6.1.x'

This commit is contained in:
Juergen Hoeller 2024-03-13 18:07:21 +01:00
commit 7f7c0d59f6
2 changed files with 34 additions and 4 deletions

View File

@ -25,15 +25,15 @@ dependencies {
constraints {
api("com.fasterxml:aalto-xml:1.3.2")
api("com.fasterxml.woodstox:woodstox-core:6.5.1")
api("com.fasterxml.woodstox:woodstox-core:6.6.1")
api("com.github.ben-manes.caffeine:caffeine:3.1.8")
api("com.github.librepdf:openpdf:1.3.42")
api("com.google.code.findbugs:findbugs:3.0.1")
api("com.google.code.findbugs:jsr305:3.0.2")
api("com.google.code.gson:gson:2.10.1")
api("com.google.protobuf:protobuf-java-util:3.25.2")
api("com.google.protobuf:protobuf-java-util:3.25.3")
api("com.h2database:h2:2.2.224")
api("com.jayway.jsonpath:json-path:2.8.0")
api("com.jayway.jsonpath:json-path:2.9.0")
api("com.rometools:rome:1.19.0")
api("com.squareup.okhttp3:mockwebserver:3.14.9")
api("com.squareup.okhttp3:okhttp:3.14.9")
@ -42,7 +42,7 @@ dependencies {
api("com.sun.xml.bind:jaxb-core:3.0.2")
api("com.sun.xml.bind:jaxb-impl:3.0.2")
api("com.sun.xml.bind:jaxb-xjc:3.0.2")
api("com.thoughtworks.qdox:qdox:2.0.3")
api("com.thoughtworks.qdox:qdox:2.1.0")
api("com.thoughtworks.xstream:xstream:1.4.20")
api("commons-io:commons-io:2.15.0")
api("de.bechte.junit:junit-hierarchicalcontextrunner:4.12.2")

View File

@ -53,6 +53,13 @@ class UriTemplateTests {
assertThat(variableNames).as("Invalid variable names").isEqualTo(Arrays.asList("hotel", "booking"));
}
@Test
void getVariableNamesFromEmpty() {
UriTemplate template = new UriTemplate("");
List<String> variableNames = template.getVariableNames();
assertThat(variableNames).isEmpty();
}
@Test
void expandVarArgs() {
UriTemplate template = new UriTemplate("/hotels/{hotel}/bookings/{booking}");
@ -60,6 +67,13 @@ class UriTemplateTests {
assertThat(result).as("Invalid expanded template").isEqualTo(URI.create("/hotels/1/bookings/42"));
}
@Test
void expandVarArgsFromEmpty() {
UriTemplate template = new UriTemplate("");
URI result = template.expand();
assertThat(result).as("Invalid expanded template").isEqualTo(URI.create(""));
}
@Test // SPR-9712
void expandVarArgsWithArrayValue() {
UriTemplate template = new UriTemplate("/sum?numbers={numbers}");
@ -135,6 +149,15 @@ class UriTemplateTests {
assertThat(template.matches(null)).as("UriTemplate matches").isFalse();
}
@Test
void matchesAgainstEmpty() {
UriTemplate template = new UriTemplate("");
assertThat(template.matches("/hotels/1/bookings/42")).as("UriTemplate matches").isFalse();
assertThat(template.matches("/hotels/bookings")).as("UriTemplate matches").isFalse();
assertThat(template.matches("")).as("UriTemplate does not match").isTrue();
assertThat(template.matches(null)).as("UriTemplate matches").isFalse();
}
@Test
void matchesCustomRegex() {
UriTemplate template = new UriTemplate("/hotels/{hotel:\\d+}");
@ -153,6 +176,13 @@ class UriTemplateTests {
assertThat(result).as("Invalid match").isEqualTo(expected);
}
@Test
void matchAgainstEmpty() {
UriTemplate template = new UriTemplate("");
Map<String, String> result = template.match("/hotels/1/bookings/42");
assertThat(result).as("Invalid match").isEmpty();
}
@Test
void matchCustomRegex() {
Map<String, String> expected = new HashMap<>(2);