@Test
    public void getProxy() throws Exception {
        JavassistProxy proxy = new JavassistProxy();
        AbstractTestClass testClass = null;
        try {
            testClass = proxy.getProxy(AbstractTestClass.class, new TestInvoker());
        } catch (Exception e) {
            LOGGER.info(e.getMessage());
        }
        Assert.assertNull(testClass);

        TestInvoker invoker = new TestInvoker();
        TestInterface testInterface = proxy.getProxy(TestInterface.class, invoker);
        Assert.assertNotNull(testInterface);

        Class clazz = testInterface.getClass().getInterfaces()[0];
        Assert.assertEquals(TestInterface.class, clazz);

        Assert.assertTrue(Proxy.class.isAssignableFrom(testInterface.getClass()));
        Assert.assertFalse(Proxy.isProxyClass(testInterface.getClass()));

        Assert.assertEquals(proxy.getInvoker(testInterface).getClass(), TestInvoker.class);
        Assert.assertEquals(testInterface.toString(), invoker.toString());
        Assert.assertEquals(testInterface.hashCode(), invoker.hashCode());

        TestInterface another1 = proxy.getProxy(TestInterface.class, invoker);
        TestInterface another2 = proxy.getProxy(TestInterface.class, new TestInvoker());
        Assert.assertFalse(testInterface.equals(invoker));
        Assert.assertFalse(testInterface.equals(another2));
        Assert.assertEquals(testInterface, another1);

        Assert.assertEquals(678, another1.sayNum(true));
        SofaRequest request = invoker.getRequest();
        Assert.assertEquals(TestInterface.class.getCanonicalName(), request.getInterfaceName());
        Assert.assertEquals("sayNum", request.getMethodName());
        Assert.assertEquals("boolean", request.getMethodArgSigs()[0]);
        Assert.assertEquals(true, request.getMethodArgs()[0]);
        Assert.assertNotNull(request.getMethod());

        Assert.assertEquals("sayHello", another1.sayHello("xxxx"));
        another1.sayNoting();
        Assert.assertArrayEquals(new int[] { 6, 7, 8 }, another1.sayNums(null, new HashMap()));
        Assert.assertNull(another1.sayNum2(1.2D));

        boolean error = false;
        try {
            another1.throwbiz1();
        } catch (Throwable e) {
            error = true;
        }
        Assert.assertFalse(error);

        error = false;
        try {
            another1.throwbiz2();
        } catch (Throwable e) {
            error = true;
        }
        Assert.assertFalse(error);

        try {
            another1.throwRPC();
        } catch (Throwable e) {
            error = true;
        }
        Assert.assertTrue(error);
    }
@author <a href="mailto:zhanggeng.zg@antfin.com">GengZhang</a>
core-impl/proxy/src/test/java/com/alipay/sofa/rpc/proxy/javassist/JavassistProxyTest.java