示例#1
0
        public bool createDbTest(
            string sDbName,
            DbSystem dbSystem)
        {
            Db    db = null;
            RCODE rc;

            beginTest("Create Database Test (" + sDbName + ")");

            for (;;)
            {
                rc = RCODE.NE_XFLM_OK;
                try
                {
                    XFLM_CREATE_OPTS createOpts = new XFLM_CREATE_OPTS();

                    createOpts.uiBlockSize           = 8192;
                    createOpts.uiVersionNum          = (uint)DBVersions.XFLM_CURRENT_VERSION_NUM;
                    createOpts.uiMinRflFileSize      = 2000000;
                    createOpts.uiMaxRflFileSize      = 20000000;
                    createOpts.bKeepRflFiles         = 1;
                    createOpts.bLogAbortedTransToRfl = 1;
                    createOpts.eDefaultLanguage      = Languages.FLM_DE_LANG;
                    db = dbSystem.dbCreate(sDbName, null, null, null, null, createOpts);
                }
                catch (XFlaimException ex)
                {
                    rc = ex.getRCode();

                    if (rc != RCODE.NE_XFLM_FILE_EXISTS)
                    {
                        endTest(false, ex, "creating database");
                        return(false);
                    }
                }
                if (rc == RCODE.NE_XFLM_OK)
                {
                    break;
                }

                // rc better be NE_XFLM_FILE_EXISTS - try to delete the file

                try
                {
                    dbSystem.dbRemove(sDbName, null, null, true);
                }
                catch (XFlaimException ex)
                {
                    endTest(false, ex, "removing database");
                    return(false);
                }
            }
            if (db != null)
            {
                db.close();
                db = null;
            }
            endTest(false, true);
            return(true);
        }
示例#2
0
        public bool rebuildDbTest(
            string sSrcDbName,
            string sDestDbName,
            DbSystem dbSystem)
        {
            MyDbRebuildStatus dbRebuildStatus = null;
            XFLM_CREATE_OPTS  createOpts      = null;

            // Try restoring the database

            beginTest("Rebuild Database Test (" + sSrcDbName + " to " + sDestDbName + ")");

            dbRebuildStatus = new MyDbRebuildStatus();
            createOpts      = new XFLM_CREATE_OPTS();

            createOpts.uiBlockSize           = 8192;
            createOpts.uiVersionNum          = (uint)DBVersions.XFLM_CURRENT_VERSION_NUM;
            createOpts.uiMinRflFileSize      = 2000000;
            createOpts.uiMaxRflFileSize      = 20000000;
            createOpts.bKeepRflFiles         = 1;
            createOpts.bLogAbortedTransToRfl = 1;
            createOpts.eDefaultLanguage      = Languages.FLM_DE_LANG;
            try
            {
                dbSystem.dbRebuild(sSrcDbName, null, sDestDbName, null, null,
                                   null, null, createOpts, dbRebuildStatus);
            }
            catch (XFlaimException ex)
            {
                endTest(dbRebuildStatus.outputLines(), ex, "rebuilding database");
                return(false);
            }

            endTest(true, true);
            return(true);
        }
示例#3
0
        public bool importTests(
            string sDbName,
            DbSystem dbSystem)
        {
            bool  bOk           = false;
            Db    db            = null;
            bool  bStartedTrans = false;
            RCODE rc;

            // Create the database

            beginTest("Create database \"" + sDbName + "\"");

            for (;;)
            {
                rc = RCODE.NE_XFLM_OK;
                try
                {
                    XFLM_CREATE_OPTS createOpts = new XFLM_CREATE_OPTS();

                    createOpts.uiBlockSize           = 8192;
                    createOpts.uiVersionNum          = (uint)DBVersions.XFLM_CURRENT_VERSION_NUM;
                    createOpts.uiMinRflFileSize      = 2000000;
                    createOpts.uiMaxRflFileSize      = 20000000;
                    createOpts.bKeepRflFiles         = 1;
                    createOpts.bLogAbortedTransToRfl = 1;
                    createOpts.eDefaultLanguage      = Languages.FLM_DE_LANG;
                    db = dbSystem.dbCreate(sDbName, null, null, null, null, createOpts);
                }
                catch (XFlaimException ex)
                {
                    rc = ex.getRCode();

                    if (rc != RCODE.NE_XFLM_FILE_EXISTS)
                    {
                        endTest(false, ex, "creating database");
                        return(false);
                    }
                }
                if (rc == RCODE.NE_XFLM_OK)
                {
                    break;
                }

                // rc better be NE_XFLM_FILE_EXISTS - try to delete the file

                try
                {
                    dbSystem.dbRemove(sDbName, null, null, true);
                }
                catch (XFlaimException ex)
                {
                    endTest(false, ex, "removing database");
                    return(false);
                }
            }
            endTest(false, true);

            // Start a transaction

            beginTest("Start Update Transaction Test");
            try
            {
                db.transBegin(eDbTransType.XFLM_UPDATE_TRANS, 255, 0);
            }
            catch (XFlaimException ex)
            {
                endTest(false, ex, "starting update transaction");
                goto Exit;
            }
            endTest(false, true);
            bStartedTrans = true;

            // Create a document

            if (!importTests(db, dbSystem))
            {
                goto Exit;
            }

            // Commit the transaction

            beginTest("Commit Update Transaction Test");
            try
            {
                bStartedTrans = false;
                db.transCommit();
            }
            catch (XFlaimException ex)
            {
                endTest(false, ex, "committing update transaction");
                goto Exit;
            }
            endTest(false, true);

            bOk = true;

Exit:
            if (bStartedTrans)
            {
                db.transAbort();
            }
            if (db != null)
            {
                db.close();
                db = null;
            }
            return(bOk);
        }