|
1 | 1 | /* |
2 | | - * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2014, 2025 Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials are made available under the |
5 | 5 | * terms of the Eclipse Public License v. 2.0, which is available at |
@@ -151,27 +151,46 @@ public void testCreateCookies() { |
151 | 151 | @Test |
152 | 152 | public void testMultipleCookiesWithSameName(){ |
153 | 153 |
|
154 | | - String cookieHeader = "kobe=longeststring; kobe=shortstring"; |
| 154 | + String cookieHeader = "kobe=oldeststring; kobe=neweststring"; |
155 | 155 | Map<String, Cookie> cookies = HttpHeaderReader.readCookies(cookieHeader); |
156 | 156 | assertEquals(cookies.size(), 1); |
157 | 157 | Cookie c = cookies.get("kobe"); |
158 | 158 | assertEquals(c.getVersion(), 0); |
159 | 159 | assertEquals("kobe", c.getName()); |
160 | | - assertEquals("longeststring", c.getValue()); |
| 160 | + assertEquals("neweststring", c.getValue()); |
161 | 161 |
|
162 | | - cookieHeader = "bryant=longeststring; bryant=shortstring; fred=shortstring ;fred=longeststring;$Path=/path"; |
| 162 | + cookieHeader = "bryant=longeststring; bryant=neweststring; fred=oldeststring ;fred=neweststring;$Path=/path"; |
163 | 163 | cookies = HttpHeaderReader.readCookies(cookieHeader); |
164 | 164 | assertEquals(cookies.size(), 2); |
165 | 165 | c = cookies.get("bryant"); |
166 | 166 | assertEquals(c.getVersion(), 0); |
167 | 167 | assertEquals("bryant", c.getName()); |
168 | | - assertEquals("longeststring", c.getValue()); |
| 168 | + assertEquals("neweststring", c.getValue()); |
169 | 169 | c = cookies.get("fred"); |
170 | 170 | assertEquals(c.getVersion(), 0); |
171 | 171 | assertEquals("fred", c.getName()); |
172 | | - assertEquals("longeststring", c.getValue()); |
| 172 | + assertEquals("neweststring", c.getValue()); |
173 | 173 | assertEquals("/path", c.getPath()); |
174 | 174 |
|
| 175 | + cookieHeader = "cookiewithpath=longeststring;$Path=/path; cookiewithpath=string1;$Path=/path;" |
| 176 | + + " cookiewithpath=string2;$Path=/path ;cookiewithpath=string3;$Path=/path"; |
| 177 | + cookies = HttpHeaderReader.readCookies(cookieHeader); |
| 178 | + assertEquals(cookies.size(), 1); |
| 179 | + c = cookies.get("cookiewithpath"); |
| 180 | + assertEquals(c.getVersion(), 0); |
| 181 | + assertEquals("cookiewithpath", c.getName()); |
| 182 | + assertEquals("string3", c.getValue()); |
| 183 | + |
| 184 | + cookieHeader = "cookiewithpath=longeststring;$Path=/path/added/path; cookiewithpath=string1;$Path=/path;" |
| 185 | + + " cookiewithpath=string2;$Path=/path ;cookiewithpath=string3;$Path=/path"; |
| 186 | + cookies = HttpHeaderReader.readCookies(cookieHeader); |
| 187 | + assertEquals(cookies.size(), 1); |
| 188 | + c = cookies.get("cookiewithpath"); |
| 189 | + assertEquals(c.getVersion(), 0); |
| 190 | + assertEquals("cookiewithpath", c.getName()); |
| 191 | + assertEquals("longeststring", c.getValue()); |
| 192 | + assertEquals("/path/added/path", c.getPath()); |
| 193 | + |
175 | 194 | } |
176 | 195 |
|
177 | 196 | @Test |
|
0 commit comments