KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > imap > MessageSetTokenizerTest


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.imap;
17
18 import java.util.List JavaDoc;
19
20 import junit.framework.TestCase;
21
22
23 /**
24  * Boundary testcases.
25  *
26  * @author fdietz
27  */

28 public class MessageSetTokenizerTest extends TestCase {
29     public void test() {
30         int max = 1000;
31
32         Object JavaDoc[] uids = new Object JavaDoc[max];
33
34         for (int i = 0; i < max; i++)
35             uids[i] = new Integer JavaDoc(i);
36
37         int stepSize = 100;
38         MessageSetTokenizer tok = new MessageSetTokenizer(uids, stepSize);
39
40         while (tok.hasNext()) {
41             List JavaDoc sublist = (List JavaDoc) tok.next();
42
43             System.out.print("start=" + sublist.get(0));
44             System.out.println(" end=" + sublist.get(sublist.size() - 1));
45
46             // if this is the last token, check if the last element
47
// is the same than in the array
48
if (tok.hasNext() == false) {
49                 assertEquals(sublist.get(sublist.size() - 1),
50                     uids[uids.length - 1]);
51             }
52         }
53     }
54
55     public void test2() {
56         int max = 1001;
57
58         Object JavaDoc[] uids = new Object JavaDoc[max];
59
60         for (int i = 0; i < max; i++)
61             uids[i] = new Integer JavaDoc(i);
62
63         int stepSize = 100;
64         MessageSetTokenizer tok = new MessageSetTokenizer(uids, stepSize);
65
66         while (tok.hasNext()) {
67             List JavaDoc sublist = (List JavaDoc) tok.next();
68
69             System.out.print("start=" + sublist.get(0));
70             System.out.println(" end=" + sublist.get(sublist.size() - 1));
71
72             // if this is the last token, check if the last element
73
// is the same than in the array
74
if (tok.hasNext() == false) {
75                 assertEquals(sublist.get(sublist.size() - 1),
76                     uids[uids.length - 1]);
77             }
78         }
79     }
80
81     public void test3() {
82         int max = 999;
83
84         Object JavaDoc[] uids = new Object JavaDoc[max];
85
86         for (int i = 0; i < max; i++)
87             uids[i] = new Integer JavaDoc(i);
88
89         int stepSize = 100;
90         MessageSetTokenizer tok = new MessageSetTokenizer(uids, stepSize);
91
92         while (tok.hasNext()) {
93             List JavaDoc sublist = (List JavaDoc) tok.next();
94
95             System.out.print("start=" + sublist.get(0));
96             System.out.println(" end=" + sublist.get(sublist.size() - 1));
97
98             // if this is the last token, check if the last element
99
// is the same than in the array
100
if (tok.hasNext() == false) {
101                 assertEquals(sublist.get(sublist.size() - 1),
102                     uids[uids.length - 1]);
103             }
104         }
105     }
106
107     public void test4() {
108         int max = 99;
109
110         Object JavaDoc[] uids = new Object JavaDoc[max];
111
112         for (int i = 0; i < max; i++)
113             uids[i] = new Integer JavaDoc(i);
114
115         int stepSize = 100;
116         MessageSetTokenizer tok = new MessageSetTokenizer(uids, stepSize);
117
118         while (tok.hasNext()) {
119             List JavaDoc sublist = (List JavaDoc) tok.next();
120
121             System.out.print("start=" + sublist.get(0));
122             System.out.println(" end=" + sublist.get(sublist.size() - 1));
123
124             // if this is the last token, check if the last element
125
// is the same than in the array
126
if (tok.hasNext() == false) {
127                 assertEquals(sublist.get(sublist.size() - 1),
128                     uids[uids.length - 1]);
129             }
130         }
131     }
132
133     public void test5() {
134         int max = 1;
135
136         Object JavaDoc[] uids = new Object JavaDoc[max];
137
138         for (int i = 0; i < max; i++)
139             uids[i] = new Integer JavaDoc(i);
140
141         int stepSize = 100;
142         MessageSetTokenizer tok = new MessageSetTokenizer(uids, stepSize);
143
144         while (tok.hasNext()) {
145             List JavaDoc sublist = (List JavaDoc) tok.next();
146
147             System.out.print("start=" + sublist.get(0));
148             System.out.println(" end=" + sublist.get(sublist.size() - 1));
149
150             // if this is the last token, check if the last element
151
// is the same than in the array
152
if (tok.hasNext() == false) {
153                 assertEquals(sublist.get(sublist.size() - 1),
154                     uids[uids.length - 1]);
155             }
156         }
157     }
158 }
159
Popular Tags