From: <mro...@us...> - 2012-08-06 12:56:31
|
Revision: 57004 http://firebird.svn.sourceforge.net/firebird/?rev=57004&view=rev Author: mrotteveel Date: 2012-08-06 12:56:23 +0000 (Mon, 06 Aug 2012) Log Message: ----------- JDBC-201: * Rename SimpleFBTestBase to FBTestProperties to better reflect its purpose * Move common factory methods from FBTestBase to FBTestProperties * Move DDL helper methods from FBTestBase to separate class (DdlHelper) * Move closeQuietly methods from FBTestBase to separate class (JdbcResourceHelper) Modified Paths: -------------- client-java/trunk/src/test/org/firebirdsql/common/FBTestBase.java client-java/trunk/src/test/org/firebirdsql/ds/FBConnectionPoolTestBase.java client-java/trunk/src/test/org/firebirdsql/ds/TestFBXADataSource.java client-java/trunk/src/test/org/firebirdsql/event/TestFBEventManager.java client-java/trunk/src/test/org/firebirdsql/gds/TestReconnectTransaction.java client-java/trunk/src/test/org/firebirdsql/gds/impl/jni/TestNgds.java client-java/trunk/src/test/org/firebirdsql/gds/impl/jni/TestNgdsBlobReadBug.java client-java/trunk/src/test/org/firebirdsql/gds/impl/wire/TestGds.java client-java/trunk/src/test/org/firebirdsql/jca/TestFBDatabaseMetaData.java client-java/trunk/src/test/org/firebirdsql/jca/TestFBTpbMapper.java client-java/trunk/src/test/org/firebirdsql/jca/TestFBXAResource.java client-java/trunk/src/test/org/firebirdsql/jca/TestXABase.java client-java/trunk/src/test/org/firebirdsql/jdbc/FBMetaDataTestBase.java client-java/trunk/src/test/org/firebirdsql/jdbc/FBTestGeneratedKeysBase.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestBoundary.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBBlobStream.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBCallableStatement.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBClob.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBConnection.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataColumns.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataIndexInfo.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataProcedureColumns.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataProcedures.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataTables.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataUDTs.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDriver.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBEncodings.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBLongVarCharEncodings.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBParameterMetaData.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBPreparedStatement.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBPreparedStatementGeneratedKeys.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBResultSet.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBResultSetMetaData.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatement.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatementGeneratedKeys.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBUnmanagedConnection.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBWrappingDataSource.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestTableReservation.java client-java/trunk/src/test/org/firebirdsql/management/TestBackupManager.java client-java/trunk/src/test/org/firebirdsql/management/TestFBMaintenanceManager.java client-java/trunk/src/test/org/firebirdsql/management/TestFBManager.java client-java/trunk/src/test/org/firebirdsql/management/TestFBStatisticsManager.java client-java/trunk/src/test/org/firebirdsql/management/TestUserManager.java client-java/trunk/src/test/org/firebirdsql/pool/TestDriverConnectionPoolDataSource.java client-java/trunk/src/test/org/firebirdsql/pool/TestFBConnectionPoolDataSource.java client-java/trunk/src/test/org/firebirdsql/pool/TestXADataSource.java Added Paths: ----------- client-java/trunk/src/test/org/firebirdsql/common/DdlHelper.java client-java/trunk/src/test/org/firebirdsql/common/FBTestProperties.java client-java/trunk/src/test/org/firebirdsql/common/JdbcResourceHelper.java Removed Paths: ------------- client-java/trunk/src/test/org/firebirdsql/common/SimpleFBTestBase.java Added: client-java/trunk/src/test/org/firebirdsql/common/DdlHelper.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/common/DdlHelper.java (rev 0) +++ client-java/trunk/src/test/org/firebirdsql/common/DdlHelper.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -0,0 +1,109 @@ +/* + * $Id$ + * Firebird Open Source J2ee connector - jdbc driver + * + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.common; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +import org.firebirdsql.gds.GDSException; +import org.firebirdsql.gds.ISCConstants; +import org.firebirdsql.gds.impl.GDSHelper; +import org.firebirdsql.jdbc.FBConnection; +import org.firebirdsql.jdbc.FBSQLException; + +/** + * Helper class for executing DDL while ignoring certain errors. + * + * @author <a href="mailto:mro...@us...">Mark Rotteveel</a> + */ +public final class DdlHelper { + + private DdlHelper() { + } + + public static void executeCreateTable(Connection connection, String sql) throws SQLException { + DdlHelper.executeDDL(connection, sql, new int[] { ISCConstants.isc_no_meta_update }); + } + + public static void executeDDL(Connection connection, String sql, int[] ignoreErrors) + throws SQLException { + try { + Statement stmt = connection.createStatement(); + try { + stmt.execute(sql); + } finally { + stmt.close(); + } + } catch (SQLException ex) { + if (ignoreErrors == null || ignoreErrors.length == 0) + throw ex; + + boolean ignoreException = false; + + int errorCode = ex.getErrorCode(); + Throwable current = ex; + errorcodeloop: do { + for (int i = 0; i < ignoreErrors.length; i++) { + if (ignoreErrors[i] == errorCode) { + ignoreException = true; + break errorcodeloop; + } + } + if (current instanceof GDSException) { + current = ((GDSException) current).getNext(); + } else { + current = current.getCause(); + } + if (current == null || !(current instanceof GDSException)) { + break; + } else { + errorCode = ((GDSException) current).getFbErrorCode(); + } + } while (errorCode != -1); + + if (!ignoreException) + throw ex; + } + } + + public static void executeDropTable(Connection connection, String sql) throws SQLException { + executeDDL(connection, sql, DdlHelper.getDropIgnoreErrors(connection)); + } + + private static int[] getDropIgnoreErrors(Connection connection) throws SQLException { + GDSHelper gdsHelper; + try { + gdsHelper = ((FBConnection) connection).getGDSHelper(); + if (gdsHelper.compareToVersion(2, 0) < 0) { + // Firebird 1.5 and earlier do not always return specific error + // codes + return new int[] { ISCConstants.isc_dsql_error, ISCConstants.isc_no_meta_update, + ISCConstants.isc_dsql_table_not_found, ISCConstants.isc_dsql_view_not_found }; + } else { + return new int[] { ISCConstants.isc_no_meta_update, + ISCConstants.isc_dsql_table_not_found, ISCConstants.isc_dsql_view_not_found }; + } + } catch (GDSException e) { + throw new FBSQLException(e); + } + } + +} Property changes on: client-java/trunk/src/test/org/firebirdsql/common/DdlHelper.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: client-java/trunk/src/test/org/firebirdsql/common/FBTestBase.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/common/FBTestBase.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/common/FBTestBase.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -19,31 +19,17 @@ package org.firebirdsql.common; import java.sql.*; -import java.util.*; -import javax.resource.spi.ConnectionManager; -import javax.sql.PooledConnection; import junit.framework.TestCase; -import org.firebirdsql.gds.GDSException; -import org.firebirdsql.gds.ISCConstants; -import org.firebirdsql.gds.impl.GDSHelper; import org.firebirdsql.gds.impl.GDSType; -import org.firebirdsql.jca.FBManagedConnectionFactory; -import org.firebirdsql.jca.InternalConnectionManager; -import org.firebirdsql.jdbc.FBConnection; -import org.firebirdsql.jdbc.FBDriver; -import org.firebirdsql.jdbc.FBSQLException; import org.firebirdsql.jdbc.FirebirdConnection; import org.firebirdsql.logging.Logger; import org.firebirdsql.logging.LoggerFactory; import org.firebirdsql.management.FBManager; -import org.firebirdsql.pool.AbstractFBConnectionPoolDataSource; -import org.firebirdsql.pool.FBPooledDataSourceFactory; -import org.firebirdsql.pool.FBWrappingDataSource; -import static org.firebirdsql.common.SimpleFBTestBase.*; +import static org.firebirdsql.common.FBTestProperties.*; /** * Base class for test cases which could be run against more then a single GDS @@ -53,154 +39,14 @@ protected final Logger log = LoggerFactory.getLogger(getClass(), true); - protected static final String DB_LC_CTYPE = getProperty("test.db.lc_ctype", "NONE"); - - protected final String DB_DATASOURCE_URL = getdbpath(DB_NAME); - protected FBTestBase(String name) { super(name); } - // FACTORY METHODS - // - // These methods should be used where possible so as to create the objects - // bound to the - // appropriate GDS implementation. - - protected AbstractFBConnectionPoolDataSource createFBConnectionPoolDataSource() - throws SQLException { - final AbstractFBConnectionPoolDataSource returnValue = FBPooledDataSourceFactory - .createFBConnectionPoolDataSource(); - - returnValue.setType(getGdsType().toString()); - - return returnValue; + protected final FirebirdConnection getConnectionViaDriverManager() throws SQLException { + return FBTestProperties.getConnectionViaDriverManager(); } - - protected FBManagedConnectionFactory createFBManagedConnectionFactory() { - return new FBManagedConnectionFactory(getGdsType()); - } - - protected FBManagedConnectionFactory createFBManagedConnectionFactory( - ConnectionManager cm) { - FBManagedConnectionFactory mcf = new FBManagedConnectionFactory( - getGdsType()); - mcf.setDefaultConnectionManager(new InternalConnectionManager()); - return mcf; - } - - protected FBManager createFBManager() { - return new FBManager(getGdsType()); - } - - protected FBWrappingDataSource createFBWrappingDataSource() - throws SQLException { - final FBWrappingDataSource returnValue = new FBWrappingDataSource(); - - returnValue.setType(getGdsType().toString()); - - return returnValue; - } - - protected FirebirdConnection getConnectionViaDriverManager() throws SQLException { - try { - Class.forName(FBDriver.class.getName()); - } catch (ClassNotFoundException ex) { - throw new SQLException("No suitable driver."); - } - - return (FirebirdConnection)DriverManager.getConnection(getUrl(), - getDefaultPropertiesForConnection()); - } - - protected Properties getDefaultPropertiesForConnection() { - final Properties returnValue = new Properties(); - - returnValue.setProperty("user", DB_USER); - returnValue.setProperty("password", DB_PASSWORD); - returnValue.setProperty("lc_ctype", DB_LC_CTYPE); - - return returnValue; - } - protected void executeCreateTable(Connection connection, String sql) throws SQLException { - executeDDL(connection, sql, new int[]{ISCConstants.isc_no_meta_update}); - } - - protected void executeDropTable(Connection connection, String sql) throws SQLException { - executeDDL(connection, sql, getDropIgnoreErrors(connection)); - } - - private int[] getDropIgnoreErrors(Connection connection) throws SQLException { - GDSHelper gdsHelper; - try { - gdsHelper = ((FBConnection)connection).getGDSHelper(); - if (gdsHelper.compareToVersion(2, 0) < 0) { - // Firebird 1.5 and earlier do not always return specific error codes - return new int[] {ISCConstants.isc_dsql_error, ISCConstants.isc_no_meta_update, ISCConstants.isc_dsql_table_not_found, ISCConstants.isc_dsql_view_not_found}; - } else { - return new int[]{ISCConstants.isc_no_meta_update, ISCConstants.isc_dsql_table_not_found, ISCConstants.isc_dsql_view_not_found}; - } - } catch (GDSException e) { - throw new FBSQLException(e); - } - } - - protected void executeDDL(Connection connection, String sql, int[] ignoreErrors) throws SQLException { - try { - Statement stmt = connection.createStatement(); - try { - stmt.execute(sql); - } finally { - stmt.close(); - } - } catch(SQLException ex) { - if (ignoreErrors == null || ignoreErrors.length == 0) - throw ex; - - boolean ignoreException = false; - - int errorCode = ex.getErrorCode(); - Throwable current = ex; - errorcodeloop: do { - for (int i = 0; i < ignoreErrors.length; i++) { - if (ignoreErrors[i] == errorCode) { - ignoreException = true; - break errorcodeloop; - } - } - if (current instanceof GDSException) { - current = ((GDSException)current).getNext(); - } else { - current = current.getCause(); - } - if (current == null || !(current instanceof GDSException)) { - break; - } else { - errorCode = ((GDSException)current).getFbErrorCode(); - } - } while (errorCode != -1); - - if (!ignoreException) - throw ex; - } - } - - // USEFULL PROPERTY GETTERS - - protected String getUrl() { - return gdsTypeToUrlPrefixMap.get(getGdsType()) + getdbpath(DB_NAME); - } - - protected GDSType getGdsType() { - final GDSType gdsType = GDSType.getType(getProperty("test.gds_type", "PURE_JAVA")); - if (gdsType == null) - throw new RuntimeException( - "Unrecoginzed value for 'test.gds_type' property."); - - return gdsType; - } - // STANDARD RIG protected void setUp() throws Exception { @@ -223,84 +69,4 @@ } protected FBManager fbManager = null; - - private static final Map gdsTypeToUrlPrefixMap = new HashMap(); - static { - gdsTypeToUrlPrefixMap.put(GDSType.getType("PURE_JAVA"), - "jdbc:firebirdsql:"); - gdsTypeToUrlPrefixMap.put(GDSType.getType("EMBEDDED"), - "jdbc:firebirdsql:embedded:"); - gdsTypeToUrlPrefixMap.put(GDSType.getType("NATIVE"), - "jdbc:firebirdsql:native:"); - gdsTypeToUrlPrefixMap.put(GDSType.getType("ORACLE_MODE"), - "jdbc:firebirdsql:oracle:"); - gdsTypeToUrlPrefixMap.put(GDSType.getType("LOCAL"), - "jdbc:firebirdsql:local:"); - gdsTypeToUrlPrefixMap.put(GDSType.getType("NIO"), - "jdbc:firebirdsql:nio:"); - } - - /** - * Helper method to quietly close statements. - * - * @param stmt Statement object - */ - protected void closeQuietly(Statement stmt) { - if (stmt == null) { - return; - } - try { - stmt.close(); - } catch (SQLException ex) { - //ignore - } - } - - /** - * Helper method to quietly close connections. - * - * @param con Connection object - */ - protected void closeQuietly(Connection con) { - if (con == null) { - return; - } - try { - con.close(); - } catch (SQLException ex) { - //ignore - } - } - - /** - * Helper method to quietly close resultsets. - * - * @param rs ResultSet object - */ - protected void closeQuietly(ResultSet rs) { - if (rs == null) { - return; - } - try { - rs.close(); - } catch (SQLException ex) { - //ignore - } - } - - /** - * Helper method to quietly close pooled connections. - * - * @param con PooledConnection object - */ - protected void closeQuietly(PooledConnection con) { - if (con == null) { - return; - } - try { - con.close(); - } catch (SQLException ex) { - //ignore - } - } } Copied: client-java/trunk/src/test/org/firebirdsql/common/FBTestProperties.java (from rev 57003, client-java/trunk/src/test/org/firebirdsql/common/SimpleFBTestBase.java) =================================================================== --- client-java/trunk/src/test/org/firebirdsql/common/FBTestProperties.java (rev 0) +++ client-java/trunk/src/test/org/firebirdsql/common/FBTestProperties.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -0,0 +1,192 @@ +/* + * $Id$ + * Firebird Open Source J2ee connector - jdbc driver + * + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.common; + +import java.io.File; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import java.util.MissingResourceException; +import java.util.Properties; +import java.util.ResourceBundle; + +import javax.resource.spi.ConnectionManager; + +import org.firebirdsql.gds.impl.GDSType; +import org.firebirdsql.jca.FBManagedConnectionFactory; +import org.firebirdsql.jca.InternalConnectionManager; +import org.firebirdsql.jdbc.FBDriver; +import org.firebirdsql.jdbc.FirebirdConnection; +import org.firebirdsql.management.FBManager; +import org.firebirdsql.pool.AbstractFBConnectionPoolDataSource; +import org.firebirdsql.pool.FBPooledDataSourceFactory; +import org.firebirdsql.pool.FBWrappingDataSource; + +/** + * Helper class for test properties (database user, password, paths etc) + */ +public final class FBTestProperties { + private static ResourceBundle testDefaults = ResourceBundle.getBundle("unit_test_defaults"); + + public static String getProperty(String property) { + return getProperty(property, null); + } + + public static String getProperty(String property, String defaultValue) { + try { + return System.getProperty(property, testDefaults.getString(property)); + } catch (MissingResourceException ex) { + return System.getProperty(property, defaultValue); + } + } + + /** + * Default name of database file to use for the test case. + */ + public static final String DB_NAME = "fbtest.fdb"; + public static final String DB_USER = getProperty("test.user", "sysdba"); + public static final String DB_PASSWORD = getProperty("test.password", "masterkey"); + public static final String DB_PATH = getProperty("test.db.dir", ""); + public static final String DB_SERVER_URL = getProperty("test.db.host", "localhost"); + public static final int DB_SERVER_PORT = Integer.parseInt(getProperty("test.db.port", "3050")); + public static final String DB_LC_CTYPE = getProperty("test.db.lc_ctype", "NONE"); + public static final String DB_DATASOURCE_URL = getdbpath(DB_NAME); + + public static String getDatabasePath() { + return getDatabasePath(DB_NAME); + } + + public static String getDatabasePath(String name) { + if (!"127.0.0.1".equals(DB_SERVER_URL) && !"localhost".equals(DB_SERVER_URL)) + return DB_PATH + "/" + name; + else + return new File(DB_PATH, name).getAbsolutePath(); + } + + /** + * Builds a firebird database connection string for the supplied database + * file. + * + * @param name + * @return + */ + public static String getdbpath(String name) { + final String gdsType = getProperty("test.gds_type", null); + if ("EMBEDDED".equalsIgnoreCase(gdsType) || "LOCAL".equalsIgnoreCase(gdsType)) { + return new File(DB_PATH, name).getAbsolutePath(); + } else { + return DB_SERVER_URL + "/" + DB_SERVER_PORT + ":" + getDatabasePath(name); + } + } + + /** + * @return Default database connection properties for this testrun + */ + public static Properties getDefaultPropertiesForConnection() { + final Properties returnValue = new Properties(); + + returnValue.setProperty("user", DB_USER); + returnValue.setProperty("password", DB_PASSWORD); + returnValue.setProperty("lc_ctype", DB_LC_CTYPE); + + return returnValue; + } + + /** + * @return {@link GDSType} for this testrun + */ + public static GDSType getGdsType() { + final GDSType gdsType = GDSType.getType(getProperty("test.gds_type", "PURE_JAVA")); + if (gdsType == null) { + throw new RuntimeException("Unrecognized value for 'test.gds_type' property."); + } + return gdsType; + } + + private static final Map gdsTypeToUrlPrefixMap = new HashMap(); + static { + gdsTypeToUrlPrefixMap.put(GDSType.getType("PURE_JAVA"), "jdbc:firebirdsql:"); + gdsTypeToUrlPrefixMap.put(GDSType.getType("EMBEDDED"), "jdbc:firebirdsql:embedded:"); + gdsTypeToUrlPrefixMap.put(GDSType.getType("NATIVE"), "jdbc:firebirdsql:native:"); + gdsTypeToUrlPrefixMap.put(GDSType.getType("ORACLE_MODE"), "jdbc:firebirdsql:oracle:"); + gdsTypeToUrlPrefixMap.put(GDSType.getType("LOCAL"), "jdbc:firebirdsql:local:"); + gdsTypeToUrlPrefixMap.put(GDSType.getType("NIO"), "jdbc:firebirdsql:nio:"); + } + + /** + * @return JDBC URL (without parameters) for this testrun + */ + public static String getUrl() { + return gdsTypeToUrlPrefixMap.get(getGdsType()) + getdbpath(DB_NAME); + } + + // FACTORY METHODS + // + // These methods should be used where possible so as to create the objects + // bound to the + // appropriate GDS implementation. + + public static AbstractFBConnectionPoolDataSource createFBConnectionPoolDataSource() + throws SQLException { + final AbstractFBConnectionPoolDataSource returnValue = FBPooledDataSourceFactory + .createFBConnectionPoolDataSource(); + + returnValue.setType(getGdsType().toString()); + + return returnValue; + } + + public static FBManagedConnectionFactory createFBManagedConnectionFactory() { + return new FBManagedConnectionFactory(getGdsType()); + } + + public static FBManagedConnectionFactory createFBManagedConnectionFactory(ConnectionManager cm) { + FBManagedConnectionFactory mcf = new FBManagedConnectionFactory(getGdsType()); + mcf.setDefaultConnectionManager(new InternalConnectionManager()); + return mcf; + } + + public static FBManager createFBManager() { + return new FBManager(getGdsType()); + } + + public static FBWrappingDataSource createFBWrappingDataSource() throws SQLException { + final FBWrappingDataSource returnValue = new FBWrappingDataSource(); + + returnValue.setType(getGdsType().toString()); + + return returnValue; + } + + public static FirebirdConnection getConnectionViaDriverManager() throws SQLException { + try { + Class.forName(FBDriver.class.getName()); + } catch (ClassNotFoundException ex) { + throw new SQLException("No suitable driver."); + } + + return (FirebirdConnection) DriverManager.getConnection(getUrl(), + getDefaultPropertiesForConnection()); + } + + private FBTestProperties() { + } +} Added: client-java/trunk/src/test/org/firebirdsql/common/JdbcResourceHelper.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/common/JdbcResourceHelper.java (rev 0) +++ client-java/trunk/src/test/org/firebirdsql/common/JdbcResourceHelper.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -0,0 +1,107 @@ +/* + * $Id$ + * Firebird Open Source J2ee connector - jdbc driver + * + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.common; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import javax.sql.PooledConnection; + +/** + * Helper class for closing JDBC resources, ignoring all SQLExceptions. + * + * @author <a href="mailto:mro...@us...">Mark Rotteveel</a> + */ +public final class JdbcResourceHelper { + + private JdbcResourceHelper() { + } + + /** + * Helper method to quietly close statements. + * + * @param stmt + * Statement object + */ + public static void closeQuietly(Statement stmt) { + if (stmt == null) { + return; + } + try { + stmt.close(); + } catch (SQLException ex) { + // ignore + } + } + + /** + * Helper method to quietly close connections. + * + * @param con + * Connection object + */ + public static void closeQuietly(Connection con) { + if (con == null) { + return; + } + try { + con.close(); + } catch (SQLException ex) { + // ignore + } + } + + /** + * Helper method to quietly close resultsets. + * + * @param rs + * ResultSet object + */ + public static void closeQuietly(ResultSet rs) { + if (rs == null) { + return; + } + try { + rs.close(); + } catch (SQLException ex) { + // ignore + } + } + + /** + * Helper method to quietly close pooled connections. + * + * @param con + * PooledConnection object + */ + public static void closeQuietly(PooledConnection con) { + if (con == null) { + return; + } + try { + con.close(); + } catch (SQLException ex) { + // ignore + } + } + +} Property changes on: client-java/trunk/src/test/org/firebirdsql/common/JdbcResourceHelper.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Deleted: client-java/trunk/src/test/org/firebirdsql/common/SimpleFBTestBase.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/common/SimpleFBTestBase.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/common/SimpleFBTestBase.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -1,86 +0,0 @@ -/* - * $Id$ - * Firebird Open Source J2ee connector - jdbc driver - * - * Distributable under LGPL license. - * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * LGPL License for more details. - * - * This file was created by members of the firebird development team. - * All individual contributions remain the Copyright (C) of those - * individuals. Contributors to this file are either listed here or - * can be obtained from a CVS history command. - * - * All rights reserved. - */ -package org.firebirdsql.common; - -import java.io.File; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * Helper class for test properties (database user, password, paths etc) - */ -public final class SimpleFBTestBase { - private static ResourceBundle testDefaults = ResourceBundle.getBundle("unit_test_defaults"); - - public static String getProperty(String property) { - return getProperty(property, null); - } - - public static String getProperty(String property, String defaultValue) { - try { - return System.getProperty(property, testDefaults.getString(property)); - } catch (MissingResourceException ex) { - return System.getProperty(property, defaultValue); - } - } - - /** - * Default name of database file to use for the test case. - */ - public static final String DB_NAME = "fbtest.fdb"; - - public static final String DB_USER = getProperty("test.user", "sysdba"); - public static final String DB_PASSWORD = getProperty("test.password", "masterkey"); - - public static final String DB_PATH = getProperty("test.db.dir", ""); - public static final String DB_SERVER_URL = getProperty("test.db.host", "localhost"); - public static final int DB_SERVER_PORT = Integer.parseInt(getProperty("test.db.port", "3050")); - - public static String getDatabasePath() { - return getDatabasePath(DB_NAME); - } - - public static String getDatabasePath(String name) { - if (!"127.0.0.1".equals(DB_SERVER_URL) && !"localhost".equals(DB_SERVER_URL)) - return DB_PATH + "/" + name; - else - return new File(DB_PATH, name).getAbsolutePath(); - } - - - /** - * Builds an firebird database connection string for the supplied database - * file. - * - * @param name - * @return - */ - public static String getdbpath(String name) { - final String gdsType = getProperty("test.gds_type", null); - if ("EMBEDDED".equalsIgnoreCase(gdsType) || "LOCAL".equalsIgnoreCase(gdsType)) { - return new File(DB_PATH, name).getAbsolutePath(); - } else { - return DB_SERVER_URL + "/" + DB_SERVER_PORT + ":" + getDatabasePath(name); - } - } - - private SimpleFBTestBase() { - } -} Modified: client-java/trunk/src/test/org/firebirdsql/ds/FBConnectionPoolTestBase.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/ds/FBConnectionPoolTestBase.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/ds/FBConnectionPoolTestBase.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -28,10 +28,10 @@ import javax.sql.PooledConnection; import org.firebirdsql.common.FBTestBase; -import org.firebirdsql.common.SimpleFBTestBase; import org.firebirdsql.gds.impl.GDSType; -import static org.firebirdsql.common.SimpleFBTestBase.*; +import static org.firebirdsql.common.JdbcResourceHelper.*; +import static org.firebirdsql.common.FBTestProperties.*; /** * Common testbase for tests using {@link FBConnectionPoolDataSource} @@ -50,7 +50,7 @@ super.setUp(); FBConnectionPoolDataSource newDs = new FBConnectionPoolDataSource(); - newDs.setType(SimpleFBTestBase.getProperty("test.gds_type", null)); + newDs.setType(getProperty("test.gds_type", null)); if (getGdsType() == GDSType.getType("PURE_JAVA") || getGdsType() == GDSType.getType("NATIVE")) { newDs.setServerName(DB_SERVER_URL); Modified: client-java/trunk/src/test/org/firebirdsql/ds/TestFBXADataSource.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/ds/TestFBXADataSource.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/ds/TestFBXADataSource.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -34,12 +34,12 @@ import javax.transaction.xa.Xid; import org.firebirdsql.common.FBTestBase; -import org.firebirdsql.common.SimpleFBTestBase; import org.firebirdsql.gds.impl.GDSType; import org.firebirdsql.jca.TestXABase.XidImpl; import org.firebirdsql.jdbc.FBSQLException; -import static org.firebirdsql.common.SimpleFBTestBase.*; +import static org.firebirdsql.common.JdbcResourceHelper.*; +import static org.firebirdsql.common.FBTestProperties.*; /** * Test for XADataSource. Note behavior of XAResource (ManagedConnection) is tested in {@link org.firebirdsql.jca.TestFBXAResource}. @@ -61,7 +61,7 @@ super.setUp(); FBXADataSource newDs = new FBXADataSource(); - newDs.setType(SimpleFBTestBase.getProperty("test.gds_type", null)); + newDs.setType(getProperty("test.gds_type", null)); if (getGdsType() == GDSType.getType("PURE_JAVA") || getGdsType() == GDSType.getType("NATIVE")) { newDs.setServerName(DB_SERVER_URL); Modified: client-java/trunk/src/test/org/firebirdsql/event/TestFBEventManager.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/event/TestFBEventManager.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/event/TestFBEventManager.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -6,7 +6,7 @@ import org.firebirdsql.common.FBTestBase; import org.firebirdsql.gds.impl.GDSType; -import static org.firebirdsql.common.SimpleFBTestBase.*; +import static org.firebirdsql.common.FBTestProperties.*; /** * Test the FBEventManager class Modified: client-java/trunk/src/test/org/firebirdsql/gds/TestReconnectTransaction.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/gds/TestReconnectTransaction.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/gds/TestReconnectTransaction.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -10,7 +10,7 @@ import org.firebirdsql.jdbc.field.FBField; import org.firebirdsql.jdbc.field.FieldDataProvider; -import static org.firebirdsql.common.SimpleFBTestBase.*; +import static org.firebirdsql.common.FBTestProperties.*; /** * Modified: client-java/trunk/src/test/org/firebirdsql/gds/impl/jni/TestNgds.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/gds/impl/jni/TestNgds.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/gds/impl/jni/TestNgds.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -38,7 +38,7 @@ import org.firebirdsql.logging.Logger; import org.firebirdsql.logging.LoggerFactory; -import static org.firebirdsql.common.SimpleFBTestBase.*; +import static org.firebirdsql.common.FBTestProperties.*; /** * Performs basic low level tests of the ngds package. Modified: client-java/trunk/src/test/org/firebirdsql/gds/impl/jni/TestNgdsBlobReadBug.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/gds/impl/jni/TestNgdsBlobReadBug.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/gds/impl/jni/TestNgdsBlobReadBug.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -44,7 +44,7 @@ import org.firebirdsql.logging.Logger; import org.firebirdsql.logging.LoggerFactory; -import static org.firebirdsql.common.SimpleFBTestBase.*; +import static org.firebirdsql.common.FBTestProperties.*; /** * Performs test to reproduce bug found in blob reading done by type 2 driver. Modified: client-java/trunk/src/test/org/firebirdsql/gds/impl/wire/TestGds.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/gds/impl/wire/TestGds.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/gds/impl/wire/TestGds.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -32,7 +32,7 @@ import org.firebirdsql.gds.impl.wire.isc_stmt_handle_impl; import org.firebirdsql.jca.FBTpb; -import static org.firebirdsql.common.SimpleFBTestBase.*; +import static org.firebirdsql.common.FBTestProperties.*; /** * @author <a href="mailto:alb...@us...">Alejandro Modified: client-java/trunk/src/test/org/firebirdsql/jca/TestFBDatabaseMetaData.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jca/TestFBDatabaseMetaData.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jca/TestFBDatabaseMetaData.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -30,7 +30,7 @@ import org.firebirdsql.jdbc.*; -import static org.firebirdsql.common.SimpleFBTestBase.*; +import static org.firebirdsql.common.FBTestProperties.*; /** * Describe class <code>TestFBDatabaseMetaData</code> here. Modified: client-java/trunk/src/test/org/firebirdsql/jca/TestFBTpbMapper.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jca/TestFBTpbMapper.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jca/TestFBTpbMapper.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -18,7 +18,6 @@ */ package org.firebirdsql.jca; - import java.sql.Connection; import org.firebirdsql.gds.ISCConstants; @@ -27,6 +26,8 @@ import org.firebirdsql.common.FBTestBase; +import static org.firebirdsql.common.FBTestProperties.*; + /** * <a href="mailto:rro...@us...">Roman Rokytskyy</a> */ @@ -44,9 +45,8 @@ protected void setUp() throws Exception { super.setUp(); - mcf = super.createFBManagedConnectionFactory();//new FBManagedConnectionFactory(); + mcf = createFBManagedConnectionFactory(); } - /** * Test if default isolation level is Connection.TRANSACTION_READ_COMMITTED Modified: client-java/trunk/src/test/org/firebirdsql/jca/TestFBXAResource.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jca/TestFBXAResource.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jca/TestFBXAResource.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -28,6 +28,8 @@ import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; +import static org.firebirdsql.common.FBTestProperties.*; + /** * Describe class <code>TestFBXAResource</code> here. * Modified: client-java/trunk/src/test/org/firebirdsql/jca/TestXABase.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jca/TestXABase.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jca/TestXABase.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -26,7 +26,7 @@ import org.firebirdsql.common.FBTestBase; -import static org.firebirdsql.common.SimpleFBTestBase.*; +import static org.firebirdsql.common.FBTestProperties.*; /** * THIS FILE INCLUDES AN XID IMPLEMENTATION FROM THE JBOSS PROJECT Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/FBMetaDataTestBase.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/FBMetaDataTestBase.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/FBMetaDataTestBase.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -32,6 +32,9 @@ import org.firebirdsql.common.FBTestBase; import org.firebirdsql.jdbc.MetaDataValidator.MetaDataInfo; +import static org.firebirdsql.common.DdlHelper.*; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * Base test class for testing and validating the various DatabaseMetaData * methods returning a ResultSet. Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/FBTestGeneratedKeysBase.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/FBTestGeneratedKeysBase.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/FBTestGeneratedKeysBase.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -24,6 +24,9 @@ import org.firebirdsql.common.FBTestBase; +import static org.firebirdsql.common.DdlHelper.*; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * Test base for tests of retrieval of auto generated keys. * <p> Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestBoundary.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestBoundary.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestBoundary.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -6,6 +6,9 @@ import org.firebirdsql.common.FBTestBase; +import static org.firebirdsql.common.DdlHelper.*; +import static org.firebirdsql.common.JdbcResourceHelper.*; + public class TestBoundary extends FBTestBase { private static final String CREATE_META_ONE = Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBBlobStream.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBBlobStream.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBBlobStream.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -27,6 +27,8 @@ import java.util.Properties; import java.util.Random; +import static org.firebirdsql.common.FBTestProperties.*; + /** * Describe class <code>TestFBBlobAccess</code> here. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBCallableStatement.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBCallableStatement.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBCallableStatement.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -22,6 +22,8 @@ import java.sql.*; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * This test case checks callable statements by executing procedure through * {@link java.sql.CallableStatement} and {@link java.sql.PreparedStatement}. Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBClob.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBClob.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBClob.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -35,6 +35,8 @@ import org.firebirdsql.common.FBTestBase; +import static org.firebirdsql.common.FBTestProperties.*; + public class TestFBClob extends FBTestBase { private static final String PLAIN_BLOB = "plain_blob"; Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBConnection.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBConnection.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBConnection.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -25,6 +25,9 @@ import org.firebirdsql.gds.*; import org.firebirdsql.jca.FBManagedConnection; +import static org.firebirdsql.common.JdbcResourceHelper.*; +import static org.firebirdsql.common.FBTestProperties.*; + /** * Test cases for FirebirdConnection interface. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataColumns.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataColumns.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataColumns.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -34,6 +34,8 @@ import org.firebirdsql.jdbc.MetaDataValidator.MetaDataInfo; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * Tests for {@link FBDatabaseMetaData} for column related metadata. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataIndexInfo.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataIndexInfo.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataIndexInfo.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -31,6 +31,8 @@ import org.firebirdsql.jdbc.MetaDataValidator.MetaDataInfo; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * Tests for {@link FBDatabaseMetaData} for index info related metadata. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataProcedureColumns.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataProcedureColumns.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataProcedureColumns.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -32,6 +32,8 @@ import org.firebirdsql.jdbc.MetaDataValidator.MetaDataInfo; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * Tests for {@link FBDatabaseMetaData} for procedure columns related metadata. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataProcedures.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataProcedures.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataProcedures.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -31,6 +31,8 @@ import org.firebirdsql.jdbc.MetaDataValidator.MetaDataInfo; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * Tests for {@link FBDatabaseMetaData} for procedure related metadata. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataTables.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataTables.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataTables.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -31,6 +31,8 @@ import org.firebirdsql.jdbc.MetaDataValidator.MetaDataInfo; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * Tests for {@link FBDatabaseMetaData} for table related metadata. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataUDTs.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataUDTs.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDatabaseMetaDataUDTs.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -27,6 +27,8 @@ import org.firebirdsql.jdbc.MetaDataValidator.MetaDataInfo; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * Tests for {@link FBDatabaseMetaData} for UDT related metadata. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDriver.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDriver.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBDriver.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -30,6 +30,8 @@ import junit.framework.TestSuite; import org.firebirdsql.common.FBTestBase; +import static org.firebirdsql.common.FBTestProperties.*; + /** * Test suite for the FBDriver class implementation. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBEncodings.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBEncodings.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBEncodings.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -30,6 +30,8 @@ import java.sql.Statement; import java.util.*; +import static org.firebirdsql.common.FBTestProperties.*; + /** * Describe class <code>TestFBEncodings</code> here. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBLongVarCharEncodings.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBLongVarCharEncodings.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBLongVarCharEncodings.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -26,6 +26,8 @@ import java.sql.ResultSet; import java.util.Properties; +import static org.firebirdsql.common.FBTestProperties.*; + /** * This test case tests encodings in text blobs. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBParameterMetaData.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBParameterMetaData.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBParameterMetaData.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -27,6 +27,8 @@ import java.sql.Statement; import java.util.Properties; +import static org.firebirdsql.common.FBTestProperties.*; + /** * This method tests correctness of {@link FBParameterMetaData} class. * @@ -66,10 +68,10 @@ Class.forName(FBDriver.class.getName()); Properties props = new Properties(); - props.putAll(this.getDefaultPropertiesForConnection()); + props.putAll(getDefaultPropertiesForConnection()); props.put("lc_ctype", "UNICODE_FSS"); - Connection connection = DriverManager.getConnection(this.getUrl(), props); + Connection connection = DriverManager.getConnection(getUrl(), props); Statement stmt = connection.createStatement(); try { @@ -89,10 +91,10 @@ public void testParameterMetaData() throws Exception { Properties props = new Properties(); - props.putAll(this.getDefaultPropertiesForConnection()); + props.putAll(getDefaultPropertiesForConnection()); props.put("lc_ctype", "UNICODE_FSS"); - Connection connection = DriverManager.getConnection(this.getUrl(), props); + Connection connection = DriverManager.getConnection(getUrl(), props); FirebirdPreparedStatement stmt = (FirebirdPreparedStatement)connection.prepareStatement(TEST_QUERY); Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBPreparedStatement.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBPreparedStatement.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBPreparedStatement.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -26,6 +26,10 @@ import java.util.Properties; import java.util.TimeZone; +import static org.firebirdsql.common.DdlHelper.*; +import static org.firebirdsql.common.JdbcResourceHelper.*; +import static org.firebirdsql.common.FBTestProperties.*; + /** * Describe class <code>TestFBPreparedStatement</code> here. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBPreparedStatementGeneratedKeys.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBPreparedStatementGeneratedKeys.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBPreparedStatementGeneratedKeys.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -29,6 +29,8 @@ import org.firebirdsql.gds.ISCConstants; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * Tests for retrieval of auto generated keys through {@link java.sql.PreparedStatement} * implementation {@link FBPreparedStatement} created through {@link FBConnection} Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBResultSet.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBResultSet.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBResultSet.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -31,6 +31,8 @@ import junit.textui.TestRunner; +import static org.firebirdsql.common.FBTestProperties.*; + public class TestFBResultSet extends FBTestBase { public static final String SELECT_STATEMENT = "" Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBResultSetMetaData.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBResultSetMetaData.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBResultSetMetaData.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -24,6 +24,8 @@ import java.sql.*; import java.util.Properties; +import static org.firebirdsql.common.FBTestProperties.*; + /** * This method tests correctness of {@link FBResultSetMetaData} class. * @@ -65,10 +67,10 @@ Class.forName(FBDriver.class.getName()); Properties props = new Properties(); - props.putAll(this.getDefaultPropertiesForConnection()); + props.putAll(getDefaultPropertiesForConnection()); props.put("lc_ctype", "UNICODE_FSS"); - Connection connection = DriverManager.getConnection(this.getUrl(), props); + Connection connection = DriverManager.getConnection(getUrl(), props); Statement stmt = connection.createStatement(); try { @@ -102,10 +104,10 @@ public void testResultSetMetaData() throws Exception { Properties props = new Properties(); - props.putAll(this.getDefaultPropertiesForConnection()); + props.putAll(getDefaultPropertiesForConnection()); props.put("lc_ctype", "UNICODE_FSS"); - Connection connection = DriverManager.getConnection(this.getUrl(), props); + Connection connection = DriverManager.getConnection(getUrl(), props); Statement stmt = connection.createStatement(); @@ -137,10 +139,10 @@ public void testResultSetMetaData2() throws Exception { Properties props = new Properties(); - props.putAll(this.getDefaultPropertiesForConnection()); + props.putAll(getDefaultPropertiesForConnection()); props.put("lc_ctype", "UNICODE_FSS"); - Connection connection = DriverManager.getConnection(this.getUrl(), props); + Connection connection = DriverManager.getConnection(getUrl(), props); FBDatabaseMetaData dmd = (FBDatabaseMetaData)connection.getMetaData(); int firebirdVersion = dmd.getDatabaseMajorVersion(); @@ -178,11 +180,11 @@ public void testColumnTypeName() throws Exception { Properties props = new Properties(); - props.putAll(this.getDefaultPropertiesForConnection()); + props.putAll(getDefaultPropertiesForConnection()); props.put("lc_ctype", "UNICODE_FSS"); Connection connection = - DriverManager.getConnection(this.getUrl(), props); + DriverManager.getConnection(getUrl(), props); Statement stmt = connection.createStatement(); Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatement.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatement.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatement.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -7,6 +7,9 @@ import org.firebirdsql.common.FBTestBase; +import static org.firebirdsql.common.DdlHelper.*; +import static org.firebirdsql.common.JdbcResourceHelper.*; + public class TestFBStatement extends FBTestBase { private Connection con; Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatementGeneratedKeys.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatementGeneratedKeys.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatementGeneratedKeys.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -28,6 +28,8 @@ import org.firebirdsql.gds.ISCConstants; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * Tests for retrieval of auto generated keys through {@link java.sql.Statement} * implementation {@link FBStatement}. Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBUnmanagedConnection.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBUnmanagedConnection.java 2012-08-06 11:11:31 UTC (rev 57003) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBUnmanagedConnection.java 2012-08-06 12:56:23 UTC (rev 57004) @@ -26,8 +26,12 @@ import junit.framework.Test; import junit.framework.TestSuite; + import org.firebirdsql.common.FBTestBase; +import static org.firebirdsql.common.DdlHelper.*; +import static org.firebirdsql.common.JdbcResourceHelper.*; + /** * Describe class <code>TestFBUnmanagedConnection</code> here. * Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBWrappingDataSource.java ============================================================... [truncated message content] |