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

📄 loadertest.java

📁 数据仓库工具
💻 JAVA
字号:
/*
* LoaderTest.java   Sept 01, 2002
*
* Sample JUnit test using Loader for creating test database and
* inserting data into it.
*
 */

package test.org.webdocwf.util.loader;

import java.sql.Connection;
import java.sql.DriverManager;

import org.webdocwf.util.loader.test.LoaderTestCase;
import org.webdocwf.util.loader.Loader;
import org.webdocwf.util.loader.test.DatabaseOperation;
import org.webdocwf.util.loader.test.LoaderOperation;


import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.framework.TestResult;

/**
 * @author Sinisa Milosevic
 * @version $Revision: 1.6 $
 */
public class LoaderTest extends LoaderTestCase
{
  public static final String DATABASE_LOCATION_PROPERTY="database.location";

  public LoaderTest(String name)
  {
    super(name);
  }

  /**
   * Returns the test database connection.
   * @throws Exception
   * @return connection
   */
  public Connection getConnection() throws Exception
  {

    Class driverClass = Class.forName("org.hsqldb.jdbcDriver");
    java.sql.Connection jdbcConnection = java.sql.DriverManager.getConnection("jdbc:hsqldb:test/LoaderTest/LoaderTest","sa","");

    return jdbcConnection;
  }

  /**
   * Returns the name of test database.
   * @throws Exception
   * @return string
   */

  public String getDatabaseName() throws Exception
  {
    return "LoaderTest";
  }



  /**
   * Returns the database operations executed in test setup. First operation will be
   * executed dbOperation[0], then dbOperation[1]...
   * @throws Exception
   * @return dbOperation parameter
   */
  public DatabaseOperation[] getSetUpOperation() throws Exception
  {
//        Creating test database.....
    DatabaseOperation[] dbOperation = new DatabaseOperation[1];
//        dbOperation[0]=new CreateDatabaseOperation(getDatabaseName());

    dbOperation[0]=new LoaderOperation(getLoader());

    return dbOperation;
  }

  /**
   * Returns the test Loader class (loaderjob).
   * @throws Exception
   * @return Loader object
   */
  public Loader getLoader() throws Exception
  {
    showHeader();
    Loader loadJob= new Loader("modules/Octopus/src/testdata/ObjectLoader/LoadTestExample.xml");
    loadJob.setUserID("admin");
    loadJob.setLogDirName("test");
    loadJob.setLogFileName("LoaderTest.txt");

    return loadJob;
  }

  private static boolean isHeaderShown = false;
  private void showHeader() {
  	if( !this.isHeaderShown ) {
  	System.out.println();
    	System.out.println("**************************************************************************");
    	System.out.println("   Executing test: testMe 1 - Transfering data and creating integrity");
    	System.out.println("**************************************************************************");
    	this.isHeaderShown = true;
  	}
  }

  /**
   * Returns the database operation executed in test cleanup.
   *  First operation will be executed dbOperation[0], then dbOperation[1]...
   * @throws Exception
   * @return dbOperation parameter
   */
  public DatabaseOperation[] getTearDownOperation() throws Exception
  {
//				Do nothing...
    DatabaseOperation[] dbOperation = new DatabaseOperation[1];
    dbOperation[0]=DatabaseOperation.DO_NOTHING;

    return dbOperation;
  }

  public void testMe() throws Exception
  {

  }

  public static Test suite() {
    return new TestSuite(LoaderTest.class);
  }


  public static void main(String args[]) {

//    	junit.textui.TestRunner.run(suite());
    TestResult result= (new LoaderTest("testMe 1")).run();

  }



}

⌨️ 快捷键说明

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