📄 loadertest2.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.test.DatabaseOperation;
import org.webdocwf.util.loader.test.LoaderOperation;
import org.webdocwf.util.loader.Loader;
import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.framework.TestResult;
/**
* @author Sinisa Milosevic
* @version $Revision: 1.4 $
*/
public class LoaderTest2 extends LoaderTestCase
{
public LoaderTest2(String name)
{
super(name);
}
/**
* Returns the test database connection.
* @throws Exception
* @return jdbcConnection
*/
public Connection getConnection() throws Exception
{
Class driverClass = Class.forName("org.hsqldb.jdbcDriver");
Connection jdbcConnection = DriverManager.getConnection(
"jdbc:hsqldb:test/LoaderTest2/LoaderTest2","sa","");
return jdbcConnection;
}
/**
* 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/LoaderExample1.xml");
loadJob.setUserID("admin");
loadJob.setLogDirName("test");
loadJob.setLogFileName("LoaderTest2.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 2 - SQL Statements as a source data");
System.out.println("****************************************************************");
this.isHeaderShown = true;
}
}
/**
* 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
{
// Executing loaderJob defined in xml file.
DatabaseOperation[] dbOperation = new DatabaseOperation[1];
dbOperation[0]=new LoaderOperation(getLoader());
return dbOperation;
}
/**
* 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(LoaderTest2.class);
}
public static void main(String args[]) {
// junit.textui.TestRunner.run(suite());
TestResult result= (new LoaderTest2("testMe 2")).run();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -