5 public abstract class PgpoolTest {
6 protected String url = "jdbc:postgresql://";
8 protected String password;
9 protected String dbname;
10 protected String host;
11 protected String port;
12 protected String options;
13 protected Connection connection;
14 protected PrintWriter logwriter;
19 Properties prop = new Properties();
20 prop.load(new FileInputStream("pgpool.properties"));
21 host = prop.getProperty("pgpooltest.host");
22 port = prop.getProperty("pgpooltest.port");
23 user = prop.getProperty("pgpooltest.user");
24 password = prop.getProperty("pgpooltest.password");
25 dbname = prop.getProperty("pgpooltest.dbname");
26 options = prop.getProperty("pgpooltest.options");
28 url = url + host + ":" + port + "/" + dbname;
30 if (!options.equals(""))
31 url = url + "?" + options;
33 File dir = new File("result");
36 logwriter = new PrintWriter(new FileWriter("result/" + getTestName()), true);
38 Class.forName("org.postgresql.Driver");
39 connection = DriverManager.getConnection(url, user, password);
40 } catch (ClassNotFoundException e) {
41 System.out.println("cannot load JDBC Driver");
43 } catch (Exception e) {
44 System.out.println("cannot connect to pgpool");
47 } catch (Exception e) {
48 System.out.println("cannot read property file");
55 String command_line = "diff -u expected/" + getTestName() + " result/" +
59 proc = Runtime.getRuntime().exec(command_line);
61 System.out.print(getTestName() + ": ");
62 if (proc.exitValue() == 0)
63 System.out.println("ok");
64 else if (proc.exitValue() == 0)
65 System.out.println("FAIL");
67 System.out.println("unknown error" + proc.exitValue());
68 } catch (Exception e) {
73 public abstract void do_test() throws SQLException, IOException;
74 public abstract String getTestName();