Examples of IndexedTestBean


Examples of org.springframework.beans.IndexedTestBean

    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.array[0].age=99\ntb.list[1].name=test");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
    assertEquals(99, tb.getArray()[0].getAge());
    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
  }
View Full Code Here

Examples of org.springframework.beans.IndexedTestBean

    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "my.tb_array[0].age=99\nmy.tb_list[1].name=test");
    pvs.addPropertyValue("beanNameSeparator", "_");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("my.tb");
    assertEquals(99, tb.getArray()[0].getAge());
    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
  }
View Full Code Here

Examples of org.springframework.beans.IndexedTestBean

    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.map[key1]=99\ntb.map[key2.ext]=test");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
    assertEquals("99", tb.getMap().get("key1"));
    assertEquals("test", tb.getMap().get("key2.ext"));
  }
View Full Code Here

Examples of org.springframework.beans.IndexedTestBean

    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("location", "classpath:org/springframework/beans/factory/config/test.properties");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
    assertEquals(99, tb.getArray()[0].getAge());
    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
  }
View Full Code Here

Examples of org.springframework.beans.IndexedTestBean

        new String[] {"classpath:org/springframework/beans/factory/config/test.properties",
                      "classpath:org/springframework/beans/factory/config/xtest.properties"});
    pvs.addPropertyValue("ignoreResourceNotFound", Boolean.TRUE);
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
    assertEquals(99, tb.getArray()[0].getAge());
    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
  }
View Full Code Here

Examples of org.springframework.beans.IndexedTestBean

    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("location", "classpath:org/springframework/beans/factory/config/test-properties.xml");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
    assertEquals(99, tb.getArray()[0].getAge());
    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
  }
View Full Code Here

Examples of org.springframework.beans.IndexedTestBean

    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.array[0].name=99\ntb.list[1].name=test");
    ac.registerSingleton("configurer", ConvertingOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
    assertEquals("X99", tb.getArray()[0].getName());
    assertEquals("Xtest", ((TestBean) tb.getList().get(1)).getName());
  }
View Full Code Here

Examples of org.springframework.beans.IndexedTestBean

    editor.setValue(null);
    assertEquals("", editor.getAsText());
  }

  public void testIndexedPropertiesWithCustomEditorForType() {
    IndexedTestBean bean = new IndexedTestBean();
    BeanWrapper bw = new BeanWrapperImpl(bean);
    bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("prefix" + text);
      }
    });
    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 tb4 = ((TestBean) bean.getMap().get("key1"));
    TestBean tb5 = ((TestBean) bean.getMap().get("key2"));
    assertEquals("name0", tb0.getName());
    assertEquals("name1", tb1.getName());
    assertEquals("name2", tb2.getName());
    assertEquals("name3", tb3.getName());
    assertEquals("name4", tb4.getName());
View Full Code Here

Examples of org.springframework.beans.IndexedTestBean

    assertEquals("prefixname1", bw.getPropertyValue("map[\"key1\"].name"));
    assertEquals("prefixname0", bw.getPropertyValue("map['key2'].name"));
  }

  public void testIndexedPropertiesWithCustomEditorForProperty() {
    IndexedTestBean bean = new IndexedTestBean(false);
    BeanWrapper bw = new BeanWrapperImpl(bean);
    bw.registerCustomEditor(String.class, "array.name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("array" + text);
      }
    });
    bw.registerCustomEditor(String.class, "list.name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("list" + text);
      }
    });
    bw.registerCustomEditor(String.class, "map.name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("map" + text);
      }
    });
    bean.populate();

    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 tb4 = ((TestBean) bean.getMap().get("key1"));
    TestBean tb5 = ((TestBean) bean.getMap().get("key2"));
    assertEquals("name0", tb0.getName());
    assertEquals("name1", tb1.getName());
    assertEquals("name2", tb2.getName());
    assertEquals("name3", tb3.getName());
    assertEquals("name4", tb4.getName());
View Full Code Here

Examples of org.springframework.beans.IndexedTestBean

    assertEquals("mapname1", bw.getPropertyValue("map[\"key1\"].name"));
    assertEquals("mapname0", bw.getPropertyValue("map['key2'].name"));
  }

  public void testIndexedPropertiesWithIndividualCustomEditorForProperty() {
    IndexedTestBean bean = new IndexedTestBean(false);
    BeanWrapper bw = new BeanWrapperImpl(bean);
    bw.registerCustomEditor(String.class, "array[0].name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("array0" + text);
      }
    });
    bw.registerCustomEditor(String.class, "array[1].name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("array1" + text);
      }
    });
    bw.registerCustomEditor(String.class, "list[0].name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("list0" + text);
      }
    });
    bw.registerCustomEditor(String.class, "list[1].name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("list1" + text);
      }
    });
    bw.registerCustomEditor(String.class, "map[key1].name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("mapkey1" + text);
      }
    });
    bw.registerCustomEditor(String.class, "map[key2].name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("mapkey2" + text);
      }
    });
    bean.populate();

    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 tb4 = ((TestBean) bean.getMap().get("key1"));
    TestBean tb5 = ((TestBean) bean.getMap().get("key2"));
    assertEquals("name0", tb0.getName());
    assertEquals("name1", tb1.getName());
    assertEquals("name2", tb2.getName());
    assertEquals("name3", tb3.getName());
    assertEquals("name4", tb4.getName());
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.