KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jmx > serialization > SerializeTestCase


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.serialization;
23
24 import java.io.ByteArrayInputStream JavaDoc;
25 import java.io.ByteArrayOutputStream JavaDoc;
26 import java.io.IOException JavaDoc;
27 import java.io.ObjectInputStream JavaDoc;
28 import java.io.ObjectOutputStream JavaDoc;
29 import java.lang.reflect.Array JavaDoc;
30 import java.lang.reflect.Constructor JavaDoc;
31 import java.lang.reflect.Method JavaDoc;
32 import java.util.ArrayList JavaDoc;
33 import java.util.List JavaDoc;
34
35 import junit.framework.TestCase;
36
37 /**
38  * Tests serialization with the RI
39  *
40  * @todo Proper equality tests instead of toString()
41  *
42  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
43  */

44 public class SerializeTestCase
45    extends TestCase
46 {
47    // Attributes ----------------------------------------------------------------
48

49    // Constructor ---------------------------------------------------------------
50

51    /**
52     * Construct the test
53     */

54    public SerializeTestCase(String JavaDoc s)
55    {
56       super(s);
57    }
58
59    public void testArrayType()
60       throws Exception JavaDoc
61    {
62       if (SerializationSUITE.form < 11)
63          return;
64       Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
65       Object JavaDoc elementType = clazz.getField("BIGDECIMAL").get(null);
66       Object JavaDoc obj = instantiate(
67          "javax.management.openmbean.ArrayType",
68          new Class JavaDoc[] { Integer.TYPE,
69                        loadClass("javax.management.openmbean.OpenType") },
70          new Object JavaDoc[] { new Integer JavaDoc(3), elementType }
71       );
72       Object JavaDoc result = runTest(obj);
73       assertEquals(obj, result);
74    }
75
76    public void testAttribute()
77       throws Exception JavaDoc
78    {
79       Object JavaDoc obj = instantiate(
80          "javax.management.Attribute",
81          new Class JavaDoc[] { String JavaDoc.class, Object JavaDoc.class },
82          new Object JavaDoc[] { "name", "value" }
83       );
84       Object JavaDoc result = runTest(obj);
85       assertEquals(obj, result);
86    }
87
88    public void testAttributeChangeNotification()
89       throws Exception JavaDoc
90    {
91       Object JavaDoc obj = instantiate(
92          "javax.management.AttributeChangeNotification",
93          new Class JavaDoc[] { Object JavaDoc.class, Long.TYPE, Long.TYPE,
94                        String JavaDoc.class, String JavaDoc.class, String JavaDoc.class,
95                        Object JavaDoc.class, Object JavaDoc.class },
96          new Object JavaDoc[] { "source", new Long JavaDoc(1), new Long JavaDoc(2), "message", "name",
97                         "type", "old", "new" }
98       );
99       Object JavaDoc result = runTest(obj);
100       assertEquals(obj.toString(), result.toString());
101    }
102
103    public void testAttributeChangeNotificationFilter()
104       throws Exception JavaDoc
105    {
106       Object JavaDoc obj = instantiate(
107          "javax.management.AttributeChangeNotificationFilter",
108          new Class JavaDoc[0],
109          new Object JavaDoc[0]
110       );
111       Method JavaDoc method = obj.getClass().getMethod("enableAttribute",
112           new Class JavaDoc[] { String JavaDoc.class });
113       method.invoke(obj, new Object JavaDoc[] { "attribute" });
114       Object JavaDoc result = runTest(obj);
115       assertEquals(obj.toString(), result.toString());
116    }
117
118    public void testAttributeList()
119       throws Exception JavaDoc
120    {
121       Object JavaDoc obj = instantiate(
122          "javax.management.AttributeList",
123          new Class JavaDoc[0],
124          new Object JavaDoc[0]
125       );
126       Object JavaDoc attr = instantiate(
127          "javax.management.Attribute",
128          new Class JavaDoc[] { String JavaDoc.class, Object JavaDoc.class },
129          new Object JavaDoc[] { "name", "value" }
130       );
131       Method JavaDoc method = obj.getClass().getMethod("add",
132           new Class JavaDoc[] { attr.getClass() });
133       method.invoke(obj, new Object JavaDoc[] { attr });
134       Object JavaDoc result = runTest(obj);
135       assertEquals(obj.toString(), result.toString());
136    }
137
138    public void testAttributeNotFoundException()
139       throws Exception JavaDoc
140    {
141       Object JavaDoc obj = instantiate(
142          "javax.management.AttributeNotFoundException",
143          new Class JavaDoc[] { String JavaDoc.class },
144          new Object JavaDoc[] { "message" }
145       );
146       Object JavaDoc result = runTest(obj);
147       assertEquals(obj.toString(), result.toString());
148    }
149
150    public void testAttributeValueExp()
151       throws Exception JavaDoc
152    {
153       Object JavaDoc obj = instantiate(
154          "javax.management.AttributeValueExp",
155          new Class JavaDoc[] { String JavaDoc.class },
156          new Object JavaDoc[] { "attr" }
157       );
158       Object JavaDoc result = runTest(obj);
159       assertEquals(obj.toString(), result.toString());
160    }
161
162    public void testBadAttributeValueExpException()
163       throws Exception JavaDoc
164    {
165       Object JavaDoc obj = instantiate(
166          "javax.management.BadAttributeValueExpException",
167          new Class JavaDoc[] { Object JavaDoc.class },
168          new Object JavaDoc[] { "value" }
169       );
170       Object JavaDoc result = runTest(obj);
171       assertEquals(obj.toString(), result.toString());
172    }
173
174    public void testBadBinaryOpValueExpException()
175       throws Exception JavaDoc
176    {
177       Object JavaDoc exp = instantiate(
178          "javax.management.AttributeValueExp",
179          new Class JavaDoc[] { String JavaDoc.class },
180          new Object JavaDoc[] { "attr" }
181       );
182
183       Object JavaDoc obj = instantiate(
184          "javax.management.BadBinaryOpValueExpException",
185          new Class JavaDoc[] { loadClass("javax.management.ValueExp") },
186          new Object JavaDoc[] { exp }
187       );
188       Object JavaDoc result = runTest(obj);
189       assertEquals(obj.toString(), result.toString());
190    }
191
192    public void testBadStringOperationException()
193       throws Exception JavaDoc
194    {
195       Object JavaDoc obj = instantiate(
196          "javax.management.BadStringOperationException",
197          new Class JavaDoc[] { String JavaDoc.class },
198          new Object JavaDoc[] { "message" }
199       );
200       Object JavaDoc result = runTest(obj);
201       assertEquals(obj.toString(), result.toString());
202    }
203
204    public void testCompositeDataSupport()
205       throws Exception JavaDoc
206    {
207       if (SerializationSUITE.form < 11)
208          return;
209       Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
210       Object JavaDoc openType = clazz.getField("STRING").get(null);
211
212       Class JavaDoc elementClass = loadClass("javax.management.openmbean.OpenType");
213       Object JavaDoc array = Array.newInstance(elementClass, 2);
214       Array.set(array, 0, openType);
215       Array.set(array, 1, openType);
216
217       Object JavaDoc compositeType = instantiate(
218          "javax.management.openmbean.CompositeType",
219          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc[].class, String JavaDoc[].class, array.getClass() },
220          new Object JavaDoc[] { "typeName", "description", new String JavaDoc[] { "name1", "name2" },
221             new String JavaDoc[] { "desc1", "desc2" }, array }
222       );
223       Object JavaDoc obj = instantiate(
224          "javax.management.openmbean.CompositeDataSupport",
225          new Class JavaDoc[] { compositeType.getClass(), String JavaDoc[].class, Object JavaDoc[].class },
226          new Object JavaDoc[] { compositeType, new String JavaDoc[] { "name1", "name2" },
227             new Object JavaDoc[] { "itemValue1", "itemValue2" } }
228       );
229       Object JavaDoc result = runTest(obj);
230       assertEquals(obj, result);
231    }
232
233    public void testCompositeType()
234       throws Exception JavaDoc
235    {
236       if (SerializationSUITE.form < 11)
237          return;
238       Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
239       Object JavaDoc openType = clazz.getField("STRING").get(null);
240
241       Class JavaDoc elementClass = loadClass("javax.management.openmbean.OpenType");
242       Object JavaDoc array = Array.newInstance(elementClass, 2);
243       Array.set(array, 0, openType);
244       Array.set(array, 1, openType);
245
246       Object JavaDoc obj = instantiate(
247          "javax.management.openmbean.CompositeType",
248          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc[].class, String JavaDoc[].class, array.getClass() },
249          new Object JavaDoc[] { "typeName", "description", new String JavaDoc[] { "name1", "name2" },
250             new String JavaDoc[] { "desc1", "desc2" }, array }
251       );
252       Object JavaDoc result = runTest(obj);
253       assertEquals(obj, result);
254    }
255
256    public void testDescriptorSupport()
257       throws Exception JavaDoc
258    {
259       Object JavaDoc obj = instantiate(
260          "javax.management.modelmbean.DescriptorSupport",
261          new Class JavaDoc[] { new String JavaDoc[0].getClass(), new Object JavaDoc[0].getClass() },
262          new Object JavaDoc[] { new String JavaDoc[] { "name1", "name2"},
263                         new Object JavaDoc[] { "value1", "value2" } }
264       );
265       runTest(obj);
266    }
267
268    public void testInstanceAlreadyExistsException()
269       throws Exception JavaDoc
270    {
271       Object JavaDoc obj = instantiate(
272          "javax.management.InstanceAlreadyExistsException",
273          new Class JavaDoc[] { String JavaDoc.class },
274          new Object JavaDoc[] { "message" }
275       );
276       Object JavaDoc result = runTest(obj);
277       assertEquals(obj.toString(), result.toString());
278    }
279
280    public void testInstanceNotFoundException()
281       throws Exception JavaDoc
282    {
283       Object JavaDoc obj = instantiate(
284          "javax.management.InstanceNotFoundException",
285          new Class JavaDoc[] { String JavaDoc.class },
286          new Object JavaDoc[] { "message" }
287       );
288       Object JavaDoc result = runTest(obj);
289       assertEquals(obj.toString(), result.toString());
290    }
291
292    public void testIntrospectionException()
293       throws Exception JavaDoc
294    {
295       Object JavaDoc obj = instantiate(
296          "javax.management.IntrospectionException",
297          new Class JavaDoc[] { String JavaDoc.class },
298          new Object JavaDoc[] { "message" }
299       );
300       Object JavaDoc result = runTest(obj);
301       assertEquals(obj.toString(), result.toString());
302    }
303
304    public void testInvalidApplicationException()
305       throws Exception JavaDoc
306    {
307       Object JavaDoc obj = instantiate(
308          "javax.management.InvalidApplicationException",
309          new Class JavaDoc[] { Object JavaDoc.class },
310          new Object JavaDoc[] { "value" }
311       );
312       Object JavaDoc result = runTest(obj);
313       assertEquals(obj.toString(), result.toString());
314    }
315
316    public void testInvalidAttributeValueException()
317       throws Exception JavaDoc
318    {
319       Object JavaDoc obj = instantiate(
320          "javax.management.InvalidAttributeValueException",
321          new Class JavaDoc[] { String JavaDoc.class },
322          new Object JavaDoc[] { "message" }
323       );
324       Object JavaDoc result = runTest(obj);
325       assertEquals(obj.toString(), result.toString());
326    }
327
328    public void testInvalidKeyException()
329       throws Exception JavaDoc
330    {
331       if (SerializationSUITE.form < 11)
332          return;
333       Object JavaDoc obj = instantiate(
334          "javax.management.openmbean.InvalidKeyException",
335          new Class JavaDoc[] { String JavaDoc.class },
336          new Object JavaDoc[] { "message" }
337       );
338       Object JavaDoc result = runTest(obj);
339       assertEquals(obj.toString(), result.toString());
340    }
341
342    public void testInvalidOpenTypeException()
343       throws Exception JavaDoc
344    {
345       if (SerializationSUITE.form < 11)
346          return;
347       Object JavaDoc obj = instantiate(
348          "javax.management.openmbean.InvalidOpenTypeException",
349          new Class JavaDoc[] { String JavaDoc.class },
350          new Object JavaDoc[] { "message" }
351       );
352       Object JavaDoc result = runTest(obj);
353       assertEquals(obj.toString(), result.toString());
354    }
355
356    public void testInvalidRelationIdException()
357       throws Exception JavaDoc
358    {
359       Object JavaDoc obj = instantiate(
360          "javax.management.relation.InvalidRelationIdException",
361          new Class JavaDoc[] { String JavaDoc.class },
362          new Object JavaDoc[] { "message" }
363       );
364       Object JavaDoc result = runTest(obj);
365       assertEquals(obj.toString(), result.toString());
366    }
367
368    public void testInvalidRelationServiceException()
369       throws Exception JavaDoc
370    {
371       Object JavaDoc obj = instantiate(
372          "javax.management.relation.InvalidRelationServiceException",
373          new Class JavaDoc[] { String JavaDoc.class },
374          new Object JavaDoc[] { "message" }
375       );
376       Object JavaDoc result = runTest(obj);
377       assertEquals(obj.toString(), result.toString());
378    }
379
380    public void testInvalidRelationTypeException()
381       throws Exception JavaDoc
382    {
383       Object JavaDoc obj = instantiate(
384          "javax.management.relation.InvalidRelationTypeException",
385          new Class JavaDoc[] { String JavaDoc.class },
386          new Object JavaDoc[] { "message" }
387       );
388       Object JavaDoc result = runTest(obj);
389       assertEquals(obj.toString(), result.toString());
390    }
391
392    public void testInvalidRoleInfoException()
393       throws Exception JavaDoc
394    {
395       Object JavaDoc obj = instantiate(
396          "javax.management.relation.InvalidRoleInfoException",
397          new Class JavaDoc[] { String JavaDoc.class },
398          new Object JavaDoc[] { "message" }
399       );
400       Object JavaDoc result = runTest(obj);
401       assertEquals(obj.toString(), result.toString());
402    }
403
404    public void testInvalidRoleValueException()
405       throws Exception JavaDoc
406    {
407       Object JavaDoc obj = instantiate(
408          "javax.management.relation.InvalidRoleValueException",
409          new Class JavaDoc[] { String JavaDoc.class },
410          new Object JavaDoc[] { "message" }
411       );
412       Object JavaDoc result = runTest(obj);
413       assertEquals(obj.toString(), result.toString());
414    }
415
416    public void testInvalidTargetObjectTypeException()
417       throws Exception JavaDoc
418    {
419       Object JavaDoc obj = instantiate(
420          "javax.management.modelmbean.InvalidTargetObjectTypeException",
421          new Class JavaDoc[] { Exception JavaDoc.class, String JavaDoc.class },
422          new Object JavaDoc[] { new Exception JavaDoc("exception"), "message" }
423       );
424       Object JavaDoc result = runTest(obj);
425       assertEquals(obj.toString(), result.toString());
426    }
427
428    public void testKeyAlreadyExistsException()
429       throws Exception JavaDoc
430    {
431       if (SerializationSUITE.form < 11)
432          return;
433       Object JavaDoc obj = instantiate(
434          "javax.management.openmbean.KeyAlreadyExistsException",
435          new Class JavaDoc[] { String JavaDoc.class },
436          new Object JavaDoc[] { "message" }
437       );
438       Object JavaDoc result = runTest(obj);
439       assertEquals(obj.toString(), result.toString());
440    }
441
442    public void testJMException()
443       throws Exception JavaDoc
444    {
445       Object JavaDoc obj = instantiate(
446          "javax.management.JMException",
447          new Class JavaDoc[] { String JavaDoc.class },
448          new Object JavaDoc[] { "message" }
449       );
450       Object JavaDoc result = runTest(obj);
451       assertEquals(obj.toString(), result.toString());
452    }
453
454    public void testJMRuntimeException()
455       throws Exception JavaDoc
456    {
457       Object JavaDoc obj = instantiate(
458          "javax.management.JMRuntimeException",
459          new Class JavaDoc[] { String JavaDoc.class },
460          new Object JavaDoc[] { "message" }
461       );
462       Object JavaDoc result = runTest(obj);
463       assertEquals(obj.toString(), result.toString());
464    }
465
466    public void testListenerNotFoundException()
467       throws Exception JavaDoc
468    {
469       Object JavaDoc obj = instantiate(
470          "javax.management.ListenerNotFoundException",
471          new Class JavaDoc[] { String JavaDoc.class },
472          new Object JavaDoc[] { "message" }
473       );
474       Object JavaDoc result = runTest(obj);
475       assertEquals(obj.toString(), result.toString());
476    }
477
478    public void testMalformedObjectNameException()
479       throws Exception JavaDoc
480    {
481       Object JavaDoc obj = instantiate(
482          "javax.management.MalformedObjectNameException",
483          new Class JavaDoc[] { String JavaDoc.class },
484          new Object JavaDoc[] { "message" }
485       );
486       Object JavaDoc result = runTest(obj);
487       assertEquals(obj.toString(), result.toString());
488    }
489
490    public void testMBeanAttributeInfo()
491       throws Exception JavaDoc
492    {
493       Object JavaDoc obj = instantiate(
494          "javax.management.MBeanAttributeInfo",
495          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc.class,
496                        Boolean.TYPE, Boolean.TYPE, Boolean.TYPE },
497          new Object JavaDoc[] { "name", "type", "description", new Boolean JavaDoc(true),
498                         new Boolean JavaDoc(true), new Boolean JavaDoc(false)}
499       );
500       try
501       {
502          Object JavaDoc result = runTest(obj);
503          assertEquals(obj.toString(), result.toString());
504       }
505       catch (java.io.InvalidClassException JavaDoc e)
506       {
507          fail("FAILS IN RI 1.1: Wrong serialization for form 1.0");
508       }
509    }
510
511    public void testMBeanConstructorInfo()
512       throws Exception JavaDoc
513    {
514       Object JavaDoc parm = instantiate(
515          "javax.management.MBeanParameterInfo",
516          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc.class },
517          new Object JavaDoc[] { "name", "type", "description" }
518       );
519       Object JavaDoc array = Array.newInstance(parm.getClass(), 1);
520       Array.set(array, 0, parm);
521       Object JavaDoc obj = instantiate(
522          "javax.management.MBeanConstructorInfo",
523          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, array.getClass() },
524          new Object JavaDoc[] { "name", "description", array }
525       );
526       Object JavaDoc result = runTest(obj);
527       assertEquals(obj.toString(), result.toString());
528    }
529
530    public void testMBeanException()
531       throws Exception JavaDoc
532    {
533       Object JavaDoc obj = instantiate(
534          "javax.management.MBeanException",
535          new Class JavaDoc[] { Exception JavaDoc.class, String JavaDoc.class },
536          new Object JavaDoc[] { new Exception JavaDoc("Cause"), "message" }
537       );
538       Object JavaDoc result = runTest(obj);
539       assertEquals(obj.toString(), result.toString());
540    }
541
542    public void testMBeanFeatureInfo()
543       throws Exception JavaDoc
544    {
545       Object JavaDoc obj = instantiate(
546          "javax.management.MBeanFeatureInfo",
547          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class },
548          new Object JavaDoc[] { "name", "description" }
549       );
550       Object JavaDoc result = runTest(obj);
551       assertEquals(obj.toString(), result.toString());
552    }
553
554    public void testMBeanInfo()
555       throws Exception JavaDoc
556    {
557       Object JavaDoc parm = instantiate(
558          "javax.management.MBeanParameterInfo",
559          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc.class },
560          new Object JavaDoc[] { "name", "type", "description" }
561       );
562       Object JavaDoc parms = Array.newInstance(parm.getClass(), 1);
563       Array.set(parms, 0, parm);
564
565       Object JavaDoc att = instantiate(
566          "javax.management.MBeanAttributeInfo",
567          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc.class,
568                        Boolean.TYPE, Boolean.TYPE, Boolean.TYPE },
569          new Object JavaDoc[] { "name", "type", "description", new Boolean JavaDoc(true),
570                         new Boolean JavaDoc(true), new Boolean JavaDoc(false)}
571       );
572       Object JavaDoc atts = Array.newInstance(att.getClass(), 1);
573       Array.set(atts, 0, att);
574
575       Object JavaDoc con = instantiate(
576          "javax.management.MBeanConstructorInfo",
577          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, parms.getClass() },
578          new Object JavaDoc[] { "name", "description", parms }
579       );
580       Object JavaDoc cons = Array.newInstance(con.getClass(), 1);
581       Array.set(cons, 0, con);
582
583       Class JavaDoc clazz = loadClass("javax.management.MBeanOperationInfo");
584       Integer JavaDoc impact = new Integer JavaDoc(clazz.getField("ACTION").getInt(null));
585       Object JavaDoc op = instantiate(
586          "javax.management.MBeanOperationInfo",
587          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, parms.getClass(),
588                        String JavaDoc.class, Integer.TYPE },
589          new Object JavaDoc[] { "name", "description", parms, "type", impact }
590       );
591       Object JavaDoc ops = Array.newInstance(op.getClass(), 1);
592       Array.set(ops, 0, op);
593
594       String JavaDoc[] types = { "type1", "type2" };
595       Object JavaDoc not = instantiate(
596          "javax.management.MBeanNotificationInfo",
597          new Class JavaDoc[] { types.getClass(), String JavaDoc.class, String JavaDoc.class },
598          new Object JavaDoc[] { types, "name", "description" }
599       );
600       Object JavaDoc nots = Array.newInstance(not.getClass(), 1);
601       Array.set(nots, 0, not);
602
603       Object JavaDoc obj = instantiate(
604          "javax.management.MBeanInfo",
605          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, atts.getClass(),
606                        cons.getClass(), ops.getClass(), nots.getClass() },
607          new Object JavaDoc[] { "className", "description", atts, cons, ops, nots }
608       );
609       try
610       {
611          Object JavaDoc result = runTest(obj);
612          assertEquals(obj.toString(), result.toString());
613       }
614       catch (java.io.InvalidClassException JavaDoc e)
615       {
616          fail("FAILS IN RI 1.1: Wrong serialization for form 1.0 " +
617               "The real error is in MBeanAttributeInfo");
618       }
619    }
620
621    public void testMBeanNotificationInfo()
622       throws Exception JavaDoc
623    {
624       String JavaDoc[] types = { "type1", "type2" };
625       Object JavaDoc obj = instantiate(
626          "javax.management.MBeanNotificationInfo",
627          new Class JavaDoc[] { types.getClass(), String JavaDoc.class, String JavaDoc.class },
628          new Object JavaDoc[] { types, "name", "description" }
629       );
630       Object JavaDoc result = runTest(obj);
631       assertEquals(obj.toString(), result.toString());
632    }
633
634    public void testMBeanOperationInfo()
635       throws Exception JavaDoc
636    {
637       Object JavaDoc parm = instantiate(
638          "javax.management.MBeanParameterInfo",
639          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc.class },
640          new Object JavaDoc[] { "name", "type", "description" }
641       );
642       Object JavaDoc array = Array.newInstance(parm.getClass(), 1);
643       Array.set(array, 0, parm);
644       Class JavaDoc clazz = loadClass("javax.management.MBeanOperationInfo");
645       Integer JavaDoc impact = new Integer JavaDoc(clazz.getField("ACTION").getInt(null));
646       Object JavaDoc obj = instantiate(
647          "javax.management.MBeanOperationInfo",
648          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, array.getClass(),
649                        String JavaDoc.class, Integer.TYPE },
650          new Object JavaDoc[] { "name", "description", array, "type", impact }
651       );
652       Object JavaDoc result = runTest(obj);
653       assertEquals(obj.toString(), result.toString());
654    }
655
656    public void testMBeanParameterInfo()
657       throws Exception JavaDoc
658    {
659       Object JavaDoc obj = instantiate(
660          "javax.management.MBeanParameterInfo",
661          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc.class },
662          new Object JavaDoc[] { "name", "type", "description" }
663       );
664       Object JavaDoc result = runTest(obj);
665       assertEquals(obj.toString(), result.toString());
666    }
667
668    public void testMBeanRegistrationException()
669       throws Exception JavaDoc
670    {
671       Object JavaDoc obj = instantiate(
672          "javax.management.MBeanRegistrationException",
673          new Class JavaDoc[] { Exception JavaDoc.class, String JavaDoc.class },
674          new Object JavaDoc[] { new Exception JavaDoc("Cause"), "message" }
675       );
676       Object JavaDoc result = runTest(obj);
677       assertEquals(obj.toString(), result.toString());
678    }
679
680    public void testMBeanServerNotification()
681       throws Exception JavaDoc
682    {
683       Object JavaDoc objectName = instantiate(
684          "javax.management.ObjectName",
685          new Class JavaDoc[] { String JavaDoc.class },
686          new Object JavaDoc[] { "domain:x=y" }
687       );
688
689       Class JavaDoc clazz = loadClass("javax.management.MBeanServerNotification");
690       String JavaDoc type = (String JavaDoc) clazz.getField("REGISTRATION_NOTIFICATION").get(null);
691
692       Object JavaDoc obj = instantiate(
693          "javax.management.MBeanServerNotification",
694          new Class JavaDoc[] { String JavaDoc.class, Object JavaDoc.class, Long.TYPE,
695                        objectName.getClass() },
696          new Object JavaDoc[] { type, "source", new Long JavaDoc(1), objectName }
697       );
698       Object JavaDoc result = runTest(obj);
699       assertEquals(obj.toString(), result.toString());
700    }
701
702    public void testMBeanServerNotificationFilter()
703       throws Exception JavaDoc
704    {
705       Object JavaDoc objectName = instantiate(
706          "javax.management.ObjectName",
707          new Class JavaDoc[] { String JavaDoc.class },
708          new Object JavaDoc[] { "domain:x=y" }
709       );
710       Object JavaDoc obj = instantiate(
711          "javax.management.relation.MBeanServerNotificationFilter",
712          new Class JavaDoc[0],
713          new Object JavaDoc[0]
714       );
715       Method JavaDoc method = obj.getClass().getMethod("enableType",
716           new Class JavaDoc[] { String JavaDoc.class });
717       method.invoke(obj, new Object JavaDoc[] { "prefix" });
718       method = obj.getClass().getMethod("enableObjectName",
719           new Class JavaDoc[] { objectName.getClass() });
720       method.invoke(obj, new Object JavaDoc[] { objectName });
721       Object JavaDoc result = runTest(obj);
722       assertEquals(obj.toString(), result.toString());
723    }
724
725    public void testMBeanServerPermission()
726       throws Exception JavaDoc
727    {
728       if (SerializationSUITE.form < 11)
729          return;
730       Object JavaDoc obj = instantiate(
731          "javax.management.MBeanServerPermission",
732          new Class JavaDoc[] { String JavaDoc.class },
733          new Object JavaDoc[] { "*" }
734       );
735       Object JavaDoc result = runTest(obj);
736       assertEquals(obj.toString(), result.toString());
737    }
738
739    public void testModelMBeanAttributeInfo()
740       throws Exception JavaDoc
741    {
742       Object JavaDoc obj = instantiate(
743          "javax.management.modelmbean.ModelMBeanAttributeInfo",
744          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc.class,
745                        Boolean.TYPE, Boolean.TYPE, Boolean.TYPE },
746          new Object JavaDoc[] { "name", "type", "description", new Boolean JavaDoc(true),
747                         new Boolean JavaDoc(true), new Boolean JavaDoc(false)}
748       );
749       try
750       {
751          runTest(obj);
752       }
753       catch (java.io.InvalidClassException JavaDoc e)
754       {
755          fail("FAILS IN RI 1.1: Wrong serialization for form 1.0 ");
756       }
757    }
758
759    /**
760     * @todo equals test
761     */

762    public void testModelMBeanConstructorInfo()
763       throws Exception JavaDoc
764    {
765       Object JavaDoc parm = instantiate(
766          "javax.management.MBeanParameterInfo",
767          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc.class },
768          new Object JavaDoc[] { "name", "type", "description" }
769       );
770       Object JavaDoc array = Array.newInstance(parm.getClass(), 1);
771       Array.set(array, 0, parm);
772       Object JavaDoc obj = instantiate(
773          "javax.management.modelmbean.ModelMBeanConstructorInfo",
774          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, array.getClass() },
775          new Object JavaDoc[] { "name", "description", array }
776       );
777       runTest(obj);
778    }
779
780    /**
781     * @todo equals test
782     */

783    public void testModelMBeanInfoSupport()
784       throws Exception JavaDoc
785    {
786       Object JavaDoc parm = instantiate(
787          "javax.management.MBeanParameterInfo",
788          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc.class },
789          new Object JavaDoc[] { "name", "type", "description" }
790       );
791       Object JavaDoc parms = Array.newInstance(parm.getClass(), 1);
792       Array.set(parms, 0, parm);
793
794       Object JavaDoc att = instantiate(
795          "javax.management.modelmbean.ModelMBeanAttributeInfo",
796          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc.class,
797                        Boolean.TYPE, Boolean.TYPE, Boolean.TYPE },
798          new Object JavaDoc[] { "name", "type", "description", new Boolean JavaDoc(true),
799                         new Boolean JavaDoc(true), new Boolean JavaDoc(false)}
800       );
801       Object JavaDoc atts = Array.newInstance(att.getClass(), 1);
802       Array.set(atts, 0, att);
803
804       Object JavaDoc con = instantiate(
805          "javax.management.modelmbean.ModelMBeanConstructorInfo",
806          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, parms.getClass() },
807          new Object JavaDoc[] { "name", "description", parms }
808       );
809       Object JavaDoc cons = Array.newInstance(con.getClass(), 1);
810       Array.set(cons, 0, con);
811
812       Class JavaDoc clazz = loadClass("javax.management.modelmbean.ModelMBeanOperationInfo");
813       Integer JavaDoc impact = new Integer JavaDoc(clazz.getField("ACTION").getInt(null));
814       Object JavaDoc op = instantiate(
815          "javax.management.modelmbean.ModelMBeanOperationInfo",
816          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, parms.getClass(),
817                        String JavaDoc.class, Integer.TYPE },
818          new Object JavaDoc[] { "name", "description", parms, "type", impact }
819       );
820       Object JavaDoc ops = Array.newInstance(op.getClass(), 1);
821       Array.set(ops, 0, op);
822
823       String JavaDoc[] types = { "type1", "type2" };
824       Object JavaDoc not = instantiate(
825          "javax.management.modelmbean.ModelMBeanNotificationInfo",
826          new Class JavaDoc[] { types.getClass(), String JavaDoc.class, String JavaDoc.class },
827          new Object JavaDoc[] { types, "name", "description" }
828       );
829       Object JavaDoc nots = Array.newInstance(not.getClass(), 1);
830       Array.set(nots, 0, not);
831
832       Object JavaDoc obj = instantiate(
833          "javax.management.modelmbean.ModelMBeanInfoSupport",
834          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, atts.getClass(),
835                        cons.getClass(), ops.getClass(), nots.getClass() },
836          new Object JavaDoc[] { "className", "description", atts, cons, ops, nots }
837       );
838       try
839       {
840          runTest(obj);
841       }
842       catch (java.io.InvalidClassException JavaDoc e)
843       {
844          fail("FAILS IN RI 1.1: Wrong serialization for form 1.0 ");
845       }
846    }
847
848    /**
849     * @todo equals test
850     */

851    public void testModelMBeanNotificationInfo()
852       throws Exception JavaDoc
853    {
854       String JavaDoc[] types = { "type1", "type2" };
855       Object JavaDoc obj = instantiate(
856          "javax.management.modelmbean.ModelMBeanNotificationInfo",
857          new Class JavaDoc[] { types.getClass(), String JavaDoc.class, String JavaDoc.class },
858          new Object JavaDoc[] { types, "name", "description" }
859       );
860       try
861       {
862          runTest(obj);
863       }
864       catch (java.io.StreamCorruptedException JavaDoc e)
865       {
866          fail("FAILS IN RI 1.1: Wrong serialization for form 1.0 ");
867       }
868    }
869
870    /**
871     * @todo equals test
872     */

873    public void testModelMBeanOperationInfo()
874       throws Exception JavaDoc
875    {
876       Object JavaDoc parm = instantiate(
877          "javax.management.MBeanParameterInfo",
878          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc.class },
879          new Object JavaDoc[] { "name", "type", "description" }
880       );
881       Object JavaDoc array = Array.newInstance(parm.getClass(), 1);
882       Array.set(array, 0, parm);
883       Class JavaDoc clazz = loadClass("javax.management.MBeanOperationInfo");
884       Integer JavaDoc impact = new Integer JavaDoc(clazz.getField("ACTION").getInt(null));
885       Object JavaDoc obj = instantiate(
886          "javax.management.modelmbean.ModelMBeanOperationInfo",
887          new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, array.getClass(),
888                        String JavaDoc.class, Integer.TYPE },
889          new Object JavaDoc[] { "name", "description", array, "type", impact }
890       );
891       try
892       {
893          runTest(obj);
894       }
895       catch (java.io.StreamCorruptedException JavaDoc e)
896       {
897          fail("FAILS IN RI 1.1: Wrong serialization for form 1.0 ");
898       }
899    }
900
901    /**
902     * @todo the constructor is package private
903     * Actually tested by temporarily making the constructor public
904     */

905    public void testMonitorNotification()
906       throws Exception JavaDoc
907    {
908 /*****
909       Object monitorName = instantiate(
910          "javax.management.ObjectName",
911          new Class[] { String.class },
912          new Object[] { "monitor:x=y" }
913       );
914       Object objectName = instantiate(
915          "javax.management.ObjectName",
916          new Class[] { String.class },
917          new Object[] { "domain:x=y" }
918       );
919       Object obj = instantiate(
920          "javax.management.monitor.MonitorNotification",
921          new Class[] { String.class, Object.class, Long.TYPE, Long.TYPE,
922                        String.class, Object.class, String.class,
923                        objectName.getClass(), Object.class },
924          new Object[] { "type", monitorName, new Long(1), new Long(2),
925                         "message", "derivedGauge", "attribute", objectName,
926                         "trigger"}
927       );
928       Object result = runTest(obj);
929       assertEquals(obj.toString(), result.toString());
930 *****/

931    }
932
933    public void testMonitorSettingException()
934       throws Exception JavaDoc
935    {
936       Object JavaDoc obj = instantiate(
937          "javax.management.monitor.MonitorSettingException",
938          new Class JavaDoc[] { String JavaDoc.class },
939          new Object JavaDoc[] { "message" }
940       );
941       Object JavaDoc result = runTest(obj);
942       assertEquals(obj.toString(), result.toString());
943    }
944
945    public void testNotCompliantMBeanException()
946       throws Exception JavaDoc
947    {
948       Object JavaDoc obj = instantiate(
949          "javax.management.NotCompliantMBeanException",
950          new Class JavaDoc[] { String JavaDoc.class },
951          new Object JavaDoc[] { "message" }
952       );
953       Object JavaDoc result = runTest(obj);
954       assertEquals(obj.toString(), result.toString());
955    }
956
957    public void testNotification()
958       throws Exception JavaDoc
959    {
960       Object JavaDoc objectName = instantiate(
961          "javax.management.ObjectName",
962          new Class JavaDoc[] { String JavaDoc.class },
963          new Object JavaDoc[] { "domain:x=y" }
964       );
965       Object JavaDoc obj = instantiate(
966          "javax.management.Notification",
967          new Class JavaDoc[] { String JavaDoc.class, Object JavaDoc.class, Long.TYPE, Long.TYPE,
968                        String JavaDoc.class },
969          new Object JavaDoc[] { "type", objectName, new Long JavaDoc(1), new Long JavaDoc(2),
970                         "message" }
971       );
972       Object JavaDoc result = runTest(obj);
973       assertEquals(obj.toString(), result.toString());
974    }
975
976    /**
977     * @todo equals tests
978     */

979    public void testNotificationFilterSupport()
980       throws Exception JavaDoc
981    {
982       Object JavaDoc obj = instantiate(
983          "javax.management.NotificationFilterSupport",
984          new Class JavaDoc[0],
985          new Object JavaDoc[0]
986       );
987       Method JavaDoc method = obj.getClass().getMethod("enableType",
988           new Class JavaDoc[] { String JavaDoc.class });
989       method.invoke(obj, new Object JavaDoc[] { "prefix" });
990       runTest(obj);
991    }
992
993    public void testObjectInstance()
994       throws Exception JavaDoc
995    {
996       Object JavaDoc objectName = instantiate(
997          "javax.management.ObjectName",
998          new Class JavaDoc[] { String JavaDoc.class },
999          new Object JavaDoc[] { "domain:x=y" }
1000      );
1001      Object JavaDoc obj = instantiate(
1002         "javax.management.ObjectInstance",
1003         new Class JavaDoc[] { objectName.getClass(), String JavaDoc.class },
1004         new Object JavaDoc[] { objectName, "DummyClass" }
1005      );
1006      Object JavaDoc result = runTest(obj);
1007      assertEquals(obj, result);
1008   }
1009
1010   public void testObjectName()
1011      throws Exception JavaDoc
1012   {
1013      Object JavaDoc obj = instantiate(
1014         "javax.management.ObjectName",
1015         new Class JavaDoc[] { String JavaDoc.class },
1016         new Object JavaDoc[] { "domain:x=y" }
1017      );
1018      Object JavaDoc result = runTest(obj);
1019      assertEquals(obj, result);
1020   }
1021
1022   public void testObjectNamePattern()
1023      throws Exception JavaDoc
1024   {
1025      Object JavaDoc obj = instantiate(
1026         "javax.management.ObjectName",
1027         new Class JavaDoc[] { String JavaDoc.class },
1028         new Object JavaDoc[] { "domain*:x=y" }
1029      );
1030      Object JavaDoc result = runTest(obj);
1031      assertEquals(obj, result);
1032   }
1033
1034   public void testObjectNamePropertyPattern()
1035      throws Exception JavaDoc
1036   {
1037      Object JavaDoc obj = instantiate(
1038         "javax.management.ObjectName",
1039         new Class JavaDoc[] { String JavaDoc.class },
1040         new Object JavaDoc[] { "domain:x=y,*" }
1041      );
1042      Object JavaDoc result = runTest(obj);
1043      assertEquals(obj, result);
1044   }
1045
1046   public void testObjectNameRawPropertyPattern()
1047      throws Exception JavaDoc
1048   {
1049      Object JavaDoc obj = instantiate(
1050         "javax.management.ObjectName",
1051         new Class JavaDoc[] { String JavaDoc.class },
1052         new Object JavaDoc[] { "domain:*" }
1053      );
1054      Object JavaDoc result = runTest(obj);
1055      assertEquals(obj, result);
1056   }
1057
1058   public void testOpenDataException()
1059      throws Exception JavaDoc
1060   {
1061      if (SerializationSUITE.form < 11)
1062         return;
1063      Object JavaDoc obj = instantiate(
1064         "javax.management.openmbean.OpenDataException",
1065         new Class JavaDoc[] { String JavaDoc.class },
1066         new Object JavaDoc[] { "message" }
1067      );
1068      Object JavaDoc result = runTest(obj);
1069      assertEquals(obj.toString(), result.toString());
1070   }
1071
1072   public void testOpenMBeanAttributeInfoSupportMinMax()
1073      throws Exception JavaDoc
1074   {
1075      if (SerializationSUITE.form < 11)
1076         return;
1077      Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
1078      Object JavaDoc elementType = clazz.getField("INTEGER").get(null);
1079
1080      Object JavaDoc obj = instantiate(
1081         "javax.management.openmbean.OpenMBeanAttributeInfoSupport",
1082         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("javax.management.openmbean.OpenType"),
1083                       boolean.class, boolean.class, boolean.class, Object JavaDoc.class, Comparable JavaDoc.class, Comparable JavaDoc.class },
1084         new Object JavaDoc[] { "name", "description", elementType, new Boolean JavaDoc(true), new Boolean JavaDoc(true), new Boolean JavaDoc(false),
1085                        new Integer JavaDoc(12), new Integer JavaDoc(11), new Integer JavaDoc(13) }
1086      );
1087      Object JavaDoc result = runTest(obj);
1088      assertEquals(obj, result);
1089   }
1090
1091   public void testOpenMBeanAttributeInfoSupportLegal()
1092      throws Exception JavaDoc
1093   {
1094      if (SerializationSUITE.form < 11)
1095         return;
1096      Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
1097      Object JavaDoc elementType = clazz.getField("INTEGER").get(null);
1098
1099      Object JavaDoc obj = instantiate(
1100         "javax.management.openmbean.OpenMBeanAttributeInfoSupport",
1101         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("javax.management.openmbean.OpenType"),
1102                       boolean.class, boolean.class, boolean.class, Object JavaDoc.class, Object JavaDoc[].class },
1103         new Object JavaDoc[] { "name", "description", elementType, new Boolean JavaDoc(true), new Boolean JavaDoc(true), new Boolean JavaDoc(false),
1104                        new Integer JavaDoc(12), new Integer JavaDoc[] { new Integer JavaDoc(12), new Integer JavaDoc(13) }}
1105      );
1106      Object JavaDoc result = runTest(obj);
1107      assertEquals(obj, result);
1108   }
1109
1110   public void testOpenMBeanConstructorInfoSupport()
1111      throws Exception JavaDoc
1112   {
1113      if (SerializationSUITE.form < 11)
1114         return;
1115      Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
1116      Object JavaDoc elementType = clazz.getField("INTEGER").get(null);
1117
1118      Object JavaDoc parmInfo = instantiate(
1119         "javax.management.openmbean.OpenMBeanParameterInfoSupport",
1120         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("javax.management.openmbean.OpenType"),
1121                       Object JavaDoc.class, Object JavaDoc[].class },
1122         new Object JavaDoc[] { "name", "description", elementType,
1123                        new Integer JavaDoc(12), new Integer JavaDoc[] {new Integer JavaDoc(12), new Integer JavaDoc(13) }}
1124      );
1125      Object JavaDoc array = Array.newInstance(parmInfo.getClass(), 1);
1126      Array.set(array, 0, parmInfo);
1127
1128      Object JavaDoc obj = instantiate(
1129         "javax.management.openmbean.OpenMBeanConstructorInfoSupport",
1130         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("[Ljavax.management.openmbean.OpenMBeanParameterInfo;")},
1131         new Object JavaDoc[] { "name", "description", array }
1132      );
1133      Object JavaDoc result = runTest(obj);
1134      assertEquals(obj, result);
1135   }
1136
1137   public void testOpenMBeanInfoSupport()
1138      throws Exception JavaDoc
1139   {
1140      if (SerializationSUITE.form < 11)
1141         return;
1142      Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
1143      Object JavaDoc elementType = clazz.getField("INTEGER").get(null);
1144
1145      Object JavaDoc parmInfo = instantiate(
1146         "javax.management.openmbean.OpenMBeanParameterInfoSupport",
1147         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("javax.management.openmbean.OpenType"),
1148                       Object JavaDoc.class, Object JavaDoc[].class },
1149         new Object JavaDoc[] { "name", "description", elementType,
1150                        new Integer JavaDoc(12), new Integer JavaDoc[] {new Integer JavaDoc(12), new Integer JavaDoc(13) }}
1151      );
1152      Object JavaDoc parmArray = Array.newInstance(parmInfo.getClass(), 1);
1153      Array.set(parmArray, 0, parmInfo);
1154
1155      Object JavaDoc attInfo = instantiate(
1156         "javax.management.openmbean.OpenMBeanAttributeInfoSupport",
1157         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("javax.management.openmbean.OpenType"),
1158                       boolean.class, boolean.class, boolean.class, Object JavaDoc.class, Object JavaDoc[].class },
1159         new Object JavaDoc[] { "name", "description", elementType, new Boolean JavaDoc(true), new Boolean JavaDoc(true), new Boolean JavaDoc(false),
1160                        new Integer JavaDoc(12), new Integer JavaDoc[] { new Integer JavaDoc(12), new Integer JavaDoc(13) }}
1161      );
1162
1163      Object JavaDoc conInfo = instantiate(
1164         "javax.management.openmbean.OpenMBeanConstructorInfoSupport",
1165         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("[Ljavax.management.openmbean.OpenMBeanParameterInfo;")},
1166         new Object JavaDoc[] { "name", "description", parmArray }
1167      );
1168
1169      clazz = loadClass("javax.management.MBeanOperationInfo");
1170      Object JavaDoc impact = clazz.getField("INFO").get(null);
1171
1172      Object JavaDoc opInfo = instantiate(
1173         "javax.management.openmbean.OpenMBeanOperationInfoSupport",
1174         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("[Ljavax.management.openmbean.OpenMBeanParameterInfo;"),
1175                       loadClass("javax.management.openmbean.OpenType"), int.class },
1176         new Object JavaDoc[] { "name", "description", parmArray, elementType, impact }
1177      );
1178
1179      String JavaDoc[] types = { "type1", "type2" };
1180      Object JavaDoc notInfo = instantiate(
1181         "javax.management.MBeanNotificationInfo",
1182         new Class JavaDoc[] { types.getClass(), String JavaDoc.class, String JavaDoc.class },
1183         new Object JavaDoc[] { types, "name", "description" }
1184      );
1185
1186      Object JavaDoc attArray = Array.newInstance(attInfo.getClass(), 1);
1187      Array.set(attArray, 0, attInfo);
1188
1189      Object JavaDoc conArray = Array.newInstance(conInfo.getClass(), 1);
1190      Array.set(conArray, 0, conInfo);
1191
1192      Object JavaDoc opArray = Array.newInstance(opInfo.getClass(), 1);
1193      Array.set(opArray, 0, opInfo);
1194
1195      Object JavaDoc notArray = Array.newInstance(notInfo.getClass(), 1);
1196      Array.set(notArray, 0, notInfo);
1197
1198      Object JavaDoc obj = instantiate(
1199         "javax.management.openmbean.OpenMBeanInfoSupport",
1200         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class,
1201                       loadClass("[Ljavax.management.openmbean.OpenMBeanAttributeInfo;"),
1202                       loadClass("[Ljavax.management.openmbean.OpenMBeanConstructorInfo;"),
1203                       loadClass("[Ljavax.management.openmbean.OpenMBeanOperationInfo;"),
1204                       loadClass("[Ljavax.management.MBeanNotificationInfo;") },
1205         new Object JavaDoc[] { "classname", "description", attArray, conArray, opArray, notArray }
1206      );
1207
1208      Object JavaDoc result = runTest(obj);
1209      assertEquals(obj.toString(), result.toString());
1210   }
1211
1212   public void testOpenMBeanOperationInfoSupport()
1213      throws Exception JavaDoc
1214   {
1215      if (SerializationSUITE.form < 11)
1216         return;
1217      Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
1218      Object JavaDoc elementType = clazz.getField("INTEGER").get(null);
1219
1220      Object JavaDoc parmInfo = instantiate(
1221         "javax.management.openmbean.OpenMBeanParameterInfoSupport",
1222         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("javax.management.openmbean.OpenType"),
1223                       Object JavaDoc.class, Object JavaDoc[].class },
1224         new Object JavaDoc[] { "name", "description", elementType,
1225                        new Integer JavaDoc(12), new Integer JavaDoc[] {new Integer JavaDoc(12), new Integer JavaDoc(13) }}
1226      );
1227      Object JavaDoc array = Array.newInstance(parmInfo.getClass(), 1);
1228      Array.set(array, 0, parmInfo);
1229
1230      clazz = loadClass("javax.management.MBeanOperationInfo");
1231      Object JavaDoc impact = clazz.getField("INFO").get(null);
1232
1233      Object JavaDoc obj = instantiate(
1234         "javax.management.openmbean.OpenMBeanOperationInfoSupport",
1235         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("[Ljavax.management.openmbean.OpenMBeanParameterInfo;"),
1236                       loadClass("javax.management.openmbean.OpenType"), int.class },
1237         new Object JavaDoc[] { "name", "description", array, elementType, impact }
1238      );
1239      Object JavaDoc result = runTest(obj);
1240      assertEquals(obj, result);
1241   }
1242
1243   public void testOpenMBeanParameterInfoSupportMinMax()
1244      throws Exception JavaDoc
1245   {
1246      if (SerializationSUITE.form < 11)
1247         return;
1248      Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
1249      Object JavaDoc elementType = clazz.getField("INTEGER").get(null);
1250
1251      Object JavaDoc obj = instantiate(
1252         "javax.management.openmbean.OpenMBeanParameterInfoSupport",
1253         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("javax.management.openmbean.OpenType"),
1254                       Object JavaDoc.class, Comparable JavaDoc.class, Comparable JavaDoc.class },
1255         new Object JavaDoc[] { "name", "description", elementType,
1256                        new Integer JavaDoc(12), new Integer JavaDoc(11), new Integer JavaDoc(13) }
1257      );
1258      Object JavaDoc result = runTest(obj);
1259      assertEquals(obj, result);
1260   }
1261
1262   public void testOpenMBeanParameterInfoSupportLegal()
1263      throws Exception JavaDoc
1264   {
1265      if (SerializationSUITE.form < 11)
1266         return;
1267      Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
1268      Object JavaDoc elementType = clazz.getField("INTEGER").get(null);
1269
1270      Object JavaDoc obj = instantiate(
1271         "javax.management.openmbean.OpenMBeanParameterInfoSupport",
1272         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, loadClass("javax.management.openmbean.OpenType"),
1273                       Object JavaDoc.class, Object JavaDoc[].class },
1274         new Object JavaDoc[] { "name", "description", elementType,
1275                         new Integer JavaDoc(12), new Integer JavaDoc[] {new Integer JavaDoc(12), new Integer JavaDoc(13) }}
1276      );
1277      Object JavaDoc result = runTest(obj);
1278      assertEquals(obj, result);
1279   }
1280
1281   public void testOperationsException()
1282      throws Exception JavaDoc
1283   {
1284      Object JavaDoc obj = instantiate(
1285         "javax.management.OperationsException",
1286         new Class JavaDoc[] { String JavaDoc.class },
1287         new Object JavaDoc[] { "message" }
1288      );
1289      Object JavaDoc result = runTest(obj);
1290      assertEquals(obj.toString(), result.toString());
1291   }
1292
1293   public void testReflectionException()
1294      throws Exception JavaDoc
1295   {
1296      Object JavaDoc obj = instantiate(
1297         "javax.management.ReflectionException",
1298         new Class JavaDoc[] { Exception JavaDoc.class, String JavaDoc.class },
1299         new Object JavaDoc[] { new Exception JavaDoc("Cause"), "message" }
1300      );
1301      Object JavaDoc result = runTest(obj);
1302      assertEquals(obj.toString(), result.toString());
1303   }
1304
1305   public void testRelationException()
1306      throws Exception JavaDoc
1307   {
1308      Object JavaDoc obj = instantiate(
1309         "javax.management.relation.RelationException",
1310         new Class JavaDoc[] { String JavaDoc.class },
1311         new Object JavaDoc[] { "message" }
1312      );
1313      Object JavaDoc result = runTest(obj);
1314      assertEquals(obj.toString(), result.toString());
1315   }
1316
1317   public void testRelationNotFoundException()
1318      throws Exception JavaDoc
1319   {
1320      Object JavaDoc obj = instantiate(
1321         "javax.management.relation.RelationNotFoundException",
1322         new Class JavaDoc[] { String JavaDoc.class },
1323         new Object JavaDoc[] { "message" }
1324      );
1325      Object JavaDoc result = runTest(obj);
1326      assertEquals(obj.toString(), result.toString());
1327   }
1328
1329   public void testRelationNotification()
1330      throws Exception JavaDoc
1331   {
1332      Object JavaDoc objectName = instantiate(
1333         "javax.management.ObjectName",
1334         new Class JavaDoc[] { String JavaDoc.class },
1335         new Object JavaDoc[] { "domain:x=y" }
1336      );
1337      Class JavaDoc clazz = loadClass("javax.management.relation.RelationNotification");
1338      String JavaDoc type = (String JavaDoc) clazz.getField("RELATION_BASIC_UPDATE").get(null);
1339      ArrayList JavaDoc newValue = new ArrayList JavaDoc();
1340      newValue.add(objectName);
1341      ArrayList JavaDoc oldValue = new ArrayList JavaDoc();
1342      oldValue.add(objectName);
1343      Object JavaDoc obj = instantiate(
1344         "javax.management.relation.RelationNotification",
1345         new Class JavaDoc[] { String JavaDoc.class, Object JavaDoc.class, Long.TYPE, Long.TYPE,
1346                       String JavaDoc.class, String JavaDoc.class, String JavaDoc.class,
1347                       objectName.getClass(), String JavaDoc.class, List JavaDoc.class, List JavaDoc.class },
1348         new Object JavaDoc[] { type, objectName, new Long JavaDoc(1), new Long JavaDoc(2),
1349                        "message", "relationId", "relationType", objectName,
1350                        "roleName", newValue, oldValue}
1351      );
1352      Object JavaDoc result = runTest(obj);
1353      assertEquals(obj.toString(), result.toString());
1354   }
1355
1356   public void testRelationServiceNotRegisteredException()
1357      throws Exception JavaDoc
1358   {
1359      Object JavaDoc obj = instantiate(
1360         "javax.management.relation.RelationServiceNotRegisteredException",
1361         new Class JavaDoc[] { String JavaDoc.class },
1362         new Object JavaDoc[] { "message" }
1363      );
1364      Object JavaDoc result = runTest(obj);
1365      assertEquals(obj.toString(), result.toString());
1366   }
1367
1368   public void testRelationTypeNotFoundException()
1369      throws Exception JavaDoc
1370   {
1371      Object JavaDoc obj = instantiate(
1372         "javax.management.relation.RelationTypeNotFoundException",
1373         new Class JavaDoc[] { String JavaDoc.class },
1374         new Object JavaDoc[] { "message" }
1375      );
1376      Object JavaDoc result = runTest(obj);
1377      assertEquals(obj.toString(), result.toString());
1378   }
1379
1380   /**
1381    * @todo equals test
1382    */

1383   public void testRelationTypeSupport()
1384      throws Exception JavaDoc
1385   {
1386      Object JavaDoc roleInfo = instantiate(
1387         "javax.management.relation.RoleInfo",
1388         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, Boolean.TYPE, Boolean.TYPE,
1389                       Integer.TYPE, Integer.TYPE, String JavaDoc.class },
1390         new Object JavaDoc[] { "name", "test.serialization.support.Trivial",
1391                        new Boolean JavaDoc(true), new Boolean JavaDoc(true), new Integer JavaDoc(10),
1392                        new Integer JavaDoc(20), "descritpion" }
1393      );
1394      Object JavaDoc array = Array.newInstance(roleInfo.getClass(), 1);
1395      Array.set(array, 0, roleInfo);
1396      Object JavaDoc obj = instantiate(
1397         "javax.management.relation.RelationTypeSupport",
1398         new Class JavaDoc[] { String JavaDoc.class, array.getClass() },
1399         new Object JavaDoc[] { "name", array }
1400      );
1401      runTest(obj);
1402   }
1403
1404   public void testRole()
1405      throws Exception JavaDoc
1406   {
1407      Object JavaDoc objectName = instantiate(
1408         "javax.management.ObjectName",
1409         new Class JavaDoc[] { String JavaDoc.class },
1410         new Object JavaDoc[] { "domain:x=y" }
1411      );
1412      ArrayList JavaDoc list = new ArrayList JavaDoc();
1413      list.add(objectName);
1414      Object JavaDoc obj = instantiate(
1415         "javax.management.relation.Role",
1416         new Class JavaDoc[] { String JavaDoc.class, List JavaDoc.class},
1417         new Object JavaDoc[] { "name", list }
1418      );
1419      Object JavaDoc result = runTest(obj);
1420      assertEquals(obj.toString(), result.toString());
1421   }
1422
1423   public void testRoleInfo()
1424      throws Exception JavaDoc
1425   {
1426      Object JavaDoc obj = instantiate(
1427         "javax.management.relation.RoleInfo",
1428         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, Boolean.TYPE, Boolean.TYPE,
1429                       Integer.TYPE, Integer.TYPE, String JavaDoc.class },
1430         new Object JavaDoc[] { "name", "test.serialization.support.Trivial",
1431                        new Boolean JavaDoc(true), new Boolean JavaDoc(true), new Integer JavaDoc(10),
1432                        new Integer JavaDoc(20), "descritpion" }
1433      );
1434      Object JavaDoc result = runTest(obj);
1435      assertEquals(obj.toString(), result.toString());
1436   }
1437
1438   public void testRoleInfoNotFoundException()
1439      throws Exception JavaDoc
1440   {
1441      Object JavaDoc obj = instantiate(
1442         "javax.management.relation.RoleInfoNotFoundException",
1443         new Class JavaDoc[] { String JavaDoc.class },
1444         new Object JavaDoc[] { "message" }
1445      );
1446      Object JavaDoc result = runTest(obj);
1447      assertEquals(obj.toString(), result.toString());
1448   }
1449
1450   public void testRoleList()
1451      throws Exception JavaDoc
1452   {
1453      Object JavaDoc objectName = instantiate(
1454         "javax.management.ObjectName",
1455         new Class JavaDoc[] { String JavaDoc.class },
1456         new Object JavaDoc[] { "domain:x=y" }
1457      );
1458      ArrayList JavaDoc list = new ArrayList JavaDoc();
1459      list.add(objectName);
1460      Object JavaDoc role = instantiate(
1461         "javax.management.relation.Role",
1462         new Class JavaDoc[] { String JavaDoc.class, List JavaDoc.class},
1463         new Object JavaDoc[] { "name", list }
1464      );
1465      list = new ArrayList JavaDoc();
1466      list.add(role);
1467      Object JavaDoc obj = instantiate(
1468         "javax.management.relation.RoleList",
1469         new Class JavaDoc[] { List JavaDoc.class},
1470         new Object JavaDoc[] { list }
1471      );
1472      Object JavaDoc result = runTest(obj);
1473      assertEquals(obj.toString(), result.toString());
1474   }
1475
1476   public void testRoleNotFoundException()
1477      throws Exception JavaDoc
1478   {
1479      Object JavaDoc obj = instantiate(
1480         "javax.management.relation.RoleNotFoundException",
1481         new Class JavaDoc[] { String JavaDoc.class },
1482         new Object JavaDoc[] { "message" }
1483      );
1484      Object JavaDoc result = runTest(obj);
1485      assertEquals(obj.toString(), result.toString());
1486   }
1487
1488   public void testRoleResult()
1489      throws Exception JavaDoc
1490   {
1491      Object JavaDoc objectName = instantiate(
1492         "javax.management.ObjectName",
1493         new Class JavaDoc[] { String JavaDoc.class },
1494         new Object JavaDoc[] { "domain:x=y" }
1495      );
1496      ArrayList JavaDoc list = new ArrayList JavaDoc();
1497      list.add(objectName);
1498
1499      Object JavaDoc resolved = instantiate(
1500         "javax.management.relation.Role",
1501         new Class JavaDoc[] { String JavaDoc.class, List JavaDoc.class},
1502         new Object JavaDoc[] { "name", list }
1503      );
1504      list = new ArrayList JavaDoc();
1505      list.add(resolved);
1506      Object JavaDoc resolvedList = instantiate(
1507         "javax.management.relation.RoleList",
1508         new Class JavaDoc[] { List JavaDoc.class },
1509         new Object JavaDoc[] { list }
1510      );
1511
1512      Class JavaDoc clazz = loadClass("javax.management.relation.RoleStatus");
1513      Integer JavaDoc status = new Integer JavaDoc(clazz.getField("ROLE_NOT_READABLE").getInt(null));
1514      Object JavaDoc unresolved = instantiate(
1515         "javax.management.relation.RoleUnresolved",
1516         new Class JavaDoc[] { String JavaDoc.class, List JavaDoc.class, Integer.TYPE},
1517         new Object JavaDoc[] { "name", list, status }
1518      );
1519      list = new ArrayList JavaDoc();
1520      list.add(unresolved);
1521      Object JavaDoc unresolvedList = instantiate(
1522         "javax.management.relation.RoleUnresolvedList",
1523         new Class JavaDoc[] { List JavaDoc.class },
1524         new Object JavaDoc[] { list }
1525      );
1526      Object JavaDoc obj = instantiate(
1527         "javax.management.relation.RoleResult",
1528         new Class JavaDoc[] { resolvedList.getClass(), unresolvedList.getClass() },
1529         new Object JavaDoc[] { resolvedList, unresolvedList }
1530      );
1531      Object JavaDoc result = runTest(obj);
1532      assertEquals(obj.toString(), result.toString());
1533   }
1534
1535   public void testRoleUnresolved()
1536      throws Exception JavaDoc
1537   {
1538      Object JavaDoc objectName = instantiate(
1539         "javax.management.ObjectName",
1540         new Class JavaDoc[] { String JavaDoc.class },
1541         new Object JavaDoc[] { "domain:x=y" }
1542      );
1543      ArrayList JavaDoc list = new ArrayList JavaDoc();
1544      list.add(objectName);
1545      Class JavaDoc clazz = loadClass("javax.management.relation.RoleStatus");
1546      Integer JavaDoc status = new Integer JavaDoc(clazz.getField("ROLE_NOT_READABLE").getInt(null));
1547      Object JavaDoc obj = instantiate(
1548         "javax.management.relation.RoleUnresolved",
1549         new Class JavaDoc[] { String JavaDoc.class, List JavaDoc.class, Integer.TYPE},
1550         new Object JavaDoc[] { "name", list, status }
1551      );
1552      Object JavaDoc result = runTest(obj);
1553      assertEquals(obj.toString(), result.toString());
1554   }
1555
1556   public void testRoleUnresolvedList()
1557      throws Exception JavaDoc
1558   {
1559      Object JavaDoc objectName = instantiate(
1560         "javax.management.ObjectName",
1561         new Class JavaDoc[] { String JavaDoc.class },
1562         new Object JavaDoc[] { "domain:x=y" }
1563      );
1564      ArrayList JavaDoc list = new ArrayList JavaDoc();
1565      list.add(objectName);
1566      Class JavaDoc clazz = loadClass("javax.management.relation.RoleStatus");
1567      Integer JavaDoc status = new Integer JavaDoc(clazz.getField("ROLE_NOT_READABLE").getInt(null));
1568      Object JavaDoc unresolved = instantiate(
1569         "javax.management.relation.RoleUnresolved",
1570         new Class JavaDoc[] { String JavaDoc.class, List JavaDoc.class, Integer.TYPE},
1571         new Object JavaDoc[] { "name", list, status }
1572      );
1573      list = new ArrayList JavaDoc();
1574      list.add(unresolved);
1575      Object JavaDoc obj = instantiate(
1576         "javax.management.relation.RoleUnresolvedList",
1577         new Class JavaDoc[] { List JavaDoc.class},
1578         new Object JavaDoc[] { list }
1579      );
1580      Object JavaDoc result = runTest(obj);
1581      assertEquals(obj.toString(), result.toString());
1582   }
1583
1584   public void testRuntimeErrorException()
1585      throws Exception JavaDoc
1586   {
1587      Object JavaDoc obj = instantiate(
1588         "javax.management.RuntimeErrorException",
1589         new Class JavaDoc[] { Error JavaDoc.class, String JavaDoc.class },
1590         new Object JavaDoc[] { new Error JavaDoc("Cause"), "message" }
1591      );
1592      Object JavaDoc result = runTest(obj);
1593      assertEquals(obj.toString(), result.toString());
1594   }
1595
1596   public void testRuntimeMBeanException()
1597      throws Exception JavaDoc
1598   {
1599      Object JavaDoc obj = instantiate(
1600         "javax.management.RuntimeMBeanException",
1601         new Class JavaDoc[] { RuntimeException JavaDoc.class, String JavaDoc.class },
1602         new Object JavaDoc[] { new RuntimeException JavaDoc("Cause"), "message" }
1603      );
1604      Object JavaDoc result = runTest(obj);
1605      assertEquals(obj.toString(), result.toString());
1606   }
1607
1608   public void testRuntimeOperationsException()
1609      throws Exception JavaDoc
1610   {
1611      Object JavaDoc obj = instantiate(
1612         "javax.management.RuntimeOperationsException",
1613         new Class JavaDoc[] { RuntimeException JavaDoc.class, String JavaDoc.class },
1614         new Object JavaDoc[] { new RuntimeException JavaDoc("Cause"), "message" }
1615      );
1616      Object JavaDoc result = runTest(obj);
1617      assertEquals(obj.toString(), result.toString());
1618   }
1619
1620   public void testServiceNotFoundException()
1621      throws Exception JavaDoc
1622   {
1623      Object JavaDoc obj = instantiate(
1624         "javax.management.ServiceNotFoundException",
1625         new Class JavaDoc[] { String JavaDoc.class },
1626         new Object JavaDoc[] { "message" }
1627      );
1628      Object JavaDoc result = runTest(obj);
1629      assertEquals(obj.toString(), result.toString());
1630   }
1631
1632   public void testSimpleType()
1633      throws Exception JavaDoc
1634   {
1635      if (SerializationSUITE.form < 11)
1636         return;
1637      Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
1638      Object JavaDoc obj = clazz.getField("BIGDECIMAL").get(null);
1639      Object JavaDoc result = runTest(obj);
1640      assertTrue("Simple types should resolve to the same object",
1641                 obj == result);
1642   }
1643
1644   public void testStringValueExp()
1645      throws Exception JavaDoc
1646   {
1647      Object JavaDoc obj = instantiate(
1648         "javax.management.StringValueExp",
1649         new Class JavaDoc[] { String JavaDoc.class },
1650         new Object JavaDoc[] { "attr" }
1651      );
1652      Object JavaDoc result = runTest(obj);
1653      assertEquals(obj.toString(), result.toString());
1654   }
1655
1656   public void testTabularDataSupport()
1657      throws Exception JavaDoc
1658   {
1659      if (SerializationSUITE.form < 11)
1660         return;
1661      Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
1662      Object JavaDoc openType = clazz.getField("STRING").get(null);
1663
1664      Class JavaDoc elementClass = loadClass("javax.management.openmbean.OpenType");
1665      Object JavaDoc array = Array.newInstance(elementClass, 2);
1666      Array.set(array, 0, openType);
1667      Array.set(array, 1, openType);
1668
1669      Object JavaDoc compositeType = instantiate(
1670         "javax.management.openmbean.CompositeType",
1671         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc[].class, String JavaDoc[].class, array.getClass() },
1672         new Object JavaDoc[] { "typeName", "description", new String JavaDoc[] { "name1", "name2" },
1673            new String JavaDoc[] { "desc1", "desc2" }, array }
1674      );
1675
1676      Object JavaDoc tabularType = instantiate(
1677         "javax.management.openmbean.TabularType",
1678         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, compositeType.getClass(), String JavaDoc[].class },
1679         new Object JavaDoc[] { "typeName", "description", compositeType, new String JavaDoc[] { "name1" }}
1680      );
1681
1682      Object JavaDoc obj = instantiate(
1683         "javax.management.openmbean.TabularDataSupport",
1684         new Class JavaDoc[] { tabularType.getClass() },
1685         new Object JavaDoc[] { tabularType }
1686      );
1687      Object JavaDoc result = runTest(obj);
1688      assertEquals(obj, result);
1689   }
1690
1691   public void testTabularType()
1692      throws Exception JavaDoc
1693   {
1694      if (SerializationSUITE.form < 11)
1695         return;
1696      Class JavaDoc clazz = loadClass("javax.management.openmbean.SimpleType");
1697      Object JavaDoc openType = clazz.getField("STRING").get(null);
1698
1699      Class JavaDoc elementClass = loadClass("javax.management.openmbean.OpenType");
1700      Object JavaDoc array = Array.newInstance(elementClass, 2);
1701      Array.set(array, 0, openType);
1702      Array.set(array, 1, openType);
1703
1704      Object JavaDoc compositeType = instantiate(
1705         "javax.management.openmbean.CompositeType",
1706         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, String JavaDoc[].class, String JavaDoc[].class, array.getClass() },
1707         new Object JavaDoc[] { "typeName", "description", new String JavaDoc[] { "name1", "name2" },
1708            new String JavaDoc[] { "desc1", "desc2" }, array }
1709      );
1710
1711      Object JavaDoc obj = instantiate(
1712         "javax.management.openmbean.TabularType",
1713         new Class JavaDoc[] { String JavaDoc.class, String JavaDoc.class, compositeType.getClass(), String JavaDoc[].class },
1714         new Object JavaDoc[] { "typeName", "description", compositeType, new String JavaDoc[] { "name1" }}
1715      );
1716
1717      Object JavaDoc result = runTest(obj);
1718      assertEquals(obj, result);
1719   }
1720
1721   /**
1722    * @todo ?
1723    */

1724   public void testTimerAlarmClockNotification()
1725      throws Exception JavaDoc
1726   {
1727   }
1728
1729   public void testTimerNotification()
1730      throws Exception JavaDoc
1731   {
1732      Object JavaDoc timerName = instantiate(
1733         "javax.management.ObjectName",
1734         new Class JavaDoc[] { String JavaDoc.class },
1735         new Object JavaDoc[] { "timer:x=y" }
1736      );
1737      Object JavaDoc obj = instantiate(
1738         "javax.management.timer.TimerNotification",
1739         new Class JavaDoc[] { String JavaDoc.class, Object JavaDoc.class, Long.TYPE, Long.TYPE,
1740                       String JavaDoc.class, Integer JavaDoc.class, Object JavaDoc.class },
1741         new Object JavaDoc[] { "type", timerName, new Long JavaDoc(1), new Long JavaDoc(2),
1742                        "message", new Integer JavaDoc(1), "user data" }
1743      );
1744      Object JavaDoc result = runTest(obj);
1745      assertEquals(obj.toString(), result.toString());
1746   }
1747
1748   public void testXMLParseException()
1749      throws Exception JavaDoc
1750   {
1751      Object JavaDoc obj = instantiate(
1752         "javax.management.modelmbean.XMLParseException",
1753         new Class JavaDoc[] { Exception JavaDoc.class, String JavaDoc.class },
1754         new Object JavaDoc[] { new Exception JavaDoc("exception"), "message" }
1755      );
1756      Object JavaDoc result = runTest(obj);
1757      assertEquals(obj.toString(), result.toString());
1758   }
1759
1760   // Support -------------------------------------------------------
1761

1762   /**
1763    * Instantiate an object using JBossMX.
1764    */

1765   private Object JavaDoc instantiate(String JavaDoc className, Class JavaDoc[] sig, Object JavaDoc[] parms)
1766      throws Exception JavaDoc
1767   {
1768      Constructor JavaDoc cons = loadClass(className).getDeclaredConstructor(sig);
1769      return cons.newInstance(parms);
1770   }
1771
1772   /**
1773    * Load a class using JBossMX.
1774    */

1775   private Class JavaDoc loadClass(String JavaDoc className)
1776      throws Exception JavaDoc
1777   {
1778      return SerializationSUITE.jbossmx.loadClass(className);
1779   }
1780
1781   /**
1782    * Serialize from jbossmx to jmxri.
1783    * Serialize from jmxri to jbossmx.
1784    */

1785   private Object JavaDoc runTest(Object JavaDoc obj)
1786      throws Exception JavaDoc
1787   {
1788      ByteArrayOutputStream JavaDoc os = serializeJBoss(obj);
1789      Object JavaDoc intermediate = deserializeRI(os);
1790      os = serializeRI(intermediate);
1791      return deserializeJBoss(os);
1792   }
1793
1794   /**
1795    * Dummy method wrapper for debugging.
1796    */

1797   private ByteArrayOutputStream JavaDoc serializeJBoss(Object JavaDoc obj)
1798      throws Exception JavaDoc
1799   {
1800      return serialize(obj);
1801   }
1802
1803   /**
1804    * Dummy method wrapper for debugging.
1805    */

1806   private ByteArrayOutputStream JavaDoc serializeRI(Object JavaDoc obj)
1807      throws Exception JavaDoc
1808   {
1809      return serialize(obj);
1810   }
1811
1812   /**
1813    * Dummy method wrapper for debugging.
1814    */

1815   private Object JavaDoc deserializeJBoss(ByteArrayOutputStream JavaDoc os)
1816      throws Exception JavaDoc
1817   {
1818      return deserialize(SerializationSUITE.jbossmx, os);
1819   }
1820
1821   /**
1822    * Dummy method wrapper for debugging.
1823    */

1824   private Object JavaDoc deserializeRI(ByteArrayOutputStream JavaDoc os)
1825      throws Exception JavaDoc
1826   {
1827      return deserialize(SerializationSUITE.jmxri, os);
1828   }
1829
1830   /**
1831    * Serialize the object.
1832    */

1833   private ByteArrayOutputStream JavaDoc serialize(Object JavaDoc obj)
1834      throws Exception JavaDoc
1835   {
1836      ByteArrayOutputStream JavaDoc baos = new ByteArrayOutputStream JavaDoc();
1837      ObjectOutputStream JavaDoc oos = new ObjectOutputStream JavaDoc(baos);
1838      oos.writeObject(obj);
1839      return baos;
1840   }
1841    
1842   /**
1843    * Deserialize the object.
1844    */

1845   private Object JavaDoc deserialize(ClassLoader JavaDoc cl, ByteArrayOutputStream JavaDoc baos)
1846      throws Exception JavaDoc
1847   {
1848      ByteArrayInputStream JavaDoc bais = new ByteArrayInputStream JavaDoc(baos.toByteArray());
1849      ObjectInputStream JavaDoc ois = new MyObjectInputStream(cl, bais);
1850      return ois.readObject();
1851   }
1852
1853   /**
1854    * Custom inputstream to override classloading to the relevent
1855    * jmx implementation
1856    */

1857   public class MyObjectInputStream extends ObjectInputStream JavaDoc
1858   {
1859      ClassLoader JavaDoc cl;
1860      public MyObjectInputStream(ClassLoader JavaDoc cl, ByteArrayInputStream JavaDoc is)
1861         throws IOException JavaDoc
1862      {
1863         super(is);
1864         this.cl = cl;
1865      }
1866      protected Class JavaDoc resolveClass(java.io.ObjectStreamClass JavaDoc osc)
1867         throws IOException JavaDoc, ClassNotFoundException JavaDoc
1868      {
1869         return cl.loadClass(osc.getName());
1870      }
1871   }
1872}
1873
Popular Tags