Package org.jugile.daims

Source Code of org.jugile.daims.DBTest

package org.jugile.daims;

import org.jugile.proto2.common.FamilyType;
import org.jugile.proto2.domain.*;
import org.jugile.util.DBConnection;
import org.jugile.util.DBPool;
import org.jugile.util.HiLo;
import org.jugile.util.JugileTestCase;
import org.jugile.util.Props;
import org.jugile.util.Time;

public class DBTest extends JugileTestCase {

  public static void clearDatabase() throws Exception {
    DBPool db = DBPool.getPool();
    DBConnection c = db.getConnection();
    c.updateN("delete from person_t");
    c.updateN("delete from family_t");
    c.updateN("delete from map_person_2friend_family");
    c.updateN("delete from dbmq_queue_t");
    c.updateN("delete from dbmq_messages_t");
    c.updateN("update idpool set nextid=100 where obj=\"global\"");
    HiLo.setNextid(1);
    c.commit()
  }
  public void setUp() throws Exception {
    clearDatabase();
  }
  public void tearDown() throws Exception {
    clearDatabase();
  }

  public void testWriteAndLoadDB() throws Exception {
    setUp();
    Domain.reset();
    Domain d = Domain.getDomain();
    HiLo.setHasdb(false);
    CreateAndVerifyTest.createDomain(d);
    d.commit();
    d.saveAllToDB();

    // load and verify
    Domain.reset();
    d = Domain.getDomain();
    d.loadFromDB();
   
    CreateAndVerifyTest.verifyDomain(d);

    d.rollback();
    HiLo.resetHasdb();
  }
 
 
}
TOP

Related Classes of org.jugile.daims.DBTest

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.