Search in sources :

Example 61 with NopInterceptor

use of org.springframework.tests.aop.interceptor.NopInterceptor in project spring-framework by spring-projects.

the class AbstractMetadataAssemblerTests method testWithCglibProxy.

@Test
public void testWithCglibProxy() throws Exception {
    IJmxTestBean tb = createJmxTestBean();
    ProxyFactory pf = new ProxyFactory();
    pf.setTarget(tb);
    pf.addAdvice(new NopInterceptor());
    Object proxy = pf.getProxy();
    MetadataMBeanInfoAssembler assembler = (MetadataMBeanInfoAssembler) getAssembler();
    MBeanExporter exporter = new MBeanExporter();
    exporter.setBeanFactory(getContext());
    exporter.setAssembler(assembler);
    String objectName = "spring:bean=test,proxy=true";
    Map<String, Object> beans = new HashMap<>();
    beans.put(objectName, proxy);
    exporter.setBeans(beans);
    start(exporter);
    MBeanInfo inf = getServer().getMBeanInfo(ObjectNameManager.getInstance(objectName));
    assertEquals("Incorrect number of operations", getExpectedOperationCount(), inf.getOperations().length);
    assertEquals("Incorrect number of attributes", getExpectedAttributeCount(), inf.getAttributes().length);
    assertTrue("Not included in autodetection", assembler.includeBean(proxy.getClass(), "some bean name"));
}
Also used : NopInterceptor(org.springframework.tests.aop.interceptor.NopInterceptor) MBeanInfo(javax.management.MBeanInfo) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) ProxyFactory(org.springframework.aop.framework.ProxyFactory) HashMap(java.util.HashMap) MBeanExporter(org.springframework.jmx.export.MBeanExporter) IJmxTestBean(org.springframework.jmx.IJmxTestBean) Test(org.junit.Test)

Aggregations

NopInterceptor (org.springframework.tests.aop.interceptor.NopInterceptor)61 Test (org.junit.Test)57 ITestBean (org.springframework.tests.sample.beans.ITestBean)40 SerializableNopInterceptor (org.springframework.tests.aop.interceptor.SerializableNopInterceptor)34 TestBean (org.springframework.tests.sample.beans.TestBean)34 DefaultPointcutAdvisor (org.springframework.aop.support.DefaultPointcutAdvisor)14 CountingBeforeAdvice (org.springframework.tests.aop.advice.CountingBeforeAdvice)13 DefaultIntroductionAdvisor (org.springframework.aop.support.DefaultIntroductionAdvisor)11 Advisor (org.springframework.aop.Advisor)10 StaticMethodMatcherPointcutAdvisor (org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor)7 Method (java.lang.reflect.Method)6 LockMixinAdvisor (test.mixin.LockMixinAdvisor)6 LockedException (test.mixin.LockedException)5 IOException (java.io.IOException)4 SQLException (java.sql.SQLException)4 ProxyFactory (org.springframework.aop.framework.ProxyFactory)4 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)4 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)4 CountingAfterReturningAdvice (org.springframework.tests.aop.advice.CountingAfterReturningAdvice)4 FileNotFoundException (java.io.FileNotFoundException)3