KickJava   Java API By Example, From Geeks To Geeks.

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


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 junit.framework.TestCase;
25
26 import java.io.ByteArrayInputStream JavaDoc;
27 import java.io.ByteArrayOutputStream JavaDoc;
28 import java.io.ObjectInputStream JavaDoc;
29 import java.io.ObjectOutputStream JavaDoc;
30
31 import javax.management.openmbean.ArrayType JavaDoc;
32 import javax.management.openmbean.CompositeType JavaDoc;
33 import javax.management.openmbean.OpenDataException JavaDoc;
34 import javax.management.openmbean.OpenMBeanParameterInfoSupport JavaDoc;
35 import javax.management.openmbean.OpenType JavaDoc;
36 import javax.management.openmbean.SimpleType JavaDoc;
37 import javax.management.openmbean.TabularDataSupport JavaDoc;
38 import javax.management.openmbean.TabularType JavaDoc;
39
40 /**
41  * Open MBean Parameter Info tests.<p>
42  *
43  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
44  */

45 public class OpenMBeanParameterInfoSupportTestCase
46   extends TestCase
47 {
48    // Static --------------------------------------------------------------------
49

50    // Attributes ----------------------------------------------------------------
51

52    // Constructor ---------------------------------------------------------------
53

54    /**
55     * Construct the test
56     */

57    public OpenMBeanParameterInfoSupportTestCase(String JavaDoc s)
58    {
59       super(s);
60    }
61
62    // Tests ---------------------------------------------------------------------
63

64    public void testOpenMBeanParameterInfoSupport()
65       throws Exception JavaDoc
66    {
67       OpenMBeanParameterInfoSupport JavaDoc info = new OpenMBeanParameterInfoSupport JavaDoc(
68          "name", "description", SimpleType.STRING);
69       assertEquals("name", info.getName());
70       assertEquals("description", info.getDescription());
71       assertEquals("java.lang.String", info.getType());
72
73       info = new OpenMBeanParameterInfoSupport JavaDoc(
74          "name", "description", SimpleType.STRING, "default");
75       assertEquals("name", info.getName());
76       assertEquals("description", info.getDescription());
77       assertEquals("java.lang.String", info.getType());
78       assertEquals("default", info.getDefaultValue());
79       assertEquals(true, info.hasDefaultValue());
80
81       info = new OpenMBeanParameterInfoSupport JavaDoc(
82          "name", "description", SimpleType.STRING, null);
83       assertEquals("name", info.getName());
84       assertEquals("description", info.getDescription());
85       assertEquals("java.lang.String", info.getType());
86       assertEquals(null, info.getDefaultValue());
87       assertEquals(false, info.hasDefaultValue());
88
89       info = new OpenMBeanParameterInfoSupport JavaDoc(
90          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), new Integer JavaDoc(4));
91       assertEquals("name", info.getName());
92       assertEquals("description", info.getDescription());
93       assertEquals("java.lang.Integer", info.getType());
94       assertEquals(new Integer JavaDoc(3), info.getDefaultValue());
95       assertEquals(new Integer JavaDoc(2), info.getMinValue());
96       assertEquals(new Integer JavaDoc(4), info.getMaxValue());
97
98       info = new OpenMBeanParameterInfoSupport JavaDoc(
99          "name", "description", SimpleType.INTEGER, null, new Integer JavaDoc(2), new Integer JavaDoc(4));
100       assertEquals("name", info.getName());
101       assertEquals("description", info.getDescription());
102       assertEquals("java.lang.Integer", info.getType());
103       assertEquals(null, info.getDefaultValue());
104       assertEquals(new Integer JavaDoc(2), info.getMinValue());
105       assertEquals(new Integer JavaDoc(4), info.getMaxValue());
106
107       info = new OpenMBeanParameterInfoSupport JavaDoc(
108          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), null, new Integer JavaDoc(4));
109       assertEquals("name", info.getName());
110       assertEquals("description", info.getDescription());
111       assertEquals("java.lang.Integer", info.getType());
112       assertEquals(new Integer JavaDoc(3), info.getDefaultValue());
113       assertEquals(null, info.getMinValue());
114       assertEquals(new Integer JavaDoc(4), info.getMaxValue());
115
116       info = new OpenMBeanParameterInfoSupport JavaDoc(
117          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), null);
118       assertEquals("name", info.getName());
119       assertEquals("description", info.getDescription());
120       assertEquals("java.lang.Integer", info.getType());
121       assertEquals(new Integer JavaDoc(3), info.getDefaultValue());
122       assertEquals(new Integer JavaDoc(2), info.getMinValue());
123       assertEquals(null, info.getMaxValue());
124
125       info = new OpenMBeanParameterInfoSupport JavaDoc(
126          "name", "description", SimpleType.INTEGER, null, null, new Integer JavaDoc(4));
127       assertEquals("name", info.getName());
128       assertEquals("description", info.getDescription());
129       assertEquals("java.lang.Integer", info.getType());
130       assertEquals(null, info.getDefaultValue());
131       assertEquals(null, info.getMinValue());
132       assertEquals(new Integer JavaDoc(4), info.getMaxValue());
133
134       info = new OpenMBeanParameterInfoSupport JavaDoc(
135          "name", "description", SimpleType.INTEGER, null, new Integer JavaDoc(2), null);
136       assertEquals("name", info.getName());
137       assertEquals("description", info.getDescription());
138       assertEquals("java.lang.Integer", info.getType());
139       assertEquals(null, info.getDefaultValue());
140       assertEquals(new Integer JavaDoc(2), info.getMinValue());
141       assertEquals(null, info.getMaxValue());
142
143       info = new OpenMBeanParameterInfoSupport JavaDoc(
144          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), null, null);
145       assertEquals("name", info.getName());
146       assertEquals("description", info.getDescription());
147       assertEquals("java.lang.Integer", info.getType());
148       assertEquals(new Integer JavaDoc(3), info.getDefaultValue());
149       assertEquals(null, info.getMinValue());
150       assertEquals(null, info.getMaxValue());
151
152       info = new OpenMBeanParameterInfoSupport JavaDoc(
153          "name", "description", SimpleType.INTEGER, null, null, null);
154       assertEquals("name", info.getName());
155       assertEquals("description", info.getDescription());
156       assertEquals("java.lang.Integer", info.getType());
157       assertEquals(null, info.getDefaultValue());
158       assertEquals(null, info.getMinValue());
159       assertEquals(null, info.getMaxValue());
160
161       info = new OpenMBeanParameterInfoSupport JavaDoc(
162          "name", "description", SimpleType.STRING, "default",
163          new Object JavaDoc[] { "legal1", "legal2", "default" });
164       assertEquals("name", info.getName());
165       assertEquals("description", info.getDescription());
166       assertEquals("java.lang.String", info.getType());
167       assertEquals("default", info.getDefaultValue());
168       assertEquals(3, info.getLegalValues().size());
169       assertTrue("legal1 should be a legal value", info.getLegalValues().contains("legal1"));
170       assertTrue("legal2 should be a legal value", info.getLegalValues().contains("legal2"));
171       assertTrue("default should be a legal value", info.getLegalValues().contains("default"));
172
173       info = new OpenMBeanParameterInfoSupport JavaDoc(
174          "name", "description", SimpleType.STRING, null,
175          new Object JavaDoc[] { "legal1", "legal2", "default" });
176       assertEquals("name", info.getName());
177       assertEquals("description", info.getDescription());
178       assertEquals("java.lang.String", info.getType());
179       assertEquals(null, info.getDefaultValue());
180       assertEquals(3, info.getLegalValues().size());
181       assertTrue("legal1 should be a legal value", info.getLegalValues().contains("legal1"));
182       assertTrue("legal2 should be a legal value", info.getLegalValues().contains("legal2"));
183       assertTrue("default should be a legal value", info.getLegalValues().contains("default"));
184
185       info = new OpenMBeanParameterInfoSupport JavaDoc(
186          "name", "description", SimpleType.STRING, "default", null);
187       assertEquals("name", info.getName());
188       assertEquals("description", info.getDescription());
189       assertEquals("java.lang.String", info.getType());
190       assertEquals("default", info.getDefaultValue());
191       assertEquals(null, info.getLegalValues());
192
193       info = new OpenMBeanParameterInfoSupport JavaDoc(
194          "name", "description", SimpleType.STRING, null, null);
195       assertEquals("name", info.getName());
196       assertEquals("description", info.getDescription());
197       assertEquals("java.lang.String", info.getType());
198       assertEquals(null, info.getDefaultValue());
199       assertEquals(null, info.getLegalValues());
200    }
201
202    public void testOpenType()
203       throws Exception JavaDoc
204    {
205       OpenMBeanParameterInfoSupport JavaDoc info = new OpenMBeanParameterInfoSupport JavaDoc(
206          "name", "description", SimpleType.STRING);
207       assertEquals(SimpleType.STRING, info.getOpenType());
208    }
209
210    public void testHas()
211       throws Exception JavaDoc
212    {
213       OpenMBeanParameterInfoSupport JavaDoc info = new OpenMBeanParameterInfoSupport JavaDoc(
214          "name", "description", SimpleType.STRING, "default");
215       assertEquals(true, info.hasDefaultValue());
216
217       info = new OpenMBeanParameterInfoSupport JavaDoc(
218          "name", "description", SimpleType.STRING, null);
219       assertEquals(false, info.hasDefaultValue());
220
221       info = new OpenMBeanParameterInfoSupport JavaDoc(
222          "name", "description", SimpleType.INTEGER, null, new Integer JavaDoc(3), null);
223       assertEquals(true, info.hasMinValue());
224
225       info = new OpenMBeanParameterInfoSupport JavaDoc(
226          "name", "description", SimpleType.INTEGER, null, null, null);
227       assertEquals(false, info.hasMinValue());
228
229       info = new OpenMBeanParameterInfoSupport JavaDoc(
230          "name", "description", SimpleType.INTEGER, null, null, new Integer JavaDoc(3));
231       assertEquals(true, info.hasMaxValue());
232
233       info = new OpenMBeanParameterInfoSupport JavaDoc(
234          "name", "description", SimpleType.INTEGER, null, null, null);
235       assertEquals(false, info.hasMaxValue());
236
237       info = new OpenMBeanParameterInfoSupport JavaDoc(
238          "name", "description", SimpleType.INTEGER, null, new Object JavaDoc[] { new Integer JavaDoc(3) });
239       assertEquals(true, info.hasLegalValues());
240
241       info = new OpenMBeanParameterInfoSupport JavaDoc(
242          "name", "description", SimpleType.INTEGER, null, null);
243       assertEquals(false, info.hasLegalValues());
244    }
245
246    public void testIsValue()
247       throws Exception JavaDoc
248    {
249       OpenMBeanParameterInfoSupport JavaDoc info = new OpenMBeanParameterInfoSupport JavaDoc(
250          "name", "description", SimpleType.STRING);
251       assertTrue("String should be a value", info.isValue("string"));
252       assertTrue("Integer should not be a value", info.isValue(new Integer JavaDoc(3)) == false);
253       assertTrue("Null should not be a value", info.isValue(null) == false);
254    }
255
256    public void testEquals()
257       throws Exception JavaDoc
258    {
259       OpenMBeanParameterInfoSupport JavaDoc info = new OpenMBeanParameterInfoSupport JavaDoc(
260          "name", "description", SimpleType.STRING);
261
262       assertTrue("Null should not be equal", info.equals(null) == false);
263       assertTrue("Only OpenMBeanParameterInfo should be equal", info.equals(new Object JavaDoc()) == false);
264
265       OpenMBeanParameterInfoSupport JavaDoc info2 = new OpenMBeanParameterInfoSupport JavaDoc(
266          "name", "description", SimpleType.STRING);
267
268       assertTrue("Different instances of the same data are equal", info.equals(info2));
269       assertTrue("Different instances of the same data are equal", info2.equals(info));
270
271       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
272          "name", "description2", SimpleType.STRING);
273
274       assertTrue("Different instances with different descriptions are equal", info.equals(info2));
275       assertTrue("Different instances with different descritpions are equal", info2.equals(info));
276
277       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
278          "name2", "description", SimpleType.STRING);
279
280       assertTrue("Instances with different names are not equal", info.equals(info2) == false);
281       assertTrue("Instances with different names are not equal", info2.equals(info) == false);
282
283       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
284          "name", "description", SimpleType.INTEGER);
285
286       assertTrue("Instances with different types are not equal", info.equals(info2) == false);
287       assertTrue("Instances with different types are not equal", info2.equals(info) == false);
288
289       info = new OpenMBeanParameterInfoSupport JavaDoc(
290          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), new Integer JavaDoc(4));
291       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
292          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(2), new Integer JavaDoc(2), new Integer JavaDoc(4));
293
294       assertTrue("Instances with different default values are not equal", info.equals(info2) == false);
295       assertTrue("Instances with different default values are not equal", info2.equals(info) == false);
296
297       info = new OpenMBeanParameterInfoSupport JavaDoc(
298          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), new Integer JavaDoc(4));
299       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
300          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(2), null, new Integer JavaDoc(4));
301
302       assertTrue("Instances with different default values are not equal", info.equals(info2) == false);
303       assertTrue("Instances with different default values are not equal", info2.equals(info) == false);
304
305       info = new OpenMBeanParameterInfoSupport JavaDoc(
306          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3));
307       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
308          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3));
309
310       assertTrue("Different instances of the same default value are equal", info.equals(info2));
311       assertTrue("Different instances of the same default value are equal", info2.equals(info));
312
313       info = new OpenMBeanParameterInfoSupport JavaDoc(
314          "name", "description", SimpleType.INTEGER, null, new Integer JavaDoc(2), null);
315       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
316          "name", "description", SimpleType.INTEGER, null, new Integer JavaDoc(2), null);
317
318       assertTrue("Different instances of the same minimum are equal", info.equals(info2));
319       assertTrue("Different instances of the same minimum are equal", info2.equals(info));
320
321       info = new OpenMBeanParameterInfoSupport JavaDoc(
322          "name", "description", SimpleType.INTEGER, null, null, new Integer JavaDoc(2));
323       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
324          "name", "description", SimpleType.INTEGER, null, null, new Integer JavaDoc(2));
325
326       assertTrue("Different instances of the same maximum are equal", info.equals(info2));
327       assertTrue("Different instances of the same maximum are equal", info2.equals(info));
328
329       info = new OpenMBeanParameterInfoSupport JavaDoc(
330          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), new Integer JavaDoc(4));
331       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
332          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(1), new Integer JavaDoc(4));
333
334       assertTrue("Instances with different minimums are not equal", info.equals(info2) == false);
335       assertTrue("Instances with different minimums are not equal", info2.equals(info) == false);
336
337       info = new OpenMBeanParameterInfoSupport JavaDoc(
338          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), new Integer JavaDoc(4));
339       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
340          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), null, new Integer JavaDoc(4));
341
342       assertTrue("Instances with different minimums are not equal", info.equals(info2) == false);
343       assertTrue("Instances with different minimums are not equal", info2.equals(info) == false);
344
345       info = new OpenMBeanParameterInfoSupport JavaDoc(
346          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), new Integer JavaDoc(4));
347       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
348          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), new Integer JavaDoc(5));
349
350       assertTrue("Instances with different maximums are not equal", info.equals(info2) == false);
351       assertTrue("Instances with different maximums are not equal", info2.equals(info) == false);
352
353       info = new OpenMBeanParameterInfoSupport JavaDoc(
354          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), new Integer JavaDoc(4));
355       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
356          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), null);
357
358       assertTrue("Instances with different maximums are not equal", info.equals(info2) == false);
359       assertTrue("Instances with different maximums are not equal", info2.equals(info) == false);
360
361       info = new OpenMBeanParameterInfoSupport JavaDoc(
362          "name", "description", SimpleType.INTEGER, null, new Object JavaDoc[] { new Integer JavaDoc(2), new Integer JavaDoc(3) });
363       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
364          "name", "description", SimpleType.INTEGER, null, new Object JavaDoc[] { new Integer JavaDoc(2), new Integer JavaDoc(3) });
365
366       assertTrue("Different instances of the same legal values are equal", info.equals(info2));
367       assertTrue("Different instances of the same legal values are equal", info2.equals(info));
368
369       info = new OpenMBeanParameterInfoSupport JavaDoc(
370          "name", "description", SimpleType.INTEGER, null, new Object JavaDoc[] { new Integer JavaDoc(2), new Integer JavaDoc(3) });
371       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
372          "name", "description", SimpleType.INTEGER, null, new Object JavaDoc[] { new Integer JavaDoc(2), new Integer JavaDoc(4) });
373
374       assertTrue("Different instances with different legal values are equal", info.equals(info2) == false);
375       assertTrue("Different instances with different legal values are equal", info2.equals(info) == false);
376
377       info = new OpenMBeanParameterInfoSupport JavaDoc(
378          "name", "description", SimpleType.INTEGER, null, new Object JavaDoc[] { new Integer JavaDoc(2), new Integer JavaDoc(3) });
379       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
380          "name", "description", SimpleType.INTEGER, null, new Object JavaDoc[] { new Integer JavaDoc(2) });
381
382       assertTrue("Different instances with different legal values are equal", info.equals(info2) == false);
383       assertTrue("Different instances with different legal values are equal", info2.equals(info) == false);
384
385       info = new OpenMBeanParameterInfoSupport JavaDoc(
386          "name", "description", SimpleType.INTEGER, null, new Object JavaDoc[] { new Integer JavaDoc(2), new Integer JavaDoc(3) });
387       info2 = new OpenMBeanParameterInfoSupport JavaDoc(
388          "name", "description", SimpleType.INTEGER, null, null);
389
390       assertTrue("Different instances with different legal values are equal", info.equals(info2) == false);
391       assertTrue("Different instances with different legal values are equal", info2.equals(info) == false);
392    }
393
394    public void testHashCode()
395       throws Exception JavaDoc
396    {
397
398       OpenMBeanParameterInfoSupport JavaDoc info = new OpenMBeanParameterInfoSupport JavaDoc(
399          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), new Integer JavaDoc(4));
400       int myHash = "name".hashCode() + SimpleType.INTEGER.hashCode() +
401          new Integer JavaDoc(3).hashCode() + new Integer JavaDoc(2).hashCode() + new Integer JavaDoc(4).hashCode();
402       assertEquals(myHash, info.hashCode());
403       info = new OpenMBeanParameterInfoSupport JavaDoc(
404          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3),
405          new Object JavaDoc[] { new Integer JavaDoc(2), new Integer JavaDoc(3), new Integer JavaDoc(4) } );
406       myHash = "name".hashCode() + SimpleType.INTEGER.hashCode() +
407          new Integer JavaDoc(3).hashCode() + new Integer JavaDoc(2).hashCode() + new Integer JavaDoc(3).hashCode() + new Integer JavaDoc(4).hashCode();
408       assertEquals(myHash, info.hashCode());
409    }
410
411    public void testToString()
412       throws Exception JavaDoc
413    {
414       OpenMBeanParameterInfoSupport JavaDoc info = new OpenMBeanParameterInfoSupport JavaDoc(
415          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), new Integer JavaDoc(4));
416
417       String JavaDoc toString = info.toString();
418       assertTrue("info.toString() should contain the name", toString.indexOf("name") != -1);
419       assertTrue("info.toString() should contain the simple type",
420          toString.indexOf(SimpleType.INTEGER.toString()) != -1);
421       assertTrue("info.toString() should contain the default value",
422          toString.indexOf(new Integer JavaDoc(3).toString()) != -1);
423       assertTrue("info.toString() should contain the minimum value",
424          toString.indexOf(new Integer JavaDoc(2).toString()) != -1);
425       assertTrue("info.toString() should contain the maximum value",
426          toString.indexOf(new Integer JavaDoc(4).toString()) != -1);
427
428       info = new OpenMBeanParameterInfoSupport JavaDoc(
429          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3),
430          new Object JavaDoc[] { new Integer JavaDoc(2), new Integer JavaDoc(3), new Integer JavaDoc(4) } );
431       assertTrue("info.toString() should contain the legal value 2",
432          toString.indexOf(new Integer JavaDoc(2).toString()) != -1);
433       assertTrue("info.toString() should contain the legal value 3",
434          toString.indexOf(new Integer JavaDoc(3).toString()) != -1);
435       assertTrue("info.toString() should contain the legal value 4",
436          toString.indexOf(new Integer JavaDoc(4).toString()) != -1);
437    }
438
439    public void testSerialization()
440       throws Exception JavaDoc
441    {
442       OpenMBeanParameterInfoSupport JavaDoc info = new OpenMBeanParameterInfoSupport JavaDoc(
443          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(2), new Integer JavaDoc(4));
444
445       // Serialize it
446
ByteArrayOutputStream JavaDoc baos = new ByteArrayOutputStream JavaDoc();
447       ObjectOutputStream JavaDoc oos = new ObjectOutputStream JavaDoc(baos);
448       oos.writeObject(info);
449     
450       // Deserialize it
451
ByteArrayInputStream JavaDoc bais = new ByteArrayInputStream JavaDoc(baos.toByteArray());
452       ObjectInputStream JavaDoc ois = new ObjectInputStream JavaDoc(bais);
453       Object JavaDoc result = ois.readObject();
454
455       assertEquals(info, result);
456
457       info = new OpenMBeanParameterInfoSupport JavaDoc(
458          "name", "description", SimpleType.INTEGER, new Integer JavaDoc(3),
459          new Object JavaDoc[] { new Integer JavaDoc(2), new Integer JavaDoc(3), new Integer JavaDoc(4) } );
460
461       // Serialize it
462
baos = new ByteArrayOutputStream JavaDoc();
463       oos = new ObjectOutputStream JavaDoc(baos);
464       oos.writeObject(info);
465     
466       // Deserialize it
467
bais = new ByteArrayInputStream JavaDoc(baos.toByteArray());
468       ois = new ObjectInputStream JavaDoc(bais);
469       result = ois.readObject();
470
471       assertEquals(info, result);
472    }
473
474    public void testErrors1()
475       throws Exception JavaDoc
476    {
477       boolean caught = false;
478       try
479       {
480          new OpenMBeanParameterInfoSupport JavaDoc(
481             null, "description", SimpleType.INTEGER);
482       }
483       catch (IllegalArgumentException JavaDoc e)
484       {
485          caught = true;
486       }
487       if (caught == false)
488          fail("Expected IllegalArgumentException for null name");
489
490       caught = false;
491       try
492       {
493          new OpenMBeanParameterInfoSupport JavaDoc(
494             "", "description", SimpleType.INTEGER);
495       }
496       catch (IllegalArgumentException JavaDoc e)
497       {
498          caught = true;
499       }
500       if (caught == false)
501          fail("Expected IllegalArgumentException for an empty name");
502
503       caught = false;
504       try
505       {
506          new OpenMBeanParameterInfoSupport JavaDoc(
507             "name", null, SimpleType.INTEGER);
508       }
509       catch (IllegalArgumentException JavaDoc e)
510       {
511          caught = true;
512       }
513       if (caught == false)
514          fail("Expected IllegalArgumentException for null description");
515
516       caught = false;
517       try
518       {
519          new OpenMBeanParameterInfoSupport JavaDoc(
520             "name", "", SimpleType.INTEGER);
521       }
522       catch (IllegalArgumentException JavaDoc e)
523       {
524          caught = true;
525       }
526       if (caught == false)
527          fail("Expected IllegalArgumentException for an empty description");
528
529       caught = false;
530       try
531       {
532          new OpenMBeanParameterInfoSupport JavaDoc(
533             "", "description", SimpleType.INTEGER);
534       }
535       catch (IllegalArgumentException JavaDoc e)
536       {
537          caught = true;
538       }
539       if (caught == false)
540          fail("Expected IllegalArgumentException for an empty name");
541
542       caught = false;
543       try
544       {
545          new OpenMBeanParameterInfoSupport JavaDoc(
546             "name", "description", null);
547       }
548       catch (IllegalArgumentException JavaDoc e)
549       {
550          caught = true;
551       }
552       if (caught == false)
553          fail("Expected IllegalArgumentException for null simple type");
554    }
555
556    public void testErrors2()
557       throws Exception JavaDoc
558    {
559       boolean caught = false;
560       try
561       {
562          new OpenMBeanParameterInfoSupport JavaDoc(
563             null, "description", SimpleType.INTEGER, new Integer JavaDoc(3));
564       }
565       catch (IllegalArgumentException JavaDoc e)
566       {
567          caught = true;
568       }
569       if (caught == false)
570          fail("Expected IllegalArgumentException for null name");
571
572       caught = false;
573       try
574       {
575          new OpenMBeanParameterInfoSupport JavaDoc(
576             "", "description", SimpleType.INTEGER, new Integer JavaDoc(3));
577       }
578       catch (IllegalArgumentException JavaDoc e)
579       {
580          caught = true;
581       }
582       if (caught == false)
583          fail("Expected IllegalArgumentException for an empty name");
584
585       caught = false;
586       try
587       {
588          new OpenMBeanParameterInfoSupport JavaDoc(
589             "name", null, SimpleType.INTEGER, new Integer JavaDoc(3));
590       }
591       catch (IllegalArgumentException JavaDoc e)
592       {
593          caught = true;
594       }
595       if (caught == false)
596          fail("Expected IllegalArgumentException for null description");
597
598       caught = false;
599       try
600       {
601          new OpenMBeanParameterInfoSupport JavaDoc(
602             "name", "", SimpleType.INTEGER, new Integer JavaDoc(3));
603       }
604       catch (IllegalArgumentException JavaDoc e)
605       {
606          caught = true;
607       }
608       if (caught == false)
609          fail("Expected IllegalArgumentException for an empty description");
610
611       caught = false;
612       try
613       {
614          new OpenMBeanParameterInfoSupport JavaDoc(
615             "", "description", SimpleType.INTEGER, new Integer JavaDoc(3));
616       }
617       catch (IllegalArgumentException JavaDoc e)
618       {
619          caught = true;
620       }
621       if (caught == false)
622          fail("Expected IllegalArgumentException for an empty name");
623
624       caught = false;
625       try
626       {
627          new OpenMBeanParameterInfoSupport JavaDoc(
628             "name", "description", null, new Integer JavaDoc(3));
629       }
630       catch (IllegalArgumentException JavaDoc e)
631       {
632          caught = true;
633       }
634       if (caught == false)
635          fail("Expected IllegalArgumentException for null simple type");
636
637       caught = false;
638       try
639       {
640          new OpenMBeanParameterInfoSupport JavaDoc(
641             "name", "description", SimpleType.STRING, new Integer JavaDoc(3));
642       }
643       catch (OpenDataException JavaDoc e)
644       {
645          caught = true;
646       }
647       if (caught == false)
648          fail("Expected OpenDataException for wrong simple type and default value");
649
650       caught = false;
651       try
652       {
653          ArrayType JavaDoc arrayType = new ArrayType JavaDoc(1, SimpleType.STRING);
654          new OpenMBeanParameterInfoSupport JavaDoc(
655             "name", "description", arrayType, new String JavaDoc[0]);
656       }
657       catch (OpenDataException JavaDoc e)
658       {
659          caught = true;
660       }
661       if (caught == false)
662          fail("Expected OpenDataException for array type and default value");
663
664       caught = false;
665       try
666       {
667          ArrayType JavaDoc arrayType = new ArrayType JavaDoc(1, SimpleType.STRING);
668          new OpenMBeanParameterInfoSupport JavaDoc(
669             "name", "description", arrayType, null);
670       }
671       catch (OpenDataException JavaDoc e)
672       {
673          caught = true;
674       }
675       if (caught == true)
676          fail("Didn't execpt OpenDataException for array type and no default value");
677
678       caught = false;
679       try
680       {
681          String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
682          String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
683          OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
684          CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
685             itemNames, itemDescriptions, itemTypes);
686
687          String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
688          TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
689          TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
690
691          new OpenMBeanParameterInfoSupport JavaDoc(
692             "name", "description", tabularType, data);
693       }
694       catch (OpenDataException JavaDoc e)
695       {
696          caught = true;
697       }
698       if (caught == false)
699          fail("Expected OpenDataException for tabular type and default value");
700
701       caught = false;
702       try
703       {
704          String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
705          String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
706          OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
707          CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
708             itemNames, itemDescriptions, itemTypes);
709
710          String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
711          TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
712
713          new OpenMBeanParameterInfoSupport JavaDoc(
714             "name", "description", tabularType, null);
715       }
716       catch (OpenDataException JavaDoc e)
717       {
718          caught = true;
719       }
720       if (caught == true)
721          fail("Didn't execpt OpenDataException for tabular type and null default value");
722    }
723
724    public void testErrors3()
725       throws Exception JavaDoc
726    {
727       boolean caught = false;
728       try
729       {
730          new OpenMBeanParameterInfoSupport JavaDoc(
731             null, "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc[] { new Integer JavaDoc(3), new Integer JavaDoc(4) });
732       }
733       catch (IllegalArgumentException JavaDoc e)
734       {
735          caught = true;
736       }
737       if (caught == false)
738          fail("Expected IllegalArgumentException for null name");
739
740       caught = false;
741       try
742       {
743          new OpenMBeanParameterInfoSupport JavaDoc(
744             "", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc[] { new Integer JavaDoc(3), new Integer JavaDoc(4) });
745       }
746       catch (IllegalArgumentException JavaDoc e)
747       {
748          caught = true;
749       }
750       if (caught == false)
751          fail("Expected IllegalArgumentException for an empty name");
752
753       caught = false;
754       try
755       {
756          new OpenMBeanParameterInfoSupport JavaDoc(
757             "name", null, SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc[] { new Integer JavaDoc(3), new Integer JavaDoc(4) });
758       }
759       catch (IllegalArgumentException JavaDoc e)
760       {
761          caught = true;
762       }
763       if (caught == false)
764          fail("Expected IllegalArgumentException for null description");
765
766       caught = false;
767       try
768       {
769          new OpenMBeanParameterInfoSupport JavaDoc(
770             "name", "", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc[] { new Integer JavaDoc(3), new Integer JavaDoc(4) });
771       }
772       catch (IllegalArgumentException JavaDoc e)
773       {
774          caught = true;
775       }
776       if (caught == false)
777          fail("Expected IllegalArgumentException for an empty description");
778
779       caught = false;
780       try
781       {
782          new OpenMBeanParameterInfoSupport JavaDoc(
783             "", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc[] { new Integer JavaDoc(3), new Integer JavaDoc(4) });
784       }
785       catch (IllegalArgumentException JavaDoc e)
786       {
787          caught = true;
788       }
789       if (caught == false)
790          fail("Expected IllegalArgumentException for an empty name");
791
792       caught = false;
793       try
794       {
795          new OpenMBeanParameterInfoSupport JavaDoc(
796             "name", "description", null, new Integer JavaDoc(3), new Integer JavaDoc[] { new Integer JavaDoc(3), new Integer JavaDoc(4) });
797       }
798       catch (IllegalArgumentException JavaDoc e)
799       {
800          caught = true;
801       }
802       if (caught == false)
803          fail("Expected IllegalArgumentException for null simple type");
804
805       caught = false;
806       try
807       {
808          new OpenMBeanParameterInfoSupport JavaDoc(
809             "name", "description", SimpleType.STRING, new Integer JavaDoc(3), new Integer JavaDoc[] { new Integer JavaDoc(3), new Integer JavaDoc(4) });
810       }
811       catch (OpenDataException JavaDoc e)
812       {
813          caught = true;
814       }
815       if (caught == false)
816          fail("Expected OpenDataException for wrong simple type and default value");
817
818       caught = false;
819       try
820       {
821          ArrayType JavaDoc arrayType = new ArrayType JavaDoc(1, SimpleType.STRING);
822          new OpenMBeanParameterInfoSupport JavaDoc(
823             "name", "description", arrayType, new String JavaDoc[0], null);
824       }
825       catch (OpenDataException JavaDoc e)
826       {
827          caught = true;
828       }
829       if (caught == false)
830          fail("Expected OpenDataException for array type and default value");
831
832       caught = false;
833       try
834       {
835          ArrayType JavaDoc arrayType = new ArrayType JavaDoc(1, SimpleType.STRING);
836          new OpenMBeanParameterInfoSupport JavaDoc(
837             "name", "description", arrayType, null, null);
838       }
839       catch (OpenDataException JavaDoc e)
840       {
841          caught = true;
842       }
843       if (caught == true)
844          fail("Didn't expect OpenDataException for array type and no default value and legals");
845
846       caught = false;
847       try
848       {
849          String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
850          String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
851          OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
852          CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
853             itemNames, itemDescriptions, itemTypes);
854
855          String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
856          TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
857          TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
858
859          new OpenMBeanParameterInfoSupport JavaDoc(
860             "name", "description", tabularType, data, null);
861       }
862       catch (OpenDataException JavaDoc e)
863       {
864          caught = true;
865       }
866       if (caught == false)
867          fail("Expected OpenDataException for tabular type and default value");
868
869       caught = false;
870       try
871       {
872          String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
873          String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
874          OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
875          CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
876             itemNames, itemDescriptions, itemTypes);
877
878          String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
879          TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
880
881          new OpenMBeanParameterInfoSupport JavaDoc(
882             "name", "description", tabularType, null, null);
883       }
884       catch (OpenDataException JavaDoc e)
885       {
886          caught = true;
887       }
888       if (caught == true)
889          fail("Didn't expect OpenDataException for tabular type and null default value and legals");
890
891       caught = false;
892       try
893       {
894          ArrayType JavaDoc arrayType = new ArrayType JavaDoc(1, SimpleType.STRING);
895          new OpenMBeanParameterInfoSupport JavaDoc(
896             "name", "description", arrayType, null, new String JavaDoc[] { "hello", "goodbye" });
897       }
898       catch (OpenDataException JavaDoc e)
899       {
900          caught = true;
901       }
902       if (caught == false)
903          fail("Expected OpenDataException for array type and default value");
904
905       caught = false;
906       try
907       {
908          ArrayType JavaDoc arrayType = new ArrayType JavaDoc(1, SimpleType.STRING);
909          new OpenMBeanParameterInfoSupport JavaDoc(
910             "name", "description", arrayType, null, new String JavaDoc[0]);
911       }
912       catch (OpenDataException JavaDoc e)
913       {
914          caught = true;
915       }
916       if (caught == true)
917          fail("Didn't expect OpenDataException for array type and no default value and empty legals");
918
919       caught = false;
920       try
921       {
922          String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
923          String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
924          OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
925          CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
926             itemNames, itemDescriptions, itemTypes);
927
928          String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
929          TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
930          TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
931
932          new OpenMBeanParameterInfoSupport JavaDoc(
933             "name", "description", tabularType, null, new TabularDataSupport JavaDoc[] { data });
934       }
935       catch (OpenDataException JavaDoc e)
936       {
937          caught = true;
938       }
939       if (caught == false)
940          fail("Expected OpenDataException for tabular type and legal values");
941
942       caught = false;
943       try
944       {
945          String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
946          String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
947          OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
948          CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
949             itemNames, itemDescriptions, itemTypes);
950
951          String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
952          TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
953
954          new OpenMBeanParameterInfoSupport JavaDoc(
955             "name", "description", tabularType, null, new TabularDataSupport JavaDoc[0]);
956       }
957       catch (OpenDataException JavaDoc e)
958       {
959          caught = true;
960       }
961       if (caught == true)
962          fail("Didn't expect OpenDataException for tabular type and null default value and empty legals");
963
964       caught = false;
965       try
966       {
967          new OpenMBeanParameterInfoSupport JavaDoc(
968             "name", "description", SimpleType.STRING, new Integer JavaDoc(3), new Integer JavaDoc[] { new Integer JavaDoc(2), new Integer JavaDoc(4) });
969       }
970       catch (OpenDataException JavaDoc e)
971       {
972          caught = true;
973       }
974       if (caught == false)
975          fail("Expected OpenDataException for default value not a legal value");
976    }
977
978    public void testErrors4()
979       throws Exception JavaDoc
980    {
981       boolean caught = false;
982       try
983       {
984          new OpenMBeanParameterInfoSupport JavaDoc(
985             null, "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(3), new Integer JavaDoc(4));
986       }
987       catch (IllegalArgumentException JavaDoc e)
988       {
989          caught = true;
990       }
991       if (caught == false)
992          fail("Expected IllegalArgumentException for null name");
993
994       caught = false;
995       try
996       {
997          new OpenMBeanParameterInfoSupport JavaDoc(
998             "", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(3), new Integer JavaDoc(4));
999       }
1000      catch (IllegalArgumentException JavaDoc e)
1001      {
1002         caught = true;
1003      }
1004      if (caught == false)
1005         fail("Expected IllegalArgumentException for an empty name");
1006
1007      caught = false;
1008      try
1009      {
1010         new OpenMBeanParameterInfoSupport JavaDoc(
1011            "name", null, SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(3), new Integer JavaDoc(4));
1012      }
1013      catch (IllegalArgumentException JavaDoc e)
1014      {
1015         caught = true;
1016      }
1017      if (caught == false)
1018         fail("Expected IllegalArgumentException for null description");
1019
1020      caught = false;
1021      try
1022      {
1023         new OpenMBeanParameterInfoSupport JavaDoc(
1024            "name", "", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(3), new Integer JavaDoc(4));
1025      }
1026      catch (IllegalArgumentException JavaDoc e)
1027      {
1028         caught = true;
1029      }
1030      if (caught == false)
1031         fail("Expected IllegalArgumentException for an empty description");
1032
1033      caught = false;
1034      try
1035      {
1036         new OpenMBeanParameterInfoSupport JavaDoc(
1037            "", "description", SimpleType.INTEGER, new Integer JavaDoc(3), new Integer JavaDoc(3), new Integer JavaDoc(4));
1038      }
1039      catch (IllegalArgumentException JavaDoc e)
1040      {
1041         caught = true;
1042      }
1043      if (caught == false)
1044         fail("Expected IllegalArgumentException for an empty name");
1045
1046      caught = false;
1047      try
1048      {
1049         new OpenMBeanParameterInfoSupport JavaDoc(
1050            "name", "description", null, new Integer JavaDoc(3), new Integer JavaDoc(3), new Integer JavaDoc(4));
1051      }
1052      catch (IllegalArgumentException JavaDoc e)
1053      {
1054         caught = true;
1055      }
1056      if (caught == false)
1057         fail("Expected IllegalArgumentException for null simple type");
1058
1059      caught = false;
1060      try
1061      {
1062         new OpenMBeanParameterInfoSupport JavaDoc(
1063            "name", "description", SimpleType.STRING, new Integer JavaDoc(3), null, null);
1064      }
1065      catch (OpenDataException JavaDoc e)
1066      {
1067         caught = true;
1068      }
1069      if (caught == false)
1070         fail("Expected OpenDataException for wrong simple type and default value");
1071
1072      caught = false;
1073      try
1074      {
1075         new OpenMBeanParameterInfoSupport JavaDoc(
1076            "name", "description", SimpleType.STRING, null, new Integer JavaDoc(3), null);
1077      }
1078      catch (OpenDataException JavaDoc e)
1079      {
1080         caught = true;
1081      }
1082      if (caught == false)
1083         fail("Expected OpenDataException for wrong simple type and minimum value");
1084
1085      caught = false;
1086      try
1087      {
1088         new OpenMBeanParameterInfoSupport JavaDoc(
1089            "name", "description", SimpleType.STRING, null, null, new Integer JavaDoc(3));
1090      }
1091      catch (OpenDataException JavaDoc e)
1092      {
1093         caught = true;
1094      }
1095      if (caught == false)
1096         fail("Expected OpenDataException for wrong simple type and maximum value");
1097
1098      caught = false;
1099      try
1100      {
1101         ArrayType JavaDoc arrayType = new ArrayType JavaDoc(1, SimpleType.STRING);
1102         new OpenMBeanParameterInfoSupport JavaDoc(
1103            "name", "description", arrayType, new String JavaDoc[0], null, null);
1104      }
1105      catch (OpenDataException JavaDoc e)
1106      {
1107         caught = true;
1108      }
1109      if (caught == false)
1110         fail("Expected OpenDataException for array type and default value");
1111
1112      caught = false;
1113      try
1114      {
1115         ArrayType JavaDoc arrayType = new ArrayType JavaDoc(1, SimpleType.STRING);
1116         new OpenMBeanParameterInfoSupport JavaDoc(
1117            "name", "description", arrayType, null, null, null);
1118      }
1119      catch (OpenDataException JavaDoc e)
1120      {
1121         caught = true;
1122      }
1123      if (caught == true)
1124         fail("Didn't expect OpenDataException for array type and no default value");
1125
1126      caught = false;
1127      try
1128      {
1129         String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
1130         String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
1131         OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
1132         CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
1133            itemNames, itemDescriptions, itemTypes);
1134
1135         String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
1136         TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
1137         TabularDataSupport JavaDoc data = new TabularDataSupport JavaDoc(tabularType);
1138
1139         new OpenMBeanParameterInfoSupport JavaDoc(
1140            "name", "description", tabularType, data, null, null);
1141      }
1142      catch (OpenDataException JavaDoc e)
1143      {
1144         caught = true;
1145      }
1146      if (caught == false)
1147         fail("Expected OpenDataException for tabular type and default value");
1148
1149      caught = false;
1150      try
1151      {
1152         String JavaDoc[] itemNames = new String JavaDoc[] { "name1", "name2" };
1153         String JavaDoc[] itemDescriptions = new String JavaDoc[] { "desc1", "desc2" };
1154         OpenType JavaDoc[] itemTypes = new OpenType JavaDoc[] { SimpleType.STRING, SimpleType.INTEGER };
1155         CompositeType JavaDoc rowType = new CompositeType JavaDoc("rowTypeName", "rowDescription",
1156            itemNames, itemDescriptions, itemTypes);
1157
1158         String JavaDoc[] indexNames = new String JavaDoc[] { "name1", "name2" };
1159         TabularType JavaDoc tabularType = new TabularType JavaDoc("typeName", "description", rowType, indexNames);
1160
1161         new OpenMBeanParameterInfoSupport JavaDoc(
1162            "name", "description", tabularType, null, null, null);
1163      }
1164      catch (OpenDataException JavaDoc e)
1165      {
1166         caught = true;
1167      }
1168      if (caught == true)
1169         fail("Didn't expect OpenDataException for tabular type and null default value");
1170
1171      caught = false;
1172      try
1173      {
1174         ArrayType JavaDoc arrayType = new ArrayType JavaDoc(1, SimpleType.STRING);
1175         new OpenMBeanParameterInfoSupport JavaDoc(
1176            "name", "description", arrayType, new String JavaDoc[] { "hello", "goodbye" }, null, null);
1177      }
1178      catch (OpenDataException JavaDoc e)
1179      {
1180         caught = true;
1181      }
1182      if (caught == false)
1183         fail("Expected OpenDataException for array type and default value");
1184
1185      caught = false;
1186      try
1187      {
1188         new OpenMBeanParameterInfoSupport JavaDoc(
1189            "name", "description", SimpleType.STRING, new Integer JavaDoc(3), new Integer JavaDoc(4), new Integer JavaDoc(5));
1190      }
1191      catch (OpenDataException JavaDoc e)
1192      {
1193         caught = true;
1194      }
1195      if (caught == false)
1196         fail("Expected OpenDataException for default value less than minimum value");
1197
1198      caught = false;
1199      try
1200      {
1201         new OpenMBeanParameterInfoSupport JavaDoc(
1202            "name", "description", SimpleType.INTEGER, new Integer JavaDoc(4), new Integer JavaDoc(4), new Integer JavaDoc(5));
1203      }
1204      catch (OpenDataException JavaDoc e)
1205      {
1206         caught = true;
1207      }
1208      if (caught == true)
1209         fail("Didn't expect OpenDataException for default value equal minimum value");
1210
1211      caught = false;
1212      try
1213      {
1214         new OpenMBeanParameterInfoSupport JavaDoc(
1215            "name", "description", SimpleType.INTEGER, new Integer JavaDoc(6), new Integer JavaDoc(4), new Integer JavaDoc(5));
1216      }
1217      catch (OpenDataException JavaDoc e)
1218      {
1219         caught = true;
1220      }
1221      if (caught == false)
1222         fail("Expected OpenDataException for default value greater than maximum value");
1223
1224      caught = false;
1225      try
1226      {
1227         new OpenMBeanParameterInfoSupport JavaDoc(
1228            "name", "description", SimpleType.INTEGER, new Integer JavaDoc(5), new Integer JavaDoc(4), new Integer JavaDoc(5));
1229      }
1230      catch (OpenDataException JavaDoc e)
1231      {
1232         caught = true;
1233      }
1234      if (caught == true)
1235         fail("Didn't expect OpenDataException for default value equal maximum value");
1236
1237      caught = false;
1238      try
1239      {
1240         new OpenMBeanParameterInfoSupport JavaDoc(
1241            "name", "description", SimpleType.INTEGER, null, new Integer JavaDoc(4), new Integer JavaDoc(3));
1242      }
1243      catch (OpenDataException JavaDoc e)
1244      {
1245         caught = true;
1246      }
1247      if (caught == false)
1248         fail("Expected OpenDataException for minimum greater than maximum value");
1249
1250      caught = false;
1251      try
1252      {
1253         new OpenMBeanParameterInfoSupport JavaDoc(
1254            "name", "description", SimpleType.INTEGER, null, new Integer JavaDoc(4), new Integer JavaDoc(4));
1255      }
1256      catch (OpenDataException JavaDoc e)
1257      {
1258         caught = true;
1259      }
1260      if (caught == true)
1261         fail("Didn't expect OpenDataException for minimum equal maximum value");
1262   }
1263}
1264
Popular Tags