Package org.springframework.tests.sample.beans

Examples of org.springframework.tests.sample.beans.TestBean


    assertTrue("Proxy creation was too slow",  sw.getTotalTimeMillis() < 5000);
  }

  private void testManyProxies(int howMany) {
    int age1 = 33;
    TestBean target1 = new TestBean();
    target1.setAge(age1);
    ProxyFactory pf1 = new ProxyFactory(target1);
    pf1.addAdvice(new NopInterceptor());
    pf1.addAdvice(new NopInterceptor());
    ITestBean proxies[] = new ITestBean[howMany];
    for (int i = 0; i < howMany; i++) {
View Full Code Here


    }
  }

  @Test
  public void testSerializationAdviceAndTargetNotSerializable() throws Exception {
    TestBean tb = new TestBean();
    assertFalse(SerializationTestUtils.isSerializable(tb));

    ProxyFactory pf = new ProxyFactory(tb);

    pf.addAdvice(new NopInterceptor());
View Full Code Here

  @Test
  public void testOneAdvisedObjectCallsAnother() {
    int age1 = 33;
    int age2 = 37;

    TestBean target1 = new TestBean();
    ProxyFactory pf1 = new ProxyFactory(target1);
    // Permit proxy and invocation checkers to get context from AopContext
    pf1.setExposeProxy(true);
    NopInterceptor di1 = new NopInterceptor();
    pf1.addAdvice(0, di1);
    pf1.addAdvice(1, new ProxyMatcherInterceptor());
    pf1.addAdvice(2, new CheckMethodInvocationIsSameInAndOutInterceptor());
    pf1.addAdvice(1, new CheckMethodInvocationViaThreadLocalIsSameInAndOutInterceptor());
    // Must be first
    pf1.addAdvice(0, ExposeInvocationInterceptor.INSTANCE);
    ITestBean advised1 = (ITestBean) pf1.getProxy();
    advised1.setAge(age1); // = 1 invocation

    TestBean target2 = new TestBean();
    ProxyFactory pf2 = new ProxyFactory(target2);
    pf2.setExposeProxy(true);
    NopInterceptor di2 = new NopInterceptor();
    pf2.addAdvice(0, di2);
    pf2.addAdvice(1, new ProxyMatcherInterceptor());
View Full Code Here

  @Test
  public void testReentrance() {
    int age1 = 33;

    TestBean target1 = new TestBean();
    ProxyFactory pf1 = new ProxyFactory(target1);
    NopInterceptor di1 = new NopInterceptor();
    pf1.addAdvice(0, di1);
    ITestBean advised1 = (ITestBean) createProxy(pf1);
    advised1.setAge(age1); // = 1 invocation
View Full Code Here

      pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
    }
    pc.addAdvice(mi);
    // Keep CGLIB happy
    if (requiresTarget()) {
      pc.setTarget(new TestBean());
    }
    AopProxy aop = createAopProxy(pc);

    assertNoInvocationContext();
    ITestBean tb = (ITestBean) aop.getProxy();
View Full Code Here

   * target returns {@code this}
   */
  @Test
  public void testTargetReturnsThis() throws Throwable {
    // Test return value
    TestBean raw = new OwnSpouse();

    ProxyCreatorSupport pc = new ProxyCreatorSupport();
    pc.setInterfaces(new Class<?>[] {ITestBean.class});
    pc.setTarget(raw);

View Full Code Here

    AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class});
    pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
    pc.addAdvice(mi);

    // We don't care about the object
    pc.setTarget(new TestBean());
    AopProxy aop = createAopProxy(pc);
    ITestBean tb = (ITestBean) aop.getProxy();

    try {
      // Note: exception param below isn't used
View Full Code Here

    AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class});
    pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
    pc.addAdvice(mi);

    // We don't care about the object
    pc.setTarget(new TestBean());
    AopProxy aop = createAopProxy(pc);
    ITestBean tb = (ITestBean) aop.getProxy();

    try {
      // Note: exception param below isn't used
View Full Code Here

  /**
   * Test stateful interceptor
   */
  @Test
  public void testMixinWithIntroductionAdvisor() throws Throwable {
    TestBean tb = new TestBean();
    ProxyFactory pc = new ProxyFactory(new Class<?>[] {ITestBean.class});
    pc.addAdvisor(new LockMixinAdvisor());
    pc.setTarget(tb);

    testTestBeanIntroduction(pc);
View Full Code Here

    testTestBeanIntroduction(pc);
  }

  @Test
  public void testMixinWithIntroductionInfo() throws Throwable {
    TestBean tb = new TestBean();
    ProxyFactory pc = new ProxyFactory(new Class<?>[] {ITestBean.class});
    // We don't use an IntroductionAdvisor, we can just add an advice that implements IntroductionInfo
    pc.addAdvice(new LockMixin());
    pc.setTarget(tb);
View Full Code Here

TOP

Related Classes of org.springframework.tests.sample.beans.TestBean

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.