Package org.springframework.tests.sample.beans

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


    TestAutoProxyCreator tapc = (TestAutoProxyCreator) sac.getBean("testAutoProxyCreator");
    tapc.testInterceptor.nrOfInvocations = 0;

    FactoryBean<?> prototypeFactory = (FactoryBean<?>) sac.getBean("&prototypeFactoryToBeProxied");
    assertTrue(AopUtils.isCglibProxy(prototypeFactory));
    TestBean tb = (TestBean) sac.getBean("prototypeFactoryToBeProxied");
    assertTrue(AopUtils.isCglibProxy(tb));

    assertEquals(2, tapc.testInterceptor.nrOfInvocations);
    tb.getAge();
    assertEquals(3, tapc.testInterceptor.nrOfInvocations);
  }
View Full Code Here


    tapc.testInterceptor.nrOfInvocations = 0;

    FactoryBean<?> factory = (FactoryBean<?>) sac.getBean("&singletonFactoryToBeProxied");
    assertFalse(AopUtils.isAopProxy(factory));

    TestBean tb = (TestBean) sac.getBean("singletonFactoryToBeProxied");
    assertTrue(AopUtils.isCglibProxy(tb));
    assertEquals(0, tapc.testInterceptor.nrOfInvocations);
    tb.getAge();
    assertEquals(1, tapc.testInterceptor.nrOfInvocations);

    TestBean tb2 = (TestBean) sac.getBean("singletonFactoryToBeProxied");
    assertSame(tb, tb2);
    assertEquals(1, tapc.testInterceptor.nrOfInvocations);
    tb2.getAge();
    assertEquals(2, tapc.testInterceptor.nrOfInvocations);
  }
View Full Code Here

    TestAutoProxyCreator tapc = (TestAutoProxyCreator) sac.getBean("testAutoProxyCreator");
    tapc.testInterceptor.nrOfInvocations = 0;

    FactoryBean<?> prototypeFactory = (FactoryBean<?>) sac.getBean("&prototypeFactoryToBeProxied");
    assertTrue(AopUtils.isCglibProxy(prototypeFactory));
    TestBean tb = (TestBean) sac.getBean("prototypeFactoryToBeProxied");
    assertFalse(AopUtils.isCglibProxy(tb));

    assertEquals(2, tapc.testInterceptor.nrOfInvocations);
    tb.getAge();
    assertEquals(2, tapc.testInterceptor.nrOfInvocations);
  }
View Full Code Here

    assertEquals(0, counterAspect.count);
  }

  @Test
  public void testProgrammaticProxyCreation() {
    ITestBean testBean = new TestBean();

    AspectJProxyFactory factory = new AspectJProxyFactory();
    factory.setTarget(testBean);

    CounterAspect myCounterAspect = new CounterAspect();
View Full Code Here

    ProtectedLifecycleBean bean = (ProtectedLifecycleBean) getBeanFactory().getBean("protectedLifecycle");
    bean.businessMethod();
  }

  public void testDescriptionButNoProperties() throws Exception {
    TestBean validEmpty = (TestBean) getBeanFactory().getBean("validEmptyWithDescription");
    assertEquals(0, validEmpty.getAge());
  }
View Full Code Here

        new ClassPathResource("collectionsWithDefaultTypes.xml", getClass()));
  }

  @Test
  public void testListHasDefaultType() throws Exception {
    TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
    for (Object o : bean.getSomeList()) {
      assertEquals("Value type is incorrect", Integer.class, o.getClass());
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testSetHasDefaultType() throws Exception {
    TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
    for (Object o : bean.getSomeSet()) {
      assertEquals("Value type is incorrect", Integer.class, o.getClass());
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testMapHasDefaultKeyAndValueType() throws Exception {
    TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
    assertMap(bean.getSomeMap());
  }
View Full Code Here

  public void testValuesStick() {
    int age1 = 33;
    int age2 = 37;
    String name = "tony";

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

    assertMap(bean.getSomeMap());
  }

  @Test
  public void testMapWithNestedElementsHasDefaultKeyAndValueType() throws Exception {
    TestBean bean = (TestBean) this.beanFactory.getBean("testBean2");
    assertMap(bean.getSomeMap());
  }
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.