Package org.springframework.jmx

Examples of org.springframework.jmx.JmxTestBean


    assertEquals("Listener not notified", 1, listener.getCount(attributeName));
  }

  public void testRegisterNotificationListenerWithFilter() throws Exception {
    ObjectName objectName = ObjectName.getInstance("spring:name=Test");
    JmxTestBean bean = new JmxTestBean();

    Map beans = new HashMap();
    beans.put(objectName, bean);

    CountingAttributeChangeNotificationListener listener = new CountingAttributeChangeNotificationListener();
View Full Code Here


    assertEquals("Listener not notified for testBean2", 2, listener.getCount("Age"));
  }

  public void testNotificationListenerRegistrar() throws Exception {
    ObjectName objectName = ObjectName.getInstance("spring:name=Test");
    JmxTestBean bean = new JmxTestBean();

    Map beans = new HashMap();
    beans.put(objectName, bean);

    MBeanExporter exporter = new MBeanExporter();
View Full Code Here

  }

  public void testNotificationListenerRegistrarWithMultipleNames() throws Exception {
    ObjectName objectName = ObjectName.getInstance("spring:name=Test");
    ObjectName objectName2 = ObjectName.getInstance("spring:name=Test2");
    JmxTestBean bean = new JmxTestBean();
    JmxTestBean bean2 = new JmxTestBean();

    Map beans = new HashMap();
    beans.put(objectName, bean);
    beans.put(objectName2, bean2);
View Full Code Here

    assertListener(listener1);
    assertListener(listener2);
  }

  public void testExportJdkProxy() throws Exception {
    JmxTestBean bean = new JmxTestBean();
    bean.setName("Rob Harrop");

    ProxyFactory factory = new ProxyFactory();
    factory.setTarget(bean);
    factory.addAdvice(new NopInterceptor());
    factory.setInterfaces(new Class[]{IJmxTestBean.class});
View Full Code Here

  public void testWithExposeClassLoader() throws Exception {
    String name = "Rob Harrop";
    String otherName = "Juergen Hoeller";

    JmxTestBean bean = new JmxTestBean();
    bean.setName(name);
    ObjectName objectName = ObjectNameManager.getInstance("spring:type=Test");

    Map beans = new HashMap();
    beans.put(objectName.toString(), bean);

    MBeanExporter exporter = new MBeanExporter();
    exporter.setServer(getServer());
    exporter.setBeans(beans);
    exporter.setExposeManagedResourceClassLoader(true);
    exporter.afterPropertiesSet();

    assertIsRegistered("Bean instance not registered", objectName);

    Object result = server.invoke(objectName, "add",
        new Object[]{new Integer(2), new Integer(3)},
        new String[]{int.class.getName(), int.class.getName()});

    assertEquals("Incorrect result return from add", result, new Integer(5));
    assertEquals("Incorrect attribute value", name, server.getAttribute(objectName, "Name"));

    server.setAttribute(objectName, new Attribute("Name", otherName));
    assertEquals("Incorrect updated name.", otherName, bean.getName());
  }
View Full Code Here

  }
 

  private Map getBeanMap() {
    Map map = new HashMap();
    map.put(OBJECT_NAME, new JmxTestBean());
    return map;
  }
View Full Code Here

    DynamicMBean mbean = new TestDynamicMBean();
    assertTrue("Dynamic MBean not detected correctly", JmxUtils.isMBean(mbean.getClass()));
  }

  public void testIsMBeanWithStandardMBeanWrapper() throws Exception {
    StandardMBean mbean = new StandardMBean(new JmxTestBean(), IJmxTestBean.class);
    assertTrue("Standard MBean not detected correctly", JmxUtils.isMBean(mbean.getClass()));
  }
View Full Code Here

  protected int getExpectedOperationCount() {
    return 7;
  }

  protected IJmxTestBean createJmxTestBean() {
    return new JmxTestBean();
  }
View Full Code Here

  public void testAutodetect() throws Exception {
    if(Attributes.getAttributes(JmxTestBean.class).size() == 0) {
      return;
    }
    JmxTestBean bean = new JmxTestBean();

    AutodetectCapableMBeanInfoAssembler assembler = getAssembler();
    assertTrue("The bean should be included", assembler.includeBean(bean.getClass(), "testBean"));
  }
View Full Code Here

  }

  @Test
  public void testRegisterNotificationListenerWithHandback() throws Exception {
    String objectName = "spring:name=Test";
    JmxTestBean bean = new JmxTestBean();

    Map<String, Object> beans = new HashMap<String, Object>();
    beans.put(objectName, bean);

    CountingAttributeChangeNotificationListener listener = new CountingAttributeChangeNotificationListener();
View Full Code Here

TOP

Related Classes of org.springframework.jmx.JmxTestBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.