1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.cli2;
18
19 import java.util.Arrays;
20 import java.util.Collection;
21 import java.util.Collections;
22 import java.util.Iterator;
23 import java.util.LinkedList;
24 import java.util.List;
25
26 import junit.framework.TestCase;
27
28 public abstract class CLITestCase extends TestCase {
29
30 public static List list() {
31 return Collections.EMPTY_LIST;
32 }
33
34 public static List list(final Object args[]) {
35 return new LinkedList(Arrays.asList(args));
36 }
37
38 public static List list(final Object arg0) {
39 return list(new Object[] { arg0 });
40 }
41
42 public static List list(final Object arg0, final Object arg1) {
43 return list(new Object[] { arg0, arg1 });
44 }
45
46 public static List list(final Object arg0, final Object arg1, final Object arg2) {
47 return list(new Object[] { arg0, arg1, arg2 });
48 }
49
50 public static List list(final Object arg0, final Object arg1, final Object arg2, final Object arg3) {
51 return list(new Object[] { arg0, arg1, arg2, arg3 });
52 }
53
54 public static List list(final Object arg0, final Object arg1, final Object arg2, final Object arg3, final Object arg4) {
55 return list(new Object[] { arg0, arg1, arg2, arg3, arg4 });
56 }
57
58 public static List list(final Object arg0, final Object arg1, final Object arg2, final Object arg3, final Object arg4, final Object arg5) {
59 return list(new Object[] { arg0, arg1, arg2, arg3, arg4, arg5 });
60 }
61
62 public static void assertListContentsEqual(final List expected, final List found) {
63
64 final Iterator e = expected.iterator();
65 final Iterator f = found.iterator();
66
67 while (e.hasNext() && f.hasNext()) {
68 assertEquals(e.next(), f.next());
69 }
70
71 if (e.hasNext()) {
72 fail("Expected more elements");
73 }
74
75 if (f.hasNext()) {
76 fail("Found more elements");
77 }
78 }
79
80 public static void assertContentsEqual(final Collection expected, final Collection found) {
81 assertTrue(expected.containsAll(found));
82 assertTrue(found.containsAll(expected));
83 assertEquals(expected.size(), found.size());
84 }
85 }