Skip to content

Commit a34ceb4

Browse files
committed
Polish "Allow UriTemplate to be built with an empty template"
See gh-32432
1 parent 1b25a15 commit a34ceb4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

spring-web/src/main/java/org/springframework/web/util/UriTemplate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-web/src/test/java/org/springframework/web/util/UriTemplateTests.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,16 @@
3636
*/
3737
class UriTemplateTests {
3838

39+
@Test
40+
void emptyPathDoesNotThrowException() {
41+
assertThatNoException().isThrownBy(() -> new UriTemplate(""));
42+
}
43+
44+
@Test
45+
void nullPathThrowsException() {
46+
assertThatIllegalArgumentException().isThrownBy(() -> new UriTemplate(null));
47+
}
48+
3949
@Test
4050
void getVariableNames() {
4151
UriTemplate template = new UriTemplate("/hotels/{hotel}/bookings/{booking}");
@@ -219,14 +229,4 @@ void expandWithAtSign() {
219229
assertThat(uri.toString()).isEqualTo("http://localhost/query=foo@bar");
220230
}
221231

222-
@Test
223-
void emptyPathDoesNotThrowException() {
224-
assertThatNoException().isThrownBy(() -> new UriTemplate(""));
225-
}
226-
227-
@Test
228-
void emptyPathThrowsException() {
229-
assertThatIllegalArgumentException().isThrownBy(() -> new UriTemplate(null));
230-
}
231-
232232
}

0 commit comments

Comments
 (0)