"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient/src/test/java/org/apache/http/impl/client/TestBasicCookieStore.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.

TestBasicCookieStore.java  (httpcomponents-client-4.5.6-src):TestBasicCookieStore.java  (httpcomponents-client-4.5.7-src)
skipping to change at line 52 skipping to change at line 52
/** /**
* Unit tests for {@link BasicCookieStore}. * Unit tests for {@link BasicCookieStore}.
*/ */
public class TestBasicCookieStore { public class TestBasicCookieStore {
@Test @Test
public void testBasics() throws Exception { public void testBasics() throws Exception {
final BasicCookieStore store = new BasicCookieStore(); final BasicCookieStore store = new BasicCookieStore();
store.addCookie(new BasicClientCookie("name1", "value1")); store.addCookie(new BasicClientCookie("name1", "value1"));
store.addCookies(new BasicClientCookie[] {new BasicClientCookie("name2", "value2")}); store.addCookies(new BasicClientCookie[] {new BasicClientCookie("name2", "value2")});
List<Cookie> l = store.getCookies(); List<Cookie> list = store.getCookies();
Assert.assertNotNull(l); Assert.assertNotNull(list);
Assert.assertEquals(2, l.size()); Assert.assertEquals(2, list.size());
Assert.assertEquals("name1", l.get(0).getName()); Assert.assertEquals("name1", list.get(0).getName());
Assert.assertEquals("name2", l.get(1).getName()); Assert.assertEquals("name2", list.get(1).getName());
store.clear(); store.clear();
l = store.getCookies(); list = store.getCookies();
Assert.assertNotNull(l); Assert.assertNotNull(list);
Assert.assertEquals(0, l.size()); Assert.assertEquals(0, list.size());
} }
@Test @Test
public void testExpiredCookie() throws Exception { public void testExpiredCookie() throws Exception {
final BasicCookieStore store = new BasicCookieStore(); final BasicCookieStore store = new BasicCookieStore();
final BasicClientCookie cookie = new BasicClientCookie("name1", "value1" ); final BasicClientCookie cookie = new BasicClientCookie("name1", "value1" );
final Calendar c = Calendar.getInstance(); final Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_YEAR, -10); c.add(Calendar.DAY_OF_YEAR, -10);
cookie.setExpiryDate(c.getTime()); cookie.setExpiryDate(c.getTime());
skipping to change at line 83 skipping to change at line 83
Assert.assertNotNull(l); Assert.assertNotNull(l);
Assert.assertEquals(0, l.size()); Assert.assertEquals(0, l.size());
} }
@Test @Test
public void testSerialization() throws Exception { public void testSerialization() throws Exception {
final BasicCookieStore orig = new BasicCookieStore(); final BasicCookieStore orig = new BasicCookieStore();
orig.addCookie(new BasicClientCookie("name1", "value1")); orig.addCookie(new BasicClientCookie("name1", "value1"));
orig.addCookie(new BasicClientCookie("name2", "value2")); orig.addCookie(new BasicClientCookie("name2", "value2"));
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream(); final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer); final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
outstream.writeObject(orig); outStream.writeObject(orig);
outstream.close(); outStream.close();
final byte[] raw = outbuffer.toByteArray(); final byte[] raw = outbuffer.toByteArray();
final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw); final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
final ObjectInputStream instream = new ObjectInputStream(inbuffer); final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
final BasicCookieStore clone = (BasicCookieStore) instream.readObject(); final BasicCookieStore clone = (BasicCookieStore) inStream.readObject();
final List<Cookie> expected = orig.getCookies(); final List<Cookie> expected = orig.getCookies();
final List<Cookie> clones = clone.getCookies(); final List<Cookie> clones = clone.getCookies();
Assert.assertNotNull(expected); Assert.assertNotNull(expected);
Assert.assertNotNull(clones); Assert.assertNotNull(clones);
Assert.assertEquals(expected.size(), clones.size()); Assert.assertEquals(expected.size(), clones.size());
for (int i = 0; i < expected.size(); i++) { for (int i = 0; i < expected.size(); i++) {
Assert.assertEquals(expected.get(i).getName(), clones.get(i).getName ()); Assert.assertEquals(expected.get(i).getName(), clones.get(i).getName ());
Assert.assertEquals(expected.get(i).getValue(), clones.get(i).getVal ue()); Assert.assertEquals(expected.get(i).getValue(), clones.get(i).getVal ue());
} }
} }
 End of changes. 4 change blocks. 
14 lines changed or deleted 14 lines changed or added

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