public class TestUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.Class[] |
BOOLEAN_ARG_TYPE |
private static java.lang.String |
CONNECTION_POOL_DATASOURCE_STRING |
static int |
DB2JCC_FRAMEWORK
framework = DB2JCC for testing JCC against DB2 for
debugging jcc problems jdbc:db2://
|
static int |
DERBY_NET_CLIENT_FRAMEWORK
framework = DerbyNetClient for Derby cient jdbc:derby://
|
static int |
DERBY_NET_FRAMEWORK
framework = DerbyNet for JCC jdbc:derby:net:
|
static int |
EMBEDDED_FRAMEWORK
framework = embedded (or null) jdbc:derby:
|
static java.lang.String |
END_HTML_PAGE |
private static int |
framework |
static boolean |
HAVE_DRIVER_CLASS |
private static java.lang.Class[] |
INT_ARG_TYPE |
static int |
OLD_NET_FRAMEWORK
framework = DB2jNet
OLD_NET_FRAMEWORK is for tests that have not yet been contributed.
|
private static java.lang.String |
REGULAR_DATASOURCE_STRING |
private static java.util.Hashtable<java.lang.String,java.lang.Class[]> |
specialAttributes |
private static java.lang.Class[] |
STRING_ARG_TYPE |
static java.lang.String |
TABLE_END_TAG |
static java.lang.String |
TABLE_START_TAG
Some routines for printing test information to html
|
static java.lang.String |
TD_CENTER |
static java.lang.String |
TD_END |
static java.lang.String |
TD_INVERSE |
static java.lang.String |
TD_LEFT |
static int |
UNKNOWN_FRAMEWORK |
private static java.lang.String |
XA_DATASOURCE_STRING |
Constructor and Description |
---|
TestUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
cleanUpTest(java.sql.Statement s,
java.lang.String[] testObjects)
Drop the test objects passed in as a string identifying the
type of object (e.g.
|
static boolean |
compareURL(java.lang.String url) |
private static java.lang.String |
convertToHexString(byte[] buf) |
static void |
dumpAllStackTracesIfSupported(java.io.PrintWriter log)
For JDK 1.5 or higher print all stack traces to the
specified PrintWriter.
|
static void |
dumpSQLExceptions(java.sql.SQLException sqle) |
static void |
dumpSQLExceptions(java.sql.SQLException sqle,
boolean expected) |
static void |
endHTMLPage() |
static java.sql.Connection |
getConnection(java.lang.String databaseName,
java.lang.String connAttrs)
Get connection to given database using the connection attributes.
|
static javax.sql.ConnectionPoolDataSource |
getConnectionPoolDataSource(java.util.Properties attrs)
Get a ConnectionPoolDataSource for the appropriate framework
|
static javax.sql.DataSource |
getDataSource(java.util.Properties attrs)
Get a data source for the appropriate framework
|
static java.sql.Connection |
getDataSourceConnection(java.util.Properties prop) |
static java.lang.String |
getDataSourcePrefix() |
private static java.lang.Object |
getDataSourceWithReflection(java.lang.String classname,
java.util.Properties attrs) |
private static int |
getFramework()
Get the framework from the System Property framework
|
static java.lang.String |
getGetterName(java.lang.String attribute) |
static java.lang.String |
getHostName()
Get hostName as passed in - if not, set it to "localhost"
|
static int |
getJDBCMajorVersion(java.sql.Connection conn)
Get the JDBC version, inferring it from the driver.
|
static java.lang.String |
getJdbcUrlPrefix()
Get URL prefix for current framework.
|
static java.lang.String |
getJdbcUrlPrefix(java.lang.String server,
int port)
Get URL prefix for current framework
|
static java.lang.String |
getNameFromJdbcType(int jdbcType) |
static java.lang.String |
getSetterName(java.lang.String attribute) |
static javax.sql.XADataSource |
getXADataSource(java.util.Properties attrs)
Get an xa data source for the appropriate framework
|
static boolean |
isDerbyNetClientFramework() |
static boolean |
isEmbeddedFramework() |
static boolean |
isJCCFramework()
Is the JCC driver being used
|
static boolean |
isNetFramework()
Is this a network testingframework?
|
static void |
loadDriver()
Load the appropriate driver for the current framework
|
static void |
printBoolArrayHTMLTable(java.lang.String rowDescription,
java.lang.String columnDescription,
java.lang.String[] rowLabels,
java.lang.String[] colLabels,
boolean[][] array,
java.lang.String tableInfo)
Converts 2 dimensional boolean array into an HTML table.
|
static void |
shutdownUsingDataSource(java.lang.String dbName) |
static java.lang.String |
sqlNameFromJdbc(int jdbcType) |
static void |
startHTMLPage(java.lang.String title,
java.lang.String author) |
static java.lang.String |
stringToHexLiteral(java.lang.String s)
Just converts a string to a hex literal to assist in converting test
cases that used to insert strings into bit data tables
Converts using UTF-16BE just like the old casts used to.
|
public static boolean HAVE_DRIVER_CLASS
public static final int UNKNOWN_FRAMEWORK
public static final int EMBEDDED_FRAMEWORK
public static final int DERBY_NET_FRAMEWORK
public static final int DB2JCC_FRAMEWORK
public static final int DERBY_NET_CLIENT_FRAMEWORK
public static final int OLD_NET_FRAMEWORK
private static int framework
private static java.lang.String XA_DATASOURCE_STRING
private static java.lang.String CONNECTION_POOL_DATASOURCE_STRING
private static java.lang.String REGULAR_DATASOURCE_STRING
private static java.lang.Class[] STRING_ARG_TYPE
private static java.lang.Class[] INT_ARG_TYPE
private static java.lang.Class[] BOOLEAN_ARG_TYPE
private static java.util.Hashtable<java.lang.String,java.lang.Class[]> specialAttributes
public static java.lang.String TABLE_START_TAG
public static java.lang.String TABLE_END_TAG
public static java.lang.String TD_INVERSE
public static java.lang.String TD_CENTER
public static java.lang.String TD_LEFT
public static java.lang.String TD_END
public static java.lang.String END_HTML_PAGE
public static boolean isNetFramework()
public static boolean isJCCFramework()
public static boolean isDerbyNetClientFramework()
public static boolean isEmbeddedFramework()
private static int getFramework()
public static java.lang.String getJdbcUrlPrefix()
getJdbcUrlPrefix(String server, int port)
public static java.lang.String getHostName()
public static java.lang.String getJdbcUrlPrefix(java.lang.String server, int port)
server
- host to connect to with client driver
ignored for embedded driverport
- port to connect to with client driver
ignored with embedded driverpublic static void loadDriver() throws java.lang.Exception
java.lang.Exception
public static javax.sql.DataSource getDataSource(java.util.Properties attrs)
attrs
- A set of attribute values to set on the datasource.
The appropriate setter method wil b
For example the property databaseName with value wombat,
will mean ds.setDatabaseName("wombat") will be calledpublic static javax.sql.XADataSource getXADataSource(java.util.Properties attrs)
attrs
- A set of attribute values to set on the datasource.
The appropriate setter method wil b
For example the property databaseName with value wombat,
will mean ds.setDatabaseName("wombat") will be calledpublic static javax.sql.ConnectionPoolDataSource getConnectionPoolDataSource(java.util.Properties attrs)
attrs
- A set of attribute values to set on the datasource.
The appropriate setter method wil b
For example the property databaseName with value wombat,
will mean ds.setDatabaseName("wombat") will be calledpublic static java.lang.String getDataSourcePrefix()
private static java.lang.Object getDataSourceWithReflection(java.lang.String classname, java.util.Properties attrs)
public static java.lang.String getSetterName(java.lang.String attribute)
public static java.lang.String getGetterName(java.lang.String attribute)
public static void dumpSQLExceptions(java.sql.SQLException sqle)
public static void dumpSQLExceptions(java.sql.SQLException sqle, boolean expected)
public static java.lang.String sqlNameFromJdbc(int jdbcType)
public static java.lang.String getNameFromJdbcType(int jdbcType)
public static void startHTMLPage(java.lang.String title, java.lang.String author)
public static void endHTMLPage()
public static void printBoolArrayHTMLTable(java.lang.String rowDescription, java.lang.String columnDescription, java.lang.String[] rowLabels, java.lang.String[] colLabels, boolean[][] array, java.lang.String tableInfo)
rowLabels
- - Row labelscolLabels
- - Column labelspublic static java.lang.String stringToHexLiteral(java.lang.String s)
s
- String to convert (e.gprivate static java.lang.String convertToHexString(byte[] buf)
public static int getJDBCMajorVersion(java.sql.Connection conn)
public static void cleanUpTest(java.sql.Statement s, java.lang.String[] testObjects) throws java.sql.SQLException
java.sql.SQLException
public static java.sql.Connection getConnection(java.lang.String databaseName, java.lang.String connAttrs) throws java.sql.SQLException
databaseName
- connAttrs
- java.sql.SQLException
- on failure to connect.java.lang.ClassNotFoundException
- on failure to load driver.java.lang.InstantiationException
- on failure to load driver.java.lang.IllegalAccessException
- on failure to load driver.public static java.sql.Connection getDataSourceConnection(java.util.Properties prop) throws java.sql.SQLException
java.sql.SQLException
public static void shutdownUsingDataSource(java.lang.String dbName) throws java.sql.SQLException
java.sql.SQLException
public static boolean compareURL(java.lang.String url)
public static void dumpAllStackTracesIfSupported(java.io.PrintWriter log)
log
- PrintWriter to print toApache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.