Skip to content

Commit 97a89d6

Browse files
committed
Polish contribution
See gh-27303
1 parent 10a90d3 commit 97a89d6

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 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/UrlPathHelperTests.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 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.
@@ -24,7 +24,7 @@
2424
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
2525

2626
import static org.assertj.core.api.Assertions.assertThat;
27-
import static org.assertj.core.api.Assertions.assertThatCode;
27+
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
2828

2929
/**
3030
* Unit tests for {@link UrlPathHelper}.
@@ -168,8 +168,24 @@ public void getLookupPathWithSemicolonContentAndNullPathInfo() {
168168
}
169169

170170
@Test // gh-27303
171-
public void shouldRemoveSemicolonContentWithReadOnlyInstance() {
172-
assertThatCode(UrlPathHelper.defaultInstance::shouldRemoveSemicolonContent).doesNotThrowAnyException();
171+
public void defaultInstanceReadOnlyBehavior() {
172+
UrlPathHelper helper = UrlPathHelper.defaultInstance;
173+
174+
assertThatIllegalArgumentException()
175+
.isThrownBy(() -> helper.setAlwaysUseFullPath(true))
176+
.withMessage("This instance cannot be modified");
177+
assertThatIllegalArgumentException()
178+
.isThrownBy(() -> helper.setUrlDecode(true))
179+
.withMessage("This instance cannot be modified");
180+
assertThatIllegalArgumentException()
181+
.isThrownBy(() -> helper.setRemoveSemicolonContent(true))
182+
.withMessage("This instance cannot be modified");
183+
assertThatIllegalArgumentException()
184+
.isThrownBy(() -> helper.setDefaultEncoding("UTF-8"))
185+
.withMessage("This instance cannot be modified");
186+
187+
assertThat(helper.isUrlDecode()).isTrue();
188+
assertThat(helper.shouldRemoveSemicolonContent()).isTrue();
173189
}
174190

175191

0 commit comments

Comments
 (0)