Package org.springframework.tests.aop.interceptor

Examples of org.springframework.tests.aop.interceptor.TimestampIntroductionInterceptor


    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();

    assertEquals(age1, tb.getAge());
    tb.setAge(age2);
    assertEquals(age2, tb.getAge());
View Full Code Here


  public void testCannotAddIntroductionAdviceWithUnimplementedInterface() throws Throwable {
    TestBean target = new TestBean();
    target.setAge(21);
    ProxyFactory pc = new ProxyFactory(target);
    try {
      pc.addAdvisor(0, new DefaultIntroductionAdvisor(new TimestampIntroductionInterceptor(), ITestBean.class));
      fail("Shouldn't be able to add introduction advice introducing an unimplemented interface");
    }
    catch (IllegalArgumentException ex) {
      //assertTrue(ex.getMessage().indexOf("ntroduction") > -1);
    }
View Full Code Here

  public void testCannotAddIntroductionAdviceToIntroduceClass() throws Throwable {
    TestBean target = new TestBean();
    target.setAge(21);
    ProxyFactory pc = new ProxyFactory(target);
    try {
      pc.addAdvisor(0, new DefaultIntroductionAdvisor(new TimestampIntroductionInterceptor(), TestBean.class));
      fail("Shouldn't be able to add introduction advice that introduces a class, rather than an interface");
    }
    catch (IllegalArgumentException ex) {
      assertTrue(ex.getMessage().indexOf("interface") > -1);
    }
View Full Code Here

    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<ITestBean, Object>();
    Object value1 = "foo";
    Object value2 = "bar";
View Full Code Here

    assertThat("Shouldn't implement TimeStamped before manipulation",
        factory.getBean("test2"), not(instanceOf(TimeStamped.class)));

    ProxyFactoryBean config = (ProxyFactoryBean) factory.getBean("&test2");
    long time = 666L;
    TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor();
    ti.setTime(time);
    // Add to head of interceptor chain
    int oldCount = config.getAdvisors().length;
    config.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class));
    assertTrue(config.getAdvisors().length == oldCount + 1);
View Full Code Here

  /**
   * @param dii
   */
  public TimestampIntroductionAdvisor() {
    super(new DelegatingIntroductionInterceptor(new TimestampIntroductionInterceptor()));
  }
View Full Code Here

TOP

Related Classes of org.springframework.tests.aop.interceptor.TimestampIntroductionInterceptor

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.