Search in sources :

Example 16 with TimeStamped

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

the class DelegatingIntroductionInterceptorTests method testSerializableDelegatingIntroductionInterceptorSerializable.

@Test
public void testSerializableDelegatingIntroductionInterceptorSerializable() throws Exception {
    SerializablePerson serializableTarget = new SerializablePerson();
    String name = "Tony";
    serializableTarget.setName("Tony");
    ProxyFactory factory = new ProxyFactory(serializableTarget);
    factory.addInterface(Person.class);
    long time = 1000;
    TimeStamped ts = new SerializableTimeStamped(time);
    factory.addAdvisor(new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
    factory.addAdvice(new SerializableNopInterceptor());
    Person p = (Person) factory.getProxy();
    assertThat(p.getName()).isEqualTo(name);
    assertThat(((TimeStamped) p).getTimeStamp()).isEqualTo(time);
    Person p1 = SerializationTestUtils.serializeAndDeserialize(p);
    assertThat(p1.getName()).isEqualTo(name);
    assertThat(((TimeStamped) p1).getTimeStamp()).isEqualTo(time);
}
Also used : TimeStamped(org.springframework.core.testfixture.TimeStamped) SerializableNopInterceptor(org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor) SerializablePerson(org.springframework.beans.testfixture.beans.SerializablePerson) ProxyFactory(org.springframework.aop.framework.ProxyFactory) Person(org.springframework.beans.testfixture.beans.Person) SerializablePerson(org.springframework.beans.testfixture.beans.SerializablePerson) Test(org.junit.jupiter.api.Test)

Aggregations

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