Package org.springframework.tests.sample.beans

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


  }

  private void testFunctionality(String name) {
    SideEffectBean pooled = (SideEffectBean) beanFactory.getBean(name);
    assertEquals(INITIAL_COUNT, pooled.getCount());
    pooled.doWork();
    assertEquals(INITIAL_COUNT + 1, pooled.getCount());

    pooled = (SideEffectBean) beanFactory.getBean(name);
    // Just check that it works--we can't make assumptions
    // about the count
View Full Code Here


    assertEquals(INITIAL_COUNT + 1, pooled.getCount());

    pooled = (SideEffectBean) beanFactory.getBean(name);
    // Just check that it works--we can't make assumptions
    // about the count
    pooled.doWork();
    //assertEquals(INITIAL_COUNT + 1, apartment.getCount() );
  }

  @Test
  public void testFunctionality() {
View Full Code Here

    SideEffectBean pooled = (SideEffectBean) beanFactory.getBean("pooledWithMixin");
    assertEquals(INITIAL_COUNT, pooled.getCount());
    PoolingConfig conf = (PoolingConfig) beanFactory.getBean("pooledWithMixin");
    // TODO one invocation from setup
    //assertEquals(1, conf.getInvocations());
    pooled.doWork();
    //  assertEquals("No objects active", 0, conf.getActive());
    assertEquals("Correct target source", 25, conf.getMaxSize());
    //  assertTrue("Some free", conf.getFree() > 0);
    //assertEquals(2, conf.getInvocations());
    assertEquals(25, conf.getMaxSize());
View Full Code Here

    new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(PROTOTYPE_CONTEXT, CLASS));

    // Check it works without AOP
    SideEffectBean raw = (SideEffectBean) bf.getBean("prototypeTarget");
    assertEquals(INITIAL_COUNT, raw.getCount() );
    raw.doWork();
    assertEquals(INITIAL_COUNT+1, raw.getCount() );
    raw = (SideEffectBean) bf.getBean("prototypeTarget");
    assertEquals(INITIAL_COUNT, raw.getCount() );

    // Now try with advised instances
View Full Code Here

    assertEquals(INITIAL_COUNT, raw.getCount() );

    // Now try with advised instances
    SideEffectBean prototype2FirstInstance = (SideEffectBean) bf.getBean(beanName);
    assertEquals(INITIAL_COUNT, prototype2FirstInstance.getCount() );
    prototype2FirstInstance.doWork();
    assertEquals(INITIAL_COUNT + 1, prototype2FirstInstance.getCount() );

    SideEffectBean prototype2SecondInstance = (SideEffectBean) bf.getBean(beanName);
    assertFalse("Prototypes are not ==", prototype2FirstInstance == prototype2SecondInstance);
    assertEquals(INITIAL_COUNT, prototype2SecondInstance.getCount() );
View Full Code Here

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

    proxied = (SideEffectBean) beanFactory.getBean("swappable");
    proxied.doWork();
    assertEquals(INITIAL_COUNT + 2, proxied.getCount() );
View Full Code Here

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

    proxied = (SideEffectBean) beanFactory.getBean("swappable");
    proxied.doWork();
    assertEquals(INITIAL_COUNT + 2, proxied.getCount() );
  }

  @Test
  public void testValidSwaps() {
View Full Code Here

    SideEffectBean target1 = (SideEffectBean) beanFactory.getBean("target1");
    SideEffectBean target2 = (SideEffectBean) beanFactory.getBean("target2");

    SideEffectBean proxied = (SideEffectBean) beanFactory.getBean("swappable");
    assertEquals(target1.getCount(), proxied.getCount() );
    proxied.doWork();
    assertEquals(INITIAL_COUNT + 1, proxied.getCount() );

    HotSwappableTargetSource swapper = (HotSwappableTargetSource) beanFactory.getBean("swapper");
    Object old = swapper.swap(target2);
    assertEquals("Correct old target was returned", target1, old);
View Full Code Here

    // TODO should be able to make this assertion: need to fix target handling
    // in AdvisedSupport
    //assertEquals(target2, ((Advised) proxied).getTarget());

    assertEquals(20, proxied.getCount());
    proxied.doWork();
    assertEquals(21, target2.getCount());

    // Swap it back
    swapper.swap(target1);
    assertEquals(target1.getCount(), proxied.getCount());
View Full Code Here

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

    SideEffectBean prototype = (SideEffectBean) beanFactory.getBean("prototype");
    assertEquals(INITIAL_COUNT, prototype.getCount() );
    prototype.doWork();
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.