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 12 import java.sql.Connection; 13 import java.sql.DriverManager; 14 15 import org.webdocwf.util.loader.test.LoaderTestCase; 16 import org.webdocwf.util.loader.test.DatabaseOperation; 17 import org.webdocwf.util.loader.test.CreateDatabaseOperation; 18 import org.webdocwf.util.loader.test.DropDatabaseOperation; 19 import org.webdocwf.util.loader.test.LoaderOperation; 20 import org.webdocwf.util.loader.Loader; 21 22 import junit.framework.TestCase; 23 import junit.framework.Test; 24 import junit.framework.TestSuite; 25 import junit.framework.TestResult; 26 27 /*** 28 * @author Sinisa Milosevic 29 * @version $Revision: 1.1 $ 30 */ 31 public class LoaderTest3 extends LoaderTestCase 32 { 33 34 public LoaderTest3(String name) 35 { 36 super(name); 37 } 38 39 /*** 40 * Returns the test database connection. 41 */ 42 public Connection getConnection() throws Exception 43 { 44 45 Class driverClass = Class.forName("com.quadcap.jdbc.JdbcDriver"); 46 Connection jdbcConnection = DriverManager.getConnection( 47 "jdbc:qed:test/LoaderTest3;create=true"); 48 49 return jdbcConnection; 50 } 51 52 /*** 53 * Returns the name of test database. 54 */ 55 56 public String getDatabaseName() throws Exception 57 { 58 return "LoaderTest3"; 59 } 60 61 62 /*** 63 * Returns the test Loader class (loaderjob). 64 */ 65 public Loader getLoader() throws Exception 66 { 67 Loader loadJob= new Loader("modules/Octopus/src/testdata/ObjectLoader/CreateTables3.xml"); 68 loadJob.setUserID("admin"); 69 loadJob.setLogDirName("test"); 70 loadJob.setLogFileName("LoaderTest3.txt"); 71 72 73 return loadJob; 74 } 75 76 /*** 77 * Returns the database operations executed in test setup. First operation will be 78 * executed dbOperation[0], then dbOperation[1]... 79 */ 80 public DatabaseOperation[] getSetUpOperation() throws Exception 81 { 82 // Creating test database..... 83 DatabaseOperation[] dbOperation = new DatabaseOperation[3]; 84 // dbOperation[0]=new CreateDatabaseOperation(getDatabaseName()); 85 86 // Creating tables..... 87 dbOperation[0]=new LoaderOperation(getLoader()); 88 89 // Inserting data..... 90 Loader loadJob1= new Loader("modules/Octopus/src/testdata/ObjectLoader/InsertData.xml"); 91 loadJob1.setUserID("admin"); 92 loadJob1.setLogDirName("test"); 93 loadJob1.setLogFileName("LoaderTest3.txt"); 94 dbOperation[1]=new LoaderOperation(loadJob1); 95 96 // Creating indexes, foreign keys..... 97 Loader loadJob2= new Loader("modules/Octopus/src/testdata/ObjectLoader/CreateIndex.xml"); 98 loadJob2.setLogDirName("test"); 99 loadJob2.setLogFileName("LoaderTest3_CreateIndex.txt"); 100 dbOperation[2]=new LoaderOperation(loadJob2); 101 102 103 return dbOperation; 104 } 105 106 /*** 107 * Returns the database operation executed in test cleanup. 108 * First operation will be executed dbOperation[0], then dbOperation[1]... 109 */ 110 public DatabaseOperation[] getTearDownOperation() throws Exception 111 { 112 // Deleting test database..... 113 DatabaseOperation[] dbOperation = new DatabaseOperation[1]; 114 dbOperation[0]=DatabaseOperation.DO_NOTHING; 115 116 return dbOperation; 117 } 118 119 120 public void testMe() throws Exception 121 { 122 System.out.println("Executing test: test3"); 123 } 124 125 126 public static Test suite() { 127 return new TestSuite(LoaderTest3.class); 128 } 129 130 131 public static void main(String args[]) { 132 // junit.textui.TestRunner.run(suite()); 133 TestResult result= (new LoaderTest3("testMe 3")).run(); 134 135 } 136 137 138 139 } 140 141 142 143 144

This page automatically generated by Maven