Package org.springframework.aop.interceptor

Examples of org.springframework.aop.interceptor.DebugInterceptor


    assertEquals("foo", olup.testMethod());
    assertInterceptorCount(2);
  }

  private void assertInterceptorCount(int count) {
    DebugInterceptor interceptor = getInterceptor();
    assertEquals("Interceptor count is incorrect", count, interceptor.getCount());
  }
View Full Code Here


    DebugInterceptor interceptor = getInterceptor();
    assertEquals("Interceptor count is incorrect", count, interceptor.getCount());
  }

  private void resetInterceptor() {
    DebugInterceptor interceptor = getInterceptor();
    interceptor.resetCount();
  }
View Full Code Here

    assertFalse("Should no longer implement TimeStamped",
        config.getProxy() instanceof TimeStamped);

    // Now check non-effect of removing interceptor that isn't there
    config.removeAdvice(new DebugInterceptor());

    assertTrue(config.getAdvisors().length == oldCount);

    ITestBean it = (ITestBean) ts;
    DebugInterceptor debugInterceptor = new DebugInterceptor();
    config.addAdvice(0, debugInterceptor);
    it.getSpouse();
    assertEquals(1, debugInterceptor.getCount());
    config.removeAdvice(debugInterceptor);
    it.getSpouse();
    // not invoked again
    assertTrue(debugInterceptor.getCount() == 1);
  }
View Full Code Here

  }

  public void testProxyIsBoundBeforeTargetSourceInvoked() {
    final TestBean target = new TestBean();
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvice(new DebugInterceptor());
    pf.setExposeProxy(true);
    final ITestBean proxy = (ITestBean) createProxy(pf);
    Advised config = (Advised) proxy;
    // This class just checks proxy is bound before getTarget() call
    config.setTargetSource(new TargetSource() {
View Full Code Here

    }
    catch (ClassCastException ex) {
    }
   
    // Now check non-effect of removing interceptor that isn't there
    config.removeAdvice(new DebugInterceptor());
    assertTrue(config.getAdvisors().length == oldCount);
   
    ITestBean it = (ITestBean) ts;
    DebugInterceptor debugInterceptor = new DebugInterceptor();
    config.addAdvice(0, debugInterceptor);
    it.getSpouse();
    // Won't affect existing reference
    assertTrue(debugInterceptor.getCount() == 0);
    it = (ITestBean) factory.getBean("test2");
    it.getSpouse();
    assertEquals(1, debugInterceptor.getCount());
    config.removeAdvice(debugInterceptor);
    it.getSpouse();
   
    // Still invoked wiht old reference
    assertEquals(2, debugInterceptor.getCount());
   
    // not invoked with new object
    it = (ITestBean) factory.getBean("test2");
    it.getSpouse();
    assertEquals(2, debugInterceptor.getCount());
   
    // Our own timestamped reference should still work
    assertEquals(time, ts.getTimeStamp());
  }
View Full Code Here

  }

  public void testDetectsInterfaces() throws Exception {
    ProxyFactoryBean fb = new ProxyFactoryBean();
    fb.setTarget(new TestBean());
    fb.addAdvice(new DebugInterceptor());
    fb.setBeanFactory(new DefaultListableBeanFactory());
    ITestBean proxy = (ITestBean) fb.getObject();
    assertTrue(AopUtils.isJdkDynamicProxy(proxy));
  }
View Full Code Here

  @Test
  public void testProxyIsBoundBeforeTargetSourceInvoked() {
    final TestBean target = new TestBean();
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvice(new DebugInterceptor());
    pf.setExposeProxy(true);
    final ITestBean proxy = (ITestBean) createProxy(pf);
    Advised config = (Advised) proxy;
    // This class just checks proxy is bound before getTarget() call
    config.setTargetSource(new TargetSource() {
View Full Code Here

    assertEquals("foo", olup.testMethod());
    assertInterceptorCount(2);
  }

  private void assertInterceptorCount(int count) {
    DebugInterceptor interceptor = getInterceptor();
    assertEquals("Interceptor count is incorrect", count, interceptor.getCount());
  }
View Full Code Here

    DebugInterceptor interceptor = getInterceptor();
    assertEquals("Interceptor count is incorrect", count, interceptor.getCount());
  }

  private void resetInterceptor() {
    DebugInterceptor interceptor = getInterceptor();
    interceptor.resetCount();
  }
View Full Code Here

    ApplicationContext context = new ClassPathXmlApplicationContext("ObjenesisProxyTests-context.xml", getClass());

    ClassWithComplexConstructor bean = context.getBean(ClassWithComplexConstructor.class);
    bean.method();

    DebugInterceptor interceptor = context.getBean(DebugInterceptor.class);
    assertThat(interceptor.getCount(), is(1L));
    assertThat(bean.getDependency().getValue(), is(1));
  }
View Full Code Here

TOP

Related Classes of org.springframework.aop.interceptor.DebugInterceptor

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.