Search in sources :

Example 1 with JdkDynamicAopProxy

use of cn.taketoday.aop.framework.JdkDynamicAopProxy in project today-framework by TAKETODAY.

the class JdkDynamicAopProxyTests method testProxyIsJustInterface.

@Test
public void testProxyIsJustInterface() {
    TestBean raw = new TestBean();
    raw.setAge(32);
    AdvisedSupport pc = new AdvisedSupport(ITestBean.class);
    pc.setTarget(raw);
    JdkDynamicAopProxy aop = new JdkDynamicAopProxy(pc);
    Object proxy = aop.getProxy();
    boolean condition = proxy instanceof ITestBean;
    assertThat(condition).isTrue();
    boolean condition1 = proxy instanceof TestBean;
    assertThat(condition1).isFalse();
}
Also used : ITestBean(cn.taketoday.beans.testfixture.beans.ITestBean) JdkDynamicAopProxy(cn.taketoday.aop.framework.JdkDynamicAopProxy) TestBean(cn.taketoday.beans.testfixture.beans.TestBean) ITestBean(cn.taketoday.beans.testfixture.beans.ITestBean) AdvisedSupport(cn.taketoday.aop.framework.AdvisedSupport) Test(org.junit.jupiter.api.Test)

Example 2 with JdkDynamicAopProxy

use of cn.taketoday.aop.framework.JdkDynamicAopProxy in project today-framework by TAKETODAY.

the class JdkDynamicAopProxyTests method testEqualsAndHashCodeDefined.

@Test
public void testEqualsAndHashCodeDefined() {
    AdvisedSupport as = new AdvisedSupport(Named.class);
    as.setTarget(new Person());
    JdkDynamicAopProxy aopProxy = new JdkDynamicAopProxy(as);
    Named proxy = (Named) aopProxy.getProxy();
    Named named = new Person();
    assertThat(proxy).isEqualTo(named);
    assertThat(named.hashCode()).isEqualTo(proxy.hashCode());
}
Also used : JdkDynamicAopProxy(cn.taketoday.aop.framework.JdkDynamicAopProxy) AdvisedSupport(cn.taketoday.aop.framework.AdvisedSupport) Test(org.junit.jupiter.api.Test)

Aggregations

AdvisedSupport (cn.taketoday.aop.framework.AdvisedSupport)2 JdkDynamicAopProxy (cn.taketoday.aop.framework.JdkDynamicAopProxy)2 Test (org.junit.jupiter.api.Test)2 ITestBean (cn.taketoday.beans.testfixture.beans.ITestBean)1 TestBean (cn.taketoday.beans.testfixture.beans.TestBean)1