Package org.springframework.jmx

Examples of org.springframework.jmx.JmxTestBean


  protected JmxTestBean target;
 
  protected boolean runTests = true;

  public void onSetUp() throws Exception {
    target = new JmxTestBean();
    target.setAge(100);
    target.setName("Rob Harrop");

    MBeanExporter adapter = new MBeanExporter();
    Map beans = new HashMap();
View Full Code Here


public class MBeanExporterOperationsTests extends AbstractMBeanServerTests {

  public void testRegisterManagedResourceWithUserSuppliedObjectName() throws Exception {
    ObjectName objectName = ObjectNameManager.getInstance("spring:name=Foo");

    JmxTestBean bean = new JmxTestBean();
    bean.setName("Rob Harrop");

    MBeanExporter exporter = new MBeanExporter();
    exporter.setServer(getServer());
    exporter.registerManagedResource(bean, objectName);

    String name = (String) getServer().getAttribute(objectName, "Name");
    assertEquals("Incorrect name on MBean", name, bean.getName());
  }
View Full Code Here

      public ObjectName getObjectName(Object managedBean, String beanKey) {
        return objectNameTemplate;
      }
    });

    JmxTestBean bean1 = new JmxTestBean();
    JmxTestBean bean2 = new JmxTestBean();

    ObjectName reg1 = exporter.registerManagedResource(bean1);
    ObjectName reg2 = exporter.registerManagedResource(bean2);

    assertIsRegistered("Bean 1 not registered with MBeanServer", reg1);
View Full Code Here

      public ObjectName getObjectName(Object managedBean, String beanKey) {
        return objectNameTemplate;
      }
    });

    JmxTestBean bean1 = new JmxTestBean();
    JmxTestBean bean2 = new JmxTestBean();

    ObjectName reg1 = exporter.registerManagedResource(bean1);
    assertIsRegistered("Bean 1 not registered with MBeanServer", reg1);

    try {
View Full Code Here

    return mns;
  }

  public void testWithJdkProxy() throws Exception {
    IJmxTestBean proxy =
        (IJmxTestBean) ProxyFactory.getProxy(IJmxTestBean.class, new SingletonTargetSource(new JmxTestBean()));
    assertEquals(ObjectNameManager.getInstance("spring:bean=test"), getStrategy().getObjectName(proxy, "foo"));
  }
View Full Code Here

        (IJmxTestBean) ProxyFactory.getProxy(IJmxTestBean.class, new SingletonTargetSource(new JmxTestBean()));
    assertEquals(ObjectNameManager.getInstance("spring:bean=test"), getStrategy().getObjectName(proxy, "foo"));
  }

  protected Object getManagedResource() throws Exception {
    return new JmxTestBean();
  }
View Full Code Here

*/
public class NotificationListenerTests extends AbstractMBeanServerTests {

  public void testRegisterNotificationListenerForMBean() 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", 1, listener.getCount(attributeName));
  }

  public void testRegisterNotificationListenerWithWildcard() 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", 1, listener.getCount(attributeName));
  }

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

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

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

    assertEquals("Handback object not transmitted correctly", handback, listener.getLastHandback(attributeName));
  }

  public void testRegisterNotificationListenerForAllMBeans() 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

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.