Examples of IJmxTestBean


Examples of org.springframework.jmx.IJmxTestBean

    assertEquals("The operation should return 3", 3, result);
  }

  public void testInvokeUnexposedMethodWithException() throws Exception {
    if (!runTests) return;
    IJmxTestBean bean = getProxy();
    try {
      bean.dontExposeMe();
      fail("Method dontExposeMe should throw an exception");
    }
    catch (InvalidInvocationException desired) {
      // success
    }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

    factory.setObjectName(OBJECT_NAME);
    factory.setConnectOnStartup(false);
    factory.setRefreshOnConnectFailure(true);
    // should skip connection to the server
    factory.afterPropertiesSet();
    IJmxTestBean bean = (IJmxTestBean) factory.getObject();

    // now start the connector
    try {
      connector.start();
    }
    catch (BindException ex) {
      // couldn't bind to local port 9876 - let's skip the remainder of this test
      System.out.println(
          "Skipping JMX LazyConnectionToRemote test because binding to local port 9876 failed: " +
          ex.getMessage());
      return;
    }

    // should now be able to access data via the lazy proxy
    try {
      assertEquals("Rob Harrop", bean.getName());
      assertEquals(100, bean.getAge());
    }
    finally {
      connector.stop();
    }

    try {
      bean.getName();
    }
    catch (JmxException ex) {
      // expected
    }

    connector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, getServer());
    connector.start();

    // should now be able to access data via the lazy proxy
    try {
      assertEquals("Rob Harrop", bean.getName());
      assertEquals(100, bean.getAge());
    }
    finally {
      connector.stop();
    }
  }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

  public void testProxyFactory() throws Exception {
    MBeanProxyFactoryBean fb = getProxyFactory();
    fb.setProxyInterface(IJmxTestBean.class);
    fb.afterPropertiesSet();

    IJmxTestBean bean = (IJmxTestBean) fb.getObject();
    assertNotNull("Proxy should not be null", bean);
  }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

  public void testWithLocatedMBeanServer() throws Exception {
    MBeanProxyFactoryBean fb = new MBeanProxyFactoryBean();
    fb.setProxyInterface(IJmxTestBean.class);
    fb.setObjectName(OBJECT_NAME);
    fb.afterPropertiesSet();
    IJmxTestBean proxy = (IJmxTestBean)fb.getObject();
    assertNotNull("Proxy should not be null", proxy);
    assertEquals("Incorrect name value", "TEST", proxy.getName());
  }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

    mns.setAttributeSource(new AttributesJmxAttributeSource(new CommonsAttributes()));
    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

Examples of org.springframework.jmx.IJmxTestBean

    ObjectInstance instance = getObjectInstance();
    assertNotNull("Bean should not be null", instance);
  }

  public void testRegisterOperations() throws Exception {
    IJmxTestBean bean = getBean();
    MBeanInfo inf = getMBeanInfo();
    assertEquals("Incorrect number of operations registered",
        getExpectedOperationCount(), inf.getOperations().length);
  }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

    assertEquals("Incorrect number of operations registered",
        getExpectedOperationCount(), inf.getOperations().length);
  }

  public void testRegisterAttributes() throws Exception {
    IJmxTestBean bean = getBean();
    MBeanInfo inf = getMBeanInfo();
    assertEquals("Incorrect number of attributes registered",
        getExpectedAttributeCount(), inf.getAttributes().length);
  }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

  }

  public void testSetAttribute() throws Exception {
    ObjectName objectName = ObjectNameManager.getInstance(getObjectName());
    getServer().setAttribute(objectName, new Attribute(NAME_ATTRIBUTE, "Rob Harrop"));
    IJmxTestBean bean = (IJmxTestBean) getContext().getBean("testBean");
    assertEquals("Rob Harrop", bean.getName());
  }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

    assertEquals("Notification type.foo not found", "type.foo", notifTypes[0]);
    assertEquals("Notification type.bar not found", "type.bar", notifTypes[1]);
  }

  protected ModelMBeanInfo getMBeanInfoFromAssembler() throws Exception {
    IJmxTestBean bean = getBean();
    ModelMBeanInfo info = getAssembler().getMBeanInfo(bean, getObjectName());
    return info;
  }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

  protected String getApplicationContextPath() {
    return "org/springframework/jmx/export/propertyPlaceholderConfigurer.xml";
  }

  public void testPropertiesReplaced() {
    IJmxTestBean bean = (IJmxTestBean) getContext().getBean("testBean");

    assertEquals("Name is incorrect", "Rob Harrop", bean.getName());
    assertEquals("Age is incorrect", 100, bean.getAge());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.