Search in sources :

Example 21 with IJmxTestBean

use of org.springframework.jmx.IJmxTestBean in project spring-framework by spring-projects.

the class AbstractJmxAssemblerTests method testRegisterOperations.

@Test
public void testRegisterOperations() throws Exception {
    IJmxTestBean bean = getBean();
    assertThat(bean).isNotNull();
    MBeanInfo inf = getMBeanInfo();
    assertThat(inf.getOperations()).as("Incorrect number of operations registered").hasSize(getExpectedOperationCount());
}
Also used : MBeanInfo(javax.management.MBeanInfo) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) IJmxTestBean(org.springframework.jmx.IJmxTestBean) Test(org.junit.jupiter.api.Test)

Example 22 with IJmxTestBean

use of org.springframework.jmx.IJmxTestBean in project spring-framework by spring-projects.

the class AbstractJmxAssemblerTests method getMBeanInfoFromAssembler.

protected ModelMBeanInfo getMBeanInfoFromAssembler() throws Exception {
    IJmxTestBean bean = getBean();
    ModelMBeanInfo info = getAssembler().getMBeanInfo(bean, getObjectName());
    return info;
}
Also used : IJmxTestBean(org.springframework.jmx.IJmxTestBean) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo)

Example 23 with IJmxTestBean

use of org.springframework.jmx.IJmxTestBean in project spring-framework by spring-projects.

the class AbstractJmxAssemblerTests method testSetAttribute.

@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");
    assertThat(bean.getName()).isEqualTo("Rob Harrop");
}
Also used : Attribute(javax.management.Attribute) IJmxTestBean(org.springframework.jmx.IJmxTestBean) ObjectName(javax.management.ObjectName) Test(org.junit.jupiter.api.Test)

Example 24 with IJmxTestBean

use of org.springframework.jmx.IJmxTestBean in project spring-framework by spring-projects.

the class AbstractJmxAssemblerTests method testRegisterAttributes.

@Test
public void testRegisterAttributes() throws Exception {
    IJmxTestBean bean = getBean();
    assertThat(bean).isNotNull();
    MBeanInfo inf = getMBeanInfo();
    assertThat(inf.getAttributes()).as("Incorrect number of attributes registered").hasSize(getExpectedAttributeCount());
}
Also used : MBeanInfo(javax.management.MBeanInfo) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) IJmxTestBean(org.springframework.jmx.IJmxTestBean) Test(org.junit.jupiter.api.Test)

Example 25 with IJmxTestBean

use of org.springframework.jmx.IJmxTestBean in project spring-framework by spring-projects.

the class MBeanClientInterceptorTests method setAttributeValueWithIOException.

@Test
void setAttributeValueWithIOException() throws Exception {
    assumeTrue(runTests);
    IJmxTestBean proxy = getProxy();
    assertThatIOException().isThrownBy(() -> proxy.setName("Juergen IO"));
}
Also used : IJmxTestBean(org.springframework.jmx.IJmxTestBean) Test(org.junit.jupiter.api.Test)

Aggregations

IJmxTestBean (org.springframework.jmx.IJmxTestBean)32 Test (org.junit.jupiter.api.Test)18 Test (org.junit.Test)13 ModelMBeanInfo (javax.management.modelmbean.ModelMBeanInfo)4 MBeanInfo (javax.management.MBeanInfo)3 BindException (java.net.BindException)2 HashMap (java.util.HashMap)2 ObjectName (javax.management.ObjectName)2 JMXConnectorServer (javax.management.remote.JMXConnectorServer)2 JMXServiceURL (javax.management.remote.JMXServiceURL)2 ProxyFactory (org.springframework.aop.framework.ProxyFactory)2 NopInterceptor (org.springframework.aop.testfixture.interceptor.NopInterceptor)2 Attribute (javax.management.Attribute)1 JmxException (org.springframework.jmx.JmxException)1 JmxTestBean (org.springframework.jmx.JmxTestBean)1 MBeanExporter (org.springframework.jmx.export.MBeanExporter)1