Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public boolean isPartitioned() {
* @return the created cookie
*/
public static MockCookie parse(String setCookieHeader) {
Assert.notNull(setCookieHeader, "Set-Cookie header must not be null");
Assert.hasText(setCookieHeader, "Set-Cookie header must not be null or empty");
String[] cookieParts = setCookieHeader.split("\\s*=\\s*", 2);
Assert.isTrue(cookieParts.length == 2, () -> "Invalid Set-Cookie header '" + setCookieHeader + "'");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ private void assertCookie(MockCookie cookie, String name, String value) {
void parseNullHeader() {
assertThatIllegalArgumentException()
.isThrownBy(() -> MockCookie.parse(null))
.withMessageContaining("Set-Cookie header must not be null");
.withMessageContaining("Set-Cookie header must not be null or empty");
}

@ParameterizedTest
@ValueSource(strings = {"", " "})
void parseEmptyHeader(String header) {
assertThatIllegalArgumentException()
.isThrownBy(() -> MockCookie.parse(header))
.withMessageContaining("Set-Cookie header must not be null or empty");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public boolean isPartitioned() {
* @return the created cookie
*/
public static MockCookie parse(String setCookieHeader) {
Assert.notNull(setCookieHeader, "Set-Cookie header must not be null");
Assert.hasText(setCookieHeader, "Set-Cookie header must not be null or empty");
String[] cookieParts = setCookieHeader.split("\\s*=\\s*", 2);
Assert.isTrue(cookieParts.length == 2, () -> "Invalid Set-Cookie header '" + setCookieHeader + "'");

Expand Down