1 8 9 package test.javax.management.compliance.serialization.support; 10 11 import java.lang.reflect.Constructor ; 12 import java.util.ArrayList ; 13 import javax.management.Attribute ; 14 import javax.management.AttributeChangeNotification ; 15 import javax.management.AttributeChangeNotificationFilter ; 16 import javax.management.AttributeList ; 17 import javax.management.AttributeNotFoundException ; 18 import javax.management.AttributeValueExp ; 19 import javax.management.BadAttributeValueExpException ; 20 import javax.management.BadBinaryOpValueExpException ; 21 import javax.management.BadStringOperationException ; 22 import javax.management.Descriptor ; 23 import javax.management.InstanceAlreadyExistsException ; 24 import javax.management.InstanceNotFoundException ; 25 import javax.management.IntrospectionException ; 26 import javax.management.InvalidApplicationException ; 27 import javax.management.InvalidAttributeValueException ; 28 import javax.management.JMException ; 29 import javax.management.JMRuntimeException ; 30 import javax.management.ListenerNotFoundException ; 31 import javax.management.MBeanAttributeInfo ; 32 import javax.management.MBeanConstructorInfo ; 33 import javax.management.MBeanException ; 34 import javax.management.MBeanFeatureInfo ; 35 import javax.management.MBeanInfo ; 36 import javax.management.MBeanNotificationInfo ; 37 import javax.management.MBeanOperationInfo ; 38 import javax.management.MBeanParameterInfo ; 39 import javax.management.MBeanPermission ; 40 import javax.management.MBeanRegistrationException ; 41 import javax.management.MBeanServerDelegate ; 42 import javax.management.MBeanServerNotification ; 43 import javax.management.MBeanServerPermission ; 44 import javax.management.MBeanTrustPermission ; 45 import javax.management.MalformedObjectNameException ; 46 import javax.management.NotCompliantMBeanException ; 47 import javax.management.Notification ; 48 import javax.management.NotificationBroadcasterSupport ; 49 import javax.management.NotificationFilterSupport ; 50 import javax.management.ObjectInstance ; 51 import javax.management.ObjectName ; 52 import javax.management.OperationsException ; 53 import javax.management.Query ; 54 import javax.management.QueryExp ; 55 import javax.management.ReflectionException ; 56 import javax.management.RuntimeErrorException ; 57 import javax.management.RuntimeMBeanException ; 58 import javax.management.RuntimeOperationsException ; 59 import javax.management.ServiceNotFoundException ; 60 import javax.management.StringValueExp ; 61 import javax.management.ValueExp ; 62 import javax.management.modelmbean.DescriptorSupport ; 63 import javax.management.modelmbean.InvalidTargetObjectTypeException ; 64 import javax.management.modelmbean.ModelMBean ; 65 import javax.management.modelmbean.ModelMBeanAttributeInfo ; 66 import javax.management.modelmbean.ModelMBeanConstructorInfo ; 67 import javax.management.modelmbean.ModelMBeanInfo ; 68 import javax.management.modelmbean.ModelMBeanInfoSupport ; 69 import javax.management.modelmbean.ModelMBeanNotificationBroadcaster ; 70 import javax.management.modelmbean.ModelMBeanNotificationInfo ; 71 import javax.management.modelmbean.ModelMBeanOperationInfo ; 72 import javax.management.modelmbean.XMLParseException ; 73 import javax.management.monitor.MonitorNotification ; 74 import javax.management.monitor.MonitorSettingException ; 75 import javax.management.openmbean.ArrayType ; 76 import javax.management.openmbean.CompositeDataSupport ; 77 import javax.management.openmbean.CompositeType ; 78 import javax.management.openmbean.InvalidKeyException ; 79 import javax.management.openmbean.InvalidOpenTypeException ; 80 import javax.management.openmbean.KeyAlreadyExistsException ; 81 import javax.management.openmbean.OpenDataException ; 82 import javax.management.openmbean.OpenMBeanAttributeInfoSupport ; 83 import javax.management.openmbean.OpenMBeanConstructorInfoSupport ; 84 import javax.management.openmbean.OpenMBeanInfoSupport ; 85 import javax.management.openmbean.OpenMBeanOperationInfo ; 86 import javax.management.openmbean.OpenMBeanOperationInfoSupport ; 87 import javax.management.openmbean.OpenMBeanParameterInfo ; 88 import javax.management.openmbean.OpenMBeanParameterInfoSupport ; 89 import javax.management.openmbean.OpenType ; 90 import javax.management.openmbean.SimpleType ; 91 import javax.management.openmbean.TabularDataSupport ; 92 import javax.management.openmbean.TabularType ; 93 import javax.management.relation.InvalidRelationIdException ; 94 import javax.management.relation.InvalidRelationServiceException ; 95 import javax.management.relation.InvalidRelationTypeException ; 96 import javax.management.relation.InvalidRoleInfoException ; 97 import javax.management.relation.InvalidRoleValueException ; 98 import javax.management.relation.MBeanServerNotificationFilter ; 99 import javax.management.relation.Relation ; 100 import javax.management.relation.RelationException ; 101 import javax.management.relation.RelationNotFoundException ; 102 import javax.management.relation.RelationNotification ; 103 import javax.management.relation.RelationService ; 104 import javax.management.relation.RelationServiceNotRegisteredException ; 105 import javax.management.relation.RelationType ; 106 import javax.management.relation.RelationTypeNotFoundException ; 107 import javax.management.relation.RelationTypeSupport ; 108 import javax.management.relation.Role ; 109 import javax.management.relation.RoleInfo ; 110 import javax.management.relation.RoleInfoNotFoundException ; 111 import javax.management.relation.RoleList ; 112 import javax.management.relation.RoleNotFoundException ; 113 import javax.management.relation.RoleResult ; 114 import javax.management.relation.RoleStatus ; 115 import javax.management.relation.RoleUnresolved ; 116 import javax.management.relation.RoleUnresolvedList ; 117 import javax.management.timer.TimerNotification ; 118 119 122 public class Instantiator 123 { 124 128 public QueryExp createAndQueryExp() 129 { 130 return Query.and(createBetweenQueryExp(), createBinaryRelQueryExp()); 131 } 132 133 public Attribute createAttribute() 134 { 135 return new Attribute ("attr-name", "attr-value"); 136 } 137 138 public AttributeChangeNotification createAttributeChangeNotification() 139 { 140 AttributeChangeNotification notification = new AttributeChangeNotification ("notif-source", 13L, System.currentTimeMillis(), "notif-message", "attr-name", "attr-type", "old", "new"); 141 notification.setUserData("notif-user"); 142 return notification; 143 } 144 145 public AttributeChangeNotificationFilter createAttributeChangeNotificationFilter() 146 { 147 AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter (); 148 filter.enableAttribute("attribute-name"); 149 return filter; 150 } 151 152 public AttributeList createAttributeList() 153 { 154 AttributeList list = new AttributeList (); 155 list.add(createAttribute()); 156 return list; 157 } 158 159 public AttributeNotFoundException createAttributeNotFoundException() 160 { 161 return new AttributeNotFoundException ("AttributeNotFoundException"); 162 } 163 164 public AttributeValueExp createAttributeValueExp() 165 { 166 return new AttributeValueExp ("attribute"); 167 } 168 169 public BadAttributeValueExpException createBadAttributeValueExpException() 170 { 171 return new BadAttributeValueExpException ("BadAttributeValueExpException"); 172 } 173 174 public BadBinaryOpValueExpException createBadBinaryOpValueExpException() 175 { 176 return new BadBinaryOpValueExpException (createStringValueExp()); 177 } 178 179 public BadStringOperationException createBadStringOperationException() 180 { 181 return new BadStringOperationException ("BadStringOperationException"); 182 } 183 184 public QueryExp createBetweenQueryExp() 185 { 186 return Query.between(Query.value(5), Query.value(3), Query.value(7)); 187 } 188 189 public ValueExp createBinaryOpValueExp() 190 { 191 return Query.plus(Query.value(2), Query.value(5)); 192 } 193 194 public QueryExp createBinaryRelQueryExp() 195 { 196 return Query.eq(Query.value("simon"), Query.value("simon")); 197 } 198 199 public ValueExp createBooleanValueExp() 200 { 201 return Query.value(true); 202 } 203 204 public ValueExp createClassAttributeValueExp() 205 { 206 return Query.classattr(); 207 } 208 209 public Descriptor createDescriptor() 210 { 211 throw new Error (); 212 } 213 214 public QueryExp createInQueryExp() 215 { 216 return Query.in(Query.value(4), new ValueExp []{Query.value(3), Query.value(4), Query.value(5)}); 217 } 218 219 public InstanceAlreadyExistsException createInstanceAlreadyExistsException() 220 { 221 return new InstanceAlreadyExistsException ("InstanceAlreadyExistsException"); 222 } 223 224 public InstanceNotFoundException createInstanceNotFoundException() 225 { 226 return new InstanceNotFoundException ("InstanceNotFoundException"); 227 } 228 229 public IntrospectionException createIntrospectionException() 230 { 231 return new IntrospectionException ("IntrospectionException"); 232 } 233 234 public InvalidApplicationException createInvalidApplicationException() 235 { 236 return new InvalidApplicationException ("InvalidApplicationException"); 237 } 238 239 public InvalidAttributeValueException createInvalidAttributeValueException() 240 { 241 return new InvalidAttributeValueException ("InvalidAttributeValueException"); 242 } 243 244 public JMException createJMException() 245 { 246 return new JMException ("JMException"); 247 } 248 249 public JMRuntimeException createJMRuntimeException() 250 { 251 return new JMRuntimeException ("JMRuntimeException"); 252 } 253 254 public ListenerNotFoundException createListenerNotFoundException() 255 { 256 return new ListenerNotFoundException ("ListenerNotFoundException"); 257 } 258 259 public MalformedObjectNameException createMalformedObjectNameException() 260 { 261 return new MalformedObjectNameException ("MalformedObjectNameException"); 262 } 263 264 public QueryExp createMatchQueryExp() 265 { 266 return Query.match(createAttributeValueExp(), createStringValueExp()); 267 } 268 269 public MBeanAttributeInfo createMBeanAttributeInfo() 270 { 271 return new MBeanAttributeInfo ("name", "boolean", "description", true, true, true); 272 } 273 274 public MBeanConstructorInfo createMBeanConstructorInfo() 275 { 276 return new MBeanConstructorInfo ("name", "description", new MBeanParameterInfo []{createMBeanParameterInfo()}); 277 } 278 279 public MBeanException createMBeanException() 280 { 281 return new MBeanException (new NullPointerException ("NullPointerException"), "MBeanException"); 282 } 283 284 public MBeanFeatureInfo createMBeanFeatureInfo() 285 { 286 return new MBeanFeatureInfo ("name", "description"); 287 } 288 289 public MBeanInfo createMBeanInfo() 290 { 291 return new MBeanInfo ("my.class.name", 292 "description", 293 new MBeanAttributeInfo []{createMBeanAttributeInfo()}, 294 new MBeanConstructorInfo []{createMBeanConstructorInfo()}, 295 new MBeanOperationInfo []{createMBeanOperationInfo()}, 296 new MBeanNotificationInfo []{createMBeanNotificationInfo()}); 297 } 298 299 public MBeanNotificationInfo createMBeanNotificationInfo() 300 { 301 return new MBeanNotificationInfo (new String []{"type1", "type2"}, "name", "description"); 302 } 303 304 public MBeanOperationInfo createMBeanOperationInfo() 305 { 306 return new MBeanOperationInfo ("name", "description", new MBeanParameterInfo []{createMBeanParameterInfo()}, "java.lang.Exception", MBeanOperationInfo.UNKNOWN); 307 } 308 309 public MBeanParameterInfo createMBeanParameterInfo() 310 { 311 return new MBeanParameterInfo ("name", "java.lang.Object", "description"); 312 } 313 314 public MBeanPermission createMBeanPermission() throws MalformedObjectNameException 315 { 316 return new MBeanPermission ("className", "methodName", createObjectName(), "instantiate,registerMBean"); 317 } 318 319 public MBeanRegistrationException createMBeanRegistrationException() 320 { 321 return new MBeanRegistrationException (new NullPointerException ("NullPointerException"), "MBeanRegistrationException"); 322 } 323 324 public MBeanServerDelegate createMBeanServerDelegate() 325 { 326 return new MBeanServerDelegate (); 327 } 328 329 public MBeanServerNotification createMBeanServerNotification() throws MalformedObjectNameException 330 { 331 MBeanServerNotification n = new MBeanServerNotification (MBeanServerNotification.REGISTRATION_NOTIFICATION, "notif-source", 13L, new ObjectName (":key=value")); 332 n.setUserData("user-data"); 333 return n; 334 } 335 336 public MBeanServerPermission createMBeanServerPermission() 337 { 338 return new MBeanServerPermission ("newMBeanServer"); 339 } 340 341 public MBeanTrustPermission createMBeanTrustPermission() 342 { 343 return new MBeanTrustPermission ("register"); 344 } 345 346 public NotCompliantMBeanException createNotCompliantMBeanException() 347 { 348 return new NotCompliantMBeanException ("NotCompliantMBeanException"); 349 } 350 351 public Notification createNotification() 352 { 353 Notification notification = new Notification ("notif-type", "notif-source", 13L, System.currentTimeMillis(), "notif-message"); 354 notification.setUserData("notif-user"); 355 return notification; 356 } 357 358 public NotificationBroadcasterSupport createNotificationBroadcasterSupport() 359 { 360 return new NotificationBroadcasterSupport (); 361 } 362 363 public NotificationFilterSupport createNotificationFilterSupport() 364 { 365 NotificationFilterSupport filter = new NotificationFilterSupport (); 366 filter.enableType("notif-type"); 367 return filter; 368 } 369 370 public QueryExp createNotQueryExp() 371 { 372 return Query.not(Query.eq(Query.value("simon"), Query.value("bordet"))); 373 } 374 375 public ValueExp createNumericValueExp() 376 { 377 return Query.value(1); 378 } 379 380 public ObjectInstance createObjectInstance() throws MalformedObjectNameException 381 { 382 return new ObjectInstance (new ObjectName ("domain:p1=v1"), "java.lang.Object"); 383 } 384 385 public ObjectName createObjectName() throws MalformedObjectNameException 386 { 387 return new ObjectName ("domain?:p2=v2,*,p1=v1"); 388 } 389 390 public OperationsException createOperationsException() 391 { 392 return new OperationsException ("OperationsException"); 393 } 394 395 public QueryExp createOrQueryExp() 396 { 397 return Query.or(createBetweenQueryExp(), createBinaryRelQueryExp()); 398 } 399 400 public AttributeValueExp createQualifiedAttributeValueExp() 401 { 402 return Query.attr("mx4j.Foo", "attribute"); 403 } 404 405 public ReflectionException createReflectionException() 406 { 407 return new ReflectionException (new NullPointerException ("NullPointerException"), "ReflectionException"); 408 } 409 410 public RuntimeErrorException createRuntimeErrorException() 411 { 412 return new RuntimeErrorException (new Error ("Error"), "RuntimeErrorException"); 413 } 414 415 public RuntimeMBeanException createRuntimeMBeanException() 416 { 417 return new RuntimeMBeanException (new NullPointerException ("NullPointerException"), "RuntimeMBeanException"); 418 } 419 420 public RuntimeOperationsException createRuntimeOperationsException() 421 { 422 return new RuntimeOperationsException (new NullPointerException ("NullPointerException"), "RuntimeOperationsException"); 423 } 424 425 public ServiceNotFoundException createServiceNotFoundException() 426 { 427 return new ServiceNotFoundException ("ServiceNotFoundException"); 428 } 429 430 public StringValueExp createStringValueExp() 431 { 432 return new StringValueExp ("StringValueExp"); 433 } 434 435 436 440 public DescriptorSupport createDescriptorSupport() 441 { 442 return new DescriptorSupport (new String []{"name"}, new Object []{"value"}); 443 } 444 445 public InvalidTargetObjectTypeException createInvalidTargetObjectTypeException() 446 { 447 return new InvalidTargetObjectTypeException (new NullPointerException ("NullPointerException"), "InvalidTargetObjectTypeException"); 448 } 449 450 public ModelMBean createModelMBean() 451 { 452 throw new Error (); 453 } 454 455 public ModelMBeanAttributeInfo createModelMBeanAttributeInfo() 456 { 457 String [] names = new String []{"name", "descriptortype", "value", "iterable", "displayname"}; 458 Object [] values = new Object []{"name", "attribute", null, "false", "name"}; 459 DescriptorSupport descriptor = new DescriptorSupport (names, values); 460 return new ModelMBeanAttributeInfo ("name", "boolean", "description", true, true, true, descriptor); 461 } 462 463 public ModelMBeanConstructorInfo createModelMBeanConstructorInfo() 464 { 465 String [] names = new String []{"name", "descriptortype", "role", "displayname"}; 466 Object [] values = new Object []{"name", "operation", "constructor", "name"}; 467 DescriptorSupport descriptor = new DescriptorSupport (names, values); 468 return new ModelMBeanConstructorInfo ("name", "description", new MBeanParameterInfo []{createMBeanParameterInfo()}, descriptor); 469 } 470 471 public ModelMBeanInfo createModelMBeanInfo() 472 { 473 throw new Error (); 474 } 475 476 public ModelMBeanInfoSupport createModelMBeanInfoSupport() 477 { 478 String [] names = new String []{"name", "descriptortype", "displayname", "persistpolicy", "log", "export", "visibility"}; 479 Object [] values = new Object []{"name", "MBean", "name", "Never", "false", "F", "1"}; 480 DescriptorSupport descriptor = new DescriptorSupport (names, values); 481 return new ModelMBeanInfoSupport ("my.class.name", 482 "description", 483 new ModelMBeanAttributeInfo []{createModelMBeanAttributeInfo()}, 484 new ModelMBeanConstructorInfo []{createModelMBeanConstructorInfo()}, 485 new ModelMBeanOperationInfo []{createModelMBeanOperationInfo()}, 486 new ModelMBeanNotificationInfo []{createModelMBeanNotificationInfo()}, descriptor); 487 } 488 489 public ModelMBeanNotificationBroadcaster createModelMBeanNotificationBroadcaster() 490 { 491 throw new Error (); 492 } 493 494 public ModelMBeanNotificationInfo createModelMBeanNotificationInfo() 495 { 496 String [] names = new String []{"name", "descriptortype", "severity", "displayname"}; 497 Object [] values = new Object []{"name", "notification", "5", "name"}; 498 DescriptorSupport descriptor = new DescriptorSupport (names, values); 499 return new ModelMBeanNotificationInfo (new String []{"type1", "type2"}, "name", "description", descriptor); 500 } 501 502 public ModelMBeanOperationInfo createModelMBeanOperationInfo() 503 { 504 String [] names = new String []{"name", "descriptortype", "role", "displayname"}; 505 Object [] values = new Object []{"name", "operation", "operation", "name"}; 506 DescriptorSupport descriptor = new DescriptorSupport (names, values); 507 return new ModelMBeanOperationInfo ("name", "description", new MBeanParameterInfo []{createMBeanParameterInfo()}, "java.lang.Object", MBeanOperationInfo.UNKNOWN, descriptor); 508 } 509 510 public XMLParseException createXMLParseException() 511 { 512 return new XMLParseException ("XMLParseException"); 513 } 514 515 516 520 public MonitorNotification createMonitorNotification() throws Exception 521 { 522 Constructor ctor = MonitorNotification .class.getDeclaredConstructor(new Class []{String .class, Object .class, long.class, long.class, String .class, ObjectName .class, String .class, Object .class, Object .class}); 523 ctor.setAccessible(true); 524 MonitorNotification notification = (MonitorNotification )ctor.newInstance(new Object []{"type", "source", new Long (13), new Long (System.currentTimeMillis()), "message", new ObjectName ("domain:p1=v1"), "attribute", "gauge", "trigger"}); 525 notification.setUserData("user"); 526 return notification; 527 } 528 529 public MonitorSettingException createMonitorSettingException() 530 { 531 return new MonitorSettingException ("MonitorSettingException"); 532 } 533 534 535 539 public ArrayType createArrayType() throws OpenDataException 540 { 541 return new ArrayType (5, SimpleType.BIGDECIMAL); 542 } 543 544 public CompositeDataSupport createCompositeDataSupport() throws OpenDataException 545 { 546 CompositeType ct = createCompositeType(); 547 return new CompositeDataSupport (ct, new String []{"key1", "key2"}, new Object []{"value1", "value2"}); 548 } 549 550 public CompositeType createCompositeType() throws OpenDataException 551 { 552 return new CompositeType ("composite1", "description1", new String []{"key1", "key2"}, new String []{"d1", "d2"}, new OpenType []{SimpleType.STRING, SimpleType.STRING}); 553 } 554 555 public InvalidKeyException createInvalidKeyException() 556 { 557 return new InvalidKeyException ("InvalidKeyException"); 558 } 559 560 public InvalidOpenTypeException createInvalidOpenTypeException() 561 { 562 return new InvalidOpenTypeException ("InvalidOpenTypeException"); 563 } 564 565 public KeyAlreadyExistsException createKeyAlreadyExistsException() 566 { 567 return new KeyAlreadyExistsException ("KeyAlreadyExistsException"); 568 } 569 570 public OpenDataException createOpenDataException() 571 { 572 return new OpenDataException ("OpenDataException"); 573 } 574 575 public OpenMBeanAttributeInfoSupport createOpenMBeanAttributeInfoSupport() 576 { 577 return new OpenMBeanAttributeInfoSupport ("attrib", "An Attribute", SimpleType.STRING, true, true, false); 578 } 579 580 public OpenMBeanConstructorInfoSupport createOpenMBeanConstructorInfoSupport() 581 { 582 return new OpenMBeanConstructorInfoSupport ("const", "a constructor", new OpenMBeanParameterInfoSupport []{createOpenMBeanParameterInfoSupport()}); 583 } 584 585 public OpenMBeanInfoSupport createOpenMBeanInfoSupport() throws OpenDataException 586 { 587 OpenMBeanAttributeInfoSupport [] attrInfo = new OpenMBeanAttributeInfoSupport []{createOpenMBeanAttributeInfoSupport()}; 588 OpenMBeanConstructorInfoSupport [] ctorInfo = new OpenMBeanConstructorInfoSupport []{createOpenMBeanConstructorInfoSupport()}; 589 OpenMBeanOperationInfo [] operInfo = new OpenMBeanOperationInfoSupport []{createOpenMBeanOperationInfoSupport()}; 590 MBeanNotificationInfo [] notifInfo = new MBeanNotificationInfo [] 591 { 592 new MBeanNotificationInfo (new String []{"notif1", "notif2"}, "name", "description") 593 }; 594 return new OpenMBeanInfoSupport ("test.class.Name", "description1", attrInfo, ctorInfo, operInfo, notifInfo); 595 } 596 597 public OpenMBeanOperationInfoSupport createOpenMBeanOperationInfoSupport() 598 { 599 return new OpenMBeanOperationInfoSupport ("operation", "A operation", new OpenMBeanParameterInfo []{createOpenMBeanParameterInfoSupport()}, SimpleType.STRING, MBeanOperationInfo.ACTION); 600 } 601 602 public OpenMBeanParameterInfoSupport createOpenMBeanParameterInfoSupport() 603 { 604 return new OpenMBeanParameterInfoSupport ("param1", "A param", SimpleType.STRING); 605 } 606 607 public SimpleType createSimpleType() 608 { 609 return SimpleType.STRING; 610 } 611 612 public TabularDataSupport createTabularDataSupport() throws OpenDataException 613 { 614 return new TabularDataSupport (createTabularType()); 615 } 616 617 public TabularType createTabularType() throws OpenDataException 618 { 619 return new TabularType ("typename", "descr1", createCompositeType(), new String []{"key1", "key2"}); 620 } 621 622 623 627 public InvalidRelationIdException createInvalidRelationIdException() 628 { 629 return new InvalidRelationIdException ("InvalidRelationIdException"); 630 } 631 632 public InvalidRelationServiceException createInvalidRelationServiceException() 633 { 634 return new InvalidRelationServiceException ("InvalidRelationServiceException"); 635 } 636 637 public InvalidRelationTypeException createInvalidRelationTypeException() 638 { 639 return new InvalidRelationTypeException ("InvalidRelationTypeException"); 640 } 641 642 public InvalidRoleInfoException createInvalidRoleInfoException() 643 { 644 return new InvalidRoleInfoException ("InvalidRoleInfoException"); 645 } 646 647 public InvalidRoleValueException createInvalidRoleValueException() 648 { 649 return new InvalidRoleValueException ("InvalidRoleValueException"); 650 } 651 652 public MBeanServerNotificationFilter createMBeanServerNotificationFilter() throws MalformedObjectNameException 653 { 654 MBeanServerNotificationFilter filter = new MBeanServerNotificationFilter (); 655 filter.enableType("notif-type"); 656 filter.disableAllObjectNames(); 657 filter.enableObjectName(new ObjectName ("domain:key=val")); 658 return filter; 659 } 660 661 public Relation createRelation() 662 { 663 throw new Error (); 664 } 665 666 public RelationException createRelationException() 667 { 668 return new RelationException ("RelationException"); 669 } 670 671 public RelationNotFoundException createRelationNotFoundException() 672 { 673 return new RelationNotFoundException ("RelationNotFoundException"); 674 } 675 676 public RelationNotification createRelationNotification() throws MalformedObjectNameException 677 { 678 try 679 { 680 RelationNotification n = new RelationNotification (RelationNotification.RELATION_BASIC_UPDATE, 682 "source", 683 13L, 684 System.currentTimeMillis(), 685 "message", 686 "relation-id", 687 "relation-type", 688 new ObjectName (":key=value"), 689 "role-name", 690 createRoleList(), 691 createRoleUnresolvedList()); 692 n.setUserData("user-data"); 693 return n; 694 } 695 catch (IllegalArgumentException x) 696 { 697 RelationNotification n = new RelationNotification (RelationNotification.RELATION_BASIC_UPDATE, 699 new RelationService (true), 700 13L, 701 System.currentTimeMillis(), 702 "message", 703 "relation-id", 704 "relation-type", 705 new ObjectName (":key=value"), 706 "role-name", 707 createRoleList(), 708 createRoleUnresolvedList()); 709 n.setUserData("user-data"); 710 n.setSource("source"); 711 return n; 712 } 713 } 714 715 public RelationServiceNotRegisteredException createRelationServiceNotRegisteredException() 716 { 717 return new RelationServiceNotRegisteredException ("RelationServiceNotRegisteredException"); 718 } 719 720 public RelationTypeNotFoundException createRelationTypeNotFoundException() 721 { 722 return new RelationTypeNotFoundException ("RelationTypeNotFoundException"); 723 } 724 725 public RelationType createRelationType() 726 { 727 throw new Error (); 728 } 729 730 public RelationTypeSupport createRelationTypeSupport() throws InvalidRelationTypeException , InvalidRoleInfoException , ClassNotFoundException , NotCompliantMBeanException 731 { 732 return new RelationTypeSupport ("relation-type", new RoleInfo []{createRoleInfo()}); 733 } 734 735 public Role createRole() throws MalformedObjectNameException 736 { 737 ArrayList list = new ArrayList (); 738 list.add(new ObjectName ("domain:key=value")); 739 return new Role ("Role", list); 740 } 741 742 public RoleInfo createRoleInfo() throws InvalidRoleInfoException , ClassNotFoundException , NotCompliantMBeanException 743 { 744 return new RoleInfo ("RoleInfo", "javax.management.MBeanServerDelegate", true, true, 13, 17, "Description"); 745 } 746 747 public RoleInfoNotFoundException createRoleInfoNotFoundException() 748 { 749 return new RoleInfoNotFoundException ("RoleInfoNotFoundException"); 750 } 751 752 public RoleList createRoleList() throws MalformedObjectNameException 753 { 754 RoleList list = new RoleList (); 755 list.add(createRole()); 756 return list; 757 } 758 759 public RoleNotFoundException createRoleNotFoundException() 760 { 761 return new RoleNotFoundException ("RoleNotFoundException"); 762 } 763 764 public RoleResult createRoleResult() throws MalformedObjectNameException 765 { 766 return new RoleResult (createRoleList(), createRoleUnresolvedList()); 767 } 768 769 public RoleUnresolved createRoleUnresolved() throws MalformedObjectNameException 770 { 771 ArrayList list = new ArrayList (); 772 list.add(new ObjectName ("domain:key=value")); 773 return new RoleUnresolved ("RoleName", list, RoleStatus.NO_ROLE_WITH_NAME); 774 } 775 776 public RoleUnresolvedList createRoleUnresolvedList() throws MalformedObjectNameException 777 { 778 RoleUnresolvedList list = new RoleUnresolvedList (); 779 list.add(createRoleUnresolved()); 780 return list; 781 } 782 783 784 788 public TimerNotification createTimerNotification() throws Exception 789 { 790 try 792 { 793 Constructor ctor = TimerNotification .class.getDeclaredConstructor(new Class []{String .class, Object .class, String .class, Integer .class}); 794 ctor.setAccessible(true); 795 TimerNotification notification = (TimerNotification )ctor.newInstance(new Object []{"type", "source", "message", new Integer (13)}); 796 notification.setUserData("user"); 797 return notification; 798 } 799 catch (NoSuchMethodException x) 800 { 801 Constructor ctor = TimerNotification .class.getDeclaredConstructor(new Class []{String .class, Object .class, long.class, long.class, String .class, Integer .class}); 803 ctor.setAccessible(true); 804 TimerNotification notification = (TimerNotification )ctor.newInstance(new Object []{"type", "source", new Long (0), new Long (0), "message", new Integer (13)}); 805 notification.setUserData("user"); 806 return notification; 807 } 808 } 809 } 810 | Popular Tags |