KickJava   Java API By Example, From Geeks To Geeks.

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


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.OpenMBeanAttributeInfoSupport 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 Attribute Info tests.<p>
42  *
43  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
44  */

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

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

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

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

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

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