"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java" between
httpcomponents-client-4.5.6-src.tar.gz and httpcomponents-client-4.5.7-src.tar.gz

About: HttpComponents is an Apache project responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols. Java sources.

TestRFC6265CookieSpec.java  (httpcomponents-client-4.5.6-src):TestRFC6265CookieSpec.java  (httpcomponents-client-4.5.7-src)
skipping to change at line 43 skipping to change at line 43
import org.apache.http.Header; import org.apache.http.Header;
import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.ClientCookie;
import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie; import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.MalformedCookieException; import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SetCookie; import org.apache.http.cookie.SetCookie;
import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicHeader;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mockito; import org.mockito.Mockito;
public class TestRFC6265CookieSpec { public class TestRFC6265CookieSpec {
@Test @Test
public void testParseCookieBasics() throws Exception { public void testParseCookieBasics() throws Exception {
final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttribu teHandler.class); final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttribu teHandler.class);
Mockito.when(h1.getAttributeName()).thenReturn("this"); Mockito.when(h1.getAttributeName()).thenReturn("this");
final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttribu teHandler.class); final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttribu teHandler.class);
Mockito.when(h2.getAttributeName()).thenReturn("that"); Mockito.when(h2.getAttributeName()).thenReturn("that");
skipping to change at line 71 skipping to change at line 72
final Cookie cookie = cookies.get(0); final Cookie cookie = cookies.get(0);
Assert.assertEquals("name", cookie.getName()); Assert.assertEquals("name", cookie.getName());
Assert.assertEquals("value", cookie.getValue()); Assert.assertEquals("value", cookie.getValue());
Assert.assertEquals("/path", cookie.getPath()); Assert.assertEquals("/path", cookie.getPath());
Assert.assertEquals("host", cookie.getDomain()); Assert.assertEquals("host", cookie.getDomain());
Assert.assertTrue(cookie instanceof ClientCookie); Assert.assertTrue(cookie instanceof ClientCookie);
final ClientCookie clientCookie = (ClientCookie) cookie; final ClientCookie clientCookie = (ClientCookie) cookie;
Assert.assertEquals("stuff", clientCookie.getAttribute("this")); Assert.assertEquals("stuff", clientCookie.getAttribute("this"));
Assert.assertEquals(null, clientCookie.getAttribute("that")); Assert.assertEquals(null, clientCookie.getAttribute("that"));
Mockito.verify(h1).parse(Mockito.<SetCookie>any(), Mockito.eq("stuff")); Mockito.verify(h1).parse(Matchers.<SetCookie>any(), Matchers.eq("stuff")
Mockito.verify(h2, Mockito.never()).parse(Mockito.<SetCookie>any(), Mock );
ito.anyString()); Mockito.verify(h2, Mockito.never()).parse(Matchers.<SetCookie>any(), Mat
chers.anyString());
} }
@Test @Test
public void testParseCookieQuotedValue() throws Exception { public void testParseCookieQuotedValue() throws Exception {
final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(); final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec();
final Header header = new BasicHeader("Set-Cookie", "name = \" one, two, three; four \" ; this = stuff;"); final Header header = new BasicHeader("Set-Cookie", "name = \" one, two, three; four \" ; this = stuff;");
final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true) ; final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true) ;
final List<Cookie> cookies = cookiespec.parse(header, origin); final List<Cookie> cookies = cookiespec.parse(header, origin);
skipping to change at line 318 skipping to change at line 319
public void testParseCookieMultipleAttributes() throws Exception { public void testParseCookieMultipleAttributes() throws Exception {
final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttribu teHandler.class); final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttribu teHandler.class);
Mockito.when(h1.getAttributeName()).thenReturn("this"); Mockito.when(h1.getAttributeName()).thenReturn("this");
final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(h1); final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(h1);
final Header header = new BasicHeader("Set-Cookie", "name = value ; this = stuff; this = morestuff;"); final Header header = new BasicHeader("Set-Cookie", "name = value ; this = stuff; this = morestuff;");
final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true) ; final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true) ;
cookiespec.parse(header, origin); cookiespec.parse(header, origin);
Mockito.verify(h1).parse(Mockito.<SetCookie>any(), Mockito.eq("morestuff Mockito.verify(h1).parse(Matchers.<SetCookie>any(), Matchers.eq("morestu
")); ff"));
Mockito.verify(h1, Mockito.times(1)).parse(Mockito.<SetCookie>any(), Moc Mockito.verify(h1, Mockito.times(1)).parse(Matchers.<SetCookie>any(), Ma
kito.anyString()); tchers.anyString());
} }
@Test @Test
public void testParseCookieMaxAgeOverExpires() throws Exception { public void testParseCookieMaxAgeOverExpires() throws Exception {
final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttribu teHandler.class); final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttribu teHandler.class);
Mockito.when(h1.getAttributeName()).thenReturn("Expires"); Mockito.when(h1.getAttributeName()).thenReturn("Expires");
final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttribu teHandler.class); final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttribu teHandler.class);
Mockito.when(h2.getAttributeName()).thenReturn("Max-Age"); Mockito.when(h2.getAttributeName()).thenReturn("Max-Age");
final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(h1, h2); final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(h1, h2);
final Header header = new BasicHeader("Set-Cookie", "name = value ; expi res = stuff; max-age = otherstuff;"); final Header header = new BasicHeader("Set-Cookie", "name = value ; expi res = stuff; max-age = otherstuff;");
final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true) ; final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true) ;
cookiespec.parse(header, origin); cookiespec.parse(header, origin);
Mockito.verify(h1, Mockito.never()).parse(Mockito.<SetCookie>any(), Mock Mockito.verify(h1, Mockito.never()).parse(Matchers.<SetCookie>any(), Mat
ito.anyString()); chers.anyString());
Mockito.verify(h2).parse(Mockito.<SetCookie>any(), Mockito.eq("otherstuf Mockito.verify(h2).parse(Matchers.<SetCookie>any(), Matchers.eq("otherst
f")); uff"));
} }
} }
 End of changes. 4 change blocks. 
11 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)