Package org.springframework.tests.sample.beans

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


    assertEquals("NOT_NULL.org.springframework.tests.sample.beans.TestBean", errors.getFieldError("map[key0]").getCodes()[4]);
    assertEquals("NOT_NULL", errors.getFieldError("map[key0]").getCodes()[5]);
  }

  public void testCustomEditorWithSubclass() {
    IndexedTestBean tb = new IndexedTestBean();
    DataBinder binder = new DataBinder(tb, "tb");
    binder.registerCustomEditor(TestBean.class, new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) throws IllegalArgumentException {
        DerivedTestBean tb = new DerivedTestBean();
        tb.setName("array" + text);
        setValue(tb);
      }
      @Override
      public String getAsText() {
        return ((TestBean) getValue()).getName();
View Full Code Here


    FieldError nameError = errors.getFieldError("name");
    assertEquals("badName", nameError.getCode());
  }

  public void testBindingWithResortedList() {
    IndexedTestBean tb = new IndexedTestBean();
    DataBinder binder = new DataBinder(tb, "tb");
    MutablePropertyValues pvs = new MutablePropertyValues();
    TestBean tb1 = new TestBean("tb1", 99);
    TestBean tb2 = new TestBean("tb2", 99);
    pvs.add("list[0]", tb1);
    pvs.add("list[1]", tb2);
    binder.bind(pvs);
    assertEquals(tb1.getName(), binder.getBindingResult().getFieldValue("list[0].name"));
    assertEquals(tb2.getName(), binder.getBindingResult().getFieldValue("list[1].name"));
    tb.getList().set(0, tb2);
    tb.getList().set(1, tb1);
    assertEquals(tb2.getName(), binder.getBindingResult().getFieldValue("list[0].name"));
    assertEquals(tb1.getName(), binder.getBindingResult().getFieldValue("list[1].name"));
  }
View Full Code Here

    bpp.setBeanFactory(bf);
    bf.addBeanPostProcessor(bpp);
    bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalResourceInjectionBean.class));
    TestBean tb = new TestBean();
    bf.registerSingleton("testBean", tb);
    IndexedTestBean itb = new IndexedTestBean();
    bf.registerSingleton("indexedTestBean", itb);
    NestedTestBean ntb1 = new NestedTestBean();
    bf.registerSingleton("nestedTestBean1", ntb1);
    NestedTestBean ntb2 = new NestedTestBean();
    bf.registerSingleton("nestedTestBean2", ntb2);
View Full Code Here

    RootBeanDefinition rbd = new RootBeanDefinition(OptionalCollectionResourceInjectionBean.class);
    rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
    bf.registerBeanDefinition("annotatedBean", rbd);
    TestBean tb = new TestBean();
    bf.registerSingleton("testBean", tb);
    IndexedTestBean itb = new IndexedTestBean();
    bf.registerSingleton("indexedTestBean", itb);
    NestedTestBean ntb1 = new NestedTestBean();
    bf.registerSingleton("nestedTestBean1", ntb1);
    NestedTestBean ntb2 = new NestedTestBean();
    bf.registerSingleton("nestedTestBean2", ntb2);
View Full Code Here

    RootBeanDefinition rbd = new RootBeanDefinition(OptionalCollectionResourceInjectionBean.class);
    rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
    bf.registerBeanDefinition("annotatedBean", rbd);
    TestBean tb = new TestBean();
    bf.registerSingleton("testBean", tb);
    IndexedTestBean itb = new IndexedTestBean();
    bf.registerSingleton("indexedTestBean", itb);
    NestedTestBean ntb1 = new NestedTestBean();
    bf.registerSingleton("nestedTestBean1", ntb1);

    // Two calls to verify that caching doesn't break re-creation.
View Full Code Here

    bpp.setBeanFactory(bf);
    bf.addBeanPostProcessor(bpp);
    bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalResourceInjectionBean.class));
    TestBean tb = new TestBean();
    bf.registerSingleton("testBean", tb);
    IndexedTestBean itb = new IndexedTestBean();
    bf.registerSingleton("indexedTestBean", itb);
    OrderedNestedTestBean ntb1 = new OrderedNestedTestBean();
    ntb1.setOrder(2);
    bf.registerSingleton("nestedTestBean1", ntb1);
    OrderedNestedTestBean ntb2 = new OrderedNestedTestBean();
View Full Code Here

    bpp.setBeanFactory(bf);
    bf.addBeanPostProcessor(bpp);
    bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalResourceInjectionBean.class));
    TestBean tb = new TestBean();
    bf.registerSingleton("testBean", tb);
    IndexedTestBean itb = new IndexedTestBean();
    bf.registerSingleton("indexedTestBean", itb);
    FixedOrder2NestedTestBean ntb1 = new FixedOrder2NestedTestBean();
    bf.registerSingleton("nestedTestBean1", ntb1);
    FixedOrder1NestedTestBean ntb2 = new FixedOrder1NestedTestBean();
    bf.registerSingleton("nestedTestBean2", ntb2);
View Full Code Here

    RootBeanDefinition rbd = new RootBeanDefinition(OptionalCollectionResourceInjectionBean.class);
    rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
    bf.registerBeanDefinition("annotatedBean", rbd);
    TestBean tb = new TestBean();
    bf.registerSingleton("testBean", tb);
    IndexedTestBean itb = new IndexedTestBean();
    bf.registerSingleton("indexedTestBean", itb);
    OrderedNestedTestBean ntb1 = new OrderedNestedTestBean();
    ntb1.setOrder(2);
    bf.registerSingleton("nestedTestBean1", ntb1);
    OrderedNestedTestBean ntb2 = new OrderedNestedTestBean();
View Full Code Here

    RootBeanDefinition rbd = new RootBeanDefinition(OptionalCollectionResourceInjectionBean.class);
    rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
    bf.registerBeanDefinition("annotatedBean", rbd);
    TestBean tb = new TestBean();
    bf.registerSingleton("testBean", tb);
    IndexedTestBean itb = new IndexedTestBean();
    bf.registerSingleton("indexedTestBean", itb);
    FixedOrder2NestedTestBean ntb1 = new FixedOrder2NestedTestBean();
    bf.registerSingleton("nestedTestBean1", ntb1);
    FixedOrder1NestedTestBean ntb2 = new FixedOrder1NestedTestBean();
    bf.registerSingleton("nestedTestBean2", ntb2);
View Full Code Here

    assertEquals(lawyerCompany, tb.getLawyer().getCompany());
  }

  @Test
  public void testIndexedProperties() {
    IndexedTestBean bean = new IndexedTestBean();
    BeanWrapper bw = new BeanWrapperImpl(bean);
    TestBean tb0 = bean.getArray()[0];
    TestBean tb1 = bean.getArray()[1];
    TestBean tb2 = ((TestBean) bean.getList().get(0));
    TestBean tb3 = ((TestBean) bean.getList().get(1));
    TestBean tb6 = ((TestBean) bean.getSet().toArray()[0]);
    TestBean tb7 = ((TestBean) bean.getSet().toArray()[1]);
    TestBean tb4 = ((TestBean) bean.getMap().get("key1"));
    TestBean tb5 = ((TestBean) bean.getMap().get("key.3"));
    assertEquals("name0", tb0.getName());
    assertEquals("name1", tb1.getName());
    assertEquals("name2", tb2.getName());
    assertEquals("name3", tb3.getName());
    assertEquals("name6", tb6.getName());
View Full Code Here

TOP

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

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.