Package speculoos.utils

Source Code of speculoos.utils.SyntheticMapTest

/*---------------------------------------------------------------------------
* Speculoos, LDAP to objet mapping.
* Copyright (C) 2006  Norsys and oQube
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*
* email: contact@oqube.com
* creation: Thu Sep 14 2006
* --------------------------------------------------------------------------*/
package speculoos.utils;

import  speculoos.beans.SyntheticMap;
import  speculoos.beans.MapEntry;
import junit.framework.TestCase;

/**
* Test cases for sythetic maps.
* These tests essentially test the inheritance mechanism.
*
* @author abailly@oqube.com
* @version $Id: SyntheticMapTest.java 65 2007-03-19 22:43:27Z trecloux $
*/
public class SyntheticMapTest extends TestCase {
 
  public void test01BasicInheritance() {
    SyntheticMap child = new SyntheticMap();
    MapEntry me = new MapEntry("toto");
    me.setValue("titi");
    me.setType("tata");
    child.put("toto",me);
    SyntheticMap parent = new SyntheticMap();
    me = new MapEntry("titi");
    me.setValue("null");
    me.setType("titi");
    parent.put("titi",me);
    child.addInherits(parent);
    assertEquals("toto", ((MapEntry)child.get("toto")).getName());
    assertEquals("titi", ((MapEntry)child.get("titi")).getType());
  }

  public void test02MultipleInheritance() {
    SyntheticMap child = new SyntheticMap();
    MapEntry me = new MapEntry("toto");
    me.setValue("titi");
    me.setType("tata");
    child.put("toto",me);
    SyntheticMap parent = new SyntheticMap();
    me = new MapEntry("titi");
    me.setValue("null");
    me.setType("titi");
    parent.put("titi",me);
    child.addInherits(parent);
    parent = new SyntheticMap();
    me = new MapEntry("foo");
    me.setValue("bar");
    me.setType("baz");
    parent.put("foo",me);
    child.addInherits(parent);
    assertEquals("toto", ((MapEntry)child.get("toto")).getName());
    assertEquals("bar", ((MapEntry)child.get("foo")).getValue());
  }

  public void test03Hierarchy() {
    SyntheticMap child = new SyntheticMap();
    MapEntry me = new MapEntry("toto");
    me.setValue("titi");
    me.setType("tata");
    child.put("toto",me);
    SyntheticMap parent = new SyntheticMap();
    me = new MapEntry("titi");
    me.setValue("null");
    me.setType("titi");
    parent.put("titi",me);
    child.addInherits(parent);
    SyntheticMap parent2 = new SyntheticMap();
    me = new MapEntry("foo");
    me.setValue("bar");
    me.setType("baz");
    parent2.put("foo",me);
    parent.addInherits(parent2);
    assertEquals("toto", ((MapEntry)child.get("toto")).getName());
    assertEquals("bar", ((MapEntry)child.get("foo")).getValue());
  }
}
TOP

Related Classes of speculoos.utils.SyntheticMapTest

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.