1   package net.sourceforge.jpotpourri.util;
2   
3   import java.util.HashMap;
4   import java.util.HashSet;
5   import java.util.LinkedHashMap;
6   import java.util.LinkedHashSet;
7   import java.util.Map;
8   import java.util.Set;
9   
10  import junit.framework.TestCase;
11  
12  /**
13   * @author christoph.pickl@bmi.gv.at
14   */
15  public class CollectionUtilTest extends TestCase {
16  
17  //	public final void testAsCollection() {
18  //		fail("Not yet implemented");
19  //	}
20  //
21  //	public final void testAsSet() {
22  //		fail("Not yet implemented");
23  //	}
24  //
25  //	public final void testAsList() {
26  //		fail("Not yet implemented");
27  //	}
28  //
29  //	public final void testAsImmutableList() {
30  //		fail("Not yet implemented");
31  //	}
32  //
33  //	public final void testAsStringCollection() {
34  //		fail("Not yet implemented");
35  //	}
36  //
37  //	public final void testAsStringSet() {
38  //		fail("Not yet implemented");
39  //	}
40  //
41  //	public final void testAsArray() {
42  //		fail("Not yet implemented");
43  //	}
44  //
45  //	public final void testToStringCollectionOfQ() {
46  //		fail("Not yet implemented");
47  //	}
48  //
49  //	public final void testImmutableSetSetOfString() {
50  //		fail("Not yet implemented");
51  //	}
52  //
53  //	public final void testImmutableSetStringArray() {
54  //		fail("Not yet implemented");
55  //	}
56  //
57  //	public final void testImmutableList() {
58  //		fail("Not yet implemented");
59  //	}
60  
61  	public final void testToStringSetOfObject() {
62  
63  		assertEquals("null", CollectionUtil.toString((Set<?>) null));
64  		assertEquals("Set[]", CollectionUtil.toString(new HashSet<String>()));
65  		
66  		final Set<String> set = new LinkedHashSet<String>(2);
67  		set.add("abc");
68  		set.add("def");
69  		assertEquals("Set[abc;def]", CollectionUtil.toString(set));
70  	}
71  
72  //	public final void testToStringSetOfObjectString() {
73  //		fail("Not yet implemented");
74  //		// with own separator
75  //	}
76  
77  
78  	public final void testToStringMapOfObjectObject() throws Exception {
79  		assertEquals("null", CollectionUtil.toString((Map<?, ?>) null));
80  		assertEquals("Map[]", CollectionUtil.toString(new HashMap<String, String>()));
81  		
82  		final Map<String, String> map = new LinkedHashMap<String, String>(4);
83  		map.put("a", "b");
84  		map.put("1", "2");
85  		map.put("x", "");
86  		map.put("y", null);
87  		assertEquals("Map[a=b;1=2;x=;y=null]", CollectionUtil.toString(map));
88  	}
89  }