⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ozonetestcase.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Library License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.
//
// $Id$

package test;

import junit.framework.TestCase;
import org.apache.log4j.Category;
import org.apache.log4j.Logger;
import org.ozoneDB.ExternalDatabase;

/**
 * Base class for the Ozone based TestCase. The following is an
 * example of writting OzoneTestCase.
 *
 * <pre>
 *  packge com.foo;
 *
 *  import junit.framework.*;
 *  import test.OzoneTestCase;
 *  import org.ozoneDB.test.simple.*;
 *
 *  package FooTestCase extends OzoneTestCase {
 *    public static Test suite() {
 *      TestSuite suite = new TestSuite();
 *      suite.addTestSuite(FooTestCase.class);
 *      return suite;
 *    }
 *
 *    public void testCreate() {
 *      // db() provide the access to database setup by TestRunner
 *      Auto auto = (Auto)db().createObject(AutoImpl.class.getName());
 *      assertNotNull(auto);
 *      // Test away!!!
 *    }
 *  }
 *</pre>
 *
 * @author <a href="http://www.softwarebuero.de/">SMB</a>
 * @author <a href="mailto:david@d11e.com">David Li</a>
 * @version $Revision$Date$ */
public abstract class OzoneTestCase extends TestCase {

    /**
     * log4j logger
     */
    private static Logger fLog = Logger.getLogger(OzoneTestCase.class);

    /**
     * the database to be used for testing
     */
    private ExternalDatabase db;

    /** the url used for the db, could be used to open other connections */
    private String dbUrl;

    /**
     * Constructor.
     */
    protected OzoneTestCase(String name) {
        super(name);
    }

    /**
     * Return the database set up by OzoneTestRunner
     * @return a instance of ExternalDatabase
     */
    public ExternalDatabase db() {
        return db;
    }

    /**
     * Set the database for this TestCase. This is typically used by
     * the OzoneTestRunner. However, you can also use it in the
     * setUp() method to connect to different database than the one
     * specified by the OzoneTestRunner.
     *
     * @param db the database to be used for the TestCase
     */
    public void setDB(ExternalDatabase db) {
        this.db = db;
        fLog.debug("setDB(): set new database to " + db);
    }

    public void setDbUrl(String dbUrl) {
        this.dbUrl = dbUrl;
    }

    public String getDbUrl() {
        return dbUrl;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -