Package org.springframework.aop.framework

Examples of org.springframework.aop.framework.TimeStamped


    TestBean raw = new TestBean();
    assertTrue(! (raw instanceof TimeStamped));
    ProxyFactory factory = new ProxyFactory(raw);
 
    MockControl tsControl = MockControl.createControl(TimeStamped.class);
    TimeStamped ts = (TimeStamped) tsControl.getMock();
    ts.getTimeStamp();
    long timestamp = 111L;
    tsControl.setReturnValue(timestamp, 1);
    tsControl.replay();

    factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
   
    TimeStamped tsp = (TimeStamped) factory.getProxy();
    assertTrue(tsp.getTimeStamp() == timestamp);
 
    tsControl.verify();
  }
View Full Code Here


    tsControl.setReturnValue(timestamp, 1);
    tsControl.replay();

    factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts), TimeStamped.class));

    TimeStamped tsp = (TimeStamped) factory.getProxy();
    assertTrue(!(tsp instanceof SubTimeStamped));
    assertTrue(tsp.getTimeStamp() == timestamp);

    tsControl.verify();
  }
View Full Code Here

   
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
   
    //assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
    TimeStamped ts = (TimeStamped) pf.getProxy();
   
    assertTrue(ts.getTimeStamp() == t);
    ((ITest) ts).foo();
   
    ((ITestBean) ts).getAge();
  }
View Full Code Here

    IntroductionAdvisor ia = new DefaultIntroductionAdvisor(ii);
    assertTrue(ia.isPerInstance());
    pf.addAdvisor(0, ia);
   
    //assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
    TimeStamped ts = (TimeStamped) pf.getProxy();
   
    assertTrue(ts instanceof TimeStamped);
    // Shoulnd't proxy framework interfaces
    assertTrue(!(ts instanceof MethodInterceptor));
    assertTrue(!(ts instanceof IntroductionInterceptor));
   
    assertTrue(ts.getTimeStamp() == t);
    ((ITest) ts).foo();
    ((ITestBean) ts).getAge();
   
    // Test removal
    ii.suppressInterface(TimeStamped.class);
View Full Code Here

  public void testIntroductionInterceptorDoesntReplaceToString() throws Exception {
    TestBean raw = new TestBean();
    assertTrue(! (raw instanceof TimeStamped));
    ProxyFactory factory = new ProxyFactory(raw);
 
    TimeStamped ts = new SerializableTimeStamped(0);

    factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts) {
      public String toString() {
        throw new UnsupportedOperationException("Shouldn't be invoked");
      }
    }));
   
    TimeStamped tsp = (TimeStamped) factory.getProxy();
    assertEquals(0, tsp.getTimeStamp());
 
    assertEquals(raw.toString(), tsp.toString());
  }
View Full Code Here

    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();
View Full Code Here

    TestBean target = new TargetClass(t + 1);
 
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
 
    TimeStamped ts = (TimeStamped) pf.getProxy();
    // From introduction interceptor, not target
    assertTrue(ts.getTimeStamp() == t);
  }
View Full Code Here

TOP

Related Classes of org.springframework.aop.framework.TimeStamped

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.