Package org.xorm.tests

Source Code of org.xorm.tests.TestXORM

package org.xorm.tests;

import junit.framework.*;

import org.xorm.XORM;
import org.xorm.tests.model.*;
import javax.jdo.PersistenceManager;
import javax.jdo.spi.JDOImplHelper;
import javax.jdo.spi.PersistenceCapable;

public class TestXORM extends XORMTestCase {
    public void testNewInterfaceInstance() {
        PersistenceManager mgr = factory.getPersistenceManager();
        XORM.newInstance(mgr, EmptyInterface.class);
    }

    public void testNewAbstractClassInstance() {
        PersistenceManager mgr = factory.getPersistenceManager();
        XORM.newInstance(mgr, EmptyAbstractClass.class);
    }

    /**
     * Creates and then deletes (in two separate transactions) a simple
     * String wrapper.  The String is not initialized and should be null.
     */
    public void testNewPersistentString() {
        PersistenceManager mgr = factory.getPersistenceManager();
        mgr.currentTransaction().begin();
        StringInterface si = (StringInterface) XORM.newInstance(mgr, StringInterface.class);
        mgr.makePersistent(si);
        mgr.currentTransaction().commit();

        // Now delete it
        mgr.currentTransaction().begin();
        mgr.deletePersistent(si);
        mgr.currentTransaction().commit();
    }

    public void testNewOneToMany() {
        PersistenceManager mgr = factory.getPersistenceManager();
        mgr.currentTransaction().begin();
        ManySide m1 = (ManySide) XORM.newInstance(mgr, ManySide.class);
        OneSide one = (OneSide) XORM.newInstance(mgr, OneSide.class);
        m1.setOne(one);
        one.getMany().add(m1)// shouldn't have to do both of these, but..
        mgr.makePersistent(m1);
        mgr.makePersistent(one);
        mgr.currentTransaction().commit();
    }

    public void testJDOImplHelper() {
        Object obj = JDOImplHelper.getInstance().newInstance(EmptyInterface.class, null);
        assertTrue(obj instanceof EmptyInterface);
        assertTrue(obj instanceof PersistenceCapable);
    }

    public static void main(String args[]) {
        String[] testCaseName = {TestXORM.class.getName()};
        junit.textui.TestRunner.main(testCaseName);
    }

    public static Test suite() {
        TestSuite suite = new TestSuite();
        suite.addTestSuite(TestXORM.class);
        suite.addTestSuite(TestStateManagement.class);
        suite.addTestSuite(TestJDOEnhanced.class);
        suite.addTestSuite(TestObjectId.class);
        suite.addTestSuite(TestStringOps.class);
        return suite;
    }
 
}
TOP

Related Classes of org.xorm.tests.TestXORM

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.