Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.HasMap


    }
  }

  public void testEmptyMap() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
    HasMap hasMap = (HasMap) xbf.getBean("emptyMap");
    assertTrue(hasMap.getMap().size() == 0);
  }
View Full Code Here


    assertTrue(hasMap.getMap().size() == 0);
  }

  public void testMapWithLiteralsOnly() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
    HasMap hasMap = (HasMap) xbf.getBean("literalMap");
    assertTrue(hasMap.getMap().size() == 3);
    assertTrue(hasMap.getMap().get("foo").equals("bar"));
    assertTrue(hasMap.getMap().get("fi").equals("fum"));
    assertTrue(hasMap.getMap().get("fa") == null);
  }
View Full Code Here

    assertTrue(hasMap.getMap().get("fa") == null);
  }

  public void testMapWithLiteralsAndReferences() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
    HasMap hasMap = (HasMap) xbf.getBean("mixedMap");
    assertTrue(hasMap.getMap().size() == 3);
    assertTrue(hasMap.getMap().get("foo").equals(new Integer(10)));
    TestBean jenny = (TestBean) xbf.getBean("jenny");
    assertTrue(hasMap.getMap().get("jenny") == jenny);
    assertTrue(hasMap.getMap().get(new Integer(5)).equals("david"));
  }
View Full Code Here

  public void testMapWithLiteralsAndPrototypeReferences() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));

    TestBean jenny = (TestBean) xbf.getBean("pJenny");
    HasMap hasMap = (HasMap) xbf.getBean("pMixedMap");
    assertTrue(hasMap.getMap().size() == 2);
    assertTrue(hasMap.getMap().get("foo").equals("bar"));
    assertTrue(hasMap.getMap().get("jenny").toString().equals(jenny.toString()));
    assertTrue("Not same instance", hasMap.getMap().get("jenny") != jenny);

    HasMap hasMap2 = (HasMap) xbf.getBean("pMixedMap");
    assertTrue(hasMap2.getMap().size() == 2);
    assertTrue(hasMap2.getMap().get("foo").equals("bar"));
    assertTrue(hasMap2.getMap().get("jenny").toString().equals(jenny.toString()));
    assertTrue("Not same instance", hasMap2.getMap().get("jenny") != hasMap.getMap().get("jenny"));
  }
View Full Code Here

    assertTrue("Not same instance", hasMap2.getMap().get("jenny") != hasMap.getMap().get("jenny"));
  }

  public void testMapWithLiteralsReferencesAndList() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
    HasMap hasMap = (HasMap) xbf.getBean("mixedMapWithList");
    assertTrue(hasMap.getMap().size() == 4);
    assertTrue(hasMap.getMap().get(null).equals("bar"));
    TestBean jenny = (TestBean) xbf.getBean("jenny");
    assertTrue(hasMap.getMap().get("jenny").equals(jenny));

    // Check list
    List l = (List) hasMap.getMap().get("list");
    assertNotNull(l);
    assertTrue(l.size() == 4);
    assertTrue(l.get(0).equals("zero"));
    assertTrue(l.get(3) == null);

    // Check nested map in list
    Map m = (Map) l.get(1);
    assertNotNull(m);
    assertTrue(m.size() == 2);
    assertTrue(m.get("fo").equals("bar"));
    assertTrue("Map element 'jenny' should be equal to jenny bean, not " + m.get("jen"),
        m.get("jen").equals(jenny));

    // Check nested list in list
    l = (List) l.get(2);
    assertNotNull(l);
    assertTrue(l.size() == 2);
    assertTrue(l.get(0).equals(jenny));
    assertTrue(l.get(1).equals("ba"));

    // Check nested map
    m = (Map) hasMap.getMap().get("map");
    assertNotNull(m);
    assertTrue(m.size() == 2);
    assertTrue(m.get("foo").equals("bar"));
    assertTrue("Map element 'jenny' should be equal to jenny bean, not " + m.get("jenny"),
        m.get("jenny").equals(jenny));
View Full Code Here

        m.get("jenny").equals(jenny));
  }

  public void testEmptySet() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
    HasMap hasMap = (HasMap) xbf.getBean("emptySet");
    assertTrue(hasMap.getSet().size() == 0);
  }
View Full Code Here

    assertTrue(hasMap.getSet().size() == 0);
  }

  public void testPopulatedSet() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
    HasMap hasMap = (HasMap) xbf.getBean("set");
    assertTrue(hasMap.getSet().size() == 3);
    assertTrue(hasMap.getSet().contains("bar"));
    TestBean jenny = (TestBean) xbf.getBean("jenny");
    assertTrue(hasMap.getSet().contains(jenny));
    assertTrue(hasMap.getSet().contains(null));
    Iterator it = hasMap.getSet().iterator();
    assertEquals("bar", it.next());
    assertEquals(jenny, it.next());
    assertEquals(null, it.next());
  }
View Full Code Here

    assertEquals(null, it.next());
  }

  public void testEmptyProps() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
    HasMap hasMap = (HasMap) xbf.getBean("emptyProps");
    assertTrue(hasMap.getProps().size() == 0);
    assertEquals(hasMap.getProps().getClass(), Properties.class);
  }
View Full Code Here

    assertEquals(hasMap.getProps().getClass(), Properties.class);
  }

  public void testPopulatedProps() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
    HasMap hasMap = (HasMap) xbf.getBean("props");
    assertTrue(hasMap.getProps().size() == 2);
        assertTrue(hasMap.getProps().get("foo").equals("bar"));
    assertTrue(hasMap.getProps().get("2").equals("TWO"));
  }
View Full Code Here

    assertTrue(hasMap.getProps().get("2").equals("TWO"));
  }

  public void testObjectArray() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
    HasMap hasMap = (HasMap) xbf.getBean("objectArray");
    assertTrue(hasMap.getObjectArray().length == 2);
    assertTrue(hasMap.getObjectArray()[0].equals("one"));
    assertTrue(hasMap.getObjectArray()[1].equals(xbf.getBean("jenny")));
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.HasMap

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.