Source Code Cross Referenced for RelationNotificationTestCase.java in  » EJB-Server-JBoss-4.2.1 » jmx » test » compliance » relation » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server JBoss 4.2.1 » jmx » test.compliance.relation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package test.compliance.relation;
023:
024:        import java.io.Serializable;
025:        import java.util.ArrayList;
026:
027:        import javax.management.ObjectName;
028:        import javax.management.relation.RelationNotification;
029:        import javax.management.relation.RelationService;
030:
031:        import junit.framework.TestCase;
032:
033:        /**
034:         * Relation Notification Tests
035:         *
036:         * NOTE: These tests use relation service for the source, but it is not
037:         * tested for compliance. JBossMX uses the relation service's object name
038:         * to ensure the notification is serializable
039:         *
040:         * @author  <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
041:         */
042:        public class RelationNotificationTestCase extends TestCase implements 
043:                Serializable {
044:
045:            // Constants -----------------------------------------------------------------
046:
047:            static final long serialVersionUID = 516562336428465857L;
048:            static String[] types = new String[] {
049:                    RelationNotification.RELATION_BASIC_CREATION,
050:                    RelationNotification.RELATION_MBEAN_CREATION,
051:                    RelationNotification.RELATION_BASIC_UPDATE,
052:                    RelationNotification.RELATION_MBEAN_UPDATE,
053:                    RelationNotification.RELATION_BASIC_REMOVAL,
054:                    RelationNotification.RELATION_MBEAN_REMOVAL };
055:
056:            // Attributes ----------------------------------------------------------------
057:
058:            // Constructor ---------------------------------------------------------------
059:
060:            /**
061:             * Construct the test
062:             */
063:            public RelationNotificationTestCase(String s) {
064:                super (s);
065:            }
066:
067:            // Tests ---------------------------------------------------------------------
068:
069:            /**
070:             * Make sure all the constants are different
071:             */
072:            public void testDifferent() {
073:                for (int i = 0; i < (types.length - 1); i++) {
074:                    for (int j = i + 1; j < types.length; j++)
075:                        if (types[i].equals(types[j]))
076:                            fail("Relation Notifications types not unique");
077:                }
078:            }
079:
080:            /**
081:             * Test Basic Creation
082:             */
083:            public void testBasicCreation() {
084:                RelationNotification rn = null;
085:                try {
086:                    rn = new RelationNotification(
087:                            RelationNotification.RELATION_BASIC_CREATION,
088:                            new RelationService(true), 21, 23, "message",
089:                            "relationId", "relationTypeName", null, null);
090:                } catch (Exception e) {
091:                    fail(e.toString());
092:                }
093:                assertEquals(RelationNotification.RELATION_BASIC_CREATION, rn
094:                        .getType());
095:                assertEquals(21, rn.getSequenceNumber());
096:                assertEquals(23, rn.getTimeStamp());
097:                assertEquals("message", rn.getMessage());
098:                assertEquals("relationId", rn.getRelationId());
099:                assertEquals("relationTypeName", rn.getRelationTypeName());
100:                assertEquals(null, rn.getObjectName());
101:                assertEquals(0, rn.getMBeansToUnregister().size());
102:            }
103:
104:            /**
105:             * Test Basic Removal
106:             */
107:            public void testBasicRemoval() {
108:                RelationNotification rn = null;
109:                ObjectName objectName = null;
110:                ArrayList unregs = new ArrayList();
111:                try {
112:                    rn = new RelationNotification(
113:                            RelationNotification.RELATION_BASIC_REMOVAL,
114:                            new RelationService(true), 21, 23, "message",
115:                            "relationId", "relationTypeName", null, unregs);
116:                } catch (Exception e) {
117:                    fail(e.toString());
118:                }
119:                assertEquals(RelationNotification.RELATION_BASIC_REMOVAL, rn
120:                        .getType());
121:                assertEquals(21, rn.getSequenceNumber());
122:                assertEquals(23, rn.getTimeStamp());
123:                assertEquals("message", rn.getMessage());
124:                assertEquals("relationId", rn.getRelationId());
125:                assertEquals("relationTypeName", rn.getRelationTypeName());
126:                assertEquals(null, rn.getObjectName());
127:                assertEquals(unregs, rn.getMBeansToUnregister());
128:            }
129:
130:            /**
131:             * Test MBean Creation
132:             */
133:            public void testMBeanCreation() {
134:                RelationNotification rn = null;
135:                ObjectName objectName = null;
136:                try {
137:                    objectName = new ObjectName(":a=a");
138:                    rn = new RelationNotification(
139:                            RelationNotification.RELATION_MBEAN_CREATION,
140:                            new RelationService(true), 21, 23, "message",
141:                            "relationId", "relationTypeName", objectName, null);
142:                } catch (Exception e) {
143:                    fail(e.toString());
144:                }
145:                assertEquals(RelationNotification.RELATION_MBEAN_CREATION, rn
146:                        .getType());
147:                assertEquals(21, rn.getSequenceNumber());
148:                assertEquals(23, rn.getTimeStamp());
149:                assertEquals("message", rn.getMessage());
150:                assertEquals("relationId", rn.getRelationId());
151:                assertEquals("relationTypeName", rn.getRelationTypeName());
152:                assertEquals(objectName, rn.getObjectName());
153:                assertEquals(0, rn.getMBeansToUnregister().size());
154:            }
155:
156:            /**
157:             * Test MBean Removal
158:             */
159:            public void testMBeanRemoval() {
160:                RelationNotification rn = null;
161:                ObjectName objectName = null;
162:                ArrayList unregs = new ArrayList();
163:                try {
164:                    objectName = new ObjectName(":a=a");
165:                    rn = new RelationNotification(
166:                            RelationNotification.RELATION_MBEAN_REMOVAL,
167:                            new RelationService(true), 21, 23, "message",
168:                            "relationId", "relationTypeName", objectName,
169:                            unregs);
170:                } catch (Exception e) {
171:                    fail(e.toString());
172:                }
173:                assertEquals(RelationNotification.RELATION_MBEAN_REMOVAL, rn
174:                        .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:                RelationNotification rn = null;
189:                ArrayList newRoles = new ArrayList();
190:                ArrayList oldRoles = new ArrayList();
191:                try {
192:                    rn = new RelationNotification(
193:                            RelationNotification.RELATION_BASIC_UPDATE,
194:                            new RelationService(true), 21, 23, "message",
195:                            "relationId", "relationTypeName", null, "roleName",
196:                            newRoles, oldRoles);
197:                } catch (Exception e) {
198:                    fail(e.toString());
199:                }
200:                assertEquals(RelationNotification.RELATION_BASIC_UPDATE, rn
201:                        .getType());
202:                assertEquals(21, rn.getSequenceNumber());
203:                assertEquals(23, rn.getTimeStamp());
204:                assertEquals("message", rn.getMessage());
205:                assertEquals("relationId", rn.getRelationId());
206:                assertEquals("relationTypeName", rn.getRelationTypeName());
207:                assertEquals(null, rn.getObjectName());
208:                assertEquals("roleName", rn.getRoleName());
209:                assertEquals(0, rn.getNewRoleValue().size());
210:                assertEquals(0, rn.getOldRoleValue().size());
211:            }
212:
213:            /**
214:             * Test MBean Update
215:             */
216:            public void testMBeanUpdate() {
217:                RelationNotification rn = null;
218:                ObjectName objectName = null;
219:                ArrayList newRoles = new ArrayList();
220:                ArrayList oldRoles = new ArrayList();
221:                try {
222:                    objectName = new ObjectName(":a=a");
223:                    rn = new RelationNotification(
224:                            RelationNotification.RELATION_MBEAN_UPDATE,
225:                            new RelationService(true), 21, 23, "message",
226:                            "relationId", "relationTypeName", objectName,
227:                            "roleName", newRoles, oldRoles);
228:                } catch (Exception e) {
229:                    fail(e.toString());
230:                }
231:                assertEquals(RelationNotification.RELATION_MBEAN_UPDATE, rn
232:                        .getType());
233:                assertEquals(21, rn.getSequenceNumber());
234:                assertEquals(23, rn.getTimeStamp());
235:                assertEquals("message", rn.getMessage());
236:                assertEquals("relationId", rn.getRelationId());
237:                assertEquals("relationTypeName", rn.getRelationTypeName());
238:                assertEquals(objectName, rn.getObjectName());
239:                assertEquals("roleName", rn.getRoleName());
240:                assertEquals(0, rn.getNewRoleValue().size());
241:                assertEquals(0, rn.getOldRoleValue().size());
242:            }
243:
244:            /**
245:             * Test Creation/Removal Error Handling
246:             */
247:            public void testCreationRemovalErrors() {
248:                RelationNotification rn = null;
249:                ObjectName objectName = null;
250:                try {
251:                    objectName = new ObjectName(":a=a");
252:                } catch (Exception e) {
253:                    fail(e.toString());
254:                }
255:                ArrayList unregs = new ArrayList();
256:
257:                boolean caught = false;
258:                try {
259:                    rn = new RelationNotification("blah", new RelationService(
260:                            true), 21, 23, "message", "relationId",
261:                            "relationTypeName", objectName, unregs);
262:                } catch (IllegalArgumentException e) {
263:                    caught = true;
264:                } catch (Exception e) {
265:                    fail(e.toString());
266:                }
267:                if (caught == false)
268:                    fail("Creation/Removal accepts an invalid type");
269:
270:                caught = false;
271:                try {
272:                    rn = new RelationNotification(
273:                            RelationNotification.RELATION_BASIC_UPDATE,
274:                            new RelationService(true), 21, 23, "message",
275:                            "relationId", "relationTypeName", objectName,
276:                            unregs);
277:                } catch (IllegalArgumentException e) {
278:                    caught = true;
279:                } catch (Exception e) {
280:                    fail(e.toString());
281:                }
282:                if (caught == false)
283:                    fail("Creation/Removal accepts basic update");
284:
285:                caught = false;
286:                try {
287:                    rn = new RelationNotification(
288:                            RelationNotification.RELATION_MBEAN_UPDATE,
289:                            new RelationService(true), 21, 23, "message",
290:                            "relationId", "relationTypeName", objectName,
291:                            unregs);
292:                } catch (IllegalArgumentException e) {
293:                    caught = true;
294:                } catch (Exception e) {
295:                    fail(e.toString());
296:                }
297:                if (caught == false)
298:                    fail("Creation/Removal accepts mean update");
299:
300:                caught = false;
301:                try {
302:                    rn = new RelationNotification(
303:                            RelationNotification.RELATION_BASIC_CREATION, null,
304:                            21, 23, "message", "relationId",
305:                            "relationTypeName", objectName, unregs);
306:                } catch (IllegalArgumentException e) {
307:                    caught = true;
308:                } catch (Exception e) {
309:                    fail(e.toString());
310:                }
311:                if (caught == false)
312:                    fail("Creation/Removal accepts null source");
313:
314:                caught = false;
315:                try {
316:                    rn = new RelationNotification(
317:                            RelationNotification.RELATION_BASIC_CREATION,
318:                            new RelationService(true), 21, 23, "message", null,
319:                            "relationTypeName", objectName, unregs);
320:                } catch (IllegalArgumentException e) {
321:                    caught = true;
322:                } catch (Exception e) {
323:                    fail(e.toString());
324:                }
325:                if (caught == false)
326:                    fail("Creation/Removal accepts null relation id");
327:
328:                caught = false;
329:                try {
330:                    rn = new RelationNotification(
331:                            RelationNotification.RELATION_BASIC_CREATION,
332:                            new RelationService(true), 21, 23, "message",
333:                            "relation id", null, objectName, unregs);
334:                } catch (IllegalArgumentException e) {
335:                    caught = true;
336:                } catch (Exception e) {
337:                    fail(e.toString());
338:                }
339:                if (caught == false)
340:                    fail("Creation/Removal accepts null relation type name");
341:            }
342:
343:            /**
344:             * Test Creation/Removal Error Handling
345:             */
346:            public void testCreationRemovalErrors2() {
347:                RelationNotification rn = null;
348:                ObjectName objectName = null;
349:                try {
350:                    objectName = new ObjectName(":a=a");
351:                } catch (Exception e) {
352:                    fail(e.toString());
353:                }
354:                ArrayList unregs = new ArrayList();
355:
356:                boolean caught = false;
357:                try {
358:                    rn = new RelationNotification(null, new RelationService(
359:                            true), 21, 23, "message", "relationId",
360:                            "relationTypeName", objectName, unregs);
361:                } catch (NullPointerException e) {
362:                    fail("FAILS IN RI: Throws the wrong exception type");
363:                } catch (IllegalArgumentException e) {
364:                    caught = true;
365:                } catch (Exception e) {
366:                    fail(e.toString());
367:                }
368:                if (caught == false)
369:                    fail("Creation/Removal accepts an a null type");
370:            }
371:
372:            /**
373:             * Test Update Error Handling
374:             */
375:            public void testUpdateErrors() {
376:                RelationNotification rn = null;
377:                ObjectName objectName = null;
378:                try {
379:                    objectName = new ObjectName(":a=a");
380:                } catch (Exception e) {
381:                    fail(e.toString());
382:                }
383:                ArrayList newRoles = new ArrayList();
384:                ArrayList oldRoles = new ArrayList();
385:
386:                boolean caught = false;
387:                try {
388:                    rn = new RelationNotification("blah", new RelationService(
389:                            true), 21, 23, "message", "relationId",
390:                            "relationTypeName", objectName, "roleInfo",
391:                            newRoles, oldRoles);
392:                } catch (IllegalArgumentException e) {
393:                    caught = true;
394:                } catch (Exception e) {
395:                    fail(e.toString());
396:                }
397:                if (caught == false)
398:                    fail("Update accepts an invalid type");
399:
400:                caught = false;
401:                try {
402:                    rn = new RelationNotification(
403:                            RelationNotification.RELATION_BASIC_CREATION,
404:                            new RelationService(true), 21, 23, "message",
405:                            "relationId", "relationTypeName", objectName,
406:                            "roleInfo", newRoles, oldRoles);
407:                } catch (IllegalArgumentException e) {
408:                    caught = true;
409:                } catch (Exception e) {
410:                    fail(e.toString());
411:                }
412:                if (caught == false)
413:                    fail("Update accepts basic create");
414:
415:                caught = false;
416:                try {
417:                    rn = new RelationNotification(
418:                            RelationNotification.RELATION_MBEAN_CREATION,
419:                            new RelationService(true), 21, 23, "message",
420:                            "relationId", "relationTypeName", objectName,
421:                            "roleInfo", newRoles, oldRoles);
422:                } catch (IllegalArgumentException e) {
423:                    caught = true;
424:                } catch (Exception e) {
425:                    fail(e.toString());
426:                }
427:                if (caught == false)
428:                    fail("Creation/Removal accepts mean create");
429:
430:                caught = false;
431:                try {
432:                    rn = new RelationNotification(
433:                            RelationNotification.RELATION_BASIC_REMOVAL,
434:                            new RelationService(true), 21, 23, "message",
435:                            "relationId", "relationTypeName", objectName,
436:                            "roleInfo", newRoles, oldRoles);
437:                } catch (IllegalArgumentException e) {
438:                    caught = true;
439:                } catch (Exception e) {
440:                    fail(e.toString());
441:                }
442:                if (caught == false)
443:                    fail("Update accepts basic remove");
444:
445:                caught = false;
446:                try {
447:                    rn = new RelationNotification(
448:                            RelationNotification.RELATION_MBEAN_REMOVAL,
449:                            new RelationService(true), 21, 23, "message",
450:                            "relationId", "relationTypeName", objectName,
451:                            "roleInfo", newRoles, oldRoles);
452:                } catch (IllegalArgumentException e) {
453:                    caught = true;
454:                } catch (Exception e) {
455:                    fail(e.toString());
456:                }
457:                if (caught == false)
458:                    fail("Update accepts mean remove");
459:
460:                caught = false;
461:                try {
462:                    rn = new RelationNotification(
463:                            RelationNotification.RELATION_BASIC_UPDATE, null,
464:                            21, 23, "message", "relationId",
465:                            "relationTypeName", objectName, "roleInfo",
466:                            newRoles, oldRoles);
467:                } catch (IllegalArgumentException e) {
468:                    caught = true;
469:                } catch (Exception e) {
470:                    fail(e.toString());
471:                }
472:                if (caught == false)
473:                    fail("Update accepts null source");
474:
475:                caught = false;
476:                try {
477:                    rn = new RelationNotification(
478:                            RelationNotification.RELATION_BASIC_UPDATE,
479:                            new RelationService(true), 21, 23, "message", null,
480:                            "relationTypeName", objectName, "roleInfo",
481:                            newRoles, oldRoles);
482:                } catch (IllegalArgumentException e) {
483:                    caught = true;
484:                } catch (Exception e) {
485:                    fail(e.toString());
486:                }
487:                if (caught == false)
488:                    fail("Update accepts null relation id");
489:
490:                caught = false;
491:                try {
492:                    rn = new RelationNotification(
493:                            RelationNotification.RELATION_BASIC_UPDATE,
494:                            new RelationService(true), 21, 23, "message",
495:                            "relation id", null, objectName, "roleInfo",
496:                            newRoles, oldRoles);
497:                } catch (IllegalArgumentException e) {
498:                    caught = true;
499:                } catch (Exception e) {
500:                    fail(e.toString());
501:                }
502:                if (caught == false)
503:                    fail("Update accepts null relation type name");
504:
505:                caught = false;
506:                try {
507:                    rn = new RelationNotification(
508:                            RelationNotification.RELATION_BASIC_UPDATE,
509:                            new RelationService(true), 21, 23, "message",
510:                            "relation id", null, objectName, null, newRoles,
511:                            oldRoles);
512:                } catch (IllegalArgumentException e) {
513:                    caught = true;
514:                } catch (Exception e) {
515:                    fail(e.toString());
516:                }
517:                if (caught == false)
518:                    fail("Update accepts null role info");
519:
520:                caught = false;
521:                try {
522:                    rn = new RelationNotification(
523:                            RelationNotification.RELATION_BASIC_UPDATE,
524:                            new RelationService(true), 21, 23, "message",
525:                            "relation id", "relationTypeName", objectName,
526:                            "roleInfo", null, oldRoles);
527:                } catch (IllegalArgumentException e) {
528:                    caught = true;
529:                } catch (Exception e) {
530:                    fail(e.toString());
531:                }
532:                if (caught == false)
533:                    fail("Creation/Removal accepts null new role value");
534:
535:                caught = false;
536:                try {
537:                    rn = new RelationNotification(
538:                            RelationNotification.RELATION_BASIC_UPDATE,
539:                            new RelationService(true), 21, 23, "message",
540:                            "relation id", "relationTypeName", objectName,
541:                            "roleInfo", newRoles, null);
542:                } catch (IllegalArgumentException e) {
543:                    caught = true;
544:                } catch (Exception e) {
545:                    fail(e.toString());
546:                }
547:                if (caught == false)
548:                    fail("Update accepts null old role value");
549:            }
550:
551:            /**
552:             * Test Update Error Handling
553:             */
554:            public void testUpdateErrors2() {
555:                RelationNotification rn = null;
556:                ObjectName objectName = null;
557:                try {
558:                    objectName = new ObjectName(":a=a");
559:                } catch (Exception e) {
560:                    fail(e.toString());
561:                }
562:                ArrayList newRoles = new ArrayList();
563:                ArrayList oldRoles = new ArrayList();
564:
565:                boolean caught = false;
566:                try {
567:                    rn = new RelationNotification(null, new RelationService(
568:                            true), 21, 23, "message", "relationId",
569:                            "relationTypeName", objectName, "roleInfo",
570:                            newRoles, oldRoles);
571:                } catch (NullPointerException e) {
572:                    fail("FAILS IN RI: Throws the wrong exception type");
573:                } catch (IllegalArgumentException e) {
574:                    caught = true;
575:                } catch (Exception e) {
576:                    fail(e.toString());
577:                }
578:                if (caught == false)
579:                    fail("Update accepts an a null type");
580:            }
581:
582:            /**
583:             * Test serialization.
584:             */
585:            /*  public void testSerializationBasicCreation()
586:             {
587:             RelationNotification orig = null;
588:             RelationNotification rn = null;
589:             try
590:             {
591:             orig = new RelationNotification(RelationNotification.RELATION_BASIC_CREATION,
592:             new RelationService(true), 21, 23, "message", "relationId", 
593:             "relationTypeName", null, null);
594:
595:             // Serialize it
596:             ByteArrayOutputStream baos = new ByteArrayOutputStream();
597:             ObjectOutputStream oos = new ObjectOutputStream(baos);
598:             oos.writeObject(orig);
599:            
600:             // Deserialize it
601:             ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
602:             ObjectInputStream ois = new ObjectInputStream(bais);
603:             rn = (RelationNotification) ois.readObject();
604:             }
605:             catch (Exception e)
606:             {
607:             fail(e.toString());
608:             }
609:             assertEquals(RelationNotification.RELATION_BASIC_CREATION, rn.getType());
610:             assertEquals(21, rn.getSequenceNumber());
611:             assertEquals(23, rn.getTimeStamp());
612:             assertEquals("message", rn.getMessage());
613:             assertEquals("relationId", rn.getRelationId());
614:             assertEquals("relationTypeName", rn.getRelationTypeName());
615:             assertEquals(null, rn.getObjectName());
616:             assertEquals(0, rn.getMBeansToUnregister().size());
617:             }
618:             */
619:            /**
620:             * Test serialization.
621:             */
622:            /*  public void testSerializationBasicRemoval()
623:             {
624:             RelationNotification orig = null;
625:             RelationNotification rn = null;
626:             ObjectName objectName = null;
627:             ArrayList unregs = new ArrayList();
628:             try
629:             {
630:             orig = new RelationNotification(RelationNotification.RELATION_BASIC_REMOVAL,
631:             new RelationService(true), 21, 23, "message", "relationId", 
632:             "relationTypeName", null, unregs);
633:
634:             // Serialize it
635:             ByteArrayOutputStream baos = new ByteArrayOutputStream();
636:             ObjectOutputStream oos = new ObjectOutputStream(baos);
637:             oos.writeObject(orig);
638:            
639:             // Deserialize it
640:             ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
641:             ObjectInputStream ois = new ObjectInputStream(bais);
642:             rn = (RelationNotification) ois.readObject();
643:             }
644:             catch (Exception e)
645:             {
646:             fail(e.toString());
647:             }
648:             assertEquals(RelationNotification.RELATION_BASIC_REMOVAL, rn.getType());
649:             assertEquals(21, rn.getSequenceNumber());
650:             assertEquals(23, rn.getTimeStamp());
651:             assertEquals("message", rn.getMessage());
652:             assertEquals("relationId", rn.getRelationId());
653:             assertEquals("relationTypeName", rn.getRelationTypeName());
654:             assertEquals(null, rn.getObjectName());
655:             assertEquals(unregs, rn.getMBeansToUnregister());
656:             }
657:             */
658:
659:            /**
660:             * Test serialization.
661:             */
662:            /*  public void testSerializationMBeanCreation()
663:             {
664:             RelationNotification orig = null;
665:             RelationNotification rn = null;
666:             ObjectName objectName = null;
667:             try
668:             {
669:             objectName = new ObjectName(":a=a");
670:             orig = new RelationNotification(RelationNotification.RELATION_MBEAN_CREATION,
671:             new RelationService(true), 21, 23, "message", "relationId", 
672:             "relationTypeName", objectName, null);
673:
674:             // Serialize it
675:             ByteArrayOutputStream baos = new ByteArrayOutputStream();
676:             ObjectOutputStream oos = new ObjectOutputStream(baos);
677:             oos.writeObject(orig);
678:            
679:             // Deserialize it
680:             ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
681:             ObjectInputStream ois = new ObjectInputStream(bais);
682:             rn = (RelationNotification) ois.readObject();
683:             }
684:             catch (Exception e)
685:             {
686:             fail(e.toString());
687:             }
688:             assertEquals(RelationNotification.RELATION_MBEAN_CREATION, rn.getType());
689:             assertEquals(21, rn.getSequenceNumber());
690:             assertEquals(23, rn.getTimeStamp());
691:             assertEquals("message", rn.getMessage());
692:             assertEquals("relationId", rn.getRelationId());
693:             assertEquals("relationTypeName", rn.getRelationTypeName());
694:             assertEquals(objectName, rn.getObjectName());
695:             assertEquals(0, rn.getMBeansToUnregister().size());
696:             }
697:             */
698:
699:            /**
700:             * Test serialization.
701:             */
702:            /*  public void testSerializationMBeanRemoval()
703:             {
704:             RelationNotification orig = null;
705:             RelationNotification rn = null;
706:             ObjectName objectName = null;
707:             ArrayList unregs = new ArrayList();
708:             try
709:             {
710:             objectName = new ObjectName(":a=a");
711:             orig = new RelationNotification(RelationNotification.RELATION_MBEAN_REMOVAL,
712:             new RelationService(true), 21, 23, "message", "relationId", 
713:             "relationTypeName", objectName, unregs);
714:
715:             // Serialize it
716:             ByteArrayOutputStream baos = new ByteArrayOutputStream();
717:             ObjectOutputStream oos = new ObjectOutputStream(baos);
718:             oos.writeObject(orig);
719:            
720:             // Deserialize it
721:             ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
722:             ObjectInputStream ois = new ObjectInputStream(bais);
723:             rn = (RelationNotification) ois.readObject();
724:             }
725:             catch (Exception e)
726:             {
727:             fail(e.toString());
728:             }
729:             assertEquals(RelationNotification.RELATION_MBEAN_REMOVAL, rn.getType());
730:             assertEquals(21, rn.getSequenceNumber());
731:             assertEquals(23, rn.getTimeStamp());
732:             assertEquals("message", rn.getMessage());
733:             assertEquals("relationId", rn.getRelationId());
734:             assertEquals("relationTypeName", rn.getRelationTypeName());
735:             assertEquals(objectName, rn.getObjectName());
736:             assertEquals(unregs, rn.getMBeansToUnregister());
737:             }
738:             */
739:
740:            /**
741:             * Test serialization.
742:             */
743:            /*  public void testSerializationBasicUpdate()
744:             {
745:             RelationNotification orig = null;
746:             RelationNotification rn = null;
747:             ArrayList newRoles = new ArrayList();
748:             ArrayList oldRoles = new ArrayList();
749:             try
750:             {
751:             orig = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
752:             new RelationService(true), 21, 23, "message", "relationId", 
753:             "relationTypeName", null, "roleName", newRoles, oldRoles);
754:
755:             // Serialize it
756:             ByteArrayOutputStream baos = new ByteArrayOutputStream();
757:             ObjectOutputStream oos = new ObjectOutputStream(baos);
758:             oos.writeObject(orig);
759:            
760:             // Deserialize it
761:             ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
762:             ObjectInputStream ois = new ObjectInputStream(bais);
763:             rn = (RelationNotification) ois.readObject();
764:             }
765:             catch (Exception e)
766:             {
767:             fail(e.toString());
768:             }
769:             assertEquals(RelationNotification.RELATION_BASIC_UPDATE, rn.getType());
770:             assertEquals(21, rn.getSequenceNumber());
771:             assertEquals(23, rn.getTimeStamp());
772:             assertEquals("message", rn.getMessage());
773:             assertEquals("relationId", rn.getRelationId());
774:             assertEquals("relationTypeName", rn.getRelationTypeName());
775:             assertEquals(null, rn.getObjectName());
776:             assertEquals("roleName", rn.getRoleName());
777:             assertEquals(0, rn.getNewRoleValue().size());
778:             assertEquals(0, rn.getOldRoleValue().size());
779:             }
780:             */
781:
782:            /**
783:             * Test serialization.
784:             */
785:            /*  public void testSerializationMBeanUpdate()
786:             {
787:             RelationNotification orig = null;
788:             RelationNotification rn = null;
789:             ObjectName objectName = null;
790:             ArrayList newRoles = new ArrayList();
791:             ArrayList oldRoles = new ArrayList();
792:             try
793:             {
794:             objectName = new ObjectName(":a=a");
795:             orig = new RelationNotification(RelationNotification.RELATION_MBEAN_UPDATE,
796:             new RelationService(true), 21, 23, "message", "relationId", 
797:             "relationTypeName", objectName, "roleName", newRoles, oldRoles);
798:
799:             // Serialize it
800:             ByteArrayOutputStream baos = new ByteArrayOutputStream();
801:             ObjectOutputStream oos = new ObjectOutputStream(baos);
802:             oos.writeObject(orig);
803:            
804:             // Deserialize it
805:             ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
806:             ObjectInputStream ois = new ObjectInputStream(bais);
807:             rn = (RelationNotification) ois.readObject();
808:             }
809:             catch (Exception e)
810:             {
811:             fail(e.toString());
812:             }
813:             assertEquals(RelationNotification.RELATION_MBEAN_UPDATE, rn.getType());
814:             assertEquals(21, rn.getSequenceNumber());
815:             assertEquals(23, rn.getTimeStamp());
816:             assertEquals("message", rn.getMessage());
817:             assertEquals("relationId", rn.getRelationId());
818:             assertEquals("relationTypeName", rn.getRelationTypeName());
819:             assertEquals(objectName, rn.getObjectName());
820:             assertEquals("roleName", rn.getRoleName());
821:             assertEquals(0, rn.getNewRoleValue().size());
822:             assertEquals(0, rn.getOldRoleValue().size());
823:             }
824:             */
825:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.