Search in sources :

Example 16 with TimeStamped

use of org.springframework.tests.TimeStamped in project spring-framework by spring-projects.

the class AbstractAopProxyTests method testAdviceImplementsIntroductionInfo.

@Test
public void testAdviceImplementsIntroductionInfo() throws Throwable {
    TestBean tb = new TestBean();
    String name = "tony";
    tb.setName(name);
    ProxyFactory pc = new ProxyFactory(tb);
    NopInterceptor di = new NopInterceptor();
    pc.addAdvice(di);
    final long ts = 37;
    pc.addAdvice(new DelegatingIntroductionInterceptor(new TimeStamped() {

        @Override
        public long getTimeStamp() {
            return ts;
        }
    }));
    ITestBean proxied = (ITestBean) createProxy(pc);
    assertEquals(name, proxied.getName());
    TimeStamped intro = (TimeStamped) proxied;
    assertEquals(ts, intro.getTimeStamp());
}
Also used : DelegatingIntroductionInterceptor(org.springframework.aop.support.DelegatingIntroductionInterceptor) TimeStamped(org.springframework.tests.TimeStamped) ITestBean(org.springframework.tests.sample.beans.ITestBean) SerializableNopInterceptor(org.springframework.tests.aop.interceptor.SerializableNopInterceptor) NopInterceptor(org.springframework.tests.aop.interceptor.NopInterceptor) ITestBean(org.springframework.tests.sample.beans.ITestBean) TestBean(org.springframework.tests.sample.beans.TestBean) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 TimeStamped (org.springframework.tests.TimeStamped)16 ITestBean (org.springframework.tests.sample.beans.ITestBean)14 TestBean (org.springframework.tests.sample.beans.TestBean)11 ProxyFactory (org.springframework.aop.framework.ProxyFactory)8 INestedTestBean (org.springframework.tests.sample.beans.INestedTestBean)7 NestedTestBean (org.springframework.tests.sample.beans.NestedTestBean)7 DefaultIntroductionAdvisor (org.springframework.aop.support.DefaultIntroductionAdvisor)4 NopInterceptor (org.springframework.tests.aop.interceptor.NopInterceptor)3 DebugInterceptor (org.springframework.aop.interceptor.DebugInterceptor)2 DelegatingIntroductionInterceptor (org.springframework.aop.support.DelegatingIntroductionInterceptor)2 SerializableNopInterceptor (org.springframework.tests.aop.interceptor.SerializableNopInterceptor)2 Lockable (test.mixin.Lockable)2 LockedException (test.mixin.LockedException)2 MethodInterceptor (org.aopalliance.intercept.MethodInterceptor)1 IntroductionAdvisor (org.springframework.aop.IntroductionAdvisor)1 IntroductionInterceptor (org.springframework.aop.IntroductionInterceptor)1 TimestampIntroductionInterceptor (org.springframework.tests.aop.interceptor.TimestampIntroductionInterceptor)1 IOther (org.springframework.tests.sample.beans.IOther)1 Person (org.springframework.tests.sample.beans.Person)1