Package org.springframework.tests.sample.beans

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


  @Test
  public void testSizeConstraintSatisfied() {
    GenericApplicationContext ac = new GenericApplicationContext();
    ac.registerBeanDefinition("bvpp", new RootBeanDefinition(BeanValidationPostProcessor.class));
    RootBeanDefinition bd = new RootBeanDefinition(NotNullConstrainedBean.class);
    bd.getPropertyValues().add("testBean", new TestBean());
    bd.getPropertyValues().add("stringValue", "ss");
    ac.registerBeanDefinition("bean", bd);
    ac.refresh();
  }
View Full Code Here


      this.testBean = testBean;
    }

    @PostConstruct
    public void init() {
      this.testBean = new TestBean();
    }
View Full Code Here

  public static FactoryMethods nullInstance() {
    return null;
  }

  public static FactoryMethods defaultInstance() {
    TestBean tb = new TestBean();
    tb.setName("defaultInstance");
    return new FactoryMethods(tb, "default", 0);
  }
View Full Code Here

      new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
  }

  @Test
  public void testNoProxy() {
    TestBean tb = (TestBean) beanFactory.getBean("noproxy");
    assertFalse(AopUtils.isAopProxy(tb));
    assertEquals("noproxy", tb.getName());
  }
View Full Code Here

    assertEquals("jdk1", tb.getName());
  }

  @Test
  public void testCglibProxyWithWildcardMatch() {
    TestBean tb = (TestBean) beanFactory.getBean("cglib1");
    cglibAssertions(tb);
    assertEquals("cglib1", tb.getName());
  }
View Full Code Here

  public void defaultMerge() {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
        new ClassPathResource("NestedBeansElementAttributeRecursionTests-merge-context.xml", this.getClass()));

    TestBean topLevel = bf.getBean("topLevelConcreteTestBean", TestBean.class);
    // has the concrete child bean values
    assertThat((Iterable<String>) topLevel.getSomeList(), hasItems("charlie", "delta"));
    // but does not merge the parent values
    assertThat((Iterable<String>) topLevel.getSomeList(), not(hasItems("alpha", "bravo")));

    TestBean firstLevel = bf.getBean("firstLevelNestedTestBean", TestBean.class);
    // merges all values
    assertThat((Iterable<String>) firstLevel.getSomeList(),
        hasItems("charlie", "delta", "echo", "foxtrot"));

    TestBean secondLevel = bf.getBean("secondLevelNestedTestBean", TestBean.class);
    // merges all values
    assertThat((Iterable<String>)secondLevel.getSomeList(),
        hasItems("charlie", "delta", "echo", "foxtrot", "golf", "hotel"));
  }
View Full Code Here

  /**
   * @see org.springframework.beans.factory.FactoryBean#getObject()
   */
  @Override
  public Object getObject() throws Exception {
    return new TestBean();
  }
View Full Code Here

  @Test(expected=IllegalArgumentException.class)
  public void testIgnoreAdvisorThatIsCurrentlyCreation() {
    ClassPathXmlApplicationContext ctx =
      new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
    TestBean bean = (TestBean) ctx.getBean("bean");
    bean.setName("foo");
    assertEquals("foo", bean.getName());
    bean.setName(null); // should throw
  }
View Full Code Here

  public void testByTypeAutowireWithAutoSelfExclusion() throws Exception {
    CountingFactory.reset();
    DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-exclusion.xml");
    beanFactory.preInstantiateSingletons();
    TestBean rob = (TestBean) beanFactory.getBean("rob");
    TestBean sally = (TestBean) beanFactory.getBean("sally");
    assertEquals(sally, rob.getSpouse());
    assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
  }
View Full Code Here

  public void testByTypeAutowireWithExclusion() throws Exception {
    CountingFactory.reset();
    DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-exclusion.xml");
    beanFactory.preInstantiateSingletons();
    TestBean rob = (TestBean) beanFactory.getBean("rob");
    assertEquals("props1", rob.getSomeProperties().getProperty("name"));
    assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
  }
View Full Code Here

TOP

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

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.