Package org.springframework.tests.sample.beans

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


  @Test
  public void simpleBeanConfigured() throws Exception {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
        new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
    ITestBean rob = (TestBean) beanFactory.getBean("rob");
    ITestBean sally = (TestBean) beanFactory.getBean("sally");
    assertEquals("Rob Harrop", rob.getName());
    assertEquals(24, rob.getAge());
    assertEquals(rob.getSpouse(), sally);
  }
View Full Code Here


  public void innerBeanConfigured() throws Exception {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
        new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
    TestBean sally = (TestBean) beanFactory.getBean("sally2");
    ITestBean rob = sally.getSpouse();
    assertEquals("Rob Harrop", rob.getName());
    assertEquals(24, rob.getAge());
    assertEquals(rob.getSpouse(), sally);
  }
View Full Code Here

  @Test
  public void propertyWithNameEndingInRef() throws Exception {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
        new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
    ITestBean sally = (TestBean) beanFactory.getBean("derivedSally");
    assertEquals("r", sally.getSpouse().getName());
  }
View Full Code Here

  @Test
  public void testAccessThrowable() throws Exception {
    ClassPathXmlApplicationContext ctx =
      new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());

    ITestBean bean = (ITestBean) ctx.getBean("testBean");
    ExceptionHandlingAspect aspect = (ExceptionHandlingAspect) ctx.getBean("aspect");

    assertTrue(AopUtils.isAopProxy(bean));
    try {
      bean.unreliableFileOperation();
    }
    catch (IOException e) {
      //
    }
View Full Code Here

  @Test
  public void testAdrian() {
    ClassPathXmlApplicationContext ctx =
      new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());

    ITestBean adrian = (ITestBean) ctx.getBean("adrian");
    assertEquals(0, LazyTestBean.instantiations);
    assertNotNull(adrian);
    adrian.getAge();
    assertEquals(68, adrian.getAge());
    assertEquals(1, LazyTestBean.instantiations);
  }
View Full Code Here

  private long testRepeatedAroundAdviceInvocations(String file, int howmany, String technology) {
    ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);

    StopWatch sw = new StopWatch();
    sw.start(howmany + " repeated around advice invocations with " + technology);
    ITestBean adrian = (ITestBean) bf.getBean("adrian");

    assertTrue(AopUtils.isAopProxy(adrian));
    assertEquals(68, adrian.getAge());

    for (int i = 0; i < howmany; i++) {
      adrian.getAge();
    }

    sw.stop();
    System.out.println(sw.prettyPrint());
    return sw.getLastTaskTimeMillis();
View Full Code Here

  private long testBeforeAdviceWithoutJoinPoint(String file, int howmany, String technology) {
    ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);

    StopWatch sw = new StopWatch();
    sw.start(howmany + " repeated before advice invocations with " + technology);
    ITestBean adrian = (ITestBean) bf.getBean("adrian");

    assertTrue(AopUtils.isAopProxy(adrian));
    Advised a = (Advised) adrian;
    assertTrue(a.getAdvisors().length >= 3);
    assertEquals("adrian", adrian.getName());

    for (int i = 0; i < howmany; i++) {
      adrian.getName();
    }

    sw.stop();
    System.out.println(sw.prettyPrint());
    return sw.getLastTaskTimeMillis();
View Full Code Here

  private long testAfterReturningAdviceWithoutJoinPoint(String file, int howmany, String technology) {
    ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);

    StopWatch sw = new StopWatch();
    sw.start(howmany + " repeated after returning advice invocations with " + technology);
    ITestBean adrian = (ITestBean) bf.getBean("adrian");

    assertTrue(AopUtils.isAopProxy(adrian));
    Advised a = (Advised) adrian;
    assertTrue(a.getAdvisors().length >= 3);
    // Hits joinpoint
    adrian.setAge(25);

    for (int i = 0; i < howmany; i++) {
      adrian.setAge(i);
    }

    sw.stop();
    System.out.println(sw.prettyPrint());
    return sw.getLastTaskTimeMillis();
View Full Code Here

  public void onSetUp() throws Exception {
    ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());

    AroundAdviceBindingTestAspect  aroundAdviceAspect = ((AroundAdviceBindingTestAspect) ctx.getBean("testAspect"));

    ITestBean injectedTestBean = (ITestBean) ctx.getBean("testBean");
    assertTrue(AopUtils.isAopProxy(injectedTestBean));

    this.testBeanProxy = injectedTestBean;
    // we need the real target too, not just the proxy...
View Full Code Here

  private long testMix(String file, int howmany, String technology) {
    ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);

    StopWatch sw = new StopWatch();
    sw.start(howmany + " repeated mixed invocations with " + technology);
    ITestBean adrian = (ITestBean) bf.getBean("adrian");

    assertTrue(AopUtils.isAopProxy(adrian));
    Advised a = (Advised) adrian;
    assertTrue(a.getAdvisors().length >= 3);

    for (int i = 0; i < howmany; i++) {
      // Hit all 3 joinpoints
      adrian.getAge();
      adrian.getName();
      adrian.setAge(i);

      // Invoke three non-advised methods
      adrian.getDoctor();
      adrian.getLawyer();
      adrian.getSpouse();
    }

    sw.stop();
    System.out.println(sw.prettyPrint());
    return sw.getLastTaskTimeMillis();
View Full Code Here

TOP

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

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.