Search in sources :

Example 1 with MethodTimeInterceptor

use of io.leopard.topnb.methodtime.MethodTimeInterceptor in project leopard by tanhaichao.

the class TopnbInterceptorTest method invoke.

// @Test
// public void getContext() {
// Assert.assertNotNull(TopnbInterceptor.getContext("applicationContext.xml"));
// Assert.assertNotNull(TopnbInterceptor.getContext("applicationContext.xml", false));
// Assert.assertNotNull(TopnbInterceptor.getContext("applicationContext.xml", true));
// }
@Test
public void invoke() throws Throwable {
    MethodInvocation invocation = new MethodInvocation() {

        @Override
        public Object[] getArguments() {
            return null;
        }

        @Override
        public AccessibleObject getStaticPart() {
            return null;
        }

        @Override
        public Object getThis() {
            return TopnbInterceptorTest.this;
        }

        @Override
        public Object proceed() throws Throwable {
            return "ok";
        }

        @Override
        public Method getMethod() {
            try {
                return TopnbInterceptorTest.class.getMethod("invoke");
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage(), e);
            }
        }
    };
    Object result = new MethodTimeInterceptor().invoke(invocation);
    Assert.assertEquals("ok", result);
}
Also used : MethodTimeInterceptor(io.leopard.topnb.methodtime.MethodTimeInterceptor) MethodInvocation(org.aopalliance.intercept.MethodInvocation) AccessibleObject(java.lang.reflect.AccessibleObject) Test(org.junit.Test) PerformanceUtilTest(io.leopard.topnb.methodtime.PerformanceUtilTest)

Aggregations

MethodTimeInterceptor (io.leopard.topnb.methodtime.MethodTimeInterceptor)1 PerformanceUtilTest (io.leopard.topnb.methodtime.PerformanceUtilTest)1 AccessibleObject (java.lang.reflect.AccessibleObject)1 MethodInvocation (org.aopalliance.intercept.MethodInvocation)1 Test (org.junit.Test)1