KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > util > cursor > impl > ListCursorFeedTest


1 package org.sapia.util.cursor.impl;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 import junit.framework.TestCase;
7
8 /**
9  * @author Yanick Duchesne
10  *
11  * <dl>
12  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2004 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
13  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
14  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
15  * </dl>
16  */

17 public class ListCursorFeedTest extends TestCase{
18   
19   public ListCursorFeedTest(String JavaDoc name){
20     super(name);
21   }
22   
23   public void testRead() throws Exception JavaDoc{
24     Object JavaDoc[] buffer = new Object JavaDoc[4];
25     List JavaDoc items = new ArrayList JavaDoc();
26     for(int i = 1; i <= 12; i++){
27       items.add(""+i);
28     }
29     ListCursorFeed feed = new ListCursorFeed(items);
30     int total = 1;
31     for(int i = 1; i <= 3; i++){
32       int count = feed.read(buffer);
33       super.assertEquals(4, count);
34       for(int j = 0; j < count; j++, total++){
35         super.assertEquals(""+total, buffer[j]);
36       }
37     }
38     super.assertEquals(0, feed.read(buffer));
39   }
40 }
41
Popular Tags