コード例 #1
0
  @Test
  public void testBeanInfoFromImpl() {
    ManagedBeanDefinition definition = new ManagedBeanDefinition();
    definition.setType(HelloBeanImpl.class);
    MBeanInfo info = definition.createMBeanInfo();

    Assert.assertEquals(info.getClassName(), "com.consol.citrus.jmx.mbean.HelloBeanImpl");
    Assert.assertEquals(info.getAttributes().length, 1);
    Assert.assertEquals(info.getAttributes()[0].getType(), String.class.getName());
    Assert.assertEquals(info.getAttributes()[0].getName(), "helloMessage");
    Assert.assertEquals(info.getOperations().length, 1);
    Assert.assertEquals(info.getOperations()[0].getName(), "hello");
    Assert.assertEquals(info.getOperations()[0].getSignature().length, 1);
    Assert.assertEquals(
        info.getOperations()[0].getSignature()[0].getType(), String.class.getName());
    Assert.assertEquals(info.getOperations()[0].getSignature()[0].getName(), "p1");
    Assert.assertEquals(info.getOperations()[0].getReturnType(), String.class.getName());

    definition.setType(NewsBeanImpl.class);
    info = definition.createMBeanInfo();

    Assert.assertEquals(info.getClassName(), "com.consol.citrus.jmx.mbean.NewsBeanImpl");
    Assert.assertEquals(info.getAttributes().length, 1);
    Assert.assertEquals(info.getAttributes()[0].getType(), String.class.getName());
    Assert.assertEquals(info.getAttributes()[0].getName(), "news");
    Assert.assertEquals(info.getOperations().length, 0);
  }
コード例 #2
0
  @Test
  public void testObjectName() {
    ManagedBeanDefinition definition = new ManagedBeanDefinition();
    definition.setType(HelloBean.class);
    ObjectName objectName = definition.createObjectName();

    Assert.assertEquals(objectName.toString(), "com.consol.citrus.jmx.mbean:type=HelloBean");

    definition = new ManagedBeanDefinition();
    definition.setObjectDomain(HelloBean.class.getPackage().getName());
    definition.setObjectName("type=HelloBean,name=Hello");
    objectName = definition.createObjectName();

    Assert.assertEquals(
        objectName.toString(), "com.consol.citrus.jmx.mbean:type=HelloBean,name=Hello");

    definition = new ManagedBeanDefinition();
    definition.setObjectDomain(HelloBean.class.getPackage().getName());
    definition.setName(HelloBean.class.getSimpleName());
    objectName = definition.createObjectName();

    Assert.assertEquals(objectName.toString(), "com.consol.citrus.jmx.mbean:name=HelloBean");
  }