Package org.springframework.tests.sample.beans

Examples of org.springframework.tests.sample.beans.SideEffectBean.doWork()


    singleton.doWork();
    assertEquals(INITIAL_COUNT + 1, singleton.getCount() );

    SideEffectBean prototype = (SideEffectBean) beanFactory.getBean("prototype");
    assertEquals(INITIAL_COUNT, prototype.getCount() );
    prototype.doWork();
    assertEquals(INITIAL_COUNT, prototype.getCount() );
  }


}
View Full Code Here


   */
  @Test
  public void testUseDifferentManagedInstancesInSameThread() {
    SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
    assertEquals(INITIAL_COUNT, apartment.getCount() );
    apartment.doWork();
    assertEquals(INITIAL_COUNT + 1, apartment.getCount() );

    ITestBean test = (ITestBean) beanFactory.getBean("threadLocal2");
    assertEquals("Rod", test.getName());
    assertEquals("Kerry", test.getSpouse().getName());
View Full Code Here

  @Test
  public void testReuseInSameThread() {
    SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
    assertEquals(INITIAL_COUNT, apartment.getCount() );
    apartment.doWork();
    assertEquals(INITIAL_COUNT + 1, apartment.getCount() );

    apartment = (SideEffectBean) beanFactory.getBean("apartment");
    assertEquals(INITIAL_COUNT + 1, apartment.getCount() );
  }
View Full Code Here

  public void testCanGetStatsViaMixin() {
    ThreadLocalTargetSourceStats stats = (ThreadLocalTargetSourceStats) beanFactory.getBean("apartment");
    // +1 because creating target for stats call counts
    assertEquals(1, stats.getInvocationCount());
    SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
    apartment.doWork();
    // +1 again
    assertEquals(3, stats.getInvocationCount());
    // + 1 for states call!
    assertEquals(3, stats.getHitCount());
    apartment.doWork();
View Full Code Here

    apartment.doWork();
    // +1 again
    assertEquals(3, stats.getInvocationCount());
    // + 1 for states call!
    assertEquals(3, stats.getHitCount());
    apartment.doWork();
    assertEquals(6, stats.getInvocationCount());
    assertEquals(6, stats.getHitCount());
    // Only one thread so only one object can have been bound
    assertEquals(1, stats.getObjectCount());
  }
View Full Code Here

  @Test
  public void testNewThreadHasOwnInstance() throws InterruptedException {
    SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
    assertEquals(INITIAL_COUNT, apartment.getCount() );
    apartment.doWork();
    apartment.doWork();
    apartment.doWork();
    assertEquals(INITIAL_COUNT + 3, apartment.getCount() );

    class Runner implements Runnable {
View Full Code Here

  @Test
  public void testNewThreadHasOwnInstance() throws InterruptedException {
    SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
    assertEquals(INITIAL_COUNT, apartment.getCount() );
    apartment.doWork();
    apartment.doWork();
    apartment.doWork();
    assertEquals(INITIAL_COUNT + 3, apartment.getCount() );

    class Runner implements Runnable {
      public SideEffectBean mine;
View Full Code Here

  public void testNewThreadHasOwnInstance() throws InterruptedException {
    SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
    assertEquals(INITIAL_COUNT, apartment.getCount() );
    apartment.doWork();
    apartment.doWork();
    apartment.doWork();
    assertEquals(INITIAL_COUNT + 3, apartment.getCount() );

    class Runner implements Runnable {
      public SideEffectBean mine;
      @Override
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.