]> git.8kb.co.uk Git - pgpool-ii/pgpool-ii_2.2.5/blob - test/jdbc/RunTest.java
Attempt to send a proper failure message to frontend when authentication
[pgpool-ii/pgpool-ii_2.2.5] / test / jdbc / RunTest.java
1 import java.sql.*;
2 import java.util.*;
3 import java.io.*;
4
5 public class RunTest {
6     public static void main(String[] args)
7     {
8         RunTest test = new RunTest();
9         test.run();
10     }
11
12     public void run()
13     {
14         try {
15             PgpoolTest test;
16             Properties prop = new Properties();
17             prop.load(new FileInputStream("pgpool.properties"));
18             String tests = prop.getProperty("pgpooltest.tests");
19             String host = prop.getProperty("pgpooltest.host");
20             String port = prop.getProperty("pgpooltest.port");
21             String user = prop.getProperty("pgpooltest.user");
22             String password = prop.getProperty("pgpooltest.password");
23             String dbname = prop.getProperty("pgpooltest.dbname");
24
25             // setup database
26             String command_line = "psql -f prepare.sql";
27             command_line = command_line + " -h " + host + " -p " + port +
28                 " -U " + user + " " + dbname;
29             Process proc = Runtime.getRuntime().exec(command_line);
30             proc.waitFor();
31
32             StringTokenizer tokenizer = new StringTokenizer(tests, " ");
33
34             while(tokenizer.hasMoreTokens()) {
35                 test = testFactory(tokenizer.nextToken());
36                 if (test == null) {
37                     System.out.println("unknown testcase");
38                     System.exit(1);
39                 }
40                 test.do_test();
41                 test.check();
42             }
43         } catch (IOException e) {
44             System.out.println("cannot read property file");
45             System.exit(1);
46         } catch (Exception e) {
47             e.printStackTrace();
48         }
49     }
50
51     public PgpoolTest testFactory(String testcase)
52     {
53         if (testcase == null)
54             return null;
55
56         if (testcase.equals("autocommit"))
57             return new AutoCommitTest();
58
59         if (testcase.equals("batch"))
60             return new BatchTest();
61
62         if (testcase.equals("column"))
63             return new ColumnTest();
64
65         if (testcase.equals("lock"))
66             return new LockTest();
67
68         if (testcase.equals("select"))
69             return new SelectTest();
70
71         if (testcase.equals("update"))
72             return new UpdateTest();
73
74         if (testcase.equals("insert"))
75             return new InsertTest();
76
77         if (testcase.equals("CreateTempTable"))
78             return new CreateTempTableTest();
79
80         /* unknown test case */
81         return null;
82     }
83 }