@@ -0,0 +1,2364 @@
+package org.flymine.util;%0A%0A/*%0A * Copyright (C) 2002-2003 FlyMine%0A *%0A * This code may be freely distributed and modified under the%0A * terms of the GNU Lesser General Public Licence.  This should%0A * be distributed with the code.  See the LICENSE file for more%0A * information or http://www.gnu.org/copyleft/lesser.html.%0A *%0A */%0A%0Aimport java.util.Collections;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Set;%0A%0Aimport junit.framework.TestCase;%0A%0Aimport org.flymine.metadata.Model;%0Aimport org.flymine.model.testmodel.*;%0A%0Apublic class DynamicUtilTest extends TestCase%0A%7B%0A    public DynamicUtilTest(String arg) %7B%0A        super(arg);%0A    %7D%0A%0A    private Model model;%0A%0A    public void setUp() throws Exception %7B%0A        model = Model.getInstanceByName(%22testmodel%22);%0A    %7D%0A%0A    // NEED MORE TESTS FOR MULTIPLE INHERITED INTERFACES WHEN AVAILABLE%0A    // eg.    - B%0A    //       /%0A    //      A     - D%0A    //       %5C   /   %5C%0A    //        - C     - F%0A    //           %5C   /%0A    //            - E%0A%0A    public void testCreateObjectInterfaceAsClass() throws Exception %7B%0A        try %7B%0A            DynamicUtil.createObject(model, Collections.singleton(%22org.flymine.model.testmodel.Company%22));%0A            fail(%22Expected: IllegalArgumentException%22);%0A        %7D catch (IllegalArgumentException e) %7B%0A        %7D%0A    %7D%0A%0A    public void testCreateObjectRubbishClass() throws Exception %7B%0A        try %7B%0A            DynamicUtil.createObject(model, Collections.singleton(%22org.flymine.model.testmodel.BlahBlahBlah%22));%0A            fail(%22Expected: ClassNotFoundException%22);%0A        %7D catch (ClassNotFoundException e) %7B%0A        %7D%0A    %7D%0A%0A    public void testCreateObjectOneInterfaceWithParents() throws Exception %7B%0A        Object obj = DynamicUtil.createObject(model, Collections.singleton(%22org.flymine.model.testmodel.Employable%22));%0A        assertTrue(obj instanceof Employable);%0A        assertTrue(obj instanceof Thing);%0A    %7D%0A%0A    public void testCreateObjectNoClassTwoInterfaces() throws Exception %7B%0A        Set intSet = new HashSet();%0A        intSet.add(%22org.flymine.model.testmodel.Employable%22);%0A        intSet.add(%22org.flymine.model.testmodel.ImportantPerson%22);%0A        Object obj = DynamicUtil.createObject(model, intSet);%0A        assertTrue(obj instanceof Employable);%0A        assertTrue(obj instanceof Thing);%0A        assertTrue(obj instanceof ImportantPerson);%0A    %7D%0A%7D%0A

Test class for DynamicUtil