View Javadoc
1 /* 2 * LoaderTest.java Sept 01, 2002 3 * 4 * Sample JUnit test using Loader for creating test database and 5 * inserting data into it. 6 * 7 */ 8 9 package test.org.webdocwf.util.loader; 10 11 import java.sql.Connection; 12 import java.sql.DriverManager; 13 14 import org.webdocwf.util.loader.test.LoaderTestCase; 15 import org.webdocwf.util.loader.Loader; 16 import org.webdocwf.util.loader.test.DatabaseOperation; 17 import org.webdocwf.util.loader.test.LoaderOperation; 18 19 20 import junit.framework.TestCase; 21 import junit.framework.Test; 22 import junit.framework.TestSuite; 23 import junit.framework.TestResult; 24 25 /*** 26 * @author Sinisa Milosevic 27 * @version $Revision: 1.1 $ 28 */ 29 public class LoaderTest extends LoaderTestCase 30 { 31 public static final String DATABASE_LOCATION_PROPERTY="database.location"; 32 33 public LoaderTest(String name) 34 { 35 super(name); 36 } 37 38 /*** 39 * Returns the test database connection. 40 */ 41 public Connection getConnection() throws Exception 42 { 43 44 Class driverClass = Class.forName("com.quadcap.jdbc.JdbcDriver"); 45 java.sql.Connection jdbcConnection = java.sql.DriverManager.getConnection("jdbc:qed:test/LoaderTest;create=true"); 46 47 return jdbcConnection; 48 } 49 50 /*** 51 * Returns the name of test database. 52 */ 53 54 public String getDatabaseName() throws Exception 55 { 56 return "LoaderTest"; 57 } 58 59 60 61 /*** 62 * Returns the database operations executed in test setup. First operation will be 63 * executed dbOperation[0], then dbOperation[1]... 64 */ 65 public DatabaseOperation[] getSetUpOperation() throws Exception 66 { 67 // Creating test database..... 68 DatabaseOperation[] dbOperation = new DatabaseOperation[1]; 69 // dbOperation[0]=new CreateDatabaseOperation(getDatabaseName()); 70 71 dbOperation[0]=new LoaderOperation(getLoader()); 72 73 return dbOperation; 74 } 75 76 /*** 77 * Returns the test Loader class (loaderjob). 78 */ 79 public Loader getLoader() throws Exception 80 { 81 Loader loadJob= new Loader("modules/Octopus/src/testdata/ObjectLoader/LoadTestExample.xml"); 82 loadJob.setUserID("admin"); 83 loadJob.setLogDirName("test"); 84 loadJob.setLogFileName("LoaderTest.txt"); 85 86 return loadJob; 87 } 88 89 /*** 90 * Returns the database operation executed in test cleanup. 91 * First operation will be executed dbOperation[0], then dbOperation[1]... 92 */ 93 public DatabaseOperation[] getTearDownOperation() throws Exception 94 { 95 // Do nothing... 96 DatabaseOperation[] dbOperation = new DatabaseOperation[1]; 97 dbOperation[0]=DatabaseOperation.DO_NOTHING; 98 99 return dbOperation; 100 } 101 102 public void testMe() throws Exception 103 { 104 System.out.println("Executing test: testMe 1"); 105 } 106 107 public static Test suite() { 108 return new TestSuite(LoaderTest.class); 109 } 110 111 112 public static void main(String args[]) { 113 // junit.textui.TestRunner.run(suite()); 114 TestResult result= (new LoaderTest("testMe 1")).run(); 115 116 } 117 118 119 120 } 121 122 123 124 125

This page automatically generated by Maven