KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jmx > compliance > relation > RelationNotificationTestCase


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

22 package org.jboss.test.jmx.compliance.relation;
23
24 import java.util.ArrayList JavaDoc;
25
26 import javax.management.ObjectName JavaDoc;
27 import javax.management.relation.RelationNotification JavaDoc;
28 import javax.management.relation.RelationService JavaDoc;
29
30 import junit.framework.TestCase;
31
32 /**
33  * Relation Notification Tests
34  *
35  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
36  */

37 public class RelationNotificationTestCase
38   extends TestCase
39 {
40
41   // Constants -----------------------------------------------------------------
42

43   static String JavaDoc[] types = new String JavaDoc[]
44   {
45     RelationNotification.RELATION_BASIC_CREATION,
46     RelationNotification.RELATION_MBEAN_CREATION,
47     RelationNotification.RELATION_BASIC_UPDATE,
48     RelationNotification.RELATION_MBEAN_UPDATE,
49     RelationNotification.RELATION_BASIC_REMOVAL,
50     RelationNotification.RELATION_MBEAN_REMOVAL
51   };
52
53   // Attributes ----------------------------------------------------------------
54

55   // Constructor ---------------------------------------------------------------
56

57   /**
58    * Construct the test
59    */

60   public RelationNotificationTestCase(String JavaDoc s)
61   {
62     super(s);
63   }
64
65   // Tests ---------------------------------------------------------------------
66

67   /**
68    * Make sure all the constants are different
69    */

70   public void testDifferent()
71   {
72     for (int i = 0; i < (types.length - 1); i++)
73     {
74       for (int j = i + 1; j < types.length; j++)
75         if (types[i].equals(types[j]))
76           fail("Relation Notifications types not unique");
77     }
78   }
79
80   /**
81    * Test Basic Creation
82    */

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

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

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

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

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

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

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

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

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

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

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

709   /**
710    * Test serialization.
711    */

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

748
749   /**
750    * Test serialization.
751    */

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

788
789   /**
790    * Test serialization.
791    */

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

829
830   /**
831    * Test serialization.
832    */

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

871
872   /**
873    * Test serialization.
874    */

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

915 }
916
Popular Tags