Examples of IJmxTestBean


Examples of org.springframework.jmx.IJmxTestBean

  @Test
  public void testSetAttributeValueWithIOException() throws Exception {
    if (!runTests)
      return;
    IJmxTestBean proxy = getProxy();
    try {
      proxy.setName("Juergen IO");
      fail("Should have thrown IOException");
    } catch (IOException ex) {
      // expected
    }
  }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

  @Test
  public void testSetReadOnlyAttribute() throws Exception {
    if (!runTests)
      return;
    IJmxTestBean proxy = getProxy();
    try {
      proxy.setAge(900);
      fail("Should not be able to write to a read only attribute");
    } catch (InvalidInvocationException ex) {
      // success
    }
  }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

  @Test
  public void testInvokeNoArgs() throws Exception {
    if (!runTests)
      return;
    IJmxTestBean proxy = getProxy();
    long result = proxy.myOperation();
    assertEquals("The operation should return 1", 1, result);
  }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

  @Test
  public void testInvokeArgs() throws Exception {
    if (!runTests)
      return;
    IJmxTestBean proxy = getProxy();
    int result = proxy.add(1, 2);
    assertEquals("The operation should return 3", 3, result);
  }
View Full Code Here

Examples of org.springframework.jmx.IJmxTestBean

  @Test
  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

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

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

Examples of org.springframework.jmx.IJmxTestBean

        getExpectedOperationCount(), inf.getOperations().length);
  }

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

Examples of org.springframework.jmx.IJmxTestBean

  @Test
  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
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.