KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jmx > compliance > openmbean > TabularDataSupportTestCase


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.test.jmx.compliance.openmbean;
23
24 import java.io.ByteArrayInputStream JavaDoc;
25 import java.io.ByteArrayOutputStream JavaDoc;
26 import java.io.ObjectInputStream JavaDoc;
27 import java.io.ObjectOutputStream JavaDoc;
28 import java.util.Arrays JavaDoc;
29 import java.util.Collection JavaDoc;
30 import java.util.HashMap JavaDoc;
31 import java.util.Map JavaDoc;
32 import java.util.Set JavaDoc;
33
34 import javax.management.openmbean.CompositeData JavaDoc;
35 import javax.management.openmbean.CompositeDataSupport JavaDoc;
36 import javax.management.openmbean.CompositeType JavaDoc;
37 import javax.management.openmbean.InvalidKeyException JavaDoc;
38 import javax.management.openmbean.InvalidOpenTypeException JavaDoc;
39 import javax.management.openmbean.KeyAlreadyExistsException JavaDoc;
40 import javax.management.openmbean.OpenType JavaDoc;
41 import javax.management.openmbean.SimpleType JavaDoc;
42 import javax.management.openmbean.TabularDataSupport JavaDoc;
43 import javax.management.openmbean.TabularType JavaDoc;
44
45 import junit.framework.TestCase;
46
47 /**
48  * Tabular data support tests.<p>
49  *
50  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
51  */

52 public class TabularDataSupportTestCase
53   extends TestCase
54 {
55    // Static --------------------------------------------------------------------
56

57    // Attributes ----------------------------------------------------------------
58

59    // Constructor ---------------------------------------------------------------
60

61    /**
62     * Construct the test
63     */

64    public TabularDataSupportTestCase(String JavaDoc s)
65    {
66       super(s);
67    }
68
69    // Tests ---------------------------------------------------------------------
70

71    public void testTabularDataSupport()
72       throws Exception JavaDoc
73    {
74       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
75       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
76       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
77       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
78          itemNames, itemDescriptions, itemTypes);
79
80       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
81       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
82
83       new TabularDataSupport JavaDoc(tabularType);
84       new TabularDataSupport JavaDoc(tabularType, 100, .5f);
85    }
86
87    public void testGetTabularType()
88       throws Exception JavaDoc
89    {
90       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
91       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
92       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
93       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
94          itemNames, itemDescriptions, itemTypes);
95
96       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
97       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
98
99       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
100       assertTrue("Expected the same tabular type", data.getTabularType().equals(tabularType));
101    }
102
103    public void testCalculateIndex()
104       throws Exception JavaDoc
105    {
106       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
107       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
108       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
109       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
110          itemNames, itemDescriptions, itemTypes);
111
112       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
113       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
114
115       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
116
117       HashMap JavaDoc map = new HashMap JavaDoc();
118       map.put("name1", "value1");
119       map.put("name2", new Integer JavaDoc(2));
120       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
121       Object JavaDoc[] index = data.calculateIndex(compData);
122
123       assertTrue("Expected index element 0 to be value1", index[0].equals("value1"));
124       assertTrue("Expected index element 1 to be 2", index[1].equals(new Integer JavaDoc(2)));
125
126       map = new HashMap JavaDoc();
127       map.put("name1", "value2");
128       map.put("name2", new Integer JavaDoc(3));
129       compData = new CompositeDataSupport JavaDoc(rowType, map);
130       index = data.calculateIndex(compData);
131
132       assertTrue("Expected index element 0 to be value2", index[0].equals("value2"));
133       assertTrue("Expected index element 1 to be 3", index[1].equals(new Integer JavaDoc(3)));
134    }
135
136    public void testContainsKeyObject()
137       throws Exception JavaDoc
138    {
139       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
140       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
141       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
142       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
143          itemNames, itemDescriptions, itemTypes);
144
145       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
146       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
147
148       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
149
150       assertTrue("Didn't expect containsKey null", data.containsKey(null) == false);
151       assertTrue("Didn't expect containsKey not an Object array", data.containsKey(new Object JavaDoc()) == false);
152
153       Object JavaDoc[] index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
154       assertTrue("Didn't expect containsKey on empty data", data.containsKey((Object JavaDoc) index) == false);
155
156       HashMap JavaDoc map = new HashMap JavaDoc();
157       map.put("name1", "value1");
158       map.put("name2", new Integer JavaDoc(3));
159       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
160       assertTrue("Didn't expect containsKey on index not present", data.containsKey((Object JavaDoc) index) == false);
161
162       map = new HashMap JavaDoc();
163       map.put("name1", "value1");
164       map.put("name2", new Integer JavaDoc(2));
165       compData = new CompositeDataSupport JavaDoc(rowType, map);
166       data.put(compData);
167       assertTrue("Expected containsKey", data.containsKey((Object JavaDoc) index));
168
169       map = new HashMap JavaDoc();
170       map.put("name1", "value1");
171       map.put("name2", new Integer JavaDoc(3));
172       compData = new CompositeDataSupport JavaDoc(rowType, map);
173       assertTrue("Didn't expect containsKey on index still not present",
174          data.containsKey((Object JavaDoc) data.calculateIndex(compData)) == false);
175
176       data.remove(index);
177       assertTrue("Didn't expect removed data in containsKey", data.containsKey((Object JavaDoc) index) == false);
178    }
179
180    public void testContainsKeyObjectArray()
181       throws Exception JavaDoc
182    {
183       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
184       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
185       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
186       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
187          itemNames, itemDescriptions, itemTypes);
188
189       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
190       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
191
192       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
193
194       assertTrue("Didn't expect containsKey null", data.containsKey(null) == false);
195       assertTrue("Didn't expect containsKey not an Object array", data.containsKey(new Object JavaDoc()) == false);
196
197       Object JavaDoc[] index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
198       assertTrue("Didn't expect containsKey on empty data", data.containsKey(index) == false);
199
200       HashMap JavaDoc map = new HashMap JavaDoc();
201       map.put("name1", "value1");
202       map.put("name2", new Integer JavaDoc(3));
203       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
204       assertTrue("Didn't expect containsKey on index not present", data.containsKey(index) == false);
205
206       map = new HashMap JavaDoc();
207       map.put("name1", "value1");
208       map.put("name2", new Integer JavaDoc(2));
209       compData = new CompositeDataSupport JavaDoc(rowType, map);
210       data.put(compData);
211       assertTrue("Expected containsKey", data.containsKey(index));
212
213       map = new HashMap JavaDoc();
214       map.put("name1", "value1");
215       map.put("name2", new Integer JavaDoc(3));
216       compData = new CompositeDataSupport JavaDoc(rowType, map);
217       assertTrue("Didn't expect containsKey on index still not present",
218          data.containsKey(data.calculateIndex(compData)) == false);
219
220       data.remove(index);
221       assertTrue("Didn't expect removed data in containsKey", data.containsKey(index) == false);
222    }
223
224    public void testContainsValueObject()
225       throws Exception JavaDoc
226    {
227       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
228       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
229       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
230       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
231          itemNames, itemDescriptions, itemTypes);
232
233       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
234       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
235
236       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
237
238       assertTrue("Didn't expect containsValue null", data.containsValue(null) == false);
239
240       itemNames = new String JavaDoc[] { "name1", "name2" };
241       itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
242       itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
243       CompositeType JavaDoc rowType2 = new CompositeType JavaDoc("rowTypeName2", "rowDescription",
244          itemNames, itemDescriptions, itemTypes);
245
246       HashMap JavaDoc map = new HashMap JavaDoc();
247       map.put("name1", "value1");
248       map.put("name2", new Integer JavaDoc(2));
249       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType2, map);
250
251       assertTrue("Didn't expect containsValue wrong composite type", data.containsValue((Object JavaDoc) compData2) == false);
252
253       map = new HashMap JavaDoc();
254       map.put("name1", "value1");
255       map.put("name2", new Integer JavaDoc(3));
256       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
257       assertTrue("Didn't expect containsValue on data not present", data.containsValue((Object JavaDoc) compData) == false);
258
259       map = new HashMap JavaDoc();
260       map.put("name1", "value1");
261       map.put("name2", new Integer JavaDoc(2));
262       compData = new CompositeDataSupport JavaDoc(rowType, map);
263       data.put(compData);
264       assertTrue("Expected containsValue", data.containsValue((Object JavaDoc) compData));
265
266       map = new HashMap JavaDoc();
267       map.put("name1", "value1");
268       map.put("name2", new Integer JavaDoc(3));
269       compData = new CompositeDataSupport JavaDoc(rowType, map);
270       assertTrue("Didn't expect containsValue on value still not present", data.containsValue((Object JavaDoc) compData) == false);
271
272       assertTrue("Didn't expect containsValue still wrong composite type", data.containsValue((Object JavaDoc) compData2) == false);
273
274       data.remove(data.calculateIndex(compData));
275       assertTrue("Didn't expect removed data in containsValue", data.containsValue((Object JavaDoc) compData) == false);
276    }
277
278    public void testContainsValueCompositeData()
279       throws Exception JavaDoc
280    {
281       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
282       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
283       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
284       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
285          itemNames, itemDescriptions, itemTypes);
286
287       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
288       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
289
290       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
291
292       assertTrue("Didn't expect containsValue null", data.containsValue(null) == false);
293
294       itemNames = new String JavaDoc[] { "name1", "name2" };
295       itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
296       itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
297       CompositeType JavaDoc rowType2 = new CompositeType JavaDoc("rowTypeName2", "rowDescription",
298          itemNames, itemDescriptions, itemTypes);
299
300       HashMap JavaDoc map = new HashMap JavaDoc();
301       map.put("name1", "value1");
302       map.put("name2", new Integer JavaDoc(2));
303       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType2, map);
304
305       assertTrue("Didn't expect containsValue wrong composite type", data.containsValue(compData2) == false);
306
307       map = new HashMap JavaDoc();
308       map.put("name1", "value1");
309       map.put("name2", new Integer JavaDoc(3));
310       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
311       assertTrue("Didn't expect containsValue on data not present", data.containsValue(compData) == false);
312
313       map = new HashMap JavaDoc();
314       map.put("name1", "value1");
315       map.put("name2", new Integer JavaDoc(2));
316       compData = new CompositeDataSupport JavaDoc(rowType, map);
317       data.put(compData);
318       assertTrue("Expected containsValue", data.containsValue(compData));
319
320       map = new HashMap JavaDoc();
321       map.put("name1", "value1");
322       map.put("name2", new Integer JavaDoc(3));
323       compData = new CompositeDataSupport JavaDoc(rowType, map);
324       assertTrue("Didn't expect containsValue on value still not present", data.containsValue(compData) == false);
325
326       assertTrue("Didn't expect containsValue still wrong composite type", data.containsValue(compData2) == false);
327
328       data.remove(data.calculateIndex(compData));
329       assertTrue("Didn't expect removed data in containsValue", data.containsValue(compData) == false);
330    }
331
332    public void testGetObject()
333       throws Exception JavaDoc
334    {
335       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
336       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
337       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
338       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
339          itemNames, itemDescriptions, itemTypes);
340
341       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
342       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
343
344       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
345
346       Object JavaDoc[] index = new Object JavaDoc[] { "value1", new Integer JavaDoc(3) };
347       assertTrue("Expected null for get on data not present", data.get((Object JavaDoc) index) == null);
348
349       HashMap JavaDoc map = new HashMap JavaDoc();
350       map.put("name1", "value1");
351       map.put("name2", new Integer JavaDoc(2));
352       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
353       index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
354       data.put(compData);
355       assertTrue("Expected get to return the same value", data.get((Object JavaDoc) index).equals(compData));
356
357       index = new Object JavaDoc[] { "value1", new Integer JavaDoc(3) };
358       assertTrue("Didn't expect get on value still not present", data.get((Object JavaDoc) index) == null);
359
360       index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
361       data.remove(index);
362       assertTrue("Didn't expect removed data in get", data.get((Object JavaDoc) index) == null);
363    }
364
365    public void testGetObjectArray()
366       throws Exception JavaDoc
367    {
368       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
369       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
370       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
371       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
372          itemNames, itemDescriptions, itemTypes);
373
374       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
375       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
376
377       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
378
379       Object JavaDoc[] index = new Object JavaDoc[] { "value1", new Integer JavaDoc(3) };
380       assertTrue("Expected null for get on data not present", data.get(index) == null);
381
382       HashMap JavaDoc map = new HashMap JavaDoc();
383       map.put("name1", "value1");
384       map.put("name2", new Integer JavaDoc(2));
385       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
386       index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
387       data.put(compData);
388       assertTrue("Expected get to return the same value", data.get(index).equals(compData));
389
390       index = new Object JavaDoc[] { "value1", new Integer JavaDoc(3) };
391       assertTrue("Didn't expect get on value still not present", data.get(index) == null);
392
393       index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
394       data.remove(index);
395       assertTrue("Didn't expect removed data in get", data.get(index) == null);
396    }
397
398    public void testPutObjectObject()
399       throws Exception JavaDoc
400    {
401       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
402       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
403       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
404       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
405          itemNames, itemDescriptions, itemTypes);
406
407       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
408       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
409
410       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
411
412       HashMap JavaDoc map = new HashMap JavaDoc();
413       map.put("name1", "value1");
414       map.put("name2", new Integer JavaDoc(2));
415       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
416       Object JavaDoc[] index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
417       data.put(index, compData);
418       assertTrue("The data should be present after put", data.get(index).equals(compData));
419
420       HashMap JavaDoc map2 = new HashMap JavaDoc();
421       map2.put("name1", "value1");
422       map2.put("name2", new Integer JavaDoc(3));
423       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
424       index = new Object JavaDoc[] { "value1", new Integer JavaDoc(3) };
425       data.put(index, compData2);
426       assertTrue("Another data should be present after put", data.get(index).equals(compData2));
427
428       index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
429       assertTrue("The previous data should be present after put", data.get(index).equals(compData));
430
431       data.remove(index);
432       data.put(index, compData);
433       assertTrue("Data should be present after remove/put", data.get(index).equals(compData));
434
435       HashMap JavaDoc map3 = new HashMap JavaDoc();
436       map3.put("name1", "value1");
437       map3.put("name2", new Integer JavaDoc(4));
438       CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
439       index = new Object JavaDoc[] { "value1", new Integer JavaDoc(4) };
440       data.put(new Object JavaDoc(), compData3);
441       assertTrue("The key should be ignored in put", data.get(index).equals(compData3));
442    }
443
444    public void testPutCompositeData()
445       throws Exception JavaDoc
446    {
447       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
448       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
449       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
450       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
451          itemNames, itemDescriptions, itemTypes);
452
453       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
454       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
455
456       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
457
458       HashMap JavaDoc map = new HashMap JavaDoc();
459       map.put("name1", "value1");
460       map.put("name2", new Integer JavaDoc(2));
461       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
462       Object JavaDoc[] index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
463       data.put(compData);
464       assertTrue("The data should be present after put", data.get(index).equals(compData));
465
466       HashMap JavaDoc map2 = new HashMap JavaDoc();
467       map2.put("name1", "value1");
468       map2.put("name2", new Integer JavaDoc(3));
469       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
470       index = new Object JavaDoc[] { "value1", new Integer JavaDoc(3) };
471       data.put(compData2);
472       assertTrue("Another data should be present after put", data.get(index).equals(compData2));
473
474       index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
475       assertTrue("The previous data should be present after put", data.get(index).equals(compData));
476
477       data.remove(index);
478       data.put(compData);
479       assertTrue("Data should be present after remove/put", data.get(index).equals(compData));
480    }
481
482    public void testRemoveObject()
483       throws Exception JavaDoc
484    {
485       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
486       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
487       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
488       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
489          itemNames, itemDescriptions, itemTypes);
490
491       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
492       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
493
494       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
495
496       HashMap JavaDoc map = new HashMap JavaDoc();
497       map.put("name1", "value1");
498       map.put("name2", new Integer JavaDoc(2));
499       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
500       Object JavaDoc[] index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
501
502       assertTrue("Remove on data not present returns null", data.remove((Object JavaDoc) index) == null);
503
504       data.put(compData);
505       assertTrue("Remove on data present returns the data", data.remove((Object JavaDoc) index).equals(compData));
506    }
507
508    public void testRemoveObjectArray()
509       throws Exception JavaDoc
510    {
511       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
512       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
513       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
514       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
515          itemNames, itemDescriptions, itemTypes);
516
517       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
518       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
519
520       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
521
522       HashMap JavaDoc map = new HashMap JavaDoc();
523       map.put("name1", "value1");
524       map.put("name2", new Integer JavaDoc(2));
525       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
526       Object JavaDoc[] index = new Object JavaDoc[] { "value1", new Integer JavaDoc(2) };
527
528       assertTrue("Remove on data not present returns null", data.remove(index) == null);
529
530       data.put(compData);
531       assertTrue("Remove on data present returns the data", data.remove(index).equals(compData));
532    }
533
534    public void testPutAllMap()
535       throws Exception JavaDoc
536    {
537       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
538       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
539       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
540       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
541          itemNames, itemDescriptions, itemTypes);
542
543       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
544       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
545
546       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
547
548       data.putAll((Map JavaDoc) null);
549       assertTrue("Put all null is ok", data.isEmpty());
550
551       HashMap JavaDoc map = new HashMap JavaDoc();
552       map.put("name1", "value1");
553       map.put("name2", new Integer JavaDoc(2));
554       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
555
556       HashMap JavaDoc toPut = new HashMap JavaDoc();
557       toPut.put(new Object JavaDoc(), compData);
558       data.putAll(toPut);
559       assertTrue("Put all added one", data.size() == 1);
560       assertTrue("Put all added the correct data", data.containsValue(compData));
561
562       HashMap JavaDoc map2 = new HashMap JavaDoc();
563       map2.put("name1", "value1");
564       map2.put("name2", new Integer JavaDoc(3));
565       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
566
567       HashMap JavaDoc map3 = new HashMap JavaDoc();
568       map3.put("name1", "value1");
569       map3.put("name2", new Integer JavaDoc(4));
570       CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
571
572       toPut = new HashMap JavaDoc();
573       toPut.put(new Object JavaDoc(), compData2);
574       toPut.put(new Object JavaDoc(), compData3);
575       data.putAll(toPut);
576       assertTrue("Put all added two", data.size() == 3);
577       assertTrue("Put all added the correct data", data.containsValue(compData2));
578       assertTrue("Put all added the correct data", data.containsValue(compData3));
579       assertTrue("Put all original data still present", data.containsValue(compData));
580    }
581
582    public void testPutAllCompositeData()
583       throws Exception JavaDoc
584    {
585       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
586       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
587       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
588       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
589          itemNames, itemDescriptions, itemTypes);
590
591       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
592       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
593
594       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
595
596       data.putAll((CompositeData JavaDoc[]) null);
597       assertTrue("Put all null is ok", data.isEmpty());
598
599       HashMap JavaDoc map = new HashMap JavaDoc();
600       map.put("name1", "value1");
601       map.put("name2", new Integer JavaDoc(2));
602       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
603
604       CompositeData JavaDoc[] toPut = new CompositeData JavaDoc[] { compData };
605       data.putAll(toPut);
606       assertTrue("Put all added one", data.size() == 1);
607       assertTrue("Put all added the correct data", data.containsValue(compData));
608
609       HashMap JavaDoc map2 = new HashMap JavaDoc();
610       map2.put("name1", "value1");
611       map2.put("name2", new Integer JavaDoc(3));
612       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
613
614       HashMap JavaDoc map3 = new HashMap JavaDoc();
615       map3.put("name1", "value1");
616       map3.put("name2", new Integer JavaDoc(4));
617       CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
618
619       toPut = new CompositeData JavaDoc[] { compData2, compData3 };
620       data.putAll(toPut);
621       assertTrue("Put all added two", data.size() == 3);
622       assertTrue("Put all added the correct data", data.containsValue(compData2));
623       assertTrue("Put all added the correct data", data.containsValue(compData3));
624       assertTrue("Put all original data still present", data.containsValue(compData));
625    }
626
627    public void testClear()
628       throws Exception JavaDoc
629    {
630       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
631       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
632       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
633       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
634          itemNames, itemDescriptions, itemTypes);
635
636       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
637       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
638
639       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
640
641       data.putAll((CompositeData JavaDoc[]) null);
642       assertTrue("Put all null is ok", data.isEmpty());
643
644       HashMap JavaDoc map = new HashMap JavaDoc();
645       map.put("name1", "value1");
646       map.put("name2", new Integer JavaDoc(2));
647       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
648
649       HashMap JavaDoc map2 = new HashMap JavaDoc();
650       map2.put("name1", "value1");
651       map2.put("name2", new Integer JavaDoc(3));
652       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
653
654       HashMap JavaDoc map3 = new HashMap JavaDoc();
655       map3.put("name1", "value1");
656       map3.put("name2", new Integer JavaDoc(4));
657       CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
658
659       HashMap JavaDoc toPut = new HashMap JavaDoc();
660       toPut.put(new Object JavaDoc(), compData);
661       toPut.put(new Object JavaDoc(), compData2);
662       toPut.put(new Object JavaDoc(), compData3);
663       data.putAll(toPut);
664
665       data.clear();
666       assertTrue("Clear should clear the data", data.isEmpty());
667    }
668
669    public void testSize()
670       throws Exception JavaDoc
671    {
672       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
673       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
674       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
675       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
676          itemNames, itemDescriptions, itemTypes);
677
678       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
679       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
680
681       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
682
683       assertTrue("Initial size is zero", data.size() == 0);
684
685       HashMap JavaDoc map = new HashMap JavaDoc();
686       map.put("name1", "value1");
687       map.put("name2", new Integer JavaDoc(2));
688       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
689
690       CompositeData JavaDoc[] toPut = new CompositeData JavaDoc[] { compData };
691       data.putAll(toPut);
692       assertTrue("Expected one element", data.size() == 1);
693
694       HashMap JavaDoc map2 = new HashMap JavaDoc();
695       map2.put("name1", "value1");
696       map2.put("name2", new Integer JavaDoc(3));
697       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
698
699       HashMap JavaDoc map3 = new HashMap JavaDoc();
700       map3.put("name1", "value1");
701       map3.put("name2", new Integer JavaDoc(4));
702       CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
703
704       toPut = new CompositeData JavaDoc[] { compData2, compData3 };
705       data.putAll(toPut);
706       assertTrue("Expected three elements", data.size() == 3);
707
708       data.remove(new Object JavaDoc[] { "value1", new Integer JavaDoc(4) });
709       assertTrue("Expected two elements", data.size() == 2);
710
711       data.clear();
712       assertTrue("Expected no elements", data.size() == 0);
713    }
714
715    public void testIsEmpty()
716       throws Exception JavaDoc
717    {
718       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
719       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
720       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
721       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
722          itemNames, itemDescriptions, itemTypes);
723
724       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
725       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
726
727       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
728
729       assertTrue("Initially empty", data.isEmpty());
730
731       HashMap JavaDoc map = new HashMap JavaDoc();
732       map.put("name1", "value1");
733       map.put("name2", new Integer JavaDoc(2));
734       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
735
736       CompositeData JavaDoc[] toPut = new CompositeData JavaDoc[] { compData };
737       data.putAll(toPut);
738       assertTrue("Not empty after a put", data.isEmpty() == false);
739
740       data.clear();
741       assertTrue("Expected no elements", data.isEmpty());
742    }
743
744    /**
745     * @todo full test, unmodifiable/iterator
746     */

747    public void testKeySet()
748       throws Exception JavaDoc
749    {
750       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
751       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
752       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
753       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
754          itemNames, itemDescriptions, itemTypes);
755
756       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
757       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
758
759       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
760
761       data.putAll((CompositeData JavaDoc[]) null);
762       assertTrue("Put all null is ok", data.isEmpty());
763
764       HashMap JavaDoc map = new HashMap JavaDoc();
765       map.put("name1", "value1");
766       map.put("name2", new Integer JavaDoc(2));
767       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
768
769       HashMap JavaDoc map2 = new HashMap JavaDoc();
770       map2.put("name1", "value1");
771       map2.put("name2", new Integer JavaDoc(3));
772       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
773
774       HashMap JavaDoc map3 = new HashMap JavaDoc();
775       map3.put("name1", "value1");
776       map3.put("name2", new Integer JavaDoc(4));
777       CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
778
779       HashMap JavaDoc toPut = new HashMap JavaDoc();
780       toPut.put(new Object JavaDoc(), compData);
781       toPut.put(new Object JavaDoc(), compData2);
782       toPut.put(new Object JavaDoc(), compData3);
783       data.putAll(toPut);
784
785       Set JavaDoc keySet = data.keySet();
786       assertTrue("Key set should contain 3 elements", keySet.size() == 3);
787       assertTrue("Key set should contain index [value1, 2]",
788          keySet.contains(Arrays.asList(new Object JavaDoc[] { "value1", new Integer JavaDoc(2) })));
789       assertTrue("Key set should contain index [value1, 3]",
790          keySet.contains(Arrays.asList(new Object JavaDoc[] { "value1", new Integer JavaDoc(3) })));
791       assertTrue("Key set should contain index [value1, 4]",
792          keySet.contains(Arrays.asList(new Object JavaDoc[] { "value1", new Integer JavaDoc(4) })));
793    }
794
795    /**
796     * @todo full test, modifiable/iterator
797     */

798    public void testValues()
799       throws Exception JavaDoc
800    {
801       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
802       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
803       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
804       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
805          itemNames, itemDescriptions, itemTypes);
806
807       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
808       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
809
810       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
811
812       data.putAll((CompositeData JavaDoc[]) null);
813       assertTrue("Put all null is ok", data.isEmpty());
814
815       HashMap JavaDoc map = new HashMap JavaDoc();
816       map.put("name1", "value1");
817       map.put("name2", new Integer JavaDoc(2));
818       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
819
820       HashMap JavaDoc map2 = new HashMap JavaDoc();
821       map2.put("name1", "value1");
822       map2.put("name2", new Integer JavaDoc(3));
823       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
824
825       HashMap JavaDoc map3 = new HashMap JavaDoc();
826       map3.put("name1", "value1");
827       map3.put("name2", new Integer JavaDoc(4));
828       CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
829
830       HashMap JavaDoc toPut = new HashMap JavaDoc();
831       toPut.put(new Object JavaDoc(), compData);
832       toPut.put(new Object JavaDoc(), compData2);
833       toPut.put(new Object JavaDoc(), compData3);
834       data.putAll(toPut);
835
836       Collection JavaDoc values = data.values();
837       assertTrue("Values should contain 3 elements", values.size() == 3);
838       assertTrue("Values should contain index compData", values.contains(compData));
839       assertTrue("Values should contain index compData2", values.contains(compData2));
840       assertTrue("Values should contain index compData3", values.contains(compData3));
841    }
842
843    /**
844     * @todo this test
845     */

846    public void testEntrySet()
847       throws Exception JavaDoc
848    {
849    }
850
851    public void testClone()
852       throws Exception JavaDoc
853    {
854       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
855       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
856       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
857       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
858          itemNames, itemDescriptions, itemTypes);
859
860       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
861       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
862
863       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
864
865       data.putAll((CompositeData JavaDoc[]) null);
866       assertTrue("Put all null is ok", data.isEmpty());
867
868       HashMap JavaDoc map = new HashMap JavaDoc();
869       map.put("name1", "value1");
870       map.put("name2", new Integer JavaDoc(2));
871       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
872
873       HashMap JavaDoc map2 = new HashMap JavaDoc();
874       map2.put("name1", "value1");
875       map2.put("name2", new Integer JavaDoc(3));
876       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
877
878       HashMap JavaDoc map3 = new HashMap JavaDoc();
879       map3.put("name1", "value1");
880       map3.put("name2", new Integer JavaDoc(4));
881       CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
882
883       HashMap JavaDoc toPut = new HashMap JavaDoc();
884       toPut.put(new Object JavaDoc(), compData);
885       toPut.put(new Object JavaDoc(), compData2);
886       toPut.put(new Object JavaDoc(), compData3);
887       data.putAll(toPut);
888
889       TabularDataSupport JavaDoc clone = (TabularDataSupport JavaDoc) data.clone();
890       assertTrue("Clone should have the same tabular type", data.getTabularType().equals(clone.getTabularType()));
891       assertTrue("Clone should have the same number of elements", data.size() == clone.size());
892       CompositeData JavaDoc compDataClone = clone.get(new Object JavaDoc[] {"value1", new Integer JavaDoc(2) });
893       assertTrue("Should be a shallow clone", compData == compDataClone);
894    }
895
896    public void testEquals()
897       throws Exception JavaDoc
898    {
899       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
900       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
901       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
902       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
903          itemNames, itemDescriptions, itemTypes);
904
905       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
906       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
907
908       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
909
910       assertTrue("Null should not be equal", data.equals(null) == false);
911       assertTrue("Only TabularData should be equal", data.equals(new Object JavaDoc()) == false);
912
913       assertTrue("An instance should equal itself", data.equals(data));
914
915       TabularDataSupport JavaDoc data2 = new TabularDataSupport JavaDoc(tabularType);
916
917       assertTrue("Two different instances with the same tabular type are equal", data.equals(data2));
918       assertTrue("Two different instances with the same tabular type are equal", data2.equals(data));
919
920       TabularType JavaDoc tabularType2 = new TabularType JavaDoc("typeName2", "description", rowType, indexNames);
921       data2 = new TabularDataSupport JavaDoc(tabularType2);
922
923       assertTrue("Instances with different tabular type are not equal", data.equals(data2) == false);
924       assertTrue("Instances with different tabular type are not equal", data2.equals(data) == false);
925
926       HashMap JavaDoc map = new HashMap JavaDoc();
927       map.put("name1", "value1");
928       map.put("name2", new Integer JavaDoc(2));
929       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
930
931       HashMap JavaDoc map2 = new HashMap JavaDoc();
932       map2.put("name1", "value1");
933       map2.put("name2", new Integer JavaDoc(3));
934       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
935
936       HashMap JavaDoc map3 = new HashMap JavaDoc();
937       map3.put("name1", "value1");
938       map3.put("name2", new Integer JavaDoc(4));
939       CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
940
941       HashMap JavaDoc toPut = new HashMap JavaDoc();
942       toPut.put(new Object JavaDoc(), compData);
943       toPut.put(new Object JavaDoc(), compData2);
944       toPut.put(new Object JavaDoc(), compData3);
945
946       data.putAll(toPut);
947       data2 = new TabularDataSupport JavaDoc(tabularType);
948       data2.putAll(toPut);
949       assertTrue("Instances with the same composite data are equal", data.equals(data2));
950       assertTrue("Instances with the same composite data are equal", data2.equals(data));
951
952       toPut = new HashMap JavaDoc();
953       toPut.put(new Object JavaDoc(), compData);
954       toPut.put(new Object JavaDoc(), compData2);
955       data2 = new TabularDataSupport JavaDoc(tabularType);
956       data2.putAll(toPut);
957       assertTrue("Instances with different composite data are not equal", data.equals(data2) == false);
958       assertTrue("Instances with different composite data are not equal", data2.equals(data) == false);
959    }
960
961    public void testHashCode()
962       throws Exception JavaDoc
963    {
964       String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
965       String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
966       OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
967       CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
968          itemNames, itemDescriptions, itemTypes);
969
970       String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
971       TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
972
973       TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
974
975       data.putAll((CompositeData JavaDoc[]) null);
976       assertTrue("Put all null is ok", data.isEmpty());
977
978       HashMap JavaDoc map = new HashMap JavaDoc();
979       map.put("name1", "value1");
980       map.put("name2", new Integer JavaDoc(2));
981       CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
982
983       HashMap JavaDoc map2 = new HashMap JavaDoc();
984       map2.put("name1", "value1");
985       map2.put("name2", new Integer JavaDoc(3));
986       CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
987
988       HashMap JavaDoc map3 = new HashMap JavaDoc();
989       map3.put("name1", "value1");
990       map3.put("name2", new Integer JavaDoc(4));
991       CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
992
993       HashMap JavaDoc toPut = new HashMap JavaDoc();
994       toPut.put(new Object JavaDoc(), compData);
995       toPut.put(new Object JavaDoc(), compData2);
996       toPut.put(new Object JavaDoc(), compData3);
997       data.putAll(toPut);
998
999       int myHashCode = tabularType.hashCode() + compData.hashCode() + compData2.hashCode() + compData3.hashCode();
1000      assertTrue("Wrong hash code generated", myHashCode == data.hashCode());
1001   }
1002
1003   public void testToString()
1004      throws Exception JavaDoc
1005   {
1006      String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
1007      String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
1008      OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
1009      CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
1010         itemNames, itemDescriptions, itemTypes);
1011
1012      String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
1013      TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
1014
1015      TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1016
1017      data.putAll((CompositeData JavaDoc[]) null);
1018      assertTrue("Put all null is ok", data.isEmpty());
1019
1020      HashMap JavaDoc map = new HashMap JavaDoc();
1021      map.put("name1", "value1");
1022      map.put("name2", new Integer JavaDoc(2));
1023      CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
1024
1025      HashMap JavaDoc map2 = new HashMap JavaDoc();
1026      map2.put("name1", "value1");
1027      map2.put("name2", new Integer JavaDoc(3));
1028      CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
1029
1030      HashMap JavaDoc map3 = new HashMap JavaDoc();
1031      map3.put("name1", "value1");
1032      map3.put("name2", new Integer JavaDoc(4));
1033      CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
1034
1035      HashMap JavaDoc toPut = new HashMap JavaDoc();
1036      toPut.put(new Object JavaDoc(), compData);
1037      toPut.put(new Object JavaDoc(), compData2);
1038      toPut.put(new Object JavaDoc(), compData3);
1039      data.putAll(toPut);
1040
1041      String JavaDoc toString = data.toString();
1042
1043      assertTrue("toString() should contain the tabular type",
1044         toString.indexOf(tabularType.toString()) != -1);
1045      assertTrue("toString() should contain index=compositeData for compData",
1046         toString.indexOf(Arrays.asList(data.calculateIndex(compData)) + "=" + compData) != -1);
1047      assertTrue("toString() should contain index=compositeData for compData2",
1048         toString.indexOf(Arrays.asList(data.calculateIndex(compData2)) + "=" + compData2) != -1);
1049      assertTrue("toString() should contain index=compositeData for compData3",
1050         toString.indexOf(Arrays.asList(data.calculateIndex(compData3)) + "=" + compData3) != -1);
1051   }
1052
1053   public void testSerialization()
1054      throws Exception JavaDoc
1055   {
1056      String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
1057      String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
1058      OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
1059      CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
1060         itemNames, itemDescriptions, itemTypes);
1061
1062      String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
1063      TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
1064
1065      TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1066
1067      data.putAll((CompositeData JavaDoc[]) null);
1068      assertTrue("Put all null is ok", data.isEmpty());
1069
1070      HashMap JavaDoc map = new HashMap JavaDoc();
1071      map.put("name1", "value1");
1072      map.put("name2", new Integer JavaDoc(2));
1073      CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
1074
1075      HashMap JavaDoc map2 = new HashMap JavaDoc();
1076      map2.put("name1", "value1");
1077      map2.put("name2", new Integer JavaDoc(3));
1078      CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType, map2);
1079
1080      HashMap JavaDoc map3 = new HashMap JavaDoc();
1081      map3.put("name1", "value1");
1082      map3.put("name2", new Integer JavaDoc(4));
1083      CompositeDataSupport JavaDoc compData3 = new CompositeDataSupport JavaDoc(rowType, map3);
1084
1085      HashMap JavaDoc toPut = new HashMap JavaDoc();
1086      toPut.put(new Object JavaDoc(), compData);
1087      toPut.put(new Object JavaDoc(), compData2);
1088      toPut.put(new Object JavaDoc(), compData3);
1089      data.putAll(toPut);
1090
1091      // Serialize it
1092
ByteArrayOutputStream JavaDoc baos = new ByteArrayOutputStream JavaDoc();
1093      ObjectOutputStream JavaDoc oos = new ObjectOutputStream JavaDoc(baos);
1094      oos.writeObject(data);
1095    
1096      // Deserialize it
1097
ByteArrayInputStream JavaDoc bais = new ByteArrayInputStream JavaDoc(baos.toByteArray());
1098      ObjectInputStream JavaDoc ois = new ObjectInputStream JavaDoc(bais);
1099      Object JavaDoc result = ois.readObject();
1100
1101      assertEquals(data, result);
1102   }
1103
1104   public void testErrors()
1105      throws Exception JavaDoc
1106   {
1107      String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
1108      String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
1109      OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
1110
1111      CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
1112         itemNames, itemDescriptions, itemTypes);
1113      HashMap JavaDoc map = new HashMap JavaDoc();
1114      map.put("name1", "value1");
1115      map.put("name2", new Integer JavaDoc(2));
1116      CompositeDataSupport JavaDoc compData = new CompositeDataSupport JavaDoc(rowType, map);
1117
1118      CompositeType JavaDoc rowType2 = new CompositeType JavaDoc("rowTypeName2", "rowDescription",
1119         itemNames, itemDescriptions, itemTypes);
1120      CompositeDataSupport JavaDoc compData2 = new CompositeDataSupport JavaDoc(rowType2, map);
1121
1122      String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
1123      TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
1124
1125      boolean caught = false;
1126      try
1127      {
1128         new TabularDataSupport JavaDoc(null);
1129      }
1130      catch (IllegalArgumentException JavaDoc e)
1131      {
1132         caught = true;
1133      }
1134      if (caught == false)
1135         fail("Expected IllegalArgumentException for null tabular type");
1136
1137      caught = false;
1138      try
1139      {
1140         new TabularDataSupport JavaDoc(null, 10, .5f);
1141      }
1142      catch (IllegalArgumentException JavaDoc e)
1143      {
1144         caught = true;
1145      }
1146      if (caught == false)
1147         fail("Expected IllegalArgumentException for null tabular type");
1148
1149      caught = false;
1150      try
1151      {
1152         new TabularDataSupport JavaDoc(tabularType, -1, .5f);
1153      }
1154      catch (IllegalArgumentException JavaDoc e)
1155      {
1156         caught = true;
1157      }
1158      if (caught == false)
1159         fail("Expected IllegalArgumentException for negative initial capacity");
1160
1161      caught = false;
1162      try
1163      {
1164         new TabularDataSupport JavaDoc(tabularType, 10, 0f);
1165      }
1166      catch (IllegalArgumentException JavaDoc e)
1167      {
1168         caught = true;
1169      }
1170      if (caught == false)
1171         fail("Expected IllegalArgumentException for zero load factor");
1172
1173      caught = false;
1174      try
1175      {
1176         new TabularDataSupport JavaDoc(tabularType, 10, -0.5f);
1177      }
1178      catch (IllegalArgumentException JavaDoc e)
1179      {
1180         caught = true;
1181      }
1182      if (caught == false)
1183         fail("Expected IllegalArgumentException for negative load factor");
1184
1185      caught = false;
1186      try
1187      {
1188         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1189         data.calculateIndex(null);
1190      }
1191      catch (NullPointerException JavaDoc e)
1192      {
1193         caught = true;
1194      }
1195      if (caught == false)
1196         fail("Expected NullPointerException for calculate index on null object");
1197
1198      caught = false;
1199      try
1200      {
1201         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1202         data.calculateIndex(compData2);
1203      }
1204      catch (InvalidOpenTypeException JavaDoc e)
1205      {
1206         caught = true;
1207      }
1208      if (caught == false)
1209         fail("Expected InvalidOpenTypeException for calculate index on wrong composite type");
1210
1211      caught = false;
1212      try
1213      {
1214         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1215         data.get((Object JavaDoc) null);
1216      }
1217      catch (NullPointerException JavaDoc e)
1218      {
1219         caught = true;
1220      }
1221      if (caught == false)
1222         fail("Expected NullPointerException for get((Object) null)");
1223
1224      caught = false;
1225      try
1226      {
1227         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1228         data.get(new Object JavaDoc());
1229      }
1230      catch (ClassCastException JavaDoc e)
1231      {
1232         caught = true;
1233      }
1234      if (caught == false)
1235         fail("Expected ClassCastException for get(new Object())");
1236
1237      caught = false;
1238      try
1239      {
1240         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1241         data.get((Object JavaDoc) new Object JavaDoc[] { "wrong" });
1242      }
1243      catch (InvalidKeyException JavaDoc e)
1244      {
1245         caught = true;
1246      }
1247      if (caught == false)
1248         fail("Expected InvalidKeyException for get(Object) wrong");
1249
1250      caught = false;
1251      try
1252      {
1253         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1254         data.get((Object JavaDoc[]) null);
1255      }
1256      catch (NullPointerException JavaDoc e)
1257      {
1258         caught = true;
1259      }
1260      if (caught == false)
1261         fail("Expected NullPointerException for get((Object[]) null)");
1262
1263      caught = false;
1264      try
1265      {
1266         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1267         data.get(new Object JavaDoc[] { "wrong" });
1268      }
1269      catch (InvalidKeyException JavaDoc e)
1270      {
1271         caught = true;
1272      }
1273      if (caught == false)
1274         fail("Expected InvalidKeyException for get(Object[]) wrong");
1275
1276      caught = false;
1277      try
1278      {
1279         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1280         data.put(new Object JavaDoc(), null);
1281      }
1282      catch (NullPointerException JavaDoc e)
1283      {
1284         caught = true;
1285      }
1286      if (caught == false)
1287         fail("Expected NullPointerException for put(Object, Object) with null value");
1288
1289      caught = false;
1290      try
1291      {
1292         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1293         data.put(new Object JavaDoc(), new Object JavaDoc());
1294      }
1295      catch (ClassCastException JavaDoc e)
1296      {
1297         caught = true;
1298      }
1299      if (caught == false)
1300         fail("Expected ClassCastException for put(Object, Object) with none CompositeData");
1301
1302      caught = false;
1303      try
1304      {
1305         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1306         data.put(new Object JavaDoc(), compData2);
1307      }
1308      catch (InvalidOpenTypeException JavaDoc e)
1309      {
1310         caught = true;
1311      }
1312      if (caught == false)
1313         fail("Expected InvalidOpenTypeException for put(Object, Object) with wrong CompositeType");
1314
1315      caught = false;
1316      try
1317      {
1318         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1319         data.put(new Object JavaDoc(), compData);
1320         data.put(new Object JavaDoc(), compData);
1321      }
1322      catch (KeyAlreadyExistsException JavaDoc e)
1323      {
1324         caught = true;
1325      }
1326      if (caught == false)
1327         fail("Expected KeyAlreadyExistsException for put(Object, Object)");
1328
1329      caught = false;
1330      try
1331      {
1332         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1333         data.put(null);
1334      }
1335      catch (NullPointerException JavaDoc e)
1336      {
1337         caught = true;
1338      }
1339      if (caught == false)
1340         fail("Expected NullPointerException for put(CompositeData) with null value");
1341
1342      caught = false;
1343      try
1344      {
1345         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1346         data.put(compData2);
1347      }
1348      catch (InvalidOpenTypeException JavaDoc e)
1349      {
1350         caught = true;
1351      }
1352      if (caught == false)
1353         fail("Expected InvalidOpenTypeException for put(CompositeData) with wrong CompositeType");
1354
1355      caught = false;
1356      try
1357      {
1358         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1359         data.put(compData);
1360         data.put(compData);
1361      }
1362      catch (KeyAlreadyExistsException JavaDoc e)
1363      {
1364         caught = true;
1365      }
1366      if (caught == false)
1367         fail("Expected KeyAlreadyExistsException for put(CompositeData)");
1368
1369      caught = false;
1370      try
1371      {
1372         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1373         data.remove((Object JavaDoc) null);
1374      }
1375      catch (NullPointerException JavaDoc e)
1376      {
1377         caught = true;
1378      }
1379      if (caught == false)
1380         fail("Expected NullPointerException for remove((Object) null)");
1381
1382      caught = false;
1383      try
1384      {
1385         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1386         data.remove(new Object JavaDoc());
1387      }
1388      catch (ClassCastException JavaDoc e)
1389      {
1390         caught = true;
1391      }
1392      if (caught == false)
1393         fail("Expected ClassCastException for remove(new Object())");
1394
1395      caught = false;
1396      try
1397      {
1398         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1399         data.remove((Object JavaDoc) new Object JavaDoc[] { "wrong" });
1400      }
1401      catch (InvalidKeyException JavaDoc e)
1402      {
1403         caught = true;
1404      }
1405      if (caught == false)
1406         fail("Expected InvalidKeyException for remove(Object) wrong");
1407
1408      caught = false;
1409      try
1410      {
1411         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1412         data.remove((Object JavaDoc[]) null);
1413      }
1414      catch (NullPointerException JavaDoc e)
1415      {
1416         caught = true;
1417      }
1418      if (caught == false)
1419         fail("Expected NullPointerException for remove((Object[]) null)");
1420
1421      caught = false;
1422      try
1423      {
1424         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1425         data.remove(new Object JavaDoc[] { "wrong" });
1426      }
1427      catch (InvalidKeyException JavaDoc e)
1428      {
1429         caught = true;
1430      }
1431      if (caught == false)
1432         fail("Expected InvalidKeyException for remove(Object[]) wrong");
1433
1434      caught = false;
1435      try
1436      {
1437         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1438         HashMap JavaDoc toPut = new HashMap JavaDoc();
1439         toPut.put(new Object JavaDoc(), compData);
1440         toPut.put(new Object JavaDoc(), null);
1441         data.putAll(toPut);
1442      }
1443      catch (NullPointerException JavaDoc e)
1444      {
1445         caught = true;
1446      }
1447      if (caught == false)
1448         fail("Expected NullPointerException for putAll(Map) null");
1449
1450      {
1451         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1452         HashMap JavaDoc toPut = new HashMap JavaDoc();
1453         toPut.put(new Object JavaDoc(), compData);
1454         toPut.put(new Object JavaDoc(), null);
1455         try
1456         {
1457            data.putAll(toPut);
1458         }
1459         catch (NullPointerException JavaDoc expected)
1460         {
1461         }
1462         assertTrue("Nothing should be added for NullPointerException putAll(Map)", data.isEmpty());
1463      }
1464
1465      caught = false;
1466      try
1467      {
1468         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1469         HashMap JavaDoc toPut = new HashMap JavaDoc();
1470         toPut.put(new Object JavaDoc(), compData);
1471         toPut.put(new Object JavaDoc(), new Object JavaDoc());
1472         data.putAll(toPut);
1473      }
1474      catch (ClassCastException JavaDoc e)
1475      {
1476         caught = true;
1477      }
1478      if (caught == false)
1479         fail("Expected ClassCastException for putAll(Map) non composite data");
1480
1481      {
1482         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1483         HashMap JavaDoc toPut = new HashMap JavaDoc();
1484         toPut.put(new Object JavaDoc(), compData);
1485         toPut.put(new Object JavaDoc(), new Object JavaDoc());
1486         try
1487         {
1488            data.putAll(toPut);
1489         }
1490         catch (ClassCastException JavaDoc expected)
1491         {
1492         }
1493         assertTrue("Nothing should be added for ClassCastException putAll(Map)", data.isEmpty());
1494      }
1495
1496      caught = false;
1497      try
1498      {
1499         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1500         HashMap JavaDoc toPut = new HashMap JavaDoc();
1501         toPut.put(new Object JavaDoc(), compData);
1502         toPut.put(new Object JavaDoc(), compData2);
1503         data.putAll(toPut);
1504      }
1505      catch (InvalidOpenTypeException JavaDoc e)
1506      {
1507         caught = true;
1508      }
1509      if (caught == false)
1510         fail("Expected InvalidOpenTypeException for putAll(Map) wrong composite type");
1511
1512      {
1513         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1514         HashMap JavaDoc toPut = new HashMap JavaDoc();
1515         toPut.put(new Object JavaDoc(), compData);
1516         toPut.put(new Object JavaDoc(), compData2);
1517         try
1518         {
1519            data.putAll(toPut);
1520         }
1521         catch (InvalidOpenTypeException JavaDoc expected)
1522         {
1523         }
1524         assertTrue("Nothing should be added for InvalidOpenTypeException putAll(Map)", data.isEmpty());
1525      }
1526
1527      caught = false;
1528      try
1529      {
1530         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1531         HashMap JavaDoc toPut = new HashMap JavaDoc();
1532         toPut.put(new Object JavaDoc(), compData);
1533         toPut.put(new Object JavaDoc(), compData);
1534         data.putAll(toPut);
1535      }
1536      catch (KeyAlreadyExistsException JavaDoc e)
1537      {
1538         caught = true;
1539      }
1540      if (caught == false)
1541         fail("Expected InvalidOpenTypeException for putAll(Map) with duplicate data");
1542
1543      {
1544         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1545         HashMap JavaDoc toPut = new HashMap JavaDoc();
1546         toPut.put(new Object JavaDoc(), compData);
1547         toPut.put(new Object JavaDoc(), compData);
1548         try
1549         {
1550            data.putAll(toPut);
1551         }
1552         catch (KeyAlreadyExistsException JavaDoc expected)
1553         {
1554         }
1555         assertTrue("Nothing should be added for KeyAlreadyExistsException duplicates putAll(Map)", data.isEmpty());
1556      }
1557
1558      caught = false;
1559      try
1560      {
1561         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1562         HashMap JavaDoc toPut = new HashMap JavaDoc();
1563         toPut.put(new Object JavaDoc(), compData);
1564         data.putAll(toPut);
1565         toPut = new HashMap JavaDoc();
1566         toPut.put(new Object JavaDoc(), compData);
1567         data.putAll(toPut);
1568      }
1569      catch (KeyAlreadyExistsException JavaDoc e)
1570      {
1571         caught = true;
1572      }
1573      if (caught == false)
1574         fail("Expected InvalidOpenTypeException for putAll(Map) adding a duplicate");
1575
1576      {
1577         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1578         HashMap JavaDoc toPut = new HashMap JavaDoc();
1579         toPut.put(new Object JavaDoc(), compData);
1580         data.putAll(toPut);
1581         toPut = new HashMap JavaDoc();
1582         toPut.put(new Object JavaDoc(), compData);
1583         try
1584         {
1585            data.putAll(toPut);
1586         }
1587         catch (KeyAlreadyExistsException JavaDoc expected)
1588         {
1589         }
1590         assertTrue("Nothing should be added for KeyAlreadyExistsException already put putAll(Map)", data.size() == 1);
1591      }
1592
1593      caught = false;
1594      try
1595      {
1596         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1597         CompositeData JavaDoc[] toPut = new CompositeData JavaDoc[] { compData, null };
1598         data.putAll(toPut);
1599      }
1600      catch (NullPointerException JavaDoc e)
1601      {
1602         caught = true;
1603      }
1604      if (caught == false)
1605         fail("Expected NullPointerException for putAll(CompositeData[]) null");
1606
1607      {
1608         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1609         CompositeData JavaDoc[] toPut = new CompositeData JavaDoc[] { compData, null };
1610         try
1611         {
1612            data.putAll(toPut);
1613         }
1614         catch (NullPointerException JavaDoc expected)
1615         {
1616         }
1617         assertTrue("Nothing should be added for NullPointerException putAll(CompositeData[])", data.isEmpty());
1618      }
1619
1620      caught = false;
1621      try
1622      {
1623         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1624         CompositeData JavaDoc[] toPut = new CompositeData JavaDoc[] { compData, compData2 };
1625         data.putAll(toPut);
1626      }
1627      catch (InvalidOpenTypeException JavaDoc e)
1628      {
1629         caught = true;
1630      }
1631      if (caught == false)
1632         fail("Expected InvalidOpenTypeException for putAll(CompositeData[]) wrong composite type");
1633
1634      {
1635         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1636         CompositeData JavaDoc[] toPut = new CompositeData JavaDoc[] { compData, compData2 };
1637         try
1638         {
1639            data.putAll(toPut);
1640         }
1641         catch (InvalidOpenTypeException JavaDoc expected)
1642         {
1643         }
1644         assertTrue("Nothing should be added for InvalidOpenTypeException putAll(CompositeData[])", data.isEmpty());
1645      }
1646
1647      caught = false;
1648      try
1649      {
1650         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1651         CompositeData JavaDoc[] toPut = new CompositeData JavaDoc[] { compData, compData };
1652         data.putAll(toPut);
1653      }
1654      catch (KeyAlreadyExistsException JavaDoc e)
1655      {
1656         caught = true;
1657      }
1658      if (caught == false)
1659         fail("Expected InvalidOpenTypeException for putAll(CompositeData[]) with duplicate data");
1660
1661      {
1662         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1663         CompositeData JavaDoc[] toPut = new CompositeData JavaDoc[] { compData, compData };
1664         try
1665         {
1666            data.putAll(toPut);
1667         }
1668         catch (KeyAlreadyExistsException JavaDoc expected)
1669         {
1670         }
1671         assertTrue("Nothing should be added for KeyAlreadyExistsException duplicates putAll(CompositeData[])", data.isEmpty());
1672      }
1673
1674      caught = false;
1675      try
1676      {
1677         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1678         CompositeData JavaDoc[] toPut = new CompositeData JavaDoc[] { compData };
1679         data.putAll(toPut);
1680         data.putAll(toPut);
1681      }
1682      catch (KeyAlreadyExistsException JavaDoc e)
1683      {
1684         caught = true;
1685      }
1686      if (caught == false)
1687         fail("Expected InvalidOpenTypeException for putAll(CompositeData[]) adding a duplicate");
1688
1689      {
1690         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1691         CompositeData JavaDoc[] toPut = new CompositeData JavaDoc[] { compData };
1692         data.putAll(toPut);
1693         try
1694         {
1695            data.putAll(toPut);
1696         }
1697         catch (KeyAlreadyExistsException JavaDoc expected)
1698         {
1699         }
1700         assertTrue("Nothing should be added for KeyAlreadyExistsException already put putAll(CompositeData[])", data.size() == 1);
1701      }
1702   }
1703}
1704
Popular Tags