|
OOoRunner test harness | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--util.DBTools
Provides useful methods for working with SOffice databases. Database creation, data transfering, outputting infromation.
Inner Class Summary | |
class |
DBTools.DataSourceInfo
It's just a structure with some useful methods for representing com.sun.star.sdb.DataSource service. |
Field Summary | |
static int |
TST_BINARY_STREAM
|
static String |
TST_BINARY_STREAM_F
|
static int |
TST_BOOLEAN
|
static String |
TST_BOOLEAN_F
|
static int |
TST_CHARACTER_STREAM
|
static String |
TST_CHARACTER_STREAM_F
|
static int |
TST_DATE
|
static String |
TST_DATE_F
|
static int |
TST_DOUBLE
|
static String |
TST_DOUBLE_F
|
static int |
TST_INT
|
static String |
TST_INT_F
|
static String |
TST_JDBC_DRIVER
|
static int[] |
TST_STREAM_LENGTHS
Array of lengths of streams for each row in of the TST_TABLE_VALUES constants. |
static int |
TST_STRING
|
static String |
TST_STRING_F
|
static Object[][] |
TST_TABLE_VALUES
Values for filling test table. |
Constructor Summary | |
DBTools(XMultiServiceFactory xMSF)
Creates class instance. |
Method Summary | |
void |
addRowToTestTable(XConnection con,
String table,
Object[] values,
int streamLength)
Inserts row into test table of the specified connection. |
XConnection |
connectToDBase(String contextName,
String dbDir)
Registers DBase database (directory with DBF files) in the global DB context, then connects to it. |
XConnection |
connectToSource(Object dbSource)
Performs connection to DataSource specified. |
XConnection |
connectToTestDB(String docPath)
Connects to DataSource specially created for testing. |
XConnection |
connectToTextDB(String contextName,
String dbDir,
String fileExtension)
RESERVED. |
protected void |
createMySQLTable(Statement statement,
String tbl_name)
Creates test table specified. |
int |
deleteAllRows(XConnection con,
String table)
Empties the table in the specified source. |
static String |
dirToUrl(String dir)
Convert system pathname to SOffice URL string (for example 'C:\Temp\DBDir\' -> 'file:///C|/Temp/DBDir/'). |
protected void |
dropMySQLTable(Statement statement,
String tbl_name)
Drops table. |
void |
initializeTestTable(XConnection con,
String table)
Initializes test table specified of the connection specified. |
void |
initTestTableUsingJDBC(String tbl_name,
DBTools.DataSourceInfo dsi)
Initializes test table specified of the connection specified using JDBC driver. |
protected void |
insertContentMySQLTable(Statement statement,
String tbl_name)
Inserts data from TST_TABLE_VALUES constant array
to test table tbl_name . |
DBTools.DataSourceInfo |
newDataSourceInfo()
Returns new instance of DataSourceInfo class. |
DBTools.DataSourceInfo |
newDataSourceInfo(Object dataSource)
Returns new instance of DataSourceInfo class. |
void |
printRegisteredDatabasesInfo(PrintWriter out)
Prints full info about currently registered DataSource's. |
void |
registerDB(String name,
Object dataSource)
Registers the datasource on the specified name in DatabaseContext service. |
Object |
registerTestDB(String docPath)
Registers Test data source in the DatabaseContext service. |
void |
reRegisterDB(String name,
Object dataSource)
First tries to revoke the datasource with the specified name and then registers a new one. |
void |
revokeDB(String name)
Revokes datasource from global DB context. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String TST_JDBC_DRIVER
public static final int TST_STRING
public static final int TST_INT
public static final int TST_DOUBLE
public static final int TST_DATE
public static final int TST_BOOLEAN
public static final int TST_CHARACTER_STREAM
public static final int TST_BINARY_STREAM
public static final String TST_STRING_F
public static final String TST_INT_F
public static final String TST_DOUBLE_F
public static final String TST_DATE_F
public static final String TST_BOOLEAN_F
public static final String TST_CHARACTER_STREAM_F
public static final String TST_BINARY_STREAM_F
public static final Object[][] TST_TABLE_VALUES
public static final int[] TST_STREAM_LENGTHS
TST_TABLE_VALUES
constants.Constructor Detail |
public DBTools(XMultiServiceFactory xMSF)
xMSF
- XMultiServiceFactory
.Method Detail |
public DBTools.DataSourceInfo newDataSourceInfo()
DataSourceInfo
class.public DBTools.DataSourceInfo newDataSourceInfo(Object dataSource)
DataSourceInfo
class.public void registerDB(String name, Object dataSource) throws Exception
DatabaseContext
service.name
- Name which dataSource will have in global context.dataSource
- DataSource
object which is to
be registered.public void reRegisterDB(String name, Object dataSource) throws Exception
name
- Name which dataSource will have in global context.dataSource
- DataSource
object which is to
be registered.public XConnection connectToTextDB(String contextName, String dbDir, String fileExtension) throws Exception
public XConnection connectToDBase(String contextName, String dbDir) throws Exception
contextName
- Name under which DB will be registered.dbDir
- The directory with DBF tables.public XConnection connectToSource(Object dbSource) throws Exception
dbSource
- com.sun.star.sdb.DataSource
service
specified data source which must be already registered in the
DatabaseContext
service.dbSource
- Data source to be connected to.public Object registerTestDB(String docPath) throws Exception
DatabaseContext
service.
This source always has name 'APITestDatabase'
and it
is registered in subdirectory TestDB
of directory
docPath
which is supposed to be a directory with test
documents, but can be any other (it must have subdirectory with DBF
tables). If such data source doesn't exists or exists with
different URL it is recreated and reregistered.docPath
- Path to database TestDB
directory.com.sun.star.sdb.DataSource
service
implementation which represents TestDB.public XConnection connectToTestDB(String docPath) throws Exception
DataSource
specially created for testing.
This source always has name 'APITestDatabase'
and it
is registered in subdirectory TestDB
of directory
docPath
which is supposed to be a directory with test
documents, but can be any other (it must have subdirectory with DBF
tables). If such data source doesn't exists or exists with
different URL it is recreated and reregistered. Finally connection
performed.docPath
- Path to database TestDB
directory.public int deleteAllRows(XConnection con, String table) throws SQLException
con
- Connection to the DataSource where appropriate
table exists.table
- The name of the table where all rows will be deleted.public void addRowToTestTable(XConnection con, String table, Object[] values, int streamLength) throws SQLException
TST_STRING
, TST_INT
, etc.
are declared for column index fast find.con
- Connection to data source where test table exists.table
- Test table name.values
- Values to be inserted into test table. Values of
this array inserted into appropriate fields depending on their
types. So String
value of the array is inserted
into the field of CHARACTER
type, etc.streamLength
- Is optional. It is used only if in values
list XCharacterInputStream
or XBinaryInputStream
types specified. In this case the parameter specifies
the length of the stream for inserting.public void initializeTestTable(XConnection con, String table) throws SQLException
TST_TABLE_VALUES
constant array.
Test table has some predefined format which includes as much
field types as possible. For every column type constants
TST_STRING
, TST_INT
, etc.
are declared for column index fast find.
con
- Connection to data source where test table exists.table
- Test table name.public void printRegisteredDatabasesInfo(PrintWriter out)
public static String dirToUrl(String dir)
public void revokeDB(String name) throws Exception
name
- DataSource name to be revoked.public void initTestTableUsingJDBC(String tbl_name, DBTools.DataSourceInfo dsi) throws SQLException, ClassNotFoundException
tbl_name
,
creates new table with this name and then inserts data from
TST_TABLE_VALUES
constant array.
Test table has some predefined format which includes as much
field types as possible. For every column type constants
TST_STRING
, TST_INT
, etc.
are declared for column index fast find.
tbl_name
- Test table name.protected void insertContentMySQLTable(Statement statement, String tbl_name) throws SQLException
TST_TABLE_VALUES
constant array
to test table tbl_name
.statement
- object used for executing a static SQL
statement and obtaining the results produced by it.tbl_name
- Test table name.protected void createMySQLTable(Statement statement, String tbl_name) throws SQLException
TST_STRING
, TST_INT
, etc.
are declared for column index fast find.statement
- object used for executing a static SQL
statement and obtaining the results produced by it.table
- Test table name.protected void dropMySQLTable(Statement statement, String tbl_name) throws SQLException
statement
- object used for executing a static SQL
statement and obtaining the results produced by it.table
- Test table name.
|
OOoRunner test harness | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |