Package org.springframework.beans

Examples of org.springframework.beans.ITestBean


    factory.setServiceUrl("http://localhosta/testbean");
    factory.afterPropertiesSet();

    assertTrue("Correct singleton value", factory.isSingleton());
    assertTrue(factory.getObject() instanceof ITestBean);
    ITestBean bean = (ITestBean) factory.getObject();

    try {
      bean.setName("test");
      fail("Should have thrown RemoteAccessException");
    }
    catch (RemoteAccessException ex) {
      // expected
    }
View Full Code Here


    factory.setOverloadEnabled(true);
    factory.afterPropertiesSet();

    assertTrue("Correct singleton value", factory.isSingleton());
    assertTrue(factory.getObject() instanceof ITestBean);
    ITestBean bean = (ITestBean) factory.getObject();

    try {
      bean.setName("test");
      fail("Should have thrown RemoteAccessException");
    }
    catch (RemoteAccessException ex) {
      // expected
    }
View Full Code Here

    factory.setOverloadEnabled(true);
    factory.afterPropertiesSet();

    assertTrue("Correct singleton value", factory.isSingleton());
    assertTrue(factory.getObject() instanceof ITestBean);
    ITestBean bean = (ITestBean) factory.getObject();

    assertEquals(proxyFactory.user, "test");
    assertEquals(proxyFactory.password, "bean");
    assertTrue(proxyFactory.overloadEnabled);

    try {
      bean.setName("test");
      fail("Should have thrown RemoteAccessException");
    }
    catch (RemoteAccessException ex) {
      // expected
    }
View Full Code Here

*/
public class ShortcutTests extends TestCase {

  public void testSimpleBeanConfigured() throws Exception {
    XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("shortcutTests.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 testInnerBeanConfigured() throws Exception {
    XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("shortcutTests.xml", getClass()));
    TestBean sally = (TestBean) beanFactory.getBean("sally2");
    ITestBean rob = (TestBean) sally.getSpouse();
    assertEquals("Rob Harrop", rob.getName());
    assertEquals(24, rob.getAge());
    assertEquals(rob.getSpouse(), sally);
  }
View Full Code Here

    }
  }

  public void testPropertyWithNameEndingInRef() throws Exception {
    XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("shortcutTests.xml", getClass()));
    ITestBean sally = (TestBean) beanFactory.getBean("derivedSally");
    assertEquals("r", sally.getSpouse().getName());
  }
View Full Code Here

    reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
    reader.loadBeanDefinitions(new ClassPathResource("reftypes.xml", getClass()));

    TestBean emma = (TestBean) xbf.getBean("emma");
    TestBean georgia = (TestBean) xbf.getBean("georgia");
    ITestBean emmasJenks = emma.getSpouse();
    ITestBean georgiasJenks = georgia.getSpouse();
    assertTrue("Emma and georgia think they have a different boyfriend", emmasJenks != georgiasJenks);
    assertTrue("Emmas jenks has right name", emmasJenks.getName().equals("Andrew"));
    assertTrue("Emmas doesn't equal new ref", emmasJenks != xbf.getBean("jenks"));
    assertTrue("Georgias jenks has right name", emmasJenks.getName().equals("Andrew"));
    assertTrue("They are object equal", emmasJenks.equals(georgiasJenks));
View Full Code Here

    reader.loadBeanDefinitions(new EncodedResource(resource, "ISO-8859-1"));

    TestBean jen = (TestBean) xbf.getBean("jenny");
    TestBean dave = (TestBean) xbf.getBean("david");
    TestBean jenks = (TestBean) xbf.getBean("jenks");
    ITestBean davesJen = dave.getSpouse();
    ITestBean jenksJen = jenks.getSpouse();
    assertTrue("1 jen instance", davesJen == jenksJen);
    assertTrue("1 jen instance", davesJen == jen);
  }
View Full Code Here

    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
    reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
    reader.loadBeanDefinitions(new ClassPathResource("reftypes.xml", getClass()));
    xbf.addBeanPostProcessor(new WrappingPostProcessor());

    ITestBean jenny = (ITestBean) xbf.getBean("jenny");
    ITestBean david = (ITestBean) xbf.getBean("david");
    assertTrue(AopUtils.isAopProxy(jenny));
    assertTrue(AopUtils.isAopProxy(david));
    assertSame(david, jenny.getSpouse());
    assertNotSame(jenny, david.getSpouse());
    assertEquals("Jenny", david.getSpouse().getName());
    assertSame(david, david.getSpouse().getSpouse());
    assertTrue(AopUtils.isAopProxy(jenny.getSpouse()));
    assertTrue(!AopUtils.isAopProxy(david.getSpouse()));
  }
View Full Code Here

    EventPublicationInterceptor interceptor =
        (EventPublicationInterceptor) ctx.getBean("publisher");
    ProxyFactory factory = new ProxyFactory(target);
    factory.addAdvice(0, interceptor);

    ITestBean testBean = (ITestBean) factory.getProxy();

    // invoke any method on the advised proxy to see if the interceptor has been invoked
    testBean.getAge();

    // two events: ContextRefreshedEvent and TestEvent
    assertTrue("Interceptor must have published 2 events", listener.getEventCount() == 2);
    TestListener otherListener = (TestListener) ctx.getBean("&otherListener");
    assertTrue("Interceptor must have published 2 events", otherListener.getEventCount() == 2);
View Full Code Here

TOP

Related Classes of org.springframework.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.