Package org.springframework.tests.sample.beans

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


    pc.addAdvice(mi);
    AopProxy aop = createAopProxy(pc);

    given(mi.invoke(null)).willReturn(age);

    ITestBean tb = (ITestBean) aop.getProxy();
    assertTrue("correct return value", tb.getAge() == age);
  }
View Full Code Here


    };
    pc.addAdvice(tii);
    pc.setTarget(expectedTarget);
    AopProxy aop = createAopProxy(pc);

    ITestBean tb = (ITestBean) aop.getProxy();
    tb.getName();
    // Not safe to trap invocation
    //assertTrue(tii.invocation == target.invocation);

    //assertTrue(target.invocation.getProxy() == tb);
View Full Code Here

  @Test
  public void testAdvisorAdapterRegistrationManagerNotPresentInContext() {
    ClassPathXmlApplicationContext ctx =
      new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-without-bpp.xml", getClass());
    ITestBean tb = (ITestBean) ctx.getBean("testBean");
    // just invoke any method to see if advice fired
    try {
      tb.getName();
      fail("Should throw UnknownAdviceTypeException");
    }
    catch (UnknownAdviceTypeException ex) {
      // expected
      assertEquals(0, getAdviceImpl(tb).getInvocationCounter());
View Full Code Here

  @Test
  public void testAdvisorAdapterRegistrationManagerPresentInContext() {
    ClassPathXmlApplicationContext ctx =
      new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-with-bpp.xml", getClass());
    ITestBean tb = (ITestBean) ctx.getBean("testBean");
    // just invoke any method to see if advice fired
    try {
      tb.getName();
      assertEquals(1, getAdviceImpl(tb).getInvocationCounter());
    }
    catch (UnknownAdviceTypeException ex) {
      fail("Should not throw UnknownAdviceTypeException");
    }
View Full Code Here

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

    ITestBean testBean = (ITestBean) ctx.getBean("testBean");
    AnInterface interfaceExtendingAspect = (AnInterface) ctx.getBean("interfaceExtendingAspect");

    assertTrue(testBean instanceof Advised);
    assertFalse(interfaceExtendingAspect instanceof Advised);
  }
View Full Code Here

  }

  @Test
  public void testTxIsProxied() throws Exception {
    BeanFactory bf = getBeanFactory();
    ITestBean test = (ITestBean) bf.getBean("test");
    assertTrue(AopUtils.isAopProxy(test));
  }
View Full Code Here

  }

  @Test
  public void testRegexpApplied() throws Exception {
    BeanFactory bf = getBeanFactory();
    ITestBean test = (ITestBean) bf.getBean("test");
    MethodCounter counter = (MethodCounter) bf.getBean("countingAdvice");
    assertEquals(0, counter.getCalls());
    test.getName();
    assertEquals(1, counter.getCalls());
  }
View Full Code Here

  }

  @Test
  public void testTransactionAttributeOnMethod() throws Exception {
    BeanFactory bf = getBeanFactory();
    ITestBean test = (ITestBean) bf.getBean("test");

    CallCountingTransactionManager txMan = (CallCountingTransactionManager) bf.getBean(TXMANAGER_BEAN_NAME);
    OrderedTxCheckAdvisor txc = (OrderedTxCheckAdvisor) bf.getBean("orderedBeforeTransaction");
    assertEquals(0, txc.getCountingBeforeAdvice().getCalls());

    assertEquals(0, txMan.commits);
    assertEquals("Initial value was correct", 4, test.getAge());
    int newAge = 5;
    test.setAge(newAge);
    assertEquals(1, txc.getCountingBeforeAdvice().getCalls());

    assertEquals("New value set correctly", newAge, test.getAge());
    assertEquals("Transaction counts match", 1, txMan.commits);
  }
View Full Code Here

    TestBean target = new TestBean();
    target.setAge(20);
    TestBean target2 = new TestBean();
    target2.setAge(21);

    ITestBean proxy1 = getAdvisedProxy(target);
    ITestBean proxy2 = getAdvisedProxy(target2);
    assertTrue(proxy1.getClass() == proxy2.getClass());
    assertEquals(target.getAge(), proxy1.getAge());
    assertEquals(target2.getAge(), proxy2.getAge());
  }
View Full Code Here

    TestBean target = new TestBean();
    target.setAge(20);
    TestBean target2 = new TestBean();
    target2.setAge(21);

    ITestBean proxy1 = getIntroductionAdvisorProxy(target);
    ITestBean proxy2 = getIntroductionAdvisorProxy(target2);
    assertTrue("Incorrect duplicate creation of proxy classes", proxy1.getClass() == proxy2.getClass());
  }
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.