use of org.springframework.aop.testfixture.interceptor.TimestampIntroductionInterceptor in project spring-framework by spring-projects.
the class AbstractAopProxyTests method testUseAsHashKey.
@Test
public void testUseAsHashKey() {
TestBean target1 = new TestBean();
ProxyFactory pf1 = new ProxyFactory(target1);
pf1.addAdvice(new NopInterceptor());
ITestBean proxy1 = (ITestBean) createProxy(pf1);
TestBean target2 = new TestBean();
ProxyFactory pf2 = new ProxyFactory(target2);
pf2.addAdvisor(new DefaultIntroductionAdvisor(new TimestampIntroductionInterceptor()));
ITestBean proxy2 = (ITestBean) createProxy(pf2);
HashMap<ITestBean, Object> h = new HashMap<>();
Object value1 = "foo";
Object value2 = "bar";
assertThat(h.get(proxy1)).isNull();
h.put(proxy1, value1);
h.put(proxy2, value2);
assertThat(value1).isEqualTo(h.get(proxy1));
assertThat(value2).isEqualTo(h.get(proxy2));
}
use of org.springframework.aop.testfixture.interceptor.TimestampIntroductionInterceptor in project spring-framework by spring-projects.
the class AbstractAopProxyTests method testValuesStick.
/**
* Simple test that if we set values we can get them out again.
*/
@Test
public void testValuesStick() {
int age1 = 33;
int age2 = 37;
String name = "tony";
TestBean target1 = new TestBean();
target1.setAge(age1);
ProxyFactory pf1 = new ProxyFactory(target1);
pf1.addAdvisor(new DefaultPointcutAdvisor(new NopInterceptor()));
pf1.addAdvisor(new DefaultPointcutAdvisor(new TimestampIntroductionInterceptor()));
ITestBean tb = (ITestBean) pf1.getProxy();
assertThat(tb.getAge()).isEqualTo(age1);
tb.setAge(age2);
assertThat(tb.getAge()).isEqualTo(age2);
assertThat(tb.getName()).isNull();
tb.setName(name);
assertThat(tb.getName()).isEqualTo(name);
}
Aggregations