[Proxool-cvs] proxool/src/java-test/org/logicalcobwebs/proxool testconfig-hsqldb.properties,NONE,1.1
UNMAINTAINED!
Brought to you by:
billhorsman
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8632/src/java-test/org/logicalcobwebs/proxool Modified Files: ProxyStatementTest.java GlobalTest.java FatalSqlExceptionTest.java ManyPoolsTest.java TestConstants.java PropertyTest.java PrototyperTest.java ConfigurationListenerTest.java ConnectionListenerTest.java UpdateDefinitionTest.java Added Files: testconfig-hsqldb.properties Log Message: Allow JUnit tests to be executed against another database. By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package. This behavior can be overriden by setting the 'testConfig' environment property to another location. --- NEW FILE: testconfig-hsqldb.properties --- HYPERSONIC_DRIVER = org.hsqldb.jdbcDriver HYPERSONIC_USER = sa HYPERSONIC_PASSWORD = HYPERSONIC_TEST_SQL = SELECT COUNT(1) FROM SYSTEM_CATALOGS HYPERSONIC_URL_PREFIX = jdbc:hsqldb:db/ HYPERSONIC_TEST_URL = jdbc:hsqldb:db/test HYPERSONIC_TEST_URL2 = jdbc:hsqldb:db/2 FATAL_SQL_STATEMENT = drop table Z FATAL_SQL_EXCEPTION = Table not found Index: ProxyStatementTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/ProxyStatementTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ProxyStatementTest.java 23 Mar 2004 21:17:23 -0000 1.9 --- ProxyStatementTest.java 26 May 2004 17:19:09 -0000 1.10 *************** *** 6,19 **** package org.logicalcobwebs.proxool; ! import org.logicalcobwebs.logging.Log; ! import org.logicalcobwebs.logging.LogFactory; ! import java.sql.Connection; import java.sql.DriverManager; - import java.sql.Statement; import java.sql.PreparedStatement; ! import java.sql.CallableStatement; import java.util.Properties; /** * Test whether ProxyStatement works --- 6,19 ---- package org.logicalcobwebs.proxool; ! import java.sql.CallableStatement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; ! import java.sql.Statement; import java.util.Properties; + import org.logicalcobwebs.logging.Log; + import org.logicalcobwebs.logging.LogFactory; + /** * Test whether ProxyStatement works *************** *** 35,61 **** * That we can get the delegate driver's Statement from the one given by Proxool */ ! public void testDelegateStatement() throws Exception { ! String testName = "delegateStatement"; - String alias = testName; - Connection c = null; // Register pool ! String url = TestHelper.buildProxoolUrl(alias, ! TestConstants.HYPERSONIC_DRIVER, ! TestConstants.HYPERSONIC_TEST_URL); ! Properties info = new Properties(); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ! ProxoolFacade.registerConnectionPool(url, info); ! c = DriverManager.getConnection(url); ! Statement s = c.createStatement(); ! Statement delegateStatement = ProxoolFacade.getDelegateStatement(s); ! LOG.debug("Statement " + s.getClass() + " is delegating to " + delegateStatement.getClass()); ! assertTrue("Delegate statement isn't a Hypersonic one as expected.", delegateStatement instanceof org.hsqldb.jdbcStatement); } /** * Test what interfaces are supported when getting a PreparedStatement --- 35,67 ---- * That we can get the delegate driver's Statement from the one given by Proxool */ ! public void testDelegateStatement() throws Exception ! { String testName = "delegateStatement"; // Register pool ! String url = registerPool(testName); ! // get a connection from the pool and create a statement with it ! Connection c = DriverManager.getConnection(url); ! Statement s = c.createStatement(); ! Statement delegateStatement = ProxoolFacade.getDelegateStatement(s); ! Class delegateStatementClass = delegateStatement.getClass(); ! s.close(); ! ! LOG.debug("Statement " + s.getClass() + " is delegating to " + delegateStatementClass); ! ! // get a *real* connection directly from the native driver (bypassing the pool) ! Connection realConnection = TestHelper.getDirectConnection(); ! Statement realStatement = realConnection.createStatement(); ! Class realStatementClass = realStatement.getClass(); ! ! realStatement.close(); ! realConnection.close(); + // are they of the same type ? + assertEquals("Delegate statement isn't of the expected type.", realStatementClass, delegateStatementClass); } + /** * Test what interfaces are supported when getting a PreparedStatement *************** *** 64,87 **** String testName = "preparedStatement"; - String alias = testName; - Connection c = null; // Register pool ! String url = TestHelper.buildProxoolUrl(alias, ! TestConstants.HYPERSONIC_DRIVER, ! TestConstants.HYPERSONIC_TEST_URL); ! Properties info = new Properties(); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ! ProxoolFacade.registerConnectionPool(url, info); ! c = DriverManager.getConnection(url); PreparedStatement s = c.prepareStatement(TestConstants.HYPERSONIC_TEST_SQL); Statement delegateStatement = ProxoolFacade.getDelegateStatement(s); ! LOG.debug("Statement " + s.getClass() + " is delegating to " + delegateStatement.getClass()); ! assertTrue("Delegate statement isn't a Hypersonic one as expected.", delegateStatement instanceof org.hsqldb.jdbcPreparedStatement); ! } /** * Test what interfaces are supported when getting a CallableStatement --- 70,99 ---- String testName = "preparedStatement"; // Register pool ! String url = registerPool(testName); ! // get a connection from the pool and create a prepare statement with it ! Connection c = DriverManager.getConnection(url); PreparedStatement s = c.prepareStatement(TestConstants.HYPERSONIC_TEST_SQL); Statement delegateStatement = ProxoolFacade.getDelegateStatement(s); ! Class delegateStatementClass = delegateStatement.getClass(); ! s.close(); ! ! LOG.debug("Statement " + s.getClass() + " is delegating to " + delegateStatementClass); ! ! // get a *real* connection directly from the native driver (bypassing the pool) ! Connection realConnection = TestHelper.getDirectConnection(); ! Statement realStatement = realConnection.prepareStatement(TestConstants.HYPERSONIC_TEST_SQL); ! Class realStatementClass = realStatement.getClass(); ! ! realStatement.close(); ! realConnection.close(); ! ! // are they of the same type ? ! assertEquals("Delegate statement isn't of the expected type.", realStatementClass, delegateStatementClass); } + /** * Test what interfaces are supported when getting a CallableStatement *************** *** 90,112 **** String testName = "callableStatement"; - String alias = testName; - Connection c = null; // Register pool ! String url = TestHelper.buildProxoolUrl(alias, ! TestConstants.HYPERSONIC_DRIVER, ! TestConstants.HYPERSONIC_TEST_URL); ! Properties info = new Properties(); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ! ProxoolFacade.registerConnectionPool(url, info); ! c = DriverManager.getConnection(url); CallableStatement s = c.prepareCall(TestConstants.HYPERSONIC_TEST_SQL); - s = c.prepareCall(TestConstants.HYPERSONIC_TEST_SQL); Statement delegateStatement = ProxoolFacade.getDelegateStatement(s); ! LOG.debug("Statement " + s.getClass() + " is delegating to " + delegateStatement.getClass()); ! assertTrue("Delegate statement isn't a Hypersonic one as expected.", delegateStatement instanceof org.hsqldb.jdbcPreparedStatement); ! } --- 102,128 ---- String testName = "callableStatement"; // Register pool ! String url = registerPool(testName); ! // get a connection from the pool and create a callable statement with it ! Connection c = DriverManager.getConnection(url); CallableStatement s = c.prepareCall(TestConstants.HYPERSONIC_TEST_SQL); Statement delegateStatement = ProxoolFacade.getDelegateStatement(s); ! Class delegateStatementClass = delegateStatement.getClass(); ! s.close(); ! ! LOG.debug("Statement " + s.getClass() + " is delegating to " + delegateStatementClass); ! ! // get a *real* connection directly from the native driver (bypassing the pool) ! Connection realConnection = TestHelper.getDirectConnection(); ! Statement realStatement = realConnection.prepareCall(TestConstants.HYPERSONIC_TEST_SQL); ! Class realStatementClass = realStatement.getClass(); ! ! realStatement.close(); ! realConnection.close(); ! ! // are they of the same type ? ! assertEquals("Delegate statement isn't of the expected type.", realStatementClass, delegateStatementClass ); } *************** *** 118,125 **** String testName = "delegateConnection"; - String alias = testName; - Connection c = null; // Register pool String url = TestHelper.buildProxoolUrl(alias, TestConstants.HYPERSONIC_DRIVER, --- 134,165 ---- String testName = "delegateConnection"; // Register pool + String url = registerPool(testName); + + // get a connection from the pool + Connection c = DriverManager.getConnection(url); + Connection delegateConnection = ProxoolFacade.getDelegateConnection(c); + Class delegateConnectionClass = delegateConnection.getClass(); + + LOG.debug("Connection " + c + " is delegating to " + delegateConnectionClass); + c.close(); + + // get a *real* connection directly from the native driver (bypassing the pool) + Connection realConnection = TestHelper.getDirectConnection(); + Class realConnectionClass = realConnection.getClass(); + realConnection.close(); + + assertEquals("Connection isn't of the expected.", realConnectionClass, delegateConnectionClass); + } + + + /** + * + * @param alias + * @throws Exception + */ + private String registerPool(String alias) throws Exception + { String url = TestHelper.buildProxoolUrl(alias, TestConstants.HYPERSONIC_DRIVER, *************** *** 129,140 **** info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); ! ! c = DriverManager.getConnection(url); ! Connection delegateConnection = ProxoolFacade.getDelegateConnection(c); ! LOG.debug("Conneciton " + c.getClass() + " is delegating to " + delegateConnection.getClass()); ! assertTrue("Connection isn't a Hypersonic one as expected.", delegateConnection instanceof org.hsqldb.jdbcConnection); ! ! } ! } --- 169,175 ---- info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); ! ! return url; ! } } *************** *** 143,146 **** --- 178,186 ---- Revision history: $Log$ + Revision 1.10 2004/05/26 17:19:09 brenuart + Allow JUnit tests to be executed against another database. + By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package. + This behavior can be overriden by setting the 'testConfig' environment property to another location. + Revision 1.9 2004/03/23 21:17:23 billhorsman added preparedStatement and callableStatement tests Index: GlobalTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/GlobalTest.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** GlobalTest.java 26 Oct 2003 16:23:20 -0000 1.18 --- GlobalTest.java 26 May 2004 17:19:09 -0000 1.19 *************** *** 6,12 **** --- 6,17 ---- package org.logicalcobwebs.proxool; + import java.io.InputStream; + import java.lang.reflect.Field; + import java.util.Properties; + import junit.extensions.TestSetup; import junit.framework.Test; import junit.framework.TestSuite; + import org.apache.log4j.xml.DOMConfigurator; import org.logicalcobwebs.logging.Log; *************** *** 16,19 **** --- 21,26 ---- * Provides a suite of all tests. And some utility methods for setting * up the logging. + * + * The test configuration can be specified using the env property "testConfig" * * @version $Revision$, $Date$ *************** *** 24,53 **** public class GlobalTest { private static final Log LOG = LogFactory.getLog(GlobalTest.class); private static boolean initialised; ! public static synchronized void globalSetup() throws ClassNotFoundException { ! if (!initialised) { ! String log4jPath = System.getProperty("log4jPath"); ! if (log4jPath != null && log4jPath.length() > 0) { ! try { ! DOMConfigurator.configureAndWatch(log4jPath); ! } catch (Exception e) { ! LOG.debug("Can't configure logging using " + log4jPath); ! } ! } else { ! // Well, at least switch on debugging ! System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "debug"); ! org.apache.log4j.BasicConfigurator.resetConfiguration(); ! org.apache.log4j.BasicConfigurator.configure(); } ! Class.forName(ProxoolDriver.class.getName()); ! initialised = true; ! } } public static synchronized void globalTeardown(String alias) { ProxoolFacade.shutdown(alias + ":teardown", 10000); --- 31,138 ---- public class GlobalTest { + private static final String defaultConfig = "/org/logicalcobwebs/proxool/testconfig-hsqldb.properties"; + private static final Log LOG = LogFactory.getLog(GlobalTest.class); private static boolean initialised; ! public static synchronized void globalSetup() throws Exception ! { ! // return immediately if we are already initialised ! if (initialised) { ! return; ! } ! ! // configure log4j ! String log4jPath = System.getProperty("log4jPath"); ! if (log4jPath != null && log4jPath.length() > 0) { ! try { ! DOMConfigurator.configureAndWatch(log4jPath); ! } catch (Exception e) { ! LOG.debug("Can't configure logging using " + log4jPath); } + } else { + // Well, at least switch on debugging + System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "debug"); + org.apache.log4j.BasicConfigurator.resetConfiguration(); + org.apache.log4j.BasicConfigurator.configure(); + } ! // Load ProxoolDriver class into DriverManager ! Class.forName(ProxoolDriver.class.getName()); ! // initialise test configuration ! initTestConstants(defaultConfig); ! ! // remember we are correctly initialized ! initialised = true; } + + /** + * + * @throws Exception + */ + private static void initTestConstants() throws Exception + { + String resourceName = System.getProperty("testConfig"); + if( resourceName==null || resourceName.length()==0 ) + { + LOG.info("Test configuration set to default value"); + } + else + { + initTestConstants(resourceName); + } + } + + /** + * + * @param resourceName + */ + private static void initTestConstants(String resourceName) throws Exception + { + // locate and read resource file + InputStream resourceStream = null; + Properties props = new Properties(); + try { + LOG.info("Loading test configuration from "+resourceName); + resourceStream = resourceName.getClass().getResourceAsStream(resourceName); + props.load(resourceStream); + } + catch(Exception e) + { + LOG.error("Problem while loading test configuration", e); + throw e; + } + finally { + if( resourceStream != null ) { + resourceStream.close(); + } + } + + // parse resource file and initialize TestConstants + Field[] fields = TestConstants.class.getDeclaredFields(); + for(int i=0; i<fields.length; i++) + { + Field field = fields[i]; + + // locate value in property file + String propertyName = field.getName(); + String value = props.getProperty(propertyName); + + if( value==null ) + { + LOG.info("Set "+propertyName+" to default value"); + } + else + { + LOG.info("Set " + propertyName+ " to '" + value + "'"); + field.set(null, value); + } + } + } + + public static synchronized void globalTeardown(String alias) { ProxoolFacade.shutdown(alias + ":teardown", 10000); *************** *** 80,83 **** --- 165,169 ---- return wrapper; } + } *************** *** 86,89 **** --- 172,180 ---- Revision history: $Log$ + Revision 1.19 2004/05/26 17:19:09 brenuart + Allow JUnit tests to be executed against another database. + By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package. + This behavior can be overriden by setting the 'testConfig' environment property to another location. + Revision 1.18 2003/10/26 16:23:20 billhorsman Fixed up test suites Index: FatalSqlExceptionTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/FatalSqlExceptionTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FatalSqlExceptionTest.java 23 Mar 2004 21:16:05 -0000 1.6 --- FatalSqlExceptionTest.java 26 May 2004 17:19:09 -0000 1.7 *************** *** 41,49 **** TestConstants.HYPERSONIC_TEST_URL); Properties info = new Properties(); ! info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, "Table not found"); ! info.setProperty(ProxoolConstants.VERBOSE_PROPERTY, String.valueOf(Boolean.TRUE)); ! info.setProperty(ProxoolConstants.TRACE_PROPERTY, String.valueOf(Boolean.TRUE)); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); --- 41,49 ---- TestConstants.HYPERSONIC_TEST_URL); Properties info = new Properties(); ! info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, TestConstants.FATAL_SQL_EXCEPTION); ! info.setProperty(ProxoolConstants.VERBOSE_PROPERTY, String.valueOf(Boolean.TRUE)); ! info.setProperty(ProxoolConstants.TRACE_PROPERTY, String.valueOf(Boolean.TRUE)); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); *************** *** 67,76 **** Statement s = c2.createStatement(); // Doing it twice will guarantee a failure. Even if it exists ! s.execute("drop table Z"); ! s.execute("drop table Z"); } catch (SQLException e) { assertTrue("Didn't expect a " + FatalSQLException.class.getName(), !(e instanceof FatalSQLException)); // Expected exception (foo doesn't exist) ! LOG.debug("Expected exception (safe to ignore)", e); } finally { if (c2 != null) { --- 67,76 ---- Statement s = c2.createStatement(); // Doing it twice will guarantee a failure. Even if it exists ! s.execute(TestConstants.FATAL_SQL_STATEMENT); ! s.execute(TestConstants.FATAL_SQL_STATEMENT); } catch (SQLException e) { assertTrue("Didn't expect a " + FatalSQLException.class.getName(), !(e instanceof FatalSQLException)); // Expected exception (foo doesn't exist) ! //LOG.debug("Expected exception (safe to ignore)", e); } finally { if (c2 != null) { *************** *** 93,96 **** --- 93,97 ---- } + public void testWrappedFatalSqlException() throws Exception { *************** *** 102,109 **** TestConstants.HYPERSONIC_TEST_URL); Properties info = new Properties(); ! info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, "Table not found"); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY, FatalSQLException.class.getName()); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); --- 103,110 ---- TestConstants.HYPERSONIC_TEST_URL); Properties info = new Properties(); ! info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, TestConstants.FATAL_SQL_EXCEPTION); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY, FatalSQLException.class.getName()); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); *************** *** 112,120 **** c = DriverManager.getConnection(url); Statement s = c.createStatement(); ! s.execute("drop table Z"); } catch (SQLException e) { assertTrue("Expected a " + FatalSQLException.class.getName() + " but got a " + e.getClass().getName() + " instead", e instanceof FatalSQLException); // Expected exception (foo doesn't exist) ! LOG.debug("Expected exception (safe to ignore)", e); } --- 113,121 ---- c = DriverManager.getConnection(url); Statement s = c.createStatement(); ! s.execute(TestConstants.FATAL_SQL_STATEMENT); } catch (SQLException e) { assertTrue("Expected a " + FatalSQLException.class.getName() + " but got a " + e.getClass().getName() + " instead", e instanceof FatalSQLException); // Expected exception (foo doesn't exist) ! //LOG.debug("Expected exception (safe to ignore)", e); } *************** *** 143,150 **** TestConstants.HYPERSONIC_TEST_URL); Properties info = new Properties(); ! info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, "Table not found"); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY, FatalRuntimeException.class.getName()); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); --- 144,151 ---- TestConstants.HYPERSONIC_TEST_URL); Properties info = new Properties(); ! info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, TestConstants.FATAL_SQL_EXCEPTION); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY, FatalRuntimeException.class.getName()); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); *************** *** 153,157 **** c = DriverManager.getConnection(url); Statement s = c.createStatement(); ! s.execute("drop table Z"); } catch (RuntimeException e) { assertTrue("Expected a " + FatalRuntimeException.class.getName() + " but got a " + e.getClass().getName() + " instead", e instanceof FatalRuntimeException); --- 154,158 ---- c = DriverManager.getConnection(url); Statement s = c.createStatement(); ! s.execute(TestConstants.FATAL_SQL_STATEMENT); } catch (RuntimeException e) { assertTrue("Expected a " + FatalRuntimeException.class.getName() + " but got a " + e.getClass().getName() + " instead", e instanceof FatalRuntimeException); *************** *** 184,191 **** TestConstants.HYPERSONIC_TEST_URL); Properties info = new Properties(); ! info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, "Table not found"); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY, "org.does.not.Exist"); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); try { ProxoolFacade.registerConnectionPool(url, info); --- 185,192 ---- TestConstants.HYPERSONIC_TEST_URL); Properties info = new Properties(); ! info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, TestConstants.FATAL_SQL_EXCEPTION); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY, "org.does.not.Exist"); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); try { ProxoolFacade.registerConnectionPool(url, info); *************** *** 207,215 **** TestConstants.HYPERSONIC_TEST_URL); Properties info = new Properties(); ! info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, "Table not found"); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); // ProxoolException isn't a RuntimeException or an SQLException info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY, ProxoolException.class.getName()); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); try { ProxoolFacade.registerConnectionPool(url, info); --- 208,216 ---- TestConstants.HYPERSONIC_TEST_URL); Properties info = new Properties(); ! info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, TestConstants.FATAL_SQL_EXCEPTION); ! info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); // ProxoolException isn't a RuntimeException or an SQLException info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY, ProxoolException.class.getName()); ! info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); try { ProxoolFacade.registerConnectionPool(url, info); *************** *** 227,230 **** --- 228,236 ---- Revision history: $Log$ + Revision 1.7 2004/05/26 17:19:09 brenuart + Allow JUnit tests to be executed against another database. + By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package. + This behavior can be overriden by setting the 'testConfig' environment property to another location. + Revision 1.6 2004/03/23 21:16:05 billhorsman make use of new getId() to compare connections Index: ManyPoolsTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/ManyPoolsTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ManyPoolsTest.java 5 Mar 2003 18:49:27 -0000 1.1 --- ManyPoolsTest.java 26 May 2004 17:19:09 -0000 1.2 *************** *** 41,45 **** info.setProperty(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY, "2"); info.setProperty(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY, "30000"); ! final int poolCount = 100; String alias[] = new String[poolCount]; --- 41,46 ---- info.setProperty(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY, "2"); info.setProperty(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY, "30000"); ! info.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, TestConstants.HYPERSONIC_TEST_SQL); ! final int poolCount = 100; String alias[] = new String[poolCount]; *************** *** 74,77 **** --- 75,83 ---- Revision history: $Log$ + Revision 1.2 2004/05/26 17:19:09 brenuart + Allow JUnit tests to be executed against another database. + By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package. + This behavior can be overriden by setting the 'testConfig' environment property to another location. + Revision 1.1 2003/03/05 18:49:27 billhorsman moved test to right tree Index: TestConstants.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/TestConstants.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TestConstants.java 30 Sep 2003 18:39:39 -0000 1.5 --- TestConstants.java 26 May 2004 17:19:09 -0000 1.6 *************** *** 7,11 **** /** ! * Some useful constants for testing * * @version $Revision$, $Date$ --- 7,13 ---- /** ! * Some useful constants for testing. ! * ! * Note: these values will be overriden at startup by the GlobalTest init procedure. * * @version $Revision$, $Date$ *************** *** 14,33 **** * @since Proxool 0.5 */ ! public interface TestConstants { ! ! static final String PROXOOL_DRIVER = "org.logicalcobwebs.proxool.ProxoolDriver"; ! static final String HYPERSONIC_DRIVER = "org.hsqldb.jdbcDriver"; ! static final String HYPERSONIC_URL_PREFIX = "jdbc:hsqldb:db/"; ! static final String HYPERSONIC_TEST_URL = HYPERSONIC_URL_PREFIX + "test"; ! static final String HYPERSONIC_USER = "sa"; ! static final String HYPERSONIC_PASSWORD = ""; ! static final String HYPERSONIC_TEST_SQL = "SELECT COUNT(1) FROM SYSTEM_CATALOGS"; } --- 16,70 ---- * @since Proxool 0.5 */ ! public class TestConstants { ! /** ! * Proxool Driver class ! */ ! public static String PROXOOL_DRIVER = "org.logicalcobwebs.proxool.ProxoolDriver"; ! /** ! * JDBC driver class ! */ ! public static String HYPERSONIC_DRIVER = "org.hsqldb.jdbcDriver"; ! /** ! * URL connection base (without database) ! */ ! public static String HYPERSONIC_URL_PREFIX = "jdbc:hsqldb:db/"; ! /** ! * URL to a first test database. User should have rw access ! */ ! public static String HYPERSONIC_TEST_URL = HYPERSONIC_URL_PREFIX + "test"; ! ! /** ! * URL to a second test database ! */ ! public static String HYPERSONIC_TEST_URL2 = HYPERSONIC_URL_PREFIX + "2"; ! ! /** ! * Connection credentials ! */ ! public static String HYPERSONIC_USER = "sa"; ! /** ! * Connection credentials ! */ ! public static String HYPERSONIC_PASSWORD = ""; ! /** ! * SQL statement that should always succeed ! */ ! public static String HYPERSONIC_TEST_SQL = "SELECT COUNT(1) FROM SYSTEM_CATALOGS"; + /** + * SQL statement that should always fail + */ + public static String FATAL_SQL_STATEMENT = "drop table Z"; + + /** + * SQLException message fragment used to detect fatal exceptions + */ + public static String FATAL_SQL_EXCEPTION = "Table not found"; } *************** *** 35,38 **** --- 72,80 ---- Revision history: $Log$ + Revision 1.6 2004/05/26 17:19:09 brenuart + Allow JUnit tests to be executed against another database. + By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package. + This behavior can be overriden by setting the 'testConfig' environment property to another location. + Revision 1.5 2003/09/30 18:39:39 billhorsman New test sql syntax constant Index: PropertyTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/PropertyTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PropertyTest.java 4 Nov 2003 13:22:43 -0000 1.1 --- PropertyTest.java 26 May 2004 17:19:09 -0000 1.2 *************** *** 49,52 **** --- 49,54 ---- info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); + info.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, TestConstants.HYPERSONIC_TEST_SQL); + Connection c = null; try { *************** *** 58,62 **** // Probably because it doesn't exist. } ! s.execute("create table z (a int(4))"); s.execute("select * from z"); --- 60,64 ---- // Probably because it doesn't exist. } ! s.execute("create table z (a int)"); s.execute("select * from z"); *************** *** 95,98 **** --- 97,105 ---- Revision history: $Log$ + Revision 1.2 2004/05/26 17:19:09 brenuart + Allow JUnit tests to be executed against another database. + By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package. + This behavior can be overriden by setting the 'testConfig' environment property to another location. + Revision 1.1 2003/11/04 13:22:43 billhorsman New test for delegate properties Index: PrototyperTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/PrototyperTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PrototyperTest.java 10 Mar 2003 15:31:26 -0000 1.9 --- PrototyperTest.java 26 May 2004 17:19:09 -0000 1.10 *************** *** 47,50 **** --- 47,52 ---- info.setProperty(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY, "2"); info.setProperty(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY, "1000"); + info.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, TestConstants.HYPERSONIC_TEST_SQL); + String url = ProxoolConstants.PROXOOL + ProxoolConstants.ALIAS_DELIMITER *************** *** 115,118 **** --- 117,121 ---- info.setProperty(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY, "0"); info.setProperty(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY, "1000"); + info.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, TestConstants.HYPERSONIC_TEST_SQL); String url = TestHelper.buildProxoolUrl(alias, TestConstants.HYPERSONIC_DRIVER, TestConstants.HYPERSONIC_TEST_URL); ProxoolFacade.registerConnectionPool(url, info); *************** *** 136,139 **** --- 139,147 ---- Revision history: $Log$ + Revision 1.10 2004/05/26 17:19:09 brenuart + Allow JUnit tests to be executed against another database. + By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package. + This behavior can be overriden by setting the 'testConfig' environment property to another location. + Revision 1.9 2003/03/10 15:31:26 billhorsman fixes Index: ConfigurationListenerTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/ConfigurationListenerTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ConfigurationListenerTest.java 27 Apr 2003 15:44:19 -0000 1.11 --- ConfigurationListenerTest.java 26 May 2004 17:19:09 -0000 1.12 *************** *** 136,141 **** // Register pool ! final String delegateUrl1 = TestConstants.HYPERSONIC_URL_PREFIX + "1"; ! final String delegateUrl2 = TestConstants.HYPERSONIC_URL_PREFIX + "2"; final String url1 = TestHelper.buildProxoolUrl(alias, --- 136,141 ---- // Register pool ! final String delegateUrl1 = TestConstants.HYPERSONIC_TEST_URL; ! final String delegateUrl2 = TestConstants.HYPERSONIC_TEST_URL2; final String url1 = TestHelper.buildProxoolUrl(alias, *************** *** 236,239 **** --- 236,244 ---- Revision history: $Log$ + Revision 1.12 2004/05/26 17:19:09 brenuart + Allow JUnit tests to be executed against another database. + By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package. + This behavior can be overriden by setting the 'testConfig' environment property to another location. + Revision 1.11 2003/04/27 15:44:19 billhorsman better tests Index: ConnectionListenerTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/ConnectionListenerTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ConnectionListenerTest.java 10 Mar 2003 23:31:04 -0000 1.11 --- ConnectionListenerTest.java 26 May 2004 17:19:10 -0000 1.12 *************** *** 55,58 **** --- 55,60 ---- ProxoolFacade.addConnectionListener(alias, new TestConnectionListener()); Connection connection2 = DriverManager.getConnection(url); + + // provoke execution error boolean errorOccured = false; try { *************** *** 62,70 **** errorOccured = true; } ! assertTrue("We failed to proovoke a connection failure.", errorOccured); ! connection2.createStatement().executeQuery("CALL 1"); connection1.close(); connection2.close(); ProxoolFacade.removeConnectionPool(alias); assertTrue("Expected 2 onBirth calls, but got " + this.onBirthCalls + ".", this.onBirthCalls == 2); assertTrue("Expected 2 onExecute calls, but got " + this.onExecuteCalls + ".", this.onExecuteCalls == 2); --- 64,80 ---- errorOccured = true; } ! assertTrue("We failed to provoke a connection failure.", errorOccured); ! ! // following statement should be ok ! connection2.createStatement().executeQuery(TestConstants.HYPERSONIC_TEST_SQL); ! ! // close both connections connection1.close(); connection2.close(); + + // shutdown connection pool ProxoolFacade.removeConnectionPool(alias); + + // test results assertTrue("Expected 2 onBirth calls, but got " + this.onBirthCalls + ".", this.onBirthCalls == 2); assertTrue("Expected 2 onExecute calls, but got " + this.onExecuteCalls + ".", this.onExecuteCalls == 2); *************** *** 99,102 **** --- 109,114 ---- ProxoolFacade.removeConnectionListener(alias, testConnectionListener2); Connection connection2 = DriverManager.getConnection(url, info); + + // provoke execution error boolean errorOccured = false; try { *************** *** 107,114 **** } assertTrue("We failed to proovoke a connection failure.", errorOccured); ! connection2.createStatement().executeQuery("CALL 1"); connection1.close(); connection2.close(); ProxoolFacade.removeConnectionPool(alias); assertTrue("Expected 0 onBirth calls, but got " + this.onBirthCalls + ".", this.onBirthCalls == 0); assertTrue("Expected 0 onExecute calls, but got " + this.onExecuteCalls + ".", this.onExecuteCalls == 0); --- 119,134 ---- } assertTrue("We failed to proovoke a connection failure.", errorOccured); ! ! // following statement should be ok ! connection2.createStatement().executeQuery(TestConstants.HYPERSONIC_TEST_SQL); ! ! // close connections connection1.close(); connection2.close(); + + // shutdown connection pool ProxoolFacade.removeConnectionPool(alias); + + // validate results assertTrue("Expected 0 onBirth calls, but got " + this.onBirthCalls + ".", this.onBirthCalls == 0); assertTrue("Expected 0 onExecute calls, but got " + this.onExecuteCalls + ".", this.onExecuteCalls == 0); *************** *** 124,135 **** } ! /** ! * Calls {@link AbstractProxoolTest#setUp} ! * @see junit.framework.TestCase#setUp ! */ ! protected void setUp() throws Exception { ! super.setUp(); ! Class.forName("org.logicalcobwebs.proxool.ProxoolDriver"); ! } class TestConnectionListener implements ConnectionListenerIF { --- 144,155 ---- } ! // /** ! // * Calls {@link AbstractProxoolTest#setUp} ! // * @see junit.framework.TestCase#setUp ! // */ ! // protected void setUp() throws Exception { ! // super.setUp(); ! // Class.forName("org.logicalcobwebs.proxool.ProxoolDriver"); ! // } class TestConnectionListener implements ConnectionListenerIF { *************** *** 155,158 **** --- 175,183 ---- Revision history: $Log$ + Revision 1.12 2004/05/26 17:19:10 brenuart + Allow JUnit tests to be executed against another database. + By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package. + This behavior can be overriden by setting the 'testConfig' environment property to another location. + Revision 1.11 2003/03/10 23:31:04 billhorsman fixed deprecated properties and doc Index: UpdateDefinitionTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/UpdateDefinitionTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** UpdateDefinitionTest.java 4 Mar 2003 12:50:44 -0000 1.6 --- UpdateDefinitionTest.java 26 May 2004 17:19:10 -0000 1.7 *************** *** 38,51 **** String url1 = TestHelper.buildProxoolUrl(alias, TestConstants.HYPERSONIC_DRIVER, ! TestConstants.HYPERSONIC_URL_PREFIX + "1"); String url2 = TestHelper.buildProxoolUrl(alias, TestConstants.HYPERSONIC_DRIVER, ! TestConstants.HYPERSONIC_URL_PREFIX + "2"); Properties info = new Properties(); info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ! info.setProperty("proxool.minimum-connection-count", "2"); // register pool --- 38,51 ---- String url1 = TestHelper.buildProxoolUrl(alias, TestConstants.HYPERSONIC_DRIVER, ! TestConstants.HYPERSONIC_TEST_URL); String url2 = TestHelper.buildProxoolUrl(alias, TestConstants.HYPERSONIC_DRIVER, ! TestConstants.HYPERSONIC_TEST_URL2); Properties info = new Properties(); info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ! info.setProperty(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY, "2"); // register pool *************** *** 120,124 **** + TestConstants.HYPERSONIC_DRIVER + ProxoolConstants.URL_DELIMITER ! + "jdbc:hsqldb:db/update"; --- 120,124 ---- + TestConstants.HYPERSONIC_DRIVER + ProxoolConstants.URL_DELIMITER ! + TestConstants.HYPERSONIC_TEST_URL2; //"jdbc:hsqldb:db/update"; *************** *** 151,154 **** --- 151,159 ---- Revision history: $Log$ + Revision 1.7 2004/05/26 17:19:10 brenuart + Allow JUnit tests to be executed against another database. + By default the test configuration will be taken from the 'testconfig-hsqldb.properties' file located in the org.logicalcobwebs.proxool package. + This behavior can be overriden by setting the 'testConfig' environment property to another location. + Revision 1.6 2003/03/04 12:50:44 billhorsman fix |