001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016: package org.columba.mail.imap;
017:
018: import java.util.List;
019:
020: import junit.framework.TestCase;
021:
022: /**
023: * Boundary testcases.
024: *
025: * @author fdietz
026: */
027: public class MessageSetTokenizerTest extends TestCase {
028: public void test() {
029: int max = 1000;
030:
031: Object[] uids = new Object[max];
032:
033: for (int i = 0; i < max; i++)
034: uids[i] = new Integer(i);
035:
036: int stepSize = 100;
037: MessageSetTokenizer tok = new MessageSetTokenizer(uids,
038: stepSize);
039:
040: while (tok.hasNext()) {
041: List sublist = (List) tok.next();
042:
043: System.out.print("start=" + sublist.get(0));
044: System.out.println(" end="
045: + sublist.get(sublist.size() - 1));
046:
047: // if this is the last token, check if the last element
048: // is the same than in the array
049: if (tok.hasNext() == false) {
050: assertEquals(sublist.get(sublist.size() - 1),
051: uids[uids.length - 1]);
052: }
053: }
054: }
055:
056: public void test2() {
057: int max = 1001;
058:
059: Object[] uids = new Object[max];
060:
061: for (int i = 0; i < max; i++)
062: uids[i] = new Integer(i);
063:
064: int stepSize = 100;
065: MessageSetTokenizer tok = new MessageSetTokenizer(uids,
066: stepSize);
067:
068: while (tok.hasNext()) {
069: List sublist = (List) tok.next();
070:
071: System.out.print("start=" + sublist.get(0));
072: System.out.println(" end="
073: + sublist.get(sublist.size() - 1));
074:
075: // if this is the last token, check if the last element
076: // is the same than in the array
077: if (tok.hasNext() == false) {
078: assertEquals(sublist.get(sublist.size() - 1),
079: uids[uids.length - 1]);
080: }
081: }
082: }
083:
084: public void test3() {
085: int max = 999;
086:
087: Object[] uids = new Object[max];
088:
089: for (int i = 0; i < max; i++)
090: uids[i] = new Integer(i);
091:
092: int stepSize = 100;
093: MessageSetTokenizer tok = new MessageSetTokenizer(uids,
094: stepSize);
095:
096: while (tok.hasNext()) {
097: List sublist = (List) tok.next();
098:
099: System.out.print("start=" + sublist.get(0));
100: System.out.println(" end="
101: + sublist.get(sublist.size() - 1));
102:
103: // if this is the last token, check if the last element
104: // is the same than in the array
105: if (tok.hasNext() == false) {
106: assertEquals(sublist.get(sublist.size() - 1),
107: uids[uids.length - 1]);
108: }
109: }
110: }
111:
112: public void test4() {
113: int max = 99;
114:
115: Object[] uids = new Object[max];
116:
117: for (int i = 0; i < max; i++)
118: uids[i] = new Integer(i);
119:
120: int stepSize = 100;
121: MessageSetTokenizer tok = new MessageSetTokenizer(uids,
122: stepSize);
123:
124: while (tok.hasNext()) {
125: List sublist = (List) tok.next();
126:
127: System.out.print("start=" + sublist.get(0));
128: System.out.println(" end="
129: + sublist.get(sublist.size() - 1));
130:
131: // if this is the last token, check if the last element
132: // is the same than in the array
133: if (tok.hasNext() == false) {
134: assertEquals(sublist.get(sublist.size() - 1),
135: uids[uids.length - 1]);
136: }
137: }
138: }
139:
140: public void test5() {
141: int max = 1;
142:
143: Object[] uids = new Object[max];
144:
145: for (int i = 0; i < max; i++)
146: uids[i] = new Integer(i);
147:
148: int stepSize = 100;
149: MessageSetTokenizer tok = new MessageSetTokenizer(uids,
150: stepSize);
151:
152: while (tok.hasNext()) {
153: List sublist = (List) tok.next();
154:
155: System.out.print("start=" + sublist.get(0));
156: System.out.println(" end="
157: + sublist.get(sublist.size() - 1));
158:
159: // if this is the last token, check if the last element
160: // is the same than in the array
161: if (tok.hasNext() == false) {
162: assertEquals(sublist.get(sublist.size() - 1),
163: uids[uids.length - 1]);
164: }
165: }
166: }
167: }
|