1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18package tests.api.java.util;
19
20import dalvik.annotation.TestTargetNew;
21import dalvik.annotation.TestTargets;
22import dalvik.annotation.TestLevel;
23import dalvik.annotation.TestTargetClass;
24
25import java.util.Arrays;
26import java.util.Collection;
27import java.util.Enumeration;
28import java.util.HashSet;
29import java.util.Iterator;
30import java.util.LinkedList;
31import java.util.List;
32import java.util.NoSuchElementException;
33import java.util.Vector;
34
35import tests.support.Support_ListTest;
36
37@TestTargetClass(Vector.class)
38public class VectorTest extends junit.framework.TestCase {
39
40    private Vector tVector = new Vector();
41
42    Object[] objArray;
43
44    private String vString = "[Test 0, Test 1, Test 2, Test 3, Test 4, Test 5, Test 6, Test 7, Test 8, Test 9, Test 10, Test 11, Test 12, Test 13, Test 14, Test 15, Test 16, Test 17, Test 18, Test 19, Test 20, Test 21, Test 22, Test 23, Test 24, Test 25, Test 26, Test 27, Test 28, Test 29, Test 30, Test 31, Test 32, Test 33, Test 34, Test 35, Test 36, Test 37, Test 38, Test 39, Test 40, Test 41, Test 42, Test 43, Test 44, Test 45, Test 46, Test 47, Test 48, Test 49, Test 50, Test 51, Test 52, Test 53, Test 54, Test 55, Test 56, Test 57, Test 58, Test 59, Test 60, Test 61, Test 62, Test 63, Test 64, Test 65, Test 66, Test 67, Test 68, Test 69, Test 70, Test 71, Test 72, Test 73, Test 74, Test 75, Test 76, Test 77, Test 78, Test 79, Test 80, Test 81, Test 82, Test 83, Test 84, Test 85, Test 86, Test 87, Test 88, Test 89, Test 90, Test 91, Test 92, Test 93, Test 94, Test 95, Test 96, Test 97, Test 98, Test 99]";
45
46    /**
47     * @tests java.util.Vector#Vector()
48     */
49    @TestTargetNew(
50        level = TestLevel.COMPLETE,
51        notes = "",
52        method = "Vector",
53        args = {}
54    )
55    public void test_Constructor() {
56        // Test for method java.util.Vector()
57
58        Vector tv = new Vector(100);
59        for (int i = 0; i < 100; i++)
60            tv.addElement(new Integer(i));
61        new Support_ListTest("", tv).runTest();
62
63        tv = new Vector(200);
64        for (int i = -50; i < 150; i++)
65            tv.addElement(new Integer(i));
66        new Support_ListTest("", tv.subList(50, 150)).runTest();
67
68        Vector v = new Vector();
69        assertEquals("Vector creation failed", 0, v.size());
70        assertEquals("Wrong capacity", 10, v.capacity());
71    }
72
73    /**
74     * @tests java.util.Vector#Vector(int)
75     */
76    @TestTargetNew(
77        level = TestLevel.COMPLETE,
78        notes = "",
79        method = "Vector",
80        args = {int.class}
81    )
82    public void test_ConstructorI() {
83        // Test for method java.util.Vector(int)
84
85        Vector v = new Vector(100);
86        assertEquals("Vector creation failed", 0, v.size());
87        assertEquals("Wrong capacity", 100, v.capacity());
88
89        try {
90            new Vector(-1);
91            fail("IllegalArgumentException expected");
92        } catch (IllegalArgumentException e) {
93            //expected
94        }
95    }
96
97    /**
98     * @tests java.util.Vector#Vector(int, int)
99     */
100    @TestTargetNew(
101        level = TestLevel.COMPLETE,
102        notes = "",
103        method = "Vector",
104        args = {int.class, int.class}
105    )
106    public void test_ConstructorII() {
107        // Test for method java.util.Vector(int, int)
108
109        Vector v = new Vector(2, 10);
110        v.addElement(new Object());
111        v.addElement(new Object());
112        v.addElement(new Object());
113
114        assertEquals("Failed to inc capacity by proper amount",
115                12, v.capacity());
116
117        Vector grow = new Vector(3, -1);
118        grow.addElement("one");
119        grow.addElement("two");
120        grow.addElement("three");
121        grow.addElement("four");
122        assertEquals("Wrong size", 4, grow.size());
123        assertEquals("Wrong capacity", 6, grow.capacity());
124
125        try {
126            new Vector(-1, 1);
127            fail("IllegalArgumentException expected");
128        } catch (IllegalArgumentException e) {
129            //expected
130        }
131    }
132
133    /**
134     * @tests java.util.Vector#Vector(java.util.Collection)
135     */
136    @TestTargetNew(
137        level = TestLevel.COMPLETE,
138        notes = "",
139        method = "Vector",
140        args = {java.util.Collection.class}
141    )
142    public void test_ConstructorLjava_util_Collection() {
143        // Test for method java.util.Vector(java.util.Collection)
144        Collection l = new LinkedList();
145        for (int i = 0; i < 100; i++)
146            l.add("Test " + i);
147        Vector myVector = new Vector(l);
148        assertTrue("Vector is not correct size",
149                myVector.size() == objArray.length);
150        for (int counter = 0; counter < objArray.length; counter++)
151            assertTrue("Vector does not contain correct elements", myVector
152                    .contains(((List) l).get(counter)));
153
154        try {
155            new Vector(null);
156            fail("NullPointerException expected");
157        } catch (NullPointerException e) {
158            //expected
159        }
160    }
161
162    /**
163     * @tests java.util.Vector#add(int, java.lang.Object)
164     */
165    @TestTargetNew(
166        level = TestLevel.COMPLETE,
167        notes = "",
168        method = "add",
169        args = {int.class, java.lang.Object.class}
170    )
171    public void test_addILjava_lang_Object() {
172        // Test for method void java.util.Vector.add(int, java.lang.Object)
173        Object o = new Object();
174        Object prev = tVector.get(45);
175        tVector.add(45, o);
176        assertTrue("Failed to add Object", tVector.get(45) == o);
177        assertTrue("Failed to fix-up existing indices", tVector.get(46) == prev);
178        assertEquals("Wrong size after add", 101, tVector.size());
179
180        prev = tVector.get(50);
181        tVector.add(50, null);
182        assertNull("Failed to add null", tVector.get(50));
183        assertTrue("Failed to fix-up existing indices after adding null",
184                tVector.get(51) == prev);
185        assertEquals("Wrong size after add", 102, tVector.size());
186
187        try {
188            tVector.add(-5, null);
189            fail("ArrayIndexOutOfBoundsException expected");
190        } catch(ArrayIndexOutOfBoundsException e) {
191            //expected
192        }
193
194        try {
195            tVector.add(tVector.size() + 1, null);
196            fail("ArrayIndexOutOfBoundsException expected");
197        } catch(ArrayIndexOutOfBoundsException e) {
198            //expected
199        }
200    }
201
202    /**
203     * @tests java.util.Vector#add(java.lang.Object)
204     */
205    @TestTargetNew(
206        level = TestLevel.COMPLETE,
207        notes = "",
208        method = "add",
209        args = {java.lang.Object.class}
210    )
211    public void test_addLjava_lang_Object() {
212        // Test for method boolean java.util.Vector.add(java.lang.Object)
213        Object o = new Object();
214        tVector.add(o);
215        assertTrue("Failed to add Object", tVector.lastElement() == o);
216        assertEquals("Wrong size after add", 101, tVector.size());
217
218        tVector.add(null);
219        assertNull("Failed to add null", tVector.lastElement());
220        assertEquals("Wrong size after add", 102, tVector.size());
221    }
222
223    /**
224     * @tests java.util.Vector#addAll(int, java.util.Collection)
225     */
226    @TestTargetNew(
227        level = TestLevel.COMPLETE,
228        notes = "",
229        method = "addAll",
230        args = {int.class, java.util.Collection.class}
231    )
232    public void test_addAllILjava_util_Collection() {
233        // Test for method boolean java.util.Vector.addAll(int,
234        // java.util.Collection)
235        Collection l = new LinkedList();
236        for (int i = 0; i < 100; i++)
237            l.add("Test " + i);
238        Vector v = new Vector();
239        tVector.addAll(50, l);
240        for (int i = 50; i < 100; i++)
241            assertTrue("Failed to add all elements",
242                    tVector.get(i) == ((List) l).get(i - 50));
243        v = new Vector();
244        v.add("one");
245        int r = 0;
246        try {
247            v.addAll(3, Arrays.asList(new String[] { "two", "three" }));
248        } catch (ArrayIndexOutOfBoundsException e) {
249            r = 1;
250        } catch (IndexOutOfBoundsException e) {
251            r = 2;
252        }
253        assertTrue("Invalid add: " + r, r == 1);
254        l = new LinkedList();
255        l.add(null);
256        l.add("gah");
257        l.add(null);
258        tVector.addAll(50, l);
259        assertNull("Wrong element at position 50--wanted null",
260                tVector.get(50));
261        assertEquals("Wrong element at position 51--wanted 'gah'", "gah", tVector
262                .get(51));
263        assertNull("Wrong element at position 52--wanted null",
264                tVector.get(52));
265
266        try {
267            tVector.addAll(-5, Arrays.asList(new String[] { "two", "three" }));
268            fail("ArrayIndexOutOfBoundsException expected");
269        } catch(ArrayIndexOutOfBoundsException e) {
270            //expected
271        }
272
273        try {
274            tVector.addAll(tVector.size() + 1, Arrays.asList(new String[] { "two", "three" }));
275            fail("ArrayIndexOutOfBoundsException expected");
276        } catch(ArrayIndexOutOfBoundsException e) {
277            //expected
278        }
279
280        try {
281            tVector.addAll(tVector.size() / 2, null);
282            fail("NullPointerException expected");
283        } catch(NullPointerException e) {
284            //expected
285        }
286    }
287
288    /**
289     * @tests java.util.Vector#addAll(java.util.Collection)
290     */
291    @TestTargetNew(
292        level = TestLevel.COMPLETE,
293        notes = "",
294        method = "addAll",
295        args = {java.util.Collection.class}
296    )
297    public void test_addAllLjava_util_Collection() {
298        // Test for method boolean java.util.Vector.addAll(java.util.Collection)
299        Vector v = new Vector();
300        Collection l = new LinkedList();
301        for (int i = 0; i < 100; i++)
302            l.add("Test " + i);
303        v.addAll(l);
304        assertTrue("Failed to add all elements", tVector.equals(v));
305
306        v.addAll(l);
307        int vSize = tVector.size();
308        for (int counter = vSize - 1; counter >= 0; counter--)
309            assertTrue("Failed to add elements correctly", v.get(counter) == v
310                    .get(counter + vSize));
311
312        l = new LinkedList();
313        l.add(null);
314        l.add("gah");
315        l.add(null);
316        tVector.addAll(l);
317        assertNull("Wrong element at 3rd last position--wanted null", tVector
318                .get(vSize));
319        assertEquals("Wrong element at 2nd last position--wanted 'gah'", "gah", tVector
320                .get(vSize + 1));
321        assertNull("Wrong element at last position--wanted null", tVector
322                .get(vSize + 2));
323
324        try {
325            tVector.addAll(tVector.size() / 2, null);
326            fail("NullPointerException expected");
327        } catch(NullPointerException e) {
328            //expected
329        }
330    }
331
332    /**
333     * @tests java.util.Vector#addElement(java.lang.Object)
334     */
335    @TestTargetNew(
336        level = TestLevel.COMPLETE,
337        notes = "",
338        method = "addElement",
339        args = {java.lang.Object.class}
340    )
341    public void test_addElementLjava_lang_Object() {
342        // Test for method void java.util.Vector.addElement(java.lang.Object)
343        Vector v = vectorClone(tVector);
344        v.addElement("Added Element");
345        assertTrue("Failed to add element", v.contains("Added Element"));
346        assertEquals("Added Element to wrong slot", "Added Element", ((String) v.elementAt(100))
347                );
348        v.addElement(null);
349        assertTrue("Failed to add null", v.contains(null));
350        assertNull("Added null to wrong slot", v.elementAt(101));
351    }
352
353    /**
354     * @tests java.util.Vector#addElement(java.lang.Object)
355     */
356    @TestTargetNew(
357        level = TestLevel.COMPLETE,
358        notes = "",
359        method = "addElement",
360        args = {java.lang.Object.class}
361    )
362    public void test_addElementLjava_lang_Object_subtest0() {
363        // Test for method void java.util.Vector.addElement(java.lang.Object)
364        Vector v = vectorClone(tVector);
365        v.addElement("Added Element");
366        assertTrue("Failed to add element", v.contains("Added Element"));
367        assertEquals("Added Element to wrong slot", "Added Element", ((String) v.elementAt(100))
368                );
369        v.addElement(null);
370        assertTrue("Failed to add null", v.contains(null));
371        assertNull("Added null to wrong slot", v.elementAt(101));
372    }
373
374    /**
375     * @tests java.util.Vector#capacity()
376     */
377    @TestTargetNew(
378        level = TestLevel.COMPLETE,
379        notes = "",
380        method = "capacity",
381        args = {}
382    )
383    public void test_capacity() {
384        // Test for method int java.util.Vector.capacity()
385
386        Vector v = new Vector(9);
387        assertEquals("Incorrect capacity returned", 9, v.capacity());
388    }
389
390    /**
391     * @tests java.util.Vector#clear()
392     */
393    @TestTargetNew(
394        level = TestLevel.COMPLETE,
395        notes = "",
396        method = "clear",
397        args = {}
398    )
399    public void test_clear() {
400        // Test for method void java.util.Vector.clear()
401        Vector orgVector = vectorClone(tVector);
402        tVector.clear();
403        assertEquals("a) Cleared Vector has non-zero size", 0, tVector.size());
404        Enumeration e = orgVector.elements();
405        while (e.hasMoreElements())
406            assertTrue("a) Cleared vector contained elements", !tVector
407                    .contains(e.nextElement()));
408
409        tVector.add(null);
410        tVector.clear();
411        assertEquals("b) Cleared Vector has non-zero size", 0, tVector.size());
412        e = orgVector.elements();
413        while (e.hasMoreElements())
414            assertTrue("b) Cleared vector contained elements", !tVector
415                    .contains(e.nextElement()));
416    }
417
418    /**
419     * @tests java.util.Vector#clone()
420     */
421    @TestTargetNew(
422        level = TestLevel.COMPLETE,
423        notes = "",
424        method = "clone",
425        args = {}
426    )
427    public void test_clone() {
428        // Test for method java.lang.Object java.util.Vector.clone()
429        tVector.add(25, null);
430        tVector.add(75, null);
431        Vector v = (Vector) tVector.clone();
432        Enumeration orgNum = tVector.elements();
433        Enumeration cnum = v.elements();
434
435        while (orgNum.hasMoreElements()) {
436            assertTrue("Not enough elements copied", cnum.hasMoreElements());
437            assertTrue("Vector cloned improperly, elements do not match",
438                    orgNum.nextElement() == cnum.nextElement());
439        }
440        assertTrue("Not enough elements copied", !cnum.hasMoreElements());
441
442    }
443
444    /**
445     * @tests java.util.Vector#contains(java.lang.Object)
446     */
447    @TestTargetNew(
448        level = TestLevel.COMPLETE,
449        notes = "",
450        method = "contains",
451        args = {java.lang.Object.class}
452    )
453    public void test_containsLjava_lang_Object() {
454        // Test for method boolean java.util.Vector.contains(java.lang.Object)
455        assertTrue("Did not find element", tVector.contains("Test 42"));
456        assertTrue("Found bogus element", !tVector.contains("Hello"));
457        assertTrue(
458                "Returned true looking for null in vector without null element",
459                !tVector.contains(null));
460        tVector.insertElementAt(null, 20);
461        assertTrue(
462                "Returned false looking for null in vector with null element",
463                tVector.contains(null));
464    }
465
466    /**
467     * @tests java.util.Vector#containsAll(java.util.Collection)
468     */
469    @TestTargetNew(
470        level = TestLevel.COMPLETE,
471        notes = "",
472        method = "containsAll",
473        args = {java.util.Collection.class}
474    )
475    public void test_containsAllLjava_util_Collection() {
476        // Test for method boolean
477        // java.util.Vector.containsAll(java.util.Collection)
478        Collection s = new HashSet();
479        for (int i = 0; i < 100; i++)
480            s.add("Test " + i);
481
482        assertTrue("Returned false for valid collection", tVector
483                .containsAll(s));
484        s.add(null);
485        assertTrue("Returned true for invlaid collection containing null",
486                !tVector.containsAll(s));
487        tVector.add(25, null);
488        assertTrue("Returned false for valid collection containing null",
489                tVector.containsAll(s));
490        s = new HashSet();
491        s.add(new Object());
492        assertTrue("Returned true for invalid collection", !tVector
493                .containsAll(s));
494
495        try {
496            tVector.containsAll(null);
497            fail("NullPointerException expected");
498        } catch (NullPointerException e) {
499            //expected
500        }
501    }
502
503    /**
504     * @tests java.util.Vector#copyInto(java.lang.Object[])
505     */
506    @TestTargetNew(
507        level = TestLevel.COMPLETE,
508        notes = "",
509        method = "copyInto",
510        args = {java.lang.Object[].class}
511    )
512    public void test_copyInto$Ljava_lang_Object() {
513        // Test for method void java.util.Vector.copyInto(java.lang.Object [])
514
515        Object[] a = new Object[100];
516        tVector.setElementAt(null, 20);
517        tVector.copyInto(a);
518
519        for (int i = 0; i < 100; i++)
520            assertTrue("copyInto failed", a[i] == tVector.elementAt(i));
521
522        try {
523            tVector.copyInto(null);
524            fail("NullPointerException expected");
525        } catch (NullPointerException e) {
526            //expected
527        }
528    }
529
530    /**
531     * @tests java.util.Vector#elementAt(int)
532     */
533    @TestTargetNew(
534        level = TestLevel.COMPLETE,
535        notes = "",
536        method = "elementAt",
537        args = {int.class}
538    )
539    public void test_elementAtI() {
540        // Test for method java.lang.Object java.util.Vector.elementAt(int)
541        assertEquals("Incorrect element returned", "Test 18", ((String) tVector
542                .elementAt(18)));
543        tVector.setElementAt(null, 20);
544        assertNull("Incorrect element returned--wanted null", tVector
545                .elementAt(20));
546
547        try {
548            tVector.elementAt(-5);
549            fail("ArrayIndexOutOfBoundsException expected");
550        } catch(ArrayIndexOutOfBoundsException e) {
551            //expected
552        }
553
554        try {
555            tVector.elementAt(tVector.size() + 1);
556            fail("ArrayIndexOutOfBoundsException expected");
557        } catch(ArrayIndexOutOfBoundsException e) {
558            //expected
559        }
560    }
561
562    /**
563     * @tests java.util.Vector#elements()
564     */
565    @TestTargetNew(
566        level = TestLevel.COMPLETE,
567        notes = "",
568        method = "elements",
569        args = {}
570    )
571    public void test_elements() {
572        // Test for method java.util.Enumeration java.util.Vector.elements()
573        tVector.insertElementAt(null, 20);
574        Enumeration e = tVector.elements();
575        int i = 0;
576        while (e.hasMoreElements()) {
577            assertTrue("Enumeration returned incorrect element at pos: " + i, e
578                    .nextElement() == tVector.elementAt(i));
579            i++;
580        }
581        assertTrue("Invalid enumeration", i == tVector.size());
582    }
583
584    /**
585     * @tests java.util.Vector#elements()
586     */
587    @TestTargetNew(
588        level = TestLevel.COMPLETE,
589        notes = "",
590        method = "elements",
591        args = {}
592    )
593    public void test_elements_subtest0() {
594        final int iterations = 10000;
595        final Vector v = new Vector();
596        Thread t1 = new Thread() {
597            public void run() {
598                for (int i = 0; i < iterations; i++) {
599                    synchronized (v) {
600                        v.addElement(String.valueOf(i));
601                        v.removeElementAt(0);
602                    }
603                }
604            }
605        };
606        t1.start();
607        for (int i = 0; i < iterations; i++) {
608            Enumeration en = v.elements();
609            try {
610                while (true) {
611                    Object result = en.nextElement();
612                    if (result == null) {
613                        fail("Null result: " + i);
614                    }
615                }
616            } catch (NoSuchElementException e) {
617            }
618        }
619    }
620
621    /**
622     * @tests java.util.Vector#ensureCapacity(int)
623     */
624    @TestTargetNew(
625        level = TestLevel.COMPLETE,
626        notes = "",
627        method = "ensureCapacity",
628        args = {int.class}
629    )
630    public void test_ensureCapacityI() {
631        // Test for method void java.util.Vector.ensureCapacity(int)
632
633        Vector v = new Vector(9);
634        v.ensureCapacity(20);
635        assertEquals("ensureCapacity failed to set correct capacity", 20, v
636                .capacity());
637        v = new Vector(100);
638        assertEquals("ensureCapacity reduced capacity", 100, v.capacity());
639    }
640
641    /**
642     * @tests java.util.Vector#equals(java.lang.Object)
643     */
644    @TestTargetNew(
645        level = TestLevel.COMPLETE,
646        notes = "",
647        method = "equals",
648        args = {java.lang.Object.class}
649    )
650    public void test_equalsLjava_lang_Object() {
651        // Test for method boolean java.util.Vector.equals(java.lang.Object)
652        Vector v = new Vector();
653        for (int i = 0; i < 100; i++)
654            v.addElement("Test " + i);
655        assertTrue("a) Equal vectors returned false", tVector.equals(v));
656        v.addElement(null);
657        assertTrue("b) UnEqual vectors returned true", !tVector.equals(v));
658        tVector.addElement(null);
659        assertTrue("c) Equal vectors returned false", tVector.equals(v));
660        tVector.removeElementAt(22);
661        assertTrue("d) UnEqual vectors returned true", !tVector.equals(v));
662    }
663
664    /**
665     * @tests java.util.Vector#firstElement()
666     */
667    @TestTargetNew(
668        level = TestLevel.COMPLETE,
669        notes = "",
670        method = "firstElement",
671        args = {}
672    )
673    public void test_firstElement() {
674        // Test for method java.lang.Object java.util.Vector.firstElement()
675        assertEquals("Returned incorrect firstElement", "Test 0", tVector.firstElement()
676                );
677        tVector.insertElementAt(null, 0);
678        assertNull("Returned incorrect firstElement--wanted null", tVector
679                .firstElement());
680
681        tVector = new Vector(10);
682
683        try {
684            tVector.firstElement();
685            fail("NoSuchElementException expected");
686        } catch (NoSuchElementException e) {
687            //expected
688        }
689    }
690
691    /**
692     * @tests java.util.Vector#get(int)
693     */
694    @TestTargetNew(
695        level = TestLevel.COMPLETE,
696        notes = "",
697        method = "get",
698        args = {int.class}
699    )
700    public void test_getI() {
701        // Test for method java.lang.Object java.util.Vector.get(int)
702        assertEquals("Get returned incorrect object",
703                "Test 80", tVector.get(80));
704        tVector.add(25, null);
705        assertNull("Returned incorrect element--wanted null",
706                tVector.get(25));
707
708        try {
709            tVector.get(-5);
710            fail("ArrayIndexOutOfBoundsException expected");
711        } catch(ArrayIndexOutOfBoundsException e) {
712            //expected
713        }
714
715        try {
716            tVector.get(tVector.size() + 1);
717            fail("ArrayIndexOutOfBoundsException expected");
718        } catch(ArrayIndexOutOfBoundsException e) {
719            //expected
720        }
721    }
722
723    /**
724     * @tests java.util.Vector#hashCode()
725     */
726    @TestTargetNew(
727        level = TestLevel.COMPLETE,
728        notes = "",
729        method = "hashCode",
730        args = {}
731    )
732    public void test_hashCode() {
733        // Test for method int java.util.Vector.hashCode()
734        int hashCode = 1; // one
735        tVector.insertElementAt(null, 20);
736        for (int i = 0; i < tVector.size(); i++) {
737            Object obj = tVector.elementAt(i);
738            hashCode = 31 * hashCode + (obj == null ? 0 : obj.hashCode());
739        }
740        assertTrue("Incorrect hashCode returned.  Wanted: " + hashCode
741                + " got: " + tVector.hashCode(), tVector.hashCode() == hashCode);
742    }
743
744    /**
745     * @tests java.util.Vector#indexOf(java.lang.Object)
746     */
747    @TestTargetNew(
748        level = TestLevel.COMPLETE,
749        notes = "",
750        method = "indexOf",
751        args = {java.lang.Object.class}
752    )
753    public void test_indexOfLjava_lang_Object() {
754        // Test for method int java.util.Vector.indexOf(java.lang.Object)
755        assertEquals("Incorrect index returned", 10, tVector.indexOf("Test 10"));
756        assertEquals("Index returned for invalid Object", -1, tVector
757                .indexOf("XXXXXXXXXXX"));
758        tVector.setElementAt(null, 20);
759        tVector.setElementAt(null, 40);
760        assertTrue("Incorrect indexOf returned for null: "
761                + tVector.indexOf(null), tVector.indexOf(null) == 20);
762    }
763
764    /**
765     * @tests java.util.Vector#indexOf(java.lang.Object, int)
766     */
767    @TestTargetNew(
768        level = TestLevel.COMPLETE,
769        notes = "",
770        method = "indexOf",
771        args = {java.lang.Object.class, int.class}
772    )
773    public void test_indexOfLjava_lang_ObjectI() {
774        // Test for method int java.util.Vector.indexOf(java.lang.Object, int)
775        assertTrue("Failed to find correct index", (tVector.indexOf("Test 98",
776                50) == 98));
777        assertTrue("Found index of bogus element", (tVector.indexOf(
778                "Test 1001", 50) == -1));
779        tVector.setElementAt(null, 20);
780        tVector.setElementAt(null, 40);
781        tVector.setElementAt(null, 60);
782        assertTrue("a) Incorrect indexOf returned for null: "
783                + tVector.indexOf(null, 25), tVector.indexOf(null, 25) == 40);
784        assertTrue("b) Incorrect indexOf returned for null: "
785                + tVector.indexOf(null, 20), tVector.indexOf(null, 20) == 20);
786
787        try {
788            tVector.indexOf(null, -1);
789            fail("IndexOutOfBoundsException expected");
790        } catch (IndexOutOfBoundsException e) {
791            //expected
792        }
793    }
794
795    /**
796     * @tests java.util.Vector#insertElementAt(java.lang.Object, int)
797     */
798    @TestTargetNew(
799        level = TestLevel.COMPLETE,
800        notes = "",
801        method = "insertElementAt",
802        args = {java.lang.Object.class, int.class}
803    )
804    public void test_insertElementAtLjava_lang_ObjectI() {
805        // Test for method void
806        // java.util.Vector.insertElementAt(java.lang.Object, int)
807        Vector v = vectorClone(tVector);
808        String prevElement = (String) v.elementAt(99);
809        v.insertElementAt("Inserted Element", 99);
810        assertEquals("Element not inserted", "Inserted Element", ((String) v.elementAt(99))
811                );
812        assertTrue("Elements shifted incorrectly", ((String) v.elementAt(100))
813                .equals(prevElement));
814        v.insertElementAt(null, 20);
815        assertNull("null not inserted", v.elementAt(20));
816
817        try {
818            tVector.insertElementAt(null, -5);
819            fail("ArrayIndexOutOfBoundsException expected");
820        } catch(ArrayIndexOutOfBoundsException e) {
821            //expected
822        }
823
824        try {
825            tVector.insertElementAt(null, tVector.size() + 1);
826            fail("ArrayIndexOutOfBoundsException expected");
827        } catch(ArrayIndexOutOfBoundsException e) {
828            //expected
829        }
830    }
831
832    /**
833     * @tests java.util.Vector#isEmpty()
834     */
835    @TestTargetNew(
836        level = TestLevel.COMPLETE,
837        notes = "",
838        method = "isEmpty",
839        args = {}
840    )
841    public void test_isEmpty() {
842        // Test for method boolean java.util.Vector.isEmpty()Vector
843        Vector v = new java.util.Vector();
844        assertTrue("Empty vector returned false", v.isEmpty());
845        v.addElement(new Object());
846        assertTrue("non-Empty vector returned true", !v.isEmpty());
847    }
848
849    /**
850     * @tests java.util.Vector#isEmpty()
851     */
852    @TestTargetNew(
853        level = TestLevel.COMPLETE,
854        notes = "",
855        method = "isEmpty",
856        args = {}
857    )
858    public void test_isEmpty_subtest0() {
859        final Vector v = new Vector();
860        v.addElement("initial");
861        Thread t1 = new Thread() {
862            public void run() {
863                while (!v.isEmpty())
864                    ;
865                v.addElement("final");
866            }
867        };
868        t1.start();
869        for (int i = 0; i < 10000; i++) {
870            synchronized (v) {
871                v.removeElementAt(0);
872                v.addElement(String.valueOf(i));
873            }
874            int size;
875            if ((size = v.size()) != 1) {
876                String result = "Size is not 1: " + size + " " + v;
877                // terminate the thread
878                v.removeAllElements();
879                fail(result);
880            }
881        }
882        // terminate the thread
883        v.removeElementAt(0);
884    }
885
886    /**
887     * @tests java.util.Vector#lastElement()
888     */
889    @TestTargetNew(
890        level = TestLevel.COMPLETE,
891        notes = "",
892        method = "lastElement",
893        args = {}
894    )
895    public void test_lastElement() {
896        // Test for method java.lang.Object java.util.Vector.lastElement()
897        assertEquals("Incorrect last element returned", "Test 99", tVector.lastElement()
898                );
899        tVector.addElement(null);
900        assertNull("Incorrect last element returned--wanted null", tVector
901                .lastElement());
902
903        tVector = new Vector(10);
904
905        try {
906            tVector.lastElement();
907            fail("NoSuchElementException expected");
908        } catch (NoSuchElementException e) {
909            //expected
910        }
911    }
912
913    /**
914     * @tests java.util.Vector#lastIndexOf(java.lang.Object)
915     */
916    @TestTargetNew(
917        level = TestLevel.COMPLETE,
918        notes = "",
919        method = "lastIndexOf",
920        args = {java.lang.Object.class}
921    )
922    public void test_lastIndexOfLjava_lang_Object() {
923        // Test for method int java.util.Vector.lastIndexOf(java.lang.Object)
924        Vector v = new Vector(9);
925        for (int i = 0; i < 9; i++)
926            v.addElement("Test");
927        v.addElement("z");
928        assertEquals("Failed to return correct index", 8, v.lastIndexOf("Test"));
929        tVector.setElementAt(null, 20);
930        tVector.setElementAt(null, 40);
931        assertTrue("Incorrect lastIndexOf returned for null: "
932                + tVector.lastIndexOf(null), tVector.lastIndexOf(null) == 40);
933    }
934
935    /**
936     * @tests java.util.Vector#lastIndexOf(java.lang.Object, int)
937     */
938    @TestTargetNew(
939        level = TestLevel.COMPLETE,
940        notes = "",
941        method = "lastIndexOf",
942        args = {java.lang.Object.class, int.class}
943    )
944    public void test_lastIndexOfLjava_lang_ObjectI() {
945        // Test for method int java.util.Vector.lastIndexOf(java.lang.Object,
946        // int)
947        assertEquals("Failed to find object",
948                0, tVector.lastIndexOf("Test 0", 0));
949        assertTrue("Found Object outside of index", (tVector.lastIndexOf(
950                "Test 0", 10) > -1));
951        tVector.setElementAt(null, 20);
952        tVector.setElementAt(null, 40);
953        tVector.setElementAt(null, 60);
954        assertTrue("Incorrect lastIndexOf returned for null: "
955                + tVector.lastIndexOf(null, 15),
956                tVector.lastIndexOf(null, 15) == -1);
957        assertTrue("Incorrect lastIndexOf returned for null: "
958                + tVector.lastIndexOf(null, 45),
959                tVector.lastIndexOf(null, 45) == 40);
960
961        try {
962            tVector.lastIndexOf(null, tVector.size());
963            fail("IndexOutOfBoundsException expected");
964        } catch (IndexOutOfBoundsException e) {
965            //expected
966        }
967    }
968
969    /**
970     * @tests java.util.Vector#remove(int)
971     */
972    @TestTargetNew(
973        level = TestLevel.COMPLETE,
974        notes = "",
975        method = "remove",
976        args = {int.class}
977    )
978    public void test_removeI() {
979        // Test for method java.lang.Object java.util.Vector.remove(int)
980        tVector.remove(36);
981        assertTrue("Contained element after remove", !tVector
982                .contains("Test 36"));
983        assertEquals("Failed to decrement size after remove",
984                99, tVector.size());
985        tVector.add(20, null);
986        tVector.remove(19);
987        assertNull("Didn't move null element over", tVector.get(19));
988        tVector.remove(19);
989        assertNotNull("Didn't remove null element", tVector.get(19));
990        assertEquals("Failed to decrement size after removing null", 98, tVector
991                .size());
992
993        try {
994            tVector.remove(-5);
995            fail("ArrayIndexOutOfBoundsException expected");
996        } catch(ArrayIndexOutOfBoundsException e) {
997            //expected
998        }
999
1000        try {
1001            tVector.remove(tVector.size() + 1);
1002            fail("ArrayIndexOutOfBoundsException expected");
1003        } catch(ArrayIndexOutOfBoundsException e) {
1004            //expected
1005        }
1006    }
1007
1008    /**
1009     * @tests java.util.Vector#remove(java.lang.Object)
1010     */
1011    @TestTargetNew(
1012        level = TestLevel.COMPLETE,
1013        notes = "",
1014        method = "remove",
1015        args = {java.lang.Object.class}
1016    )
1017    public void test_removeLjava_lang_Object() {
1018        // Test for method boolean java.util.Vector.remove(java.lang.Object)
1019        tVector.remove("Test 0");
1020        assertTrue("Contained element after remove", !tVector
1021                .contains("Test 0"));
1022        assertEquals("Failed to decrement size after remove",
1023                99, tVector.size());
1024        tVector.add(null);
1025        tVector.remove(null);
1026        assertTrue("Contained null after remove", !tVector.contains(null));
1027        assertEquals("Failed to decrement size after removing null", 99, tVector
1028                .size());
1029    }
1030
1031    /**
1032     * @tests java.util.Vector#removeAll(java.util.Collection)
1033     */
1034    @TestTargetNew(
1035        level = TestLevel.COMPLETE,
1036        notes = "",
1037        method = "removeAll",
1038        args = {java.util.Collection.class}
1039    )
1040    public void test_removeAllLjava_util_Collection() {
1041        // Test for method boolean
1042        // java.util.Vector.removeAll(java.util.Collection)
1043        Vector v = new Vector();
1044        Collection l = new LinkedList();
1045        for (int i = 0; i < 5; i++)
1046            l.add("Test " + i);
1047        v.addElement(l);
1048
1049        Collection s = new HashSet();
1050        Object o;
1051        s.add(o = v.firstElement());
1052        v.removeAll(s);
1053        assertTrue("Failed to remove items in collection", !v.contains(o));
1054        v.removeAll(l);
1055        assertTrue("Failed to remove all elements", v.isEmpty());
1056
1057        v.add(null);
1058        v.add(null);
1059        v.add("Boom");
1060        v.removeAll(s);
1061        assertEquals("Should not have removed any elements", 3, v.size());
1062        l = new LinkedList();
1063        l.add(null);
1064        v.removeAll(l);
1065        assertEquals("Should only have one element", 1, v.size());
1066        assertEquals("Element should be 'Boom'", "Boom", v.firstElement());
1067
1068        try {
1069            v.removeAll(null);
1070            fail("NullPointerException expected");
1071        } catch (NullPointerException e) {
1072            //expected
1073        }
1074    }
1075
1076    /**
1077     * @tests java.util.Vector#removeAllElements()
1078     */
1079    @TestTargetNew(
1080        level = TestLevel.COMPLETE,
1081        notes = "",
1082        method = "removeAllElements",
1083        args = {}
1084    )
1085    public void test_removeAllElements() {
1086        // Test for method void java.util.Vector.removeAllElements()
1087        Vector v = vectorClone(tVector);
1088        v.removeAllElements();
1089        assertEquals("Failed to remove all elements", 0, v.size());
1090    }
1091
1092    /**
1093     * @tests java.util.Vector#removeElement(java.lang.Object)
1094     */
1095    @TestTargetNew(
1096        level = TestLevel.COMPLETE,
1097        notes = "Doesn't check negative case.",
1098        method = "removeElement",
1099        args = {java.lang.Object.class}
1100    )
1101    public void test_removeElementLjava_lang_Object() {
1102        // Test for method boolean
1103        // java.util.Vector.removeElement(java.lang.Object)
1104        Vector v = vectorClone(tVector);
1105        v.removeElement("Test 98");
1106        assertEquals("Element not removed", "Test 99", ((String) v.elementAt(98))
1107                );
1108        assertTrue("Vector is wrong size after removal: " + v.size(),
1109                v.size() == 99);
1110        tVector.addElement(null);
1111        v.removeElement(null);
1112        assertTrue("Vector is wrong size after removing null: " + v.size(), v
1113                .size() == 99);
1114    }
1115
1116    /**
1117     * @tests java.util.Vector#removeElementAt(int)
1118     */
1119    @TestTargetNew(
1120        level = TestLevel.COMPLETE,
1121        notes = "",
1122        method = "removeElementAt",
1123        args = {int.class}
1124    )
1125    public void test_removeElementAtI() {
1126        // Test for method void java.util.Vector.removeElementAt(int)
1127        Vector v = vectorClone(tVector);
1128        v.removeElementAt(50);
1129        assertEquals("Failed to remove element", -1, v.indexOf("Test 50", 0));
1130        tVector.insertElementAt(null, 60);
1131        tVector.removeElementAt(60);
1132        assertNotNull("Element at 60 should not be null after removal", tVector
1133                .elementAt(60));
1134
1135        try {
1136            tVector.elementAt(-5);
1137            fail("ArrayIndexOutOfBoundsException expected");
1138        } catch(ArrayIndexOutOfBoundsException e) {
1139            //expected
1140        }
1141
1142        try {
1143            tVector.elementAt(tVector.size() + 1);
1144            fail("ArrayIndexOutOfBoundsException expected");
1145        } catch(ArrayIndexOutOfBoundsException e) {
1146            //expected
1147        }
1148    }
1149
1150    /**
1151     * @tests java.util.Vector#retainAll(java.util.Collection)
1152     */
1153    @TestTargetNew(
1154        level = TestLevel.COMPLETE,
1155        notes = "",
1156        method = "retainAll",
1157        args = {java.util.Collection.class}
1158    )
1159    public void test_retainAllLjava_util_Collection() {
1160        // Test for method boolean
1161        // java.util.Vector.retainAll(java.util.Collection)
1162        Object o = tVector.firstElement();
1163        tVector.add(null);
1164        Collection s = new HashSet();
1165        s.add(o);
1166        s.add(null);
1167        tVector.retainAll(s);
1168        assertTrue("Retained items other than specified", tVector.size() == 2
1169                && tVector.contains(o) && tVector.contains(null));
1170
1171        Iterator i = s.iterator();
1172
1173        while (i.hasNext()) {
1174            assertTrue(tVector.contains(i.next()));
1175        }
1176
1177        try {
1178            tVector.retainAll(null);
1179            fail("NullPointerException expected");
1180        } catch (NullPointerException e) {
1181            //expected
1182        }
1183    }
1184
1185    /**
1186     * @tests java.util.Vector#set(int, java.lang.Object)
1187     */
1188    @TestTargetNew(
1189        level = TestLevel.COMPLETE,
1190        notes = "",
1191        method = "set",
1192        args = {int.class, java.lang.Object.class}
1193    )
1194    public void test_setILjava_lang_Object() {
1195        // Test for method java.lang.Object java.util.Vector.set(int,
1196        // java.lang.Object)
1197        Object o = new Object();
1198        tVector.set(23, o);
1199        assertTrue("Failed to set Object", tVector.get(23) == o);
1200
1201        try {
1202            tVector.set(-5, "Wrong position");
1203            fail("ArrayIndexOutOfBoundsException expected");
1204        } catch(ArrayIndexOutOfBoundsException e) {
1205            //expected
1206        }
1207
1208        try {
1209            tVector.set(tVector.size() + 1, "Wrong position");
1210            fail("ArrayIndexOutOfBoundsException expected");
1211        } catch(ArrayIndexOutOfBoundsException e) {
1212            //expected
1213        }
1214    }
1215
1216    /**
1217     * @tests java.util.Vector#setElementAt(java.lang.Object, int)
1218     */
1219    @TestTargetNew(
1220        level = TestLevel.COMPLETE,
1221        notes = "",
1222        method = "setElementAt",
1223        args = {java.lang.Object.class, int.class}
1224    )
1225    public void test_setElementAtLjava_lang_ObjectI() {
1226        // Test for method void java.util.Vector.setElementAt(java.lang.Object,
1227        // int)
1228        Vector v = vectorClone(tVector);
1229        v.setElementAt("Inserted Element", 99);
1230        assertEquals("Element not set", "Inserted Element", ((String) v.elementAt(99))
1231                );
1232
1233        try {
1234            tVector.setElementAt("Wrong position", -5);
1235            fail("ArrayIndexOutOfBoundsException expected");
1236        } catch(ArrayIndexOutOfBoundsException e) {
1237            //expected
1238        }
1239
1240        try {
1241            tVector.setElementAt("Wrong position", tVector.size() + 1);
1242            fail("ArrayIndexOutOfBoundsException expected");
1243        } catch(ArrayIndexOutOfBoundsException e) {
1244            //expected
1245        }
1246    }
1247
1248    /**
1249     * @tests java.util.Vector#setSize(int)
1250     */
1251    @TestTargetNew(
1252        level = TestLevel.COMPLETE,
1253        notes = "",
1254        method = "setSize",
1255        args = {int.class}
1256    )
1257    public void test_setSizeI() {
1258        // Test for method void java.util.Vector.setSize(int)
1259        Vector v = vectorClone(tVector);
1260        v.setSize(10);
1261        assertEquals("Failed to set size", 10, v.size());
1262
1263        try {
1264            tVector.setSize(-5);
1265            fail("ArrayIndexOutOfBoundsException expected");
1266        } catch(ArrayIndexOutOfBoundsException e) {
1267            //expected
1268        }
1269    }
1270
1271    /**
1272     * @tests java.util.Vector#size()
1273     */
1274    @TestTargetNew(
1275        level = TestLevel.COMPLETE,
1276        notes = "",
1277        method = "size",
1278        args = {}
1279    )
1280    public void test_size() {
1281        // Test for method int java.util.Vector.size()
1282        assertEquals("Returned incorrect size", 100, tVector.size());
1283
1284        final Vector v = new Vector();
1285        v.addElement("initial");
1286        Thread t1 = new Thread() {
1287            public void run() {
1288                while (v.size() > 0)
1289                    ;
1290                v.addElement("final");
1291            }
1292        };
1293        t1.start();
1294        for (int i = 0; i < 10000; i++) {
1295            synchronized (v) {
1296                v.removeElementAt(0);
1297                v.addElement(String.valueOf(i));
1298            }
1299            int size;
1300            if ((size = v.size()) != 1) {
1301                String result = "Size is not 1: " + size + " " + v;
1302                // terminate the thread
1303                v.removeAllElements();
1304                fail(result);
1305            }
1306        }
1307        // terminate the thread
1308        v.removeElementAt(0);
1309    }
1310
1311    /**
1312     * @tests java.util.Vector#subList(int, int)
1313     */
1314    @TestTargetNew(
1315        level = TestLevel.COMPLETE,
1316        notes = "",
1317        method = "subList",
1318        args = {int.class, int.class}
1319    )
1320    public void test_subListII() {
1321        // Test for method java.util.List java.util.Vector.subList(int, int)
1322        List sl = tVector.subList(10, 25);
1323        assertEquals("Returned sublist of incorrect size", 15, sl.size());
1324        for (int i = 10; i < 25; i++)
1325            assertTrue("Returned incorrect sublist", sl
1326                    .contains(tVector.get(i)));
1327
1328        assertEquals("Not synchronized random access", "java.util.Collections$SynchronizedRandomAccessList", sl.getClass().getName()
1329                );
1330
1331        try {
1332            tVector.subList(-10, 25);
1333            fail("IndexOutOfBoundsException expected");
1334        } catch(IndexOutOfBoundsException e) {
1335            //expected
1336        }
1337
1338        try {
1339            tVector.subList(10, tVector.size() + 1);
1340            fail("IndexOutOfBoundsException expected");
1341        } catch(IndexOutOfBoundsException e) {
1342            //expected
1343        }
1344
1345        try {
1346            tVector.subList(25, 10);
1347            fail("IllegalArgumentException expected");
1348        } catch(IllegalArgumentException e) {
1349            //expected
1350        }
1351    }
1352
1353    /**
1354     * @tests java.util.Vector#toArray()
1355     */
1356    @TestTargetNew(
1357        level = TestLevel.COMPLETE,
1358        notes = "",
1359        method = "toArray",
1360        args = {}
1361    )
1362    public void test_toArray() {
1363        // Test for method java.lang.Object [] java.util.Vector.toArray()
1364        assertTrue("Returned incorrect array", Arrays.equals(objArray, tVector
1365                .toArray()));
1366    }
1367
1368    /**
1369     * @tests java.util.Vector#toArray(java.lang.Object[])
1370     */
1371    @TestTargetNew(
1372        level = TestLevel.COMPLETE,
1373        notes = "",
1374        method = "toArray",
1375        args = {java.lang.Object[].class}
1376    )
1377    public void test_toArray$Ljava_lang_Object() {
1378        // Test for method java.lang.Object []
1379        // java.util.Vector.toArray(java.lang.Object [])
1380        Object[] o = new Object[1000];
1381        Object f = new Object();
1382        for (int i = 0; i < o.length; i++)
1383            o[i] = f;
1384        tVector.toArray(o);
1385        assertNull("Failed to set slot to null", o[100]);
1386        for (int i = 0; i < tVector.size(); i++)
1387            assertTrue("Returned incorrect array", tVector.elementAt(i) == o[i]);
1388
1389        try {
1390            tVector.toArray(null);
1391            fail("NullPointerException expected");
1392        } catch(NullPointerException e) {
1393            //expected
1394        }
1395        tVector = new Vector<Integer>();
1396        tVector.add(new Integer(1));
1397        tVector.add(new Integer(2));
1398        tVector.add(new Integer(3));
1399        try {
1400            tVector.toArray(new String[tVector.size()]);
1401            fail("ArrayStoreException expected");
1402        } catch(ArrayStoreException e) {
1403            //expected
1404        }
1405    }
1406
1407    /**
1408     * @tests java.util.Vector#toString()
1409     */
1410    @TestTargetNew(
1411        level = TestLevel.COMPLETE,
1412        notes = "",
1413        method = "toString",
1414        args = {}
1415    )
1416    public void test_toString() {
1417        // Test for method java.lang.String java.util.Vector.toString()
1418        assertTrue("Incorrect String returned", tVector.toString().equals(
1419                vString));
1420
1421        Vector v = new Vector();
1422        v.addElement("one");
1423        v.addElement(v);
1424        v.addElement("3");
1425        // test last element
1426        v.addElement(v);
1427        String result = v.toString();
1428        assertTrue("should contain self ref", result.indexOf("(this") > -1);
1429    }
1430
1431    /**
1432     * @tests java.util.Vector#trimToSize()
1433     */
1434    @TestTargetNew(
1435        level = TestLevel.COMPLETE,
1436        notes = "",
1437        method = "trimToSize",
1438        args = {}
1439    )
1440    public void test_trimToSize() {
1441        // Test for method void java.util.Vector.trimToSize()
1442        Vector v = new Vector(10);
1443        v.addElement(new Object());
1444        v.trimToSize();
1445        assertEquals("Failed to trim capacity", 1, v.capacity());
1446    }
1447
1448    class Mock_Vector extends Vector {
1449        @Override
1450        protected void removeRange(int from, int to) {
1451            super.removeRange(from, to);
1452        }
1453    }
1454
1455    @TestTargetNew(
1456        level = TestLevel.COMPLETE,
1457        notes = "",
1458        method = "removeRange",
1459        args = {int.class, int.class}
1460    )
1461    public void test_removeRangeII() {
1462        Mock_Vector mv = new Mock_Vector();
1463        mv.add("First");
1464        mv.add("Second");
1465        mv.add("One more");
1466        mv.add("Last");
1467        mv.removeRange(1, 3);
1468        assertTrue(mv.contains("First"));
1469        assertFalse(mv.contains("Second"));
1470        assertFalse(mv.contains("One more"));
1471        assertTrue(mv.contains("Last"));
1472    }
1473
1474    protected Vector vectorClone(Vector s) {
1475        return (Vector) s.clone();
1476    }
1477
1478    /**
1479     * Sets up the fixture, for example, open a network connection. This method
1480     * is called before a test is executed.
1481     */
1482    protected void setUp() {
1483        for (int i = 0; i < 100; i++) {
1484            tVector.addElement("Test " + i);
1485        }
1486        objArray = new Object[100];
1487        for (int i = 0; i < 100; i++) {
1488            objArray[i] = "Test " + i;
1489        }
1490    }
1491
1492    /**
1493     * Tears down the fixture, for example, close a network connection. This
1494     * method is called after a test is executed.
1495     */
1496    protected void tearDown() {
1497    }
1498}
1499