package examples.dbo; import fc.jdbc.*; import fc.io.*; import fc.util.*; import java.sql.*; import java.io.*; /* Base testing class that various other test classes extend. This way we don't have to keep repeating the same boilerplate for each test. */ public abstract class Test { static Log log = Log.getDefault(); static Watch w = new Watch(); static void start() { w.start(); } static void stop() { w.stop(); } static void time() { System.out.println("Time: " + w.time() + " milliseconds"); } protected abstract void test(Args args, Connection con) throws Exception; public static void main(String args[]) throws Exception { Args myargs = new Args(args); myargs.setUsage("java examples.dbo.Test " + " -conf config_file " + " -test test_class_name " + " [-log level] " ); String test_class = myargs.getRequired("test"); String conf = myargs.getRequired("conf"); String loglevel = myargs.get("loglevel","INFO"); log.setLevel(loglevel); PooledConnectionMgr cmgr = new PooledConnectionMgr( new FilePropertyMgr( new File(conf)), 1); Connection con = cmgr.getConnection(); Test testobj = null; try { testobj = ((Test) Class.forName(test_class).newInstance()); } catch (Exception e) { log.error(e); System.exit(1); } testobj.test(myargs, con); } }