Package org.springframework.jmx

Examples of org.springframework.jmx.JmxTestBean


  }

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

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

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


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

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

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

  }

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

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

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

  @Test
  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<String, Object> beans = new HashMap<String, Object>();
    beans.put(objectName.getCanonicalName(), bean);
    beans.put(objectName2.getCanonicalName(), bean2);
View Full Code Here

* @author Rob Harrop
*/
public class IdentityNamingStrategyTests extends TestCase {

  public void testNaming() throws MalformedObjectNameException {
    JmxTestBean bean = new JmxTestBean();
    IdentityNamingStrategy strategy = new IdentityNamingStrategy();
    ObjectName objectName = strategy.getObjectName(bean, "null");
    assertEquals("Domain is incorrect", bean.getClass().getPackage().getName(),
        objectName.getDomain());
    assertEquals("Type property is incorrect", ClassUtils.getShortName(bean.getClass()),
        objectName.getKeyProperty(IdentityNamingStrategy.TYPE_KEY));
    assertEquals("HashCode property is incorrect", ObjectUtils.getIdentityHexString(bean),
        objectName.getKeyProperty(IdentityNamingStrategy.HASH_CODE_KEY));
  }
View Full Code Here

  }


  @Test
  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(IJmxTestBean.class);
View Full Code Here

  @Test
  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<String, Object> beans = new HashMap<String, Object>();
    beans.put(objectName.toString(), bean);

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

    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

    return new ClassPathXmlApplicationContext(context, getClass());
  }

  private Map<String, Object> getBeanMap() {
    Map<String, Object> map = new HashMap<String, Object>();
    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 boolean runTests = true;

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

    MBeanExporter adapter = new MBeanExporter();
    Map<String, Object> beans = new HashMap<String, Object>();
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.