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 * @throws Exception
42 * @return jdbc connection
43 */
44 public Connection getConnection() throws Exception
45 {
46
47 Class driverClass = Class.forName("org.hsqldb.jdbcDriver");
48 Connection jdbcConnection = DriverManager.getConnection(
49 "jdbc:hsqldb:test/LoaderTest3/LoaderTest3","sa","");
50
51 return jdbcConnection;
52 }
53
54 /***
55 * Returns the name of test database.
56 * @throws Exception
57 * @return string
58 */
59
60 public String getDatabaseName() throws Exception
61 {
62 return "LoaderTest3";
63 }
64
65
66 /***
67 * Returns the test Loader class (loaderjob).
68 * @throws Exception
69 * @return Loader object
70 */
71 public Loader getLoader() throws Exception
72 {
73
74 showHeader();
75 Loader loadJob= new Loader("modules/Octopus/src/testdata/ObjectLoader/CreateTables3.xml");
76 loadJob.setUserID("admin");
77 loadJob.setLogDirName("test");
78 loadJob.setLogFileName("LoaderTest3.txt");
79
80
81 return loadJob;
82 }
83
84 private static boolean isHeaderShown = false;
85 private void showHeader() {
86 if( !this.isHeaderShown ) {
87 System.out.println();
88 System.out.println("******************************************************");
89 System.out.println(" Executing test: test3 - ");
90 System.out.println("******************************************************");
91 this.isHeaderShown = true;
92 }
93 }
94
95 /***
96 * Returns the database operations executed in test setup. First operation will be
97 * executed dbOperation[0], then dbOperation[1]...
98 * @throws Exception
99 * @return dbOperation parameter
100 */
101 public DatabaseOperation[] getSetUpOperation() throws Exception
102 {
103 // Creating test database.....
104 DatabaseOperation[] dbOperation = new DatabaseOperation[3];
105 // dbOperation[0]=new CreateDatabaseOperation(getDatabaseName());
106
107 // Creating tables.....
108 dbOperation[0]=new LoaderOperation(getLoader());
109
110 // Inserting data.....
111 Loader loadJob1= new Loader("modules/Octopus/src/testdata/ObjectLoader/InsertData.xml");
112 loadJob1.setUserID("admin");
113 loadJob1.setLogDirName("test");
114 loadJob1.setLogFileName("LoaderTest3.txt");
115 dbOperation[1]=new LoaderOperation(loadJob1);
116
117 // Creating indexes, foreign keys.....
118 Loader loadJob2= new Loader("modules/Octopus/src/testdata/ObjectLoader/CreateIndex.xml");
119 loadJob2.setLogDirName("test");
120 loadJob2.setLogFileName("LoaderTest3_CreateIndex.txt");
121 dbOperation[2]=new LoaderOperation(loadJob2);
122
123
124 return dbOperation;
125 }
126
127 /***
128 * Returns the database operation executed in test cleanup.
129 * First operation will be executed dbOperation[0], then dbOperation[1]...
130 * @throws Exception
131 * @return dbOperation parameter
132 */
133 public DatabaseOperation[] getTearDownOperation() throws Exception
134 {
135 // Deleting test database.....
136 DatabaseOperation[] dbOperation = new DatabaseOperation[1];
137 dbOperation[0]=DatabaseOperation.DO_NOTHING;
138
139 return dbOperation;
140 }
141
142
143 public void testMe() throws Exception
144 {
145
146 }
147
148
149 public static Test suite() {
150 return new TestSuite(LoaderTest3.class);
151 }
152
153
154 public static void main(String args[]) {
155
156 // junit.textui.TestRunner.run(suite());
157 TestResult result= (new LoaderTest3("testMe 3")).run();
158
159 }
160
161
162
163 }
164
165
166
167
This page was automatically generated by Maven