1
2
3
4 package org.melati.poem.util.test;
5
6 import java.util.NoSuchElementException;
7 import java.util.Vector;
8
9 import org.melati.poem.util.FilteredEnumeration;
10 import org.melati.poem.util.EnumUtils;
11
12 import junit.framework.TestCase;
13
14
15
16
17
18
19 public class FilteredEnumerationTest extends TestCase {
20
21 FilteredEnumeration<String> it;
22
23
24
25
26 public FilteredEnumerationTest(String name) {
27 super(name);
28 }
29
30
31
32
33
34 protected void setUp() throws Exception {
35 super.setUp();
36 Vector<String> v = new Vector<String>();
37 v.add("a");
38 v.add("b");
39 v.add("c");
40 v.add("d");
41 v.add("e");
42 it = new FilteredEnumeration<String>(v.elements()) {
43 public boolean isIncluded(String o) {
44 return o.compareTo("c") <= 0;
45 }
46 };
47 }
48
49
50
51
52
53 protected void tearDown() throws Exception {
54 super.tearDown();
55 }
56
57
58
59
60 public void testFilteredEnumeration() {
61 assertEquals(3, EnumUtils.vectorOf(it).size());
62 }
63
64
65
66
67 public void testHasMoreElements() {
68
69 }
70
71
72
73
74 public void testNextElement() {
75
76 }
77
78
79
80
81 public void testSkip() {
82 it.skip();
83 it.skip();
84 it.skip();
85 try {
86 it.skip();
87 fail("Should have blown up");
88 } catch (NoSuchElementException e) {
89 e = null;
90 }
91 try {
92 it.nextElement();
93 } catch (NoSuchElementException e) {
94 e = null;
95 }
96 }
97
98 }