1 22 package org.jboss.test.mx.mxbean.test; 23 24 import java.lang.reflect.Type ; 25 import java.util.ArrayList ; 26 import java.util.Collection ; 27 import java.util.LinkedHashSet ; 28 import java.util.List ; 29 import java.util.Set ; 30 31 import org.jboss.test.mx.mxbean.support.TestParameterizedType; 32 33 import junit.framework.Test; 34 import junit.framework.TestSuite; 35 36 42 public class CompositeDataCollectionUnitTestCase extends CompositeDataTest 43 { 44 private static final TestParameterizedType COLLECTION_OF_STRINGS = new TestParameterizedType(Collection .class, new Type [] { String .class }); 45 private static final TestParameterizedType LIST_OF_STRINGS = new TestParameterizedType(List .class, new Type [] { String .class }); 46 private static final TestParameterizedType SET_OF_STRINGS = new TestParameterizedType(Set .class, new Type [] { String .class }); 47 48 public static Test suite() 49 { 50 return new TestSuite(CompositeDataCollectionUnitTestCase.class); 51 } 52 53 public CompositeDataCollectionUnitTestCase(String name) 54 { 55 super(name); 56 } 57 58 public void testCollection() throws Exception 59 { 60 Collection <String > c = new ArrayList <String >(); 61 c.add("one"); 62 c.add("two"); 63 c.add("three"); 64 String [] openData = { "one", "two", "three" }; 65 constructReconstructTest(c, COLLECTION_OF_STRINGS, openData); 66 } 67 68 public void testCollectionNull() throws Exception 69 { 70 constructReconstructTest(null, COLLECTION_OF_STRINGS); 71 } 72 73 public void testCollectionContainsNull() throws Exception 74 { 75 Collection <String > c = new ArrayList <String >(); 76 c.add("one"); 77 c.add(null); 78 c.add("three"); 79 String [] openData = { "one", null, "three" }; 80 constructReconstructTest(c, COLLECTION_OF_STRINGS, openData); 81 } 82 83 public void testList() throws Exception 84 { 85 ArrayList <String > c = new ArrayList <String >(); 86 c.add("one"); 87 c.add("two"); 88 c.add("three"); 89 String [] openData = { "one", "two", "three" }; 90 constructReconstructTest(c, LIST_OF_STRINGS, openData); 91 } 92 93 public void testListNull() throws Exception 94 { 95 constructReconstructTest(null, LIST_OF_STRINGS); 96 } 97 98 public void testListContainsNull() throws Exception 99 { 100 ArrayList <String > c = new ArrayList <String >(); 101 c.add("one"); 102 c.add(null); 103 c.add("three"); 104 String [] openData = { "one", null, "three" }; 105 constructReconstructTest(c, LIST_OF_STRINGS, openData); 106 } 107 108 public void testSet() throws Exception 109 { 110 LinkedHashSet <String > c = new LinkedHashSet <String >(); 111 c.add("one"); 112 c.add("two"); 113 c.add("three"); 114 String [] openData = { "one", "two", "three" }; 115 constructReconstructTest(c, SET_OF_STRINGS, openData); 116 } 117 118 public void testSetNull() throws Exception 119 { 120 constructReconstructTest(null, SET_OF_STRINGS); 121 } 122 123 public void testSetContainsNull() throws Exception 124 { 125 LinkedHashSet <String > c = new LinkedHashSet <String >(); 126 c.add("one"); 127 c.add(null); 128 c.add("three"); 129 String [] openData = { "one", null, "three" }; 130 constructReconstructTest(c, SET_OF_STRINGS, openData); 131 } 132 133 protected void checkOpenDataEquals(Object expected, Object actual) 134 { 135 checkArrayEquals(expected, actual); 136 } 137 } 138 | Popular Tags |