Search in sources :

Example 1 with IJmxTestBean

use of cn.taketoday.jmx.IJmxTestBean in project today-infrastructure by TAKETODAY.

the class MBeanClientInterceptorTests method invokeUnexposedMethodWithException.

@Test
void invokeUnexposedMethodWithException() throws Exception {
    assumeTrue(runTests);
    IJmxTestBean bean = getProxy();
    assertThatExceptionOfType(InvalidInvocationException.class).isThrownBy(() -> bean.dontExposeMe());
}
Also used : IJmxTestBean(cn.taketoday.jmx.IJmxTestBean) Test(org.junit.jupiter.api.Test)

Example 2 with IJmxTestBean

use of cn.taketoday.jmx.IJmxTestBean in project today-infrastructure by TAKETODAY.

the class MBeanClientInterceptorTests method proxyClassIsDifferent.

@Test
void proxyClassIsDifferent() throws Exception {
    assumeTrue(runTests);
    IJmxTestBean proxy = getProxy();
    assertThat(proxy.getClass()).as("The proxy class should be different than the base class").isNotSameAs(IJmxTestBean.class);
}
Also used : IJmxTestBean(cn.taketoday.jmx.IJmxTestBean) Test(org.junit.jupiter.api.Test)

Example 3 with IJmxTestBean

use of cn.taketoday.jmx.IJmxTestBean in project today-infrastructure by TAKETODAY.

the class MBeanClientInterceptorTests method getAttributeValue.

@Test
void getAttributeValue() throws Exception {
    assumeTrue(runTests);
    IJmxTestBean proxy1 = getProxy();
    int age = proxy1.getAge();
    assertThat(age).as("The age should be 100").isEqualTo(100);
}
Also used : IJmxTestBean(cn.taketoday.jmx.IJmxTestBean) Test(org.junit.jupiter.api.Test)

Example 4 with IJmxTestBean

use of cn.taketoday.jmx.IJmxTestBean in project today-infrastructure by TAKETODAY.

the class MBeanClientInterceptorTests method setAttributeValueWithCheckedException.

@Test
void setAttributeValueWithCheckedException() throws Exception {
    assumeTrue(runTests);
    IJmxTestBean proxy = getProxy();
    assertThatExceptionOfType(ClassNotFoundException.class).isThrownBy(() -> proxy.setName("Juergen Class"));
}
Also used : IJmxTestBean(cn.taketoday.jmx.IJmxTestBean) Test(org.junit.jupiter.api.Test)

Example 5 with IJmxTestBean

use of cn.taketoday.jmx.IJmxTestBean in project today-infrastructure by TAKETODAY.

the class MBeanClientInterceptorTests method setAttributeValue.

@Test
void setAttributeValue() throws Exception {
    assumeTrue(runTests);
    IJmxTestBean proxy = getProxy();
    proxy.setName("Rob Harrop");
    assertThat(target.getName()).as("The name of the bean should have been updated").isEqualTo("Rob Harrop");
}
Also used : IJmxTestBean(cn.taketoday.jmx.IJmxTestBean) Test(org.junit.jupiter.api.Test)

Aggregations

IJmxTestBean (cn.taketoday.jmx.IJmxTestBean)38 Test (org.junit.jupiter.api.Test)36 ModelMBeanInfo (javax.management.modelmbean.ModelMBeanInfo)8 MBeanInfo (javax.management.MBeanInfo)6 NopInterceptor (cn.taketoday.aop.NopInterceptor)4 ProxyFactory (cn.taketoday.aop.framework.ProxyFactory)4 HashMap (java.util.HashMap)4 ObjectName (javax.management.ObjectName)4 JmxTestBean (cn.taketoday.jmx.JmxTestBean)2 MBeanExporter (cn.taketoday.jmx.export.MBeanExporter)2 BindException (java.net.BindException)2 Attribute (javax.management.Attribute)2 JMXConnectorServer (javax.management.remote.JMXConnectorServer)2 JMXServiceURL (javax.management.remote.JMXServiceURL)2