Skip to content

Commit 7a8afd8

Browse files
authored
MLE-30667 Added toString() override to ClientCookie (#1949)
Added a toString() override that returns `name + "=" + value`.
1 parent e992d81 commit 7a8afd8

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

marklogic-client-api/src/main/java/com/marklogic/client/ClientCookie.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
2+
* Copyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
33
*/
44
package com.marklogic.client;
55

@@ -55,4 +55,9 @@ public int getMaxAge() {
5555
public String getValue() {
5656
return value;
5757
}
58+
59+
@Override
60+
public String toString() {
61+
return name + "=" + value;
62+
}
5863
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
3+
*/
4+
package com.marklogic.client.test;
5+
6+
import com.marklogic.client.ClientCookie;
7+
import org.junit.jupiter.api.Test;
8+
9+
import static org.junit.jupiter.api.Assertions.assertEquals;
10+
11+
public class ClientCookieTest {
12+
13+
@Test
14+
void toStringReturnsNameEqualsValue() {
15+
ClientCookie cookie = new ClientCookie("HostId", "abc123", Long.MAX_VALUE, "localhost", "/", false);
16+
assertEquals("HostId=abc123", cookie.toString(),
17+
"ClientCookie.toString() must return name=value for correct Cookie header formatting");
18+
}
19+
20+
@Test
21+
void toStringWithEmptyValue() {
22+
ClientCookie cookie = new ClientCookie("SessionId", "", Long.MAX_VALUE, "localhost", "/", false);
23+
assertEquals("SessionId=", cookie.toString());
24+
}
25+
}

0 commit comments

Comments
 (0)