KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > compliance > relation > RelationNotificationTestCase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package test.compliance.relation;
9
10 import java.io.Serializable;
11 import java.util.ArrayList;
12
13 import javax.management.ObjectName;
14 import javax.management.relation.RelationNotification;
15 import javax.management.relation.RelationService;
16
17 import junit.framework.TestCase;
18
19 /**
20  * Relation Notification Tests
21  *
22  * NOTE: These tests use relation service for the source, but it is not
23  * tested for compliance. JBossMX uses the relation service's object name
24  * to ensure the notification is serializable
25  *
26  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
27  */

28 public class RelationNotificationTestCase
29   extends TestCase
30   implements Serializable
31 {
32
33   // Constants -----------------------------------------------------------------
34

35    static final long serialVersionUID = 516562336428465857L;
36    static String[] types = new String[]
37   {
38     RelationNotification.RELATION_BASIC_CREATION,
39     RelationNotification.RELATION_MBEAN_CREATION,
40     RelationNotification.RELATION_BASIC_UPDATE,
41     RelationNotification.RELATION_MBEAN_UPDATE,
42     RelationNotification.RELATION_BASIC_REMOVAL,
43     RelationNotification.RELATION_MBEAN_REMOVAL
44   };
45
46   // Attributes ----------------------------------------------------------------
47

48   // Constructor ---------------------------------------------------------------
49

50   /**
51    * Construct the test
52    */

53   public RelationNotificationTestCase(String s)
54   {
55     super(s);
56   }
57
58   // Tests ---------------------------------------------------------------------
59

60   /**
61    * Make sure all the constants are different
62    */

63   public void testDifferent()
64   {
65     for (int i = 0; i < (types.length - 1); i++)
66     {
67       for (int j = i + 1; j < types.length; j++)
68         if (types[i].equals(types[j]))
69           fail("Relation Notifications types not unique");
70     }
71   }
72
73   /**
74    * Test Basic Creation
75    */

76   public void testBasicCreation()
77   {
78     RelationNotification rn = null;
79     try
80     {
81       rn = new RelationNotification(RelationNotification.RELATION_BASIC_CREATION,
82              new RelationService(true), 21, 23, "message", "relationId",
83              "relationTypeName", null, null);
84     }
85     catch (Exception e)
86     {
87       fail(e.toString());
88     }
89     assertEquals(RelationNotification.RELATION_BASIC_CREATION, rn.getType());
90     assertEquals(21, rn.getSequenceNumber());
91     assertEquals(23, rn.getTimeStamp());
92     assertEquals("message", rn.getMessage());
93     assertEquals("relationId", rn.getRelationId());
94     assertEquals("relationTypeName", rn.getRelationTypeName());
95     assertEquals(null, rn.getObjectName());
96     assertEquals(0, rn.getMBeansToUnregister().size());
97   }
98
99   /**
100    * Test Basic Removal
101    */

102   public void testBasicRemoval()
103   {
104     RelationNotification rn = null;
105     ObjectName objectName = null;
106     ArrayList unregs = new ArrayList();
107     try
108     {
109       rn = new RelationNotification(RelationNotification.RELATION_BASIC_REMOVAL,
110              new RelationService(true), 21, 23, "message", "relationId",
111              "relationTypeName", null, unregs);
112     }
113     catch (Exception e)
114     {
115       fail(e.toString());
116     }
117     assertEquals(RelationNotification.RELATION_BASIC_REMOVAL, rn.getType());
118     assertEquals(21, rn.getSequenceNumber());
119     assertEquals(23, rn.getTimeStamp());
120     assertEquals("message", rn.getMessage());
121     assertEquals("relationId", rn.getRelationId());
122     assertEquals("relationTypeName", rn.getRelationTypeName());
123     assertEquals(null, rn.getObjectName());
124     assertEquals(unregs, rn.getMBeansToUnregister());
125   }
126
127   /**
128    * Test MBean Creation
129    */

130   public void testMBeanCreation()
131   {
132     RelationNotification rn = null;
133     ObjectName objectName = null;
134     try
135     {
136       objectName = new ObjectName(":a=a");
137       rn = new RelationNotification(RelationNotification.RELATION_MBEAN_CREATION,
138              new RelationService(true), 21, 23, "message", "relationId",
139              "relationTypeName", objectName, null);
140     }
141     catch (Exception e)
142     {
143       fail(e.toString());
144     }
145     assertEquals(RelationNotification.RELATION_MBEAN_CREATION, rn.getType());
146     assertEquals(21, rn.getSequenceNumber());
147     assertEquals(23, rn.getTimeStamp());
148     assertEquals("message", rn.getMessage());
149     assertEquals("relationId", rn.getRelationId());
150     assertEquals("relationTypeName", rn.getRelationTypeName());
151     assertEquals(objectName, rn.getObjectName());
152     assertEquals(0, rn.getMBeansToUnregister().size());
153   }
154
155   /**
156    * Test MBean Removal
157    */

158   public void testMBeanRemoval()
159   {
160     RelationNotification rn = null;
161     ObjectName objectName = null;
162     ArrayList unregs = new ArrayList();
163     try
164     {
165       objectName = new ObjectName(":a=a");
166       rn = new RelationNotification(RelationNotification.RELATION_MBEAN_REMOVAL,
167              new RelationService(true), 21, 23, "message", "relationId",
168              "relationTypeName", objectName, unregs);
169     }
170     catch (Exception e)
171     {
172       fail(e.toString());
173     }
174     assertEquals(RelationNotification.RELATION_MBEAN_REMOVAL, rn.getType());
175     assertEquals(21, rn.getSequenceNumber());
176     assertEquals(23, rn.getTimeStamp());
177     assertEquals("message", rn.getMessage());
178     assertEquals("relationId", rn.getRelationId());
179     assertEquals("relationTypeName", rn.getRelationTypeName());
180     assertEquals(objectName, rn.getObjectName());
181     assertEquals(unregs, rn.getMBeansToUnregister());
182   }
183
184   /**
185    * Test Basic Update
186    */

187   public void testBasicUpdate()
188   {
189     RelationNotification rn = null;
190     ArrayList newRoles = new ArrayList();
191     ArrayList oldRoles = new ArrayList();
192     try
193     {
194       rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
195              new RelationService(true), 21, 23, "message", "relationId",
196              "relationTypeName", null, "roleName", newRoles, oldRoles);
197     }
198     catch (Exception e)
199     {
200       fail(e.toString());
201     }
202     assertEquals(RelationNotification.RELATION_BASIC_UPDATE, rn.getType());
203     assertEquals(21, rn.getSequenceNumber());
204     assertEquals(23, rn.getTimeStamp());
205     assertEquals("message", rn.getMessage());
206     assertEquals("relationId", rn.getRelationId());
207     assertEquals("relationTypeName", rn.getRelationTypeName());
208     assertEquals(null, rn.getObjectName());
209     assertEquals("roleName", rn.getRoleName());
210     assertEquals(0, rn.getNewRoleValue().size());
211     assertEquals(0, rn.getOldRoleValue().size());
212   }
213
214   /**
215    * Test MBean Update
216    */

217   public void testMBeanUpdate()
218   {
219     RelationNotification rn = null;
220     ObjectName objectName = null;
221     ArrayList newRoles = new ArrayList();
222     ArrayList oldRoles = new ArrayList();
223     try
224     {
225       objectName = new ObjectName(":a=a");
226       rn = new RelationNotification(RelationNotification.RELATION_MBEAN_UPDATE,
227              new RelationService(true), 21, 23, "message", "relationId",
228              "relationTypeName", objectName, "roleName", newRoles, oldRoles);
229     }
230     catch (Exception e)
231     {
232       fail(e.toString());
233     }
234     assertEquals(RelationNotification.RELATION_MBEAN_UPDATE, rn.getType());
235     assertEquals(21, rn.getSequenceNumber());
236     assertEquals(23, rn.getTimeStamp());
237     assertEquals("message", rn.getMessage());
238     assertEquals("relationId", rn.getRelationId());
239     assertEquals("relationTypeName", rn.getRelationTypeName());
240     assertEquals(objectName, rn.getObjectName());
241     assertEquals("roleName", rn.getRoleName());
242     assertEquals(0, rn.getNewRoleValue().size());
243     assertEquals(0, rn.getOldRoleValue().size());
244   }
245
246   /**
247    * Test Creation/Removal Error Handling
248    */

249   public void testCreationRemovalErrors()
250   {
251     RelationNotification rn = null;
252     ObjectName objectName = null;
253     try
254     {
255       objectName = new ObjectName(":a=a");
256     }
257     catch (Exception e)
258     {
259       fail(e.toString());
260     }
261     ArrayList unregs = new ArrayList();
262
263     boolean caught = false;
264     try
265     {
266       rn = new RelationNotification("blah",
267              new RelationService(true), 21, 23, "message", "relationId",
268              "relationTypeName", objectName, unregs);
269     }
270     catch (IllegalArgumentException e)
271     {
272       caught = true;
273     }
274     catch (Exception e)
275     {
276       fail(e.toString());
277     }
278     if (caught == false)
279       fail("Creation/Removal accepts an invalid type");
280
281     caught = false;
282     try
283     {
284       rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
285              new RelationService(true), 21, 23, "message", "relationId",
286              "relationTypeName", objectName, unregs);
287     }
288     catch (IllegalArgumentException e)
289     {
290       caught = true;
291     }
292     catch (Exception e)
293     {
294       fail(e.toString());
295     }
296     if (caught == false)
297       fail("Creation/Removal accepts basic update");
298
299     caught = false;
300     try
301     {
302       rn = new RelationNotification(RelationNotification.RELATION_MBEAN_UPDATE,
303              new RelationService(true), 21, 23, "message", "relationId",
304              "relationTypeName", objectName, unregs);
305     }
306     catch (IllegalArgumentException e)
307     {
308       caught = true;
309     }
310     catch (Exception e)
311     {
312       fail(e.toString());
313     }
314     if (caught == false)
315       fail("Creation/Removal accepts mean update");
316
317     caught = false;
318     try
319     {
320       rn = new RelationNotification(RelationNotification.RELATION_BASIC_CREATION,
321              null, 21, 23, "message", "relationId",
322              "relationTypeName", objectName, unregs);
323     }
324     catch (IllegalArgumentException e)
325     {
326       caught = true;
327     }
328     catch (Exception e)
329     {
330       fail(e.toString());
331     }
332     if (caught == false)
333       fail("Creation/Removal accepts null source");
334
335     caught = false;
336     try
337     {
338       rn = new RelationNotification(RelationNotification.RELATION_BASIC_CREATION,
339              new RelationService(true), 21, 23, "message", null,
340              "relationTypeName", objectName, unregs);
341     }
342     catch (IllegalArgumentException e)
343     {
344       caught = true;
345     }
346     catch (Exception e)
347     {
348       fail(e.toString());
349     }
350     if (caught == false)
351       fail("Creation/Removal accepts null relation id");
352
353     caught = false;
354     try
355     {
356       rn = new RelationNotification(RelationNotification.RELATION_BASIC_CREATION,
357              new RelationService(true), 21, 23, "message", "relation id",
358              null, objectName, unregs);
359     }
360     catch (IllegalArgumentException e)
361     {
362       caught = true;
363     }
364     catch (Exception e)
365     {
366       fail(e.toString());
367     }
368     if (caught == false)
369       fail("Creation/Removal accepts null relation type name");
370   }
371
372   /**
373    * Test Creation/Removal Error Handling
374    */

375   public void testCreationRemovalErrors2()
376   {
377     RelationNotification rn = null;
378     ObjectName objectName = null;
379     try
380     {
381       objectName = new ObjectName(":a=a");
382     }
383     catch (Exception e)
384     {
385       fail(e.toString());
386     }
387     ArrayList unregs = new ArrayList();
388
389     boolean caught = false;
390     try
391     {
392       rn = new RelationNotification(null,
393              new RelationService(true), 21, 23, "message", "relationId",
394              "relationTypeName", objectName, unregs);
395     }
396     catch (NullPointerException e)
397     {
398       fail("FAILS IN RI: Throws the wrong exception type");
399     }
400     catch (IllegalArgumentException e)
401     {
402       caught = true;
403     }
404     catch (Exception e)
405     {
406       fail(e.toString());
407     }
408     if (caught == false)
409       fail("Creation/Removal accepts an a null type");
410   }
411
412   /**
413    * Test Update Error Handling
414    */

415   public void testUpdateErrors()
416   {
417     RelationNotification rn = null;
418     ObjectName objectName = null;
419     try
420     {
421       objectName = new ObjectName(":a=a");
422     }
423     catch (Exception e)
424     {
425       fail(e.toString());
426     }
427     ArrayList newRoles = new ArrayList();
428     ArrayList oldRoles = new ArrayList();
429
430     boolean caught = false;
431     try
432     {
433       rn = new RelationNotification("blah",
434              new RelationService(true), 21, 23, "message", "relationId",
435              "relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
436     }
437     catch (IllegalArgumentException e)
438     {
439       caught = true;
440     }
441     catch (Exception e)
442     {
443       fail(e.toString());
444     }
445     if (caught == false)
446       fail("Update accepts an invalid type");
447
448     caught = false;
449     try
450     {
451       rn = new RelationNotification(RelationNotification.RELATION_BASIC_CREATION,
452              new RelationService(true), 21, 23, "message", "relationId",
453              "relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
454     }
455     catch (IllegalArgumentException e)
456     {
457       caught = true;
458     }
459     catch (Exception e)
460     {
461       fail(e.toString());
462     }
463     if (caught == false)
464       fail("Update accepts basic create");
465
466     caught = false;
467     try
468     {
469       rn = new RelationNotification(RelationNotification.RELATION_MBEAN_CREATION,
470              new RelationService(true), 21, 23, "message", "relationId",
471              "relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
472     }
473     catch (IllegalArgumentException e)
474     {
475       caught = true;
476     }
477     catch (Exception e)
478     {
479       fail(e.toString());
480     }
481     if (caught == false)
482       fail("Creation/Removal accepts mean create");
483
484     caught = false;
485     try
486     {
487       rn = new RelationNotification(RelationNotification.RELATION_BASIC_REMOVAL,
488              new RelationService(true), 21, 23, "message", "relationId",
489              "relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
490     }
491     catch (IllegalArgumentException e)
492     {
493       caught = true;
494     }
495     catch (Exception e)
496     {
497       fail(e.toString());
498     }
499     if (caught == false)
500       fail("Update accepts basic remove");
501
502     caught = false;
503     try
504     {
505       rn = new RelationNotification(RelationNotification.RELATION_MBEAN_REMOVAL,
506              new RelationService(true), 21, 23, "message", "relationId",
507              "relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
508     }
509     catch (IllegalArgumentException e)
510     {
511       caught = true;
512     }
513     catch (Exception e)
514     {
515       fail(e.toString());
516     }
517     if (caught == false)
518       fail("Update accepts mean remove");
519
520     caught = false;
521     try
522     {
523       rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
524              null, 21, 23, "message", "relationId",
525              "relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
526     }
527     catch (IllegalArgumentException e)
528     {
529       caught = true;
530     }
531     catch (Exception e)
532     {
533       fail(e.toString());
534     }
535     if (caught == false)
536       fail("Update accepts null source");
537
538     caught = false;
539     try
540     {
541       rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
542              new RelationService(true), 21, 23, "message", null,
543              "relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
544     }
545     catch (IllegalArgumentException e)
546     {
547       caught = true;
548     }
549     catch (Exception e)
550     {
551       fail(e.toString());
552     }
553     if (caught == false)
554       fail("Update accepts null relation id");
555
556     caught = false;
557     try
558     {
559       rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
560              new RelationService(true), 21, 23, "message", "relation id",
561              null, objectName, "roleInfo", newRoles, oldRoles);
562     }
563     catch (IllegalArgumentException e)
564     {
565       caught = true;
566     }
567     catch (Exception e)
568     {
569       fail(e.toString());
570     }
571     if (caught == false)
572       fail("Update accepts null relation type name");
573
574     caught = false;
575     try
576     {
577       rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
578              new RelationService(true), 21, 23, "message", "relation id",
579              null, objectName, null, newRoles, oldRoles);
580     }
581     catch (IllegalArgumentException e)
582     {
583       caught = true;
584     }
585     catch (Exception e)
586     {
587       fail(e.toString());
588     }
589     if (caught == false)
590       fail("Update accepts null role info");
591
592     caught = false;
593     try
594     {
595       rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
596              new RelationService(true), 21, 23, "message", "relation id",
597              "relationTypeName", objectName, "roleInfo", null, oldRoles);
598     }
599     catch (IllegalArgumentException e)
600     {
601       caught = true;
602     }
603     catch (Exception e)
604     {
605       fail(e.toString());
606     }
607     if (caught == false)
608       fail("Creation/Removal accepts null new role value");
609
610     caught = false;
611     try
612     {
613       rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
614              new RelationService(true), 21, 23, "message", "relation id",
615              "relationTypeName", objectName, "roleInfo", newRoles, null);
616     }
617     catch (IllegalArgumentException e)
618     {
619       caught = true;
620     }
621     catch (Exception e)
622     {
623       fail(e.toString());
624     }
625     if (caught == false)
626       fail("Update accepts null old role value");
627   }
628
629   /**
630    * Test Update Error Handling
631    */

632   public void testUpdateErrors2()
633   {
634     RelationNotification rn = null;
635     ObjectName objectName = null;
636     try
637     {
638       objectName = new ObjectName(":a=a");
639     }
640     catch (Exception e)
641     {
642       fail(e.toString());
643     }
644     ArrayList newRoles = new ArrayList();
645     ArrayList oldRoles = new ArrayList();
646
647     boolean caught = false;
648     try
649     {
650       rn = new RelationNotification(null,
651              new RelationService(true), 21, 23, "message", "relationId",
652              "relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
653     }
654     catch (NullPointerException e)
655     {
656       fail("FAILS IN RI: Throws the wrong exception type");
657     }
658     catch (IllegalArgumentException e)
659     {
660       caught = true;
661     }
662     catch (Exception e)
663     {
664       fail(e.toString());
665     }
666     if (caught == false)
667       fail("Update accepts an a null type");
668   }
669
670   /**
671    * Test serialization.
672    */

673 /* public void testSerializationBasicCreation()
674   {
675     RelationNotification orig = null;
676     RelationNotification rn = null;
677     try
678     {
679       orig = new RelationNotification(RelationNotification.RELATION_BASIC_CREATION,
680              new RelationService(true), 21, 23, "message", "relationId",
681              "relationTypeName", null, null);
682
683       // Serialize it
684       ByteArrayOutputStream baos = new ByteArrayOutputStream();
685       ObjectOutputStream oos = new ObjectOutputStream(baos);
686       oos.writeObject(orig);
687     
688       // Deserialize it
689       ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
690       ObjectInputStream ois = new ObjectInputStream(bais);
691       rn = (RelationNotification) ois.readObject();
692     }
693     catch (Exception e)
694     {
695       fail(e.toString());
696     }
697     assertEquals(RelationNotification.RELATION_BASIC_CREATION, rn.getType());
698     assertEquals(21, rn.getSequenceNumber());
699     assertEquals(23, rn.getTimeStamp());
700     assertEquals("message", rn.getMessage());
701     assertEquals("relationId", rn.getRelationId());
702     assertEquals("relationTypeName", rn.getRelationTypeName());
703     assertEquals(null, rn.getObjectName());
704     assertEquals(0, rn.getMBeansToUnregister().size());
705   }
706 */

707   /**
708    * Test serialization.
709    */

710 /* public void testSerializationBasicRemoval()
711   {
712     RelationNotification orig = null;
713     RelationNotification rn = null;
714     ObjectName objectName = null;
715     ArrayList unregs = new ArrayList();
716     try
717     {
718       orig = new RelationNotification(RelationNotification.RELATION_BASIC_REMOVAL,
719              new RelationService(true), 21, 23, "message", "relationId",
720              "relationTypeName", null, unregs);
721
722       // Serialize it
723       ByteArrayOutputStream baos = new ByteArrayOutputStream();
724       ObjectOutputStream oos = new ObjectOutputStream(baos);
725       oos.writeObject(orig);
726     
727       // Deserialize it
728       ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
729       ObjectInputStream ois = new ObjectInputStream(bais);
730       rn = (RelationNotification) ois.readObject();
731     }
732     catch (Exception e)
733     {
734       fail(e.toString());
735     }
736     assertEquals(RelationNotification.RELATION_BASIC_REMOVAL, rn.getType());
737     assertEquals(21, rn.getSequenceNumber());
738     assertEquals(23, rn.getTimeStamp());
739     assertEquals("message", rn.getMessage());
740     assertEquals("relationId", rn.getRelationId());
741     assertEquals("relationTypeName", rn.getRelationTypeName());
742     assertEquals(null, rn.getObjectName());
743     assertEquals(unregs, rn.getMBeansToUnregister());
744   }
745 */

746
747   /**
748    * Test serialization.
749    */

750 /* public void testSerializationMBeanCreation()
751   {
752     RelationNotification orig = null;
753     RelationNotification rn = null;
754     ObjectName objectName = null;
755     try
756     {
757       objectName = new ObjectName(":a=a");
758       orig = new RelationNotification(RelationNotification.RELATION_MBEAN_CREATION,
759              new RelationService(true), 21, 23, "message", "relationId",
760              "relationTypeName", objectName, null);
761
762       // Serialize it
763       ByteArrayOutputStream baos = new ByteArrayOutputStream();
764       ObjectOutputStream oos = new ObjectOutputStream(baos);
765       oos.writeObject(orig);
766     
767       // Deserialize it
768       ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
769       ObjectInputStream ois = new ObjectInputStream(bais);
770       rn = (RelationNotification) ois.readObject();
771     }
772     catch (Exception e)
773     {
774       fail(e.toString());
775     }
776     assertEquals(RelationNotification.RELATION_MBEAN_CREATION, rn.getType());
777     assertEquals(21, rn.getSequenceNumber());
778     assertEquals(23, rn.getTimeStamp());
779     assertEquals("message", rn.getMessage());
780     assertEquals("relationId", rn.getRelationId());
781     assertEquals("relationTypeName", rn.getRelationTypeName());
782     assertEquals(objectName, rn.getObjectName());
783     assertEquals(0, rn.getMBeansToUnregister().size());
784   }
785 */

786
787   /**
788    * Test serialization.
789    */

790 /* public void testSerializationMBeanRemoval()
791   {
792     RelationNotification orig = null;
793     RelationNotification rn = null;
794     ObjectName objectName = null;
795     ArrayList unregs = new ArrayList();
796     try
797     {
798       objectName = new ObjectName(":a=a");
799       orig = new RelationNotification(RelationNotification.RELATION_MBEAN_REMOVAL,
800              new RelationService(true), 21, 23, "message", "relationId",
801              "relationTypeName", objectName, unregs);
802
803       // Serialize it
804       ByteArrayOutputStream baos = new ByteArrayOutputStream();
805       ObjectOutputStream oos = new ObjectOutputStream(baos);
806       oos.writeObject(orig);
807     
808       // Deserialize it
809       ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
810       ObjectInputStream ois = new ObjectInputStream(bais);
811       rn = (RelationNotification) ois.readObject();
812     }
813     catch (Exception e)
814     {
815       fail(e.toString());
816     }
817     assertEquals(RelationNotification.RELATION_MBEAN_REMOVAL, rn.getType());
818     assertEquals(21, rn.getSequenceNumber());
819     assertEquals(23, rn.getTimeStamp());
820     assertEquals("message", rn.getMessage());
821     assertEquals("relationId", rn.getRelationId());
822     assertEquals("relationTypeName", rn.getRelationTypeName());
823     assertEquals(objectName, rn.getObjectName());
824     assertEquals(unregs, rn.getMBeansToUnregister());
825   }
826 */

827
828   /**
829    * Test serialization.
830    */

831 /* public void testSerializationBasicUpdate()
832   {
833     RelationNotification orig = null;
834     RelationNotification rn = null;
835     ArrayList newRoles = new ArrayList();
836     ArrayList oldRoles = new ArrayList();
837     try
838     {
839       orig = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
840              new RelationService(true), 21, 23, "message", "relationId",
841              "relationTypeName", null, "roleName", newRoles, oldRoles);
842
843       // Serialize it
844       ByteArrayOutputStream baos = new ByteArrayOutputStream();
845       ObjectOutputStream oos = new ObjectOutputStream(baos);
846       oos.writeObject(orig);
847     
848       // Deserialize it
849       ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
850       ObjectInputStream ois = new ObjectInputStream(bais);
851       rn = (RelationNotification) ois.readObject();
852     }
853     catch (Exception e)
854     {
855       fail(e.toString());
856     }
857     assertEquals(RelationNotification.RELATION_BASIC_UPDATE, rn.getType());
858     assertEquals(21, rn.getSequenceNumber());
859     assertEquals(23, rn.getTimeStamp());
860     assertEquals("message", rn.getMessage());
861     assertEquals("relationId", rn.getRelationId());
862     assertEquals("relationTypeName", rn.getRelationTypeName());
863     assertEquals(null, rn.getObjectName());
864     assertEquals("roleName", rn.getRoleName());
865     assertEquals(0, rn.getNewRoleValue().size());
866     assertEquals(0, rn.getOldRoleValue().size());
867   }
868 */

869
870   /**
871    * Test serialization.
872    */

873 /* public void testSerializationMBeanUpdate()
874   {
875     RelationNotification orig = null;
876     RelationNotification rn = null;
877     ObjectName objectName = null;
878     ArrayList newRoles = new ArrayList();
879     ArrayList oldRoles = new ArrayList();
880     try
881     {
882       objectName = new ObjectName(":a=a");
883       orig = new RelationNotification(RelationNotification.RELATION_MBEAN_UPDATE,
884              new RelationService(true), 21, 23, "message", "relationId",
885              "relationTypeName", objectName, "roleName", newRoles, oldRoles);
886
887       // Serialize it
888       ByteArrayOutputStream baos = new ByteArrayOutputStream();
889       ObjectOutputStream oos = new ObjectOutputStream(baos);
890       oos.writeObject(orig);
891     
892       // Deserialize it
893       ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
894       ObjectInputStream ois = new ObjectInputStream(bais);
895       rn = (RelationNotification) ois.readObject();
896     }
897     catch (Exception e)
898     {
899       fail(e.toString());
900     }
901     assertEquals(RelationNotification.RELATION_MBEAN_UPDATE, rn.getType());
902     assertEquals(21, rn.getSequenceNumber());
903     assertEquals(23, rn.getTimeStamp());
904     assertEquals("message", rn.getMessage());
905     assertEquals("relationId", rn.getRelationId());
906     assertEquals("relationTypeName", rn.getRelationTypeName());
907     assertEquals(objectName, rn.getObjectName());
908     assertEquals("roleName", rn.getRoleName());
909     assertEquals(0, rn.getNewRoleValue().size());
910     assertEquals(0, rn.getOldRoleValue().size());
911   }
912 */

913 }
914
Popular Tags