Fixed #1551 Moved CookieCutter to jetty-http
This commit is contained in:
parent
580310f523
commit
3bcbed7120
|
@ -57,9 +57,11 @@ public class Cookies extends CookieCutter
|
|||
super(compliance);
|
||||
}
|
||||
|
||||
|
||||
public void addCookieField(String rawField)
|
||||
{
|
||||
if (_set)
|
||||
throw new IllegalStateException();
|
||||
|
||||
if (rawField==null)
|
||||
return;
|
||||
rawField=rawField.trim();
|
||||
|
@ -83,6 +85,9 @@ public class Cookies extends CookieCutter
|
|||
|
||||
public Cookie[] getCookies()
|
||||
{
|
||||
if (_set)
|
||||
return _cookies;
|
||||
|
||||
while (_rawFields.size() > _addedFields)
|
||||
{
|
||||
_rawFields.remove(_addedFields);
|
||||
|
|
|
@ -156,4 +156,26 @@ public class CookiesTest
|
|||
assertThat(cookiesX, Matchers.not(Matchers.sameInstance(cookiesY)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSet()
|
||||
{
|
||||
Cookies cutter = new Cookies();
|
||||
cutter.setCookies(new Cookie[]
|
||||
{
|
||||
new Cookie("nameA0","A0"),
|
||||
new Cookie("nameA1","A1"),
|
||||
new Cookie("nameB0","B0"),
|
||||
new Cookie("nameB1","B1"),
|
||||
});
|
||||
|
||||
Cookie[] cookiesX = cutter.getCookies();
|
||||
assertThat(cookiesX.length,is(4));
|
||||
assertThat(cookiesX[0].getName(),is("nameA0"));
|
||||
assertThat(cookiesX[3].getValue(),is("B1"));
|
||||
|
||||
cutter.reset();
|
||||
|
||||
assertThat(cutter.getCookies().length,is(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue