1 8 9 package test.javax.management.compliance.serialization.support; 10 11 import java.lang.reflect.Field ; 12 import java.lang.reflect.Method ; 13 import java.util.ArrayList ; 14 import java.util.Arrays ; 15 import java.util.List ; 16 import java.util.Vector ; 17 import javax.management.AttributeChangeNotification ; 18 import javax.management.AttributeChangeNotificationFilter ; 19 import javax.management.AttributeList ; 20 import javax.management.AttributeValueExp ; 21 import javax.management.BadBinaryOpValueExpException ; 22 import javax.management.JMRuntimeException ; 23 import javax.management.MBeanAttributeInfo ; 24 import javax.management.MBeanConstructorInfo ; 25 import javax.management.MBeanException ; 26 import javax.management.MBeanFeatureInfo ; 27 import javax.management.MBeanInfo ; 28 import javax.management.MBeanNotificationInfo ; 29 import javax.management.MBeanOperationInfo ; 30 import javax.management.MBeanParameterInfo ; 31 import javax.management.MBeanServerNotification ; 32 import javax.management.MBeanTrustPermission ; 33 import javax.management.Notification ; 34 import javax.management.NotificationFilterSupport ; 35 import javax.management.ObjectName ; 36 import javax.management.QueryExp ; 37 import javax.management.ReflectionException ; 38 import javax.management.RuntimeErrorException ; 39 import javax.management.RuntimeMBeanException ; 40 import javax.management.RuntimeOperationsException ; 41 import javax.management.StringValueExp ; 42 import javax.management.ValueExp ; 43 import javax.management.modelmbean.DescriptorSupport ; 44 import javax.management.modelmbean.ModelMBeanAttributeInfo ; 45 import javax.management.modelmbean.ModelMBeanConstructorInfo ; 46 import javax.management.modelmbean.ModelMBeanInfoSupport ; 47 import javax.management.modelmbean.ModelMBeanNotificationInfo ; 48 import javax.management.modelmbean.ModelMBeanOperationInfo ; 49 import javax.management.monitor.MonitorNotification ; 50 import javax.management.relation.MBeanServerNotificationFilter ; 51 import javax.management.relation.RelationNotification ; 52 import javax.management.relation.RelationTypeSupport ; 53 import javax.management.relation.Role ; 54 import javax.management.relation.RoleInfo ; 55 import javax.management.relation.RoleList ; 56 import javax.management.relation.RoleResult ; 57 import javax.management.relation.RoleUnresolved ; 58 import javax.management.relation.RoleUnresolvedList ; 59 import javax.management.timer.TimerNotification ; 60 61 64 public class Comparator 65 { 66 public void compareAndQueryExp(Object o1, Object o2) throws Exception 67 { 68 compareQueryExp(o1, o2); 69 } 70 71 public void compareAttributeChangeNotification(Object o1, Object o2) 72 { 73 compareNotification(o1, o2); 74 75 AttributeChangeNotification n1 = (AttributeChangeNotification )o1; 76 AttributeChangeNotification n2 = (AttributeChangeNotification )o2; 77 78 if (!n1.getAttributeName().equals(n2.getAttributeName())) throw new RuntimeException (); 79 if (!n1.getAttributeType().equals(n2.getAttributeType())) throw new RuntimeException (); 80 if (!n1.getNewValue().equals(n2.getNewValue())) throw new RuntimeException (); 81 if (!n1.getOldValue().equals(n2.getOldValue())) throw new RuntimeException (); 82 } 83 84 public void compareAttributeChangeNotificationFilter(Object o1, Object o2) 85 { 86 AttributeChangeNotificationFilter f1 = (AttributeChangeNotificationFilter )o1; 87 AttributeChangeNotificationFilter f2 = (AttributeChangeNotificationFilter )o2; 88 89 if (!f1.getEnabledAttributes().equals(f2.getEnabledAttributes())) throw new RuntimeException (); 90 } 91 92 public void compareAttributeList(Object o1, Object o2) 93 { 94 AttributeList a1 = (AttributeList )o1; 95 AttributeList a2 = (AttributeList )o2; 96 if (!a1.equals(a2)) throw new RuntimeException (); 98 } 99 100 public void compareAttributeNotFoundException(Object o1, Object o2) 101 { 102 compareOperationsException(o1, o2); 103 } 104 105 public void compareAttributeValueExp(Object o1, Object o2) 106 { 107 AttributeValueExp val1 = (AttributeValueExp )o1; 108 AttributeValueExp val2 = (AttributeValueExp )o2; 109 110 if (!val1.getAttributeName().equals(val2.getAttributeName())) throw new RuntimeException (); 111 } 112 113 public void compareBadAttributeValueExpException(Object o1, Object o2) 114 { 115 } 117 118 public void compareBadBinaryOpValueExpException(Object o1, Object o2) 119 { 120 BadBinaryOpValueExpException b1 = (BadBinaryOpValueExpException )o1; 121 BadBinaryOpValueExpException b2 = (BadBinaryOpValueExpException )o2; 122 compareStringValueExp(b1.getExp(), b2.getExp()); 123 } 124 125 public void compareBadStringOperationException(Object o1, Object o2) 126 { 127 } 129 130 public void compareBetweenQueryExp(Object o1, Object o2) throws Exception 131 { 132 compareQueryExp(o1, o2); 133 } 134 135 public void compareBinaryOpValueExp(Object o1, Object o2) throws Exception 136 { 137 ValueExp val1 = (ValueExp )o1; 138 ValueExp val2 = (ValueExp )o2; 139 140 compareNumericValueExp(val1.apply(null), val2.apply(null)); 141 } 142 143 public void compareBinaryRelQueryExp(Object o1, Object o2) throws Exception 144 { 145 compareQueryExp(o1, o2); 146 } 147 148 public void compareBooleanValueExp(Object o1, Object o2) throws Exception 149 { 150 Field field = o1.getClass().getDeclaredField("val"); 151 field.setAccessible(true); 152 boolean res1 = field.getBoolean(o1); 153 boolean res2 = field.getBoolean(o2); 154 if (!res1 || !res2) throw new RuntimeException (); 155 } 156 157 public void compareClassAttributeValueExp(Object o1, Object o2) 158 { 159 } 161 162 public void compareInQueryExp(Object o1, Object o2) throws Exception 163 { 164 compareQueryExp(o1, o2); 165 } 166 167 public void compareInstanceAlreadyExistsException(Object o1, Object o2) 168 { 169 compareOperationsException(o1, o2); 170 } 171 172 public void compareInstanceNotFoundException(Object o1, Object o2) 173 { 174 compareOperationsException(o1, o2); 175 } 176 177 public void compareIntrospectionException(Object o1, Object o2) 178 { 179 compareOperationsException(o1, o2); 180 } 181 182 public void compareInvalidApplicationException(Object o1, Object o2) 183 { 184 } 186 187 public void compareInvalidAttributeValueException(Object o1, Object o2) 188 { 189 compareOperationsException(o1, o2); 190 } 191 192 public void compareJMException(Object o1, Object o2) 193 { 194 compareException(o1, o2); 195 } 196 197 public void compareError(Object o1, Object o2) 198 { 199 Error x1 = (Error )o1; 200 Error x2 = (Error )o2; 201 if (!x1.getMessage().equals(x2.getMessage())) throw new RuntimeException (); 202 } 203 204 public void compareException(Object o1, Object o2) 205 { 206 Exception x1 = (Exception )o1; 207 Exception x2 = (Exception )o2; 208 if (!x1.getMessage().equals(x2.getMessage())) throw new RuntimeException (); 209 } 210 211 public void compareJMRuntimeException(Object o1, Object o2) 212 { 213 JMRuntimeException x1 = (JMRuntimeException )o1; 214 JMRuntimeException x2 = (JMRuntimeException )o2; 215 if (!x1.getMessage().equals(x2.getMessage())) throw new RuntimeException (); 216 } 217 218 public void compareListenerNotFoundException(Object o1, Object o2) 219 { 220 compareOperationsException(o1, o2); 221 } 222 223 public void compareMalformedObjectNameException(Object o1, Object o2) 224 { 225 compareOperationsException(o1, o2); 226 } 227 228 public void compareMatchQueryExp(Object o1, Object o2) throws Exception 229 { 230 } 232 233 public void compareMBeanAttributeInfo(Object o1, Object o2) 234 { 235 compareMBeanFeatureInfo(o1, o2); 236 237 MBeanAttributeInfo a1 = (MBeanAttributeInfo )o1; 238 MBeanAttributeInfo a2 = (MBeanAttributeInfo )o2; 239 240 if (!a1.getType().equals(a2.getType())) throw new RuntimeException (); 241 if (a1.isReadable() != a2.isReadable()) throw new RuntimeException (); 242 if (a1.isWritable() != a2.isWritable()) throw new RuntimeException (); 243 if (a1.isIs() != a2.isIs()) throw new RuntimeException (); 244 } 245 246 public void compareMBeanConstructorInfo(Object o1, Object o2) 247 { 248 compareMBeanFeatureInfo(o1, o2); 249 250 MBeanConstructorInfo c1 = (MBeanConstructorInfo )o1; 251 MBeanConstructorInfo c2 = (MBeanConstructorInfo )o2; 252 253 MBeanParameterInfo [] p1 = c1.getSignature(); 254 MBeanParameterInfo [] p2 = c2.getSignature(); 255 256 if (p1.length != p2.length) throw new RuntimeException (); 257 for (int i = 0; i < p1.length; ++i) 258 { 259 compareMBeanParameterInfo(p1[i], p2[i]); 260 } 261 } 262 263 public void compareMBeanException(Object o1, Object o2) 264 { 265 compareJMException(o1, o2); 266 267 MBeanException x1 = (MBeanException )o1; 268 MBeanException x2 = (MBeanException )o2; 269 270 Exception xx1 = x1.getTargetException(); 271 Exception xx2 = x2.getTargetException(); 272 compareException(xx1, xx2); 273 } 274 275 public void compareMBeanFeatureInfo(Object o1, Object o2) 276 { 277 MBeanFeatureInfo f1 = (MBeanFeatureInfo )o1; 278 MBeanFeatureInfo f2 = (MBeanFeatureInfo )o2; 279 280 if (!f1.getName().equals(f2.getName())) throw new RuntimeException (); 281 if (!f1.getDescription().equals(f2.getDescription())) throw new RuntimeException (); 282 } 283 284 public void compareMBeanInfo(Object o1, Object o2) 285 { 286 MBeanInfo i1 = (MBeanInfo )o1; 287 MBeanInfo i2 = (MBeanInfo )o2; 288 289 if (!i1.getClassName().equals(i2.getClassName())) throw new RuntimeException (); 290 if (!i1.getDescription().equals(i2.getDescription())) throw new RuntimeException (); 291 292 MBeanAttributeInfo [] a1 = i1.getAttributes(); 293 MBeanAttributeInfo [] a2 = i2.getAttributes(); 294 if (a1.length != a2.length) throw new RuntimeException (); 295 for (int i = 0; i < a1.length; ++i) 296 { 297 compareMBeanAttributeInfo(a1[i], a2[i]); 298 } 299 300 MBeanConstructorInfo [] c1 = i1.getConstructors(); 301 MBeanConstructorInfo [] c2 = i2.getConstructors(); 302 if (c1.length != c2.length) throw new RuntimeException (); 303 for (int i = 0; i < c1.length; ++i) 304 { 305 compareMBeanConstructorInfo(c1[i], c2[i]); 306 } 307 308 MBeanNotificationInfo [] n1 = i1.getNotifications(); 309 MBeanNotificationInfo [] n2 = i2.getNotifications(); 310 if (n1.length != n2.length) throw new RuntimeException (); 311 for (int i = 0; i < n1.length; ++i) 312 { 313 compareMBeanNotificationInfo(n1[i], n2[i]); 314 } 315 316 MBeanOperationInfo [] op1 = i1.getOperations(); 317 MBeanOperationInfo [] op2 = i2.getOperations(); 318 if (op1.length != op2.length) throw new RuntimeException (); 319 for (int i = 0; i < op1.length; ++i) 320 { 321 compareMBeanOperationInfo(op1[i], op2[i]); 322 } 323 } 324 325 public void compareMBeanNotificationInfo(Object o1, Object o2) 326 { 327 compareMBeanFeatureInfo(o1, o2); 328 329 MBeanNotificationInfo n1 = (MBeanNotificationInfo )o1; 330 MBeanNotificationInfo n2 = (MBeanNotificationInfo )o2; 331 332 String [] t1 = n1.getNotifTypes(); 333 String [] t2 = n2.getNotifTypes(); 334 335 if (t1.length != t2.length) throw new RuntimeException (); 336 for (int i = 0; i < t1.length; ++i) 337 { 338 if (!t1[i].equals(t2[i])) throw new RuntimeException (); 339 } 340 } 341 342 public void compareMBeanOperationInfo(Object o1, Object o2) 343 { 344 compareMBeanFeatureInfo(o1, o2); 345 346 MBeanOperationInfo op1 = (MBeanOperationInfo )o1; 347 MBeanOperationInfo op2 = (MBeanOperationInfo )o2; 348 349 if (op1.getImpact() != op2.getImpact()) throw new RuntimeException (); 350 if (!op1.getReturnType().equals(op2.getReturnType())) throw new RuntimeException (); 351 352 MBeanParameterInfo [] p1 = op1.getSignature(); 353 MBeanParameterInfo [] p2 = op2.getSignature(); 354 355 if (p1.length != p2.length) throw new RuntimeException (); 356 for (int i = 0; i < p1.length; ++i) 357 { 358 compareMBeanParameterInfo(p1[i], p2[i]); 359 } 360 } 361 362 public void compareMBeanParameterInfo(Object o1, Object o2) 363 { 364 compareMBeanFeatureInfo(o1, o2); 365 366 MBeanParameterInfo p1 = (MBeanParameterInfo )o1; 367 MBeanParameterInfo p2 = (MBeanParameterInfo )o2; 368 369 if (!p1.getType().equals(p2.getType())) throw new RuntimeException (); 370 } 371 372 public void compareMBeanRegistrationException(Object o1, Object o2) 373 { 374 compareMBeanException(o1, o2); 375 } 376 377 public void compareMBeanServerNotification(Object o1, Object o2) 378 { 379 compareNotification(o1, o2); 380 ObjectName obj1 = ((MBeanServerNotification )o1).getMBeanName(); 381 ObjectName obj2 = ((MBeanServerNotification )o2).getMBeanName(); 382 if (!obj1.equals(obj2)) throw new RuntimeException (); 383 } 384 385 public void compareMBeanTrustPermission(Object o1, Object o2) 386 { 387 MBeanTrustPermission p1 = (MBeanTrustPermission )o1; 388 MBeanTrustPermission p2 = (MBeanTrustPermission )o2; 389 if (!p1.getName().equals(p2.getName())) throw new RuntimeException (); 390 } 391 392 public void compareNotCompliantMBeanException(Object o1, Object o2) 393 { 394 compareOperationsException(o1, o2); 395 } 396 397 public void compareNotification(Object o1, Object o2) 398 { 399 Notification n1 = (Notification )o1; 400 Notification n2 = (Notification )o2; 401 402 if (!n1.getSource().equals(n2.getSource())) throw new RuntimeException (); 403 if (!n1.getType().equals(n2.getType())) throw new RuntimeException (); 404 if (n1.getSequenceNumber() != n2.getSequenceNumber()) throw new RuntimeException (); 405 if (!n1.getUserData().equals(n2.getUserData())) throw new RuntimeException (); 406 if (!n1.getMessage().equals(n2.getMessage())) throw new RuntimeException (); 407 } 408 409 public void compareNotificationFilterSupport(Object o1, Object o2) 410 { 411 NotificationFilterSupport f1 = (NotificationFilterSupport )o1; 412 NotificationFilterSupport f2 = (NotificationFilterSupport )o2; 413 414 Vector types1 = f1.getEnabledTypes(); 415 Vector types2 = f2.getEnabledTypes(); 416 if (!types1.containsAll(types2) || !types2.containsAll(types1)) throw new RuntimeException (); 417 } 418 419 public void compareNotQueryExp(Object o1, Object o2) throws Exception 420 { 421 compareQueryExp(o1, o2); 422 } 423 424 public void compareNumericValueExp(Object o1, Object o2) throws Exception 425 { 426 Method method = o1.getClass().getDeclaredMethod("longValue", new Class [0]); 427 method.setAccessible(true); 428 Object res1 = method.invoke(o1, new Object [0]); 429 Object res2 = method.invoke(o2, new Object [0]); 430 if (!res1.equals(res2)) throw new RuntimeException (); 431 } 432 433 public void compareOperationsException(Object o1, Object o2) 434 { 435 compareJMException(o1, o2); 436 } 437 438 public void compareOrQueryExp(Object o1, Object o2) throws Exception 439 { 440 compareQueryExp(o1, o2); 441 } 442 443 public void compareQualifiedAttributeValueExp(Object o1, Object o2) 444 { 445 compareAttributeValueExp(o1, o2); 446 } 447 448 public void compareQueryExp(Object o1, Object o2) throws Exception 449 { 450 QueryExp exp1 = (QueryExp )o1; 451 QueryExp exp2 = (QueryExp )o2; 452 453 if (!exp1.apply(null)) throw new RuntimeException (); 454 if (!exp2.apply(null)) throw new RuntimeException (); 455 } 456 457 public void compareReflectionException(Object o1, Object o2) 458 { 459 compareJMException(o1, o2); 460 461 ReflectionException x1 = (ReflectionException )o1; 462 ReflectionException x2 = (ReflectionException )o2; 463 464 Exception xx1 = x1.getTargetException(); 465 Exception xx2 = x2.getTargetException(); 466 compareException(xx1, xx2); 467 } 468 469 public void compareRuntimeErrorException(Object o1, Object o2) 470 { 471 compareJMRuntimeException(o1, o2); 472 473 RuntimeErrorException x1 = (RuntimeErrorException )o1; 474 RuntimeErrorException x2 = (RuntimeErrorException )o2; 475 476 Error e1 = x1.getTargetError(); 477 Error e2 = x2.getTargetError(); 478 compareError(e1, e2); 479 } 480 481 public void compareRuntimeMBeanException(Object o1, Object o2) 482 { 483 compareJMRuntimeException(o1, o2); 484 485 RuntimeMBeanException x1 = (RuntimeMBeanException )o1; 486 RuntimeMBeanException x2 = (RuntimeMBeanException )o2; 487 488 RuntimeException e1 = x1.getTargetException(); 489 RuntimeException e2 = x2.getTargetException(); 490 compareException(e1, e2); 491 } 492 493 public void compareRuntimeOperationsException(Object o1, Object o2) 494 { 495 compareJMRuntimeException(o1, o2); 496 497 RuntimeOperationsException x1 = (RuntimeOperationsException )o1; 498 RuntimeOperationsException x2 = (RuntimeOperationsException )o2; 499 500 RuntimeException e1 = x1.getTargetException(); 501 RuntimeException e2 = x2.getTargetException(); 502 compareException(e1, e2); 503 } 504 505 public void compareServiceNotFoundException(Object o1, Object o2) 506 { 507 compareOperationsException(o1, o2); 508 } 509 510 public void compareStringValueExp(Object o1, Object o2) 511 { 512 StringValueExp s1 = (StringValueExp )o1; 513 StringValueExp s2 = (StringValueExp )o2; 514 if (!s1.getValue().equals(s2.getValue())) throw new RuntimeException (); 515 } 516 517 518 public void compareDescriptorSupport(Object o1, Object o2) 522 { 523 DescriptorSupport s1 = (DescriptorSupport )o1; 524 DescriptorSupport s2 = (DescriptorSupport )o2; 525 526 String [] names1 = s1.getFieldNames(); 527 String [] names2 = s2.getFieldNames(); 528 Object [] values1 = s1.getFieldValues(names1); 529 Object [] values2 = s2.getFieldValues(names2); 530 531 ArrayList list1 = new ArrayList (Arrays.asList(names1)); 532 ArrayList list2 = new ArrayList (Arrays.asList(names2)); 533 if (!list1.containsAll(list2) || !list2.containsAll(list1)) throw new RuntimeException (); 534 535 list1 = new ArrayList (Arrays.asList(values1)); 536 list2 = new ArrayList (Arrays.asList(values2)); 537 if (!list1.containsAll(list2) || !list2.containsAll(list1)) throw new RuntimeException (); 538 } 539 540 public void compareInvalidTargetObjectTypeException(Object o1, Object o2) 541 { 542 } 544 545 public void compareModelMBeanAttributeInfo(Object o1, Object o2) 546 { 547 compareMBeanAttributeInfo(o1, o2); 548 ModelMBeanAttributeInfo a1 = (ModelMBeanAttributeInfo )o1; 549 ModelMBeanAttributeInfo a2 = (ModelMBeanAttributeInfo )o2; 550 compareDescriptorSupport(a1.getDescriptor(), a2.getDescriptor()); 551 } 552 553 public void compareModelMBeanConstructorInfo(Object o1, Object o2) 554 { 555 compareMBeanConstructorInfo(o1, o2); 556 557 ModelMBeanConstructorInfo a1 = (ModelMBeanConstructorInfo )o1; 558 ModelMBeanConstructorInfo a2 = (ModelMBeanConstructorInfo )o2; 559 compareDescriptorSupport(a1.getDescriptor(), a2.getDescriptor()); 560 } 561 562 public void compareModelMBeanInfoSupport(Object o1, Object o2) throws MBeanException 563 { 564 compareMBeanInfo(o1, o2); 565 566 ModelMBeanInfoSupport i1 = (ModelMBeanInfoSupport )o1; 567 ModelMBeanInfoSupport i2 = (ModelMBeanInfoSupport )o2; 568 compareDescriptorSupport(i1.getMBeanDescriptor(), i2.getMBeanDescriptor()); 569 } 570 571 public void compareModelMBeanNotificationInfo(Object o1, Object o2) 572 { 573 compareMBeanNotificationInfo(o1, o2); 574 575 ModelMBeanNotificationInfo n1 = (ModelMBeanNotificationInfo )o1; 576 ModelMBeanNotificationInfo n2 = (ModelMBeanNotificationInfo )o2; 577 compareDescriptorSupport(n1.getDescriptor(), n2.getDescriptor()); 578 } 579 580 public void compareModelMBeanOperationInfo(Object o1, Object o2) 581 { 582 compareMBeanOperationInfo(o1, o2); 583 584 ModelMBeanOperationInfo op1 = (ModelMBeanOperationInfo )o1; 585 ModelMBeanOperationInfo op2 = (ModelMBeanOperationInfo )o2; 586 compareDescriptorSupport(op1.getDescriptor(), op2.getDescriptor()); 587 } 588 589 public void compareXMLParseException(Object o1, Object o2) 590 { 591 } 595 596 597 public void compareMonitorNotification(Object o1, Object o2) 601 { 602 compareNotification(o1, o2); 603 604 MonitorNotification n1 = (MonitorNotification )o1; 605 MonitorNotification n2 = (MonitorNotification )o2; 606 607 if (!n1.getDerivedGauge().equals(n2.getDerivedGauge())) throw new RuntimeException (); 608 if (!n1.getObservedAttribute().equals(n2.getObservedAttribute())) throw new RuntimeException (); 609 if (!n1.getObservedObject().equals(n2.getObservedObject())) throw new RuntimeException (); 610 if (!n1.getTrigger().equals(n2.getTrigger())) throw new RuntimeException (); 611 } 612 613 public void compareMonitorSettingException(Object o1, Object o2) 614 { 615 compareJMRuntimeException(o1, o2); 616 } 617 618 619 public void compareInvalidKeyException(Object o1, Object o2) 623 { 624 compareException(o1, o2); 625 } 626 627 public void compareInvalidOpenTypeException(Object o1, Object o2) 628 { 629 compareException(o1, o2); 630 } 631 632 public void compareKeyAlreadyExistsException(Object o1, Object o2) 633 { 634 compareException(o1, o2); 635 } 636 637 public void compareOpenDataException(Object o1, Object o2) 638 { 639 compareJMException(o1, o2); 640 } 641 642 public void compareInvalidRelationIdException(Object o1, Object o2) 646 { 647 compareRelationException(o1, o2); 648 } 649 650 public void compareInvalidRelationServiceException(Object o1, Object o2) 651 { 652 compareRelationException(o1, o2); 653 } 654 655 public void compareInvalidRelationTypeException(Object o1, Object o2) 656 { 657 compareRelationException(o1, o2); 658 } 659 660 public void compareInvalidRoleInfoException(Object o1, Object o2) 661 { 662 compareRelationException(o1, o2); 663 } 664 665 public void compareInvalidRoleValueException(Object o1, Object o2) 666 { 667 compareRelationException(o1, o2); 668 } 669 670 public void compareMBeanServerNotificationFilter(Object o1, Object o2) 671 { 672 compareNotificationFilterSupport(o1, o2); 673 674 MBeanServerNotificationFilter f1 = (MBeanServerNotificationFilter )o1; 675 MBeanServerNotificationFilter f2 = (MBeanServerNotificationFilter )o2; 676 Vector names1 = null; 677 try 678 { 679 names1 = f1.getEnabledObjectNames(); 680 } 681 catch (NullPointerException ignored) 682 { 683 } 685 Vector names2 = null; 686 try 687 { 688 names2 = f2.getEnabledObjectNames(); 689 } 690 catch (NullPointerException ignored) 691 { 692 } 694 if (names1 != null && (!names1.containsAll(names2) || !names2.containsAll(names1))) throw new RuntimeException (); 695 if (names1 == null && names2 != null) throw new RuntimeException (); 696 697 Vector names3 = null; 698 try 699 { 700 names3 = f1.getDisabledObjectNames(); 701 } 702 catch (NullPointerException ignored) 703 { 704 } 706 Vector names4 = null; 707 try 708 { 709 names4 = f1.getDisabledObjectNames(); 710 } 711 catch (NullPointerException ignored) 712 { 713 } 715 if (names3 != null && (!names3.containsAll(names4) || !names4.containsAll(names3))) throw new RuntimeException (); 716 if (names3 == null && names4 != null) throw new RuntimeException (); 717 } 718 719 public void compareRelationException(Object o1, Object o2) 720 { 721 compareJMException(o1, o2); 722 } 723 724 public void compareRelationNotFoundException(Object o1, Object o2) 725 { 726 compareRelationException(o1, o2); 727 } 728 729 public void compareRelationNotification(Object o1, Object o2) 730 { 731 compareNotification(o1, o2); 732 733 RelationNotification n1 = (RelationNotification )o1; 734 RelationNotification n2 = (RelationNotification )o2; 735 736 if (!n1.getMBeansToUnregister().equals(n2.getMBeansToUnregister())) throw new RuntimeException (); 737 List news1 = n1.getNewRoleValue(); 738 List news2 = n2.getNewRoleValue(); 739 if (news1.size() != news2.size()) throw new RuntimeException (); 740 if (!n1.getObjectName().equals(n2.getObjectName())) throw new RuntimeException (); 741 List olds1 = n1.getOldRoleValue(); 742 List olds2 = n2.getOldRoleValue(); 743 if (olds1.size() != olds2.size()) throw new RuntimeException (); 744 if (!n1.getRelationId().equals(n2.getRelationId())) throw new RuntimeException (); 745 if (!n1.getRelationTypeName().equals(n2.getRelationTypeName())) throw new RuntimeException (); 746 if (!n1.getRoleName().equals(n2.getRoleName())) throw new RuntimeException (); 747 } 748 749 public void compareRelationServiceNotRegisteredException(Object o1, Object o2) 750 { 751 compareRelationException(o1, o2); 752 } 753 754 public void compareRelationTypeNotFoundException(Object o1, Object o2) 755 { 756 compareRelationException(o1, o2); 757 } 758 759 public void compareRelationTypeSupport(Object o1, Object o2) 760 { 761 RelationTypeSupport r1 = (RelationTypeSupport )o1; 762 RelationTypeSupport r2 = (RelationTypeSupport )o2; 763 764 if (!r1.getRelationTypeName().equals(r2.getRelationTypeName())) throw new RuntimeException (); 765 List infos1 = r1.getRoleInfos(); 766 List infos2 = r2.getRoleInfos(); 767 if (infos1.size() != infos2.size()) throw new RuntimeException (); 769 } 770 771 public void compareRole(Object o1, Object o2) 772 { 773 Role r1 = (Role )o1; 774 Role r2 = (Role )o2; 775 776 if (!r1.getRoleName().equals(r2.getRoleName())) throw new RuntimeException (); 777 if (!r1.getRoleValue().equals(r2.getRoleValue())) throw new RuntimeException (); 778 } 779 780 public void compareRoleInfo(Object o1, Object o2) 781 { 782 RoleInfo r1 = (RoleInfo )o1; 783 RoleInfo r2 = (RoleInfo )o2; 784 785 if (!r1.getDescription().equals(r2.getDescription())) throw new RuntimeException (); 786 if (r1.getMaxDegree() != r2.getMaxDegree()) throw new RuntimeException (); 787 if (r1.getMinDegree() != r2.getMinDegree()) throw new RuntimeException (); 788 if (!r1.getName().equals(r2.getName())) throw new RuntimeException (); 789 if (!r1.getRefMBeanClassName().equals(r2.getRefMBeanClassName())) throw new RuntimeException (); 790 if (!r1.isReadable() || !r2.isReadable()) throw new RuntimeException (); 791 if (!r1.isWritable() || !r2.isWritable()) throw new RuntimeException (); 792 } 793 794 public void compareRoleInfoNotFoundException(Object o1, Object o2) 795 { 796 compareRelationException(o1, o2); 797 } 798 799 public void compareRoleList(Object o1, Object o2) 800 { 801 RoleList l1 = (RoleList )o1; 802 RoleList l2 = (RoleList )o2; 803 804 if (l1.size() != l2.size()) throw new RuntimeException (); 806 } 807 808 public void compareRoleNotFoundException(Object o1, Object o2) 809 { 810 compareRelationException(o1, o2); 811 } 812 813 public void compareRoleResult(Object o1, Object o2) 814 { 815 RoleResult r1 = (RoleResult )o1; 816 RoleResult r2 = (RoleResult )o2; 817 818 compareRoleList(r1.getRoles(), r2.getRoles()); 819 compareRoleUnresolvedList(r1.getRolesUnresolved(), r2.getRolesUnresolved()); 820 } 821 822 public void compareRoleUnresolved(Object o1, Object o2) 823 { 824 RoleUnresolved r1 = (RoleUnresolved )o1; 825 RoleUnresolved r2 = (RoleUnresolved )o2; 826 827 if (r1.getProblemType() != r2.getProblemType()) throw new RuntimeException (); 828 if (!r1.getRoleName().equals(r2.getRoleName())) throw new RuntimeException (); 829 if (!r1.getRoleValue().equals(r2.getRoleValue())) throw new RuntimeException (); 830 } 831 832 public void compareRoleUnresolvedList(Object o1, Object o2) 833 { 834 RoleUnresolvedList l1 = (RoleUnresolvedList )o1; 835 RoleUnresolvedList l2 = (RoleUnresolvedList )o2; 836 837 if (l1.size() != l2.size()) throw new RuntimeException (); 839 } 840 841 842 public void compareTimerNotification(Object o1, Object o2) 846 { 847 compareNotification(o1, o2); 848 849 TimerNotification n1 = (TimerNotification )o1; 850 TimerNotification n2 = (TimerNotification )o2; 851 852 if (!n1.getNotificationID().equals(n2.getNotificationID())) throw new RuntimeException (); 853 } 854 } 855 | Popular Tags |