/**
   * Tests correct MBean interface.
   *
   * @throws Exception Thrown if test fails.
   */
  public void testMissedNameMBeanInfo() throws Exception {
    try {
      StandardMBean mbean =
          new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterfaceBad.class);

      mbean.getMBeanInfo();
    } catch (AssertionError e) {
      return;
    }

    assert false;
  }
  /**
   * Tests correct MBean interface.
   *
   * @throws Exception Thrown if test fails.
   */
  public void testCorrectMBeanInfo() throws Exception {
    StandardMBean mbean =
        new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterface.class);

    MBeanInfo info = mbean.getMBeanInfo();

    assert info.getDescription().equals("MBeanDescription.") == true;

    assert info.getOperations().length == 2;

    for (MBeanOperationInfo opInfo : info.getOperations()) {
      if (opInfo.getDescription().equals("MBeanOperation."))
        assert opInfo.getSignature().length == 2;
      else {
        assert opInfo.getDescription().equals("MBeanSuperOperation.") == true;
        assert opInfo.getSignature().length == 1;
      }
    }

    for (MBeanParameterInfo paramInfo : info.getOperations()[0].getSignature()) {
      if (paramInfo.getName().equals("ignored"))
        assert paramInfo.getDescription().equals("MBeanOperationParameter1.") == true;
      else {
        assert paramInfo.getName().equals("someData") == true;
        assert paramInfo.getDescription().equals("MBeanOperationParameter2.") == true;
      }
    }

    assert info.getAttributes().length == 4
        : "Expected 4 attributes but got " + info.getAttributes().length;

    for (MBeanAttributeInfo attrInfo : info.getAttributes()) {
      if (attrInfo.isWritable() == false) {
        assert (attrInfo.getDescription().equals("MBeanReadonlyGetter.") == true
            || attrInfo.getDescription().equals("MBeanROGetter."));
      } else {
        assert (attrInfo.getDescription().equals("MBeanWritableGetter.") == true
            || attrInfo.getDescription().equals("MBeanWritableIsGetter."));
      }
    }
  }
示例#3
0
 public void cacheMBeanInfo(MBeanInfo mbi) {
   if (mbi != null) mbi = new ExoticMBeanInfo(mbi);
   super.cacheMBeanInfo(mbi);
 }