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();
}
}