summaryrefslogtreecommitdiff
path: root/testautomation/dbaccess/tools
diff options
context:
space:
mode:
authorms93807 <ms93807@x4240-so5>2010-02-05 08:39:58 +0100
committerms93807 <ms93807@x4240-so5>2010-02-05 08:39:58 +0100
commit220073a41a5bc68e84aaf19124ef487ab361a31b (patch)
tree3af46050dfdcb02206e29b1c0a543d3e86b0d954 /testautomation/dbaccess/tools
parent090bc5591c2bc09c2097771b1bf182bcfc45dd0a (diff)
dba33e: #108973# refactor and code cleanup
Diffstat (limited to 'testautomation/dbaccess/tools')
-rwxr-xr-xtestautomation/dbaccess/tools/dbcreatetools.inc66
-rwxr-xr-xtestautomation/dbaccess/tools/dbtools.inc60
2 files changed, 96 insertions, 30 deletions
diff --git a/testautomation/dbaccess/tools/dbcreatetools.inc b/testautomation/dbaccess/tools/dbcreatetools.inc
index f3d5abd6c944..6e4670966927 100755
--- a/testautomation/dbaccess/tools/dbcreatetools.inc
+++ b/testautomation/dbaccess/tools/dbcreatetools.inc
@@ -58,6 +58,9 @@
' #1 getIdForDatabaseType
'*
'\***********************************************************************************
+
+private const VERBOSE = true
+
function fCreateMySQL_ODBC_Datasource(sFileName, sOdbcDSN, sUser,optional sRegister) as boolean
'/// create a new MySQL database via ODBC file with the given filename
'///+ and the given URL
@@ -159,7 +162,9 @@ function fCreateMySQL_JDBC_Datasource(sFileName,sDatabaseName,sHost,sPort,sUser,
'/// <b>sUser:</b> the user for the connection
'/// <b><i>optional</i> sRegister:</b> the name under which the database is be registered
dim bOK as boolean
- bOK = FALSE
+ bOK = FALSE
+
+ dim sEntry as string
' delete the file
if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then
@@ -181,8 +186,12 @@ function fCreateMySQL_JDBC_Datasource(sFileName,sDatabaseName,sHost,sPort,sUser,
Kontext "DatabaseWizard"
ConnectToDatabase.Check
- sleep(1)
- DatabaseType.select( hGetDatabaseDisplayName( "sdbc:mysql:jdbc:*" ) )
+ sleep(1)
+ sEntry = hGetDatabaseDisplayName( "sdbc:mysql:jdbc:*" )
+ 'cut off the (JDBC) string
+ sEntry = Mid( sEntry , 1, len(sEntry) - Instr(sEntry,"(") )
+ printlog "entry = " + sEntry
+ DatabaseType.select( sEntry )
sleep(1)
NextBtn.Click
sleep(1)
@@ -203,8 +212,8 @@ function fCreateMySQL_JDBC_Datasource(sFileName,sDatabaseName,sHost,sPort,sUser,
'/// check the password required checkbox
printlog "check the password required checkbox"
PasswordRequired.Check
-
- Kontext "DatabaseWizard"
+
+ NextBtn.Click
FinishBtn.Click
Kontext "SpeichernDlg"
@@ -1460,13 +1469,12 @@ function fSetJDBCDriverFiles(sClassPath) as boolean
end function
'-------------------------------------------------------------------------
-private const VERBOSE = false
function hGetInstalledDatabaseDrivers( dbDriverList() as string ) as integer
' This function returns the number of currently installed database drivers.
' Additionally it fills a given list (which should be large enough to hold
- ' the names of all installed drivers) with the names and makes the list
+ ' the names of all installed drivers) with the url and makes the list
' compatible to the listfunctions (which places the list size in element 0)
' The list is platform dependent and might be locale dependent
' Note that some drivers (like e.g. HSQL Database Engine) do *not* show up
@@ -1480,7 +1488,7 @@ function hGetInstalledDatabaseDrivers( dbDriverList() as string ) as integer
dim iCurrentDriver as integer
dim iDriverCount as integer
- const CFN = "global::tools::includes::optional::t_database.inc::hGetInstalledDatabaseDrivers(): "
+ const CFN = "dbaccess::tools::dbcreatetools.inc::hGetInstalledDatabaseDrivers(): "
' Path to the node, searches all files below "Drivers" for "Installed"
aPropertyValue( 0 ).Name = "nodepath"
@@ -1499,11 +1507,11 @@ function hGetInstalledDatabaseDrivers( dbDriverList() as string ) as integer
' Get access
xViewRoot = oUnoConfigurationAccess.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", aPropertyValue() )
aElements() = xViewRoot.getElementNames()
-
+
iDriverCount = ubound( aElements() )
dbDriverList( 0 ) = iDriverCount
for iCurrentDriver = 1 to iDriverCount
- dbDriverList( iCurrentDriver ) = xViewRoot.getByName( aElements( iCurrentDriver ) ).getByName( "DriverTypeDisplayName" )
+ dbDriverList( iCurrentDriver ) = aElements( iCurrentDriver )
next iCurrentDriver
endif
@@ -1511,11 +1519,12 @@ function hGetInstalledDatabaseDrivers( dbDriverList() as string ) as integer
if ( VERBOSE ) then
printlog( CFN & "Returning " & iDriverCount & " drivers" )
endif
+
hGetInstalledDatabaseDrivers() = iDriverCount
end function
-'*******************************************************************************
+'-------------------------------------------------------------------------
function hGetDatabaseDisplayName( dbDriverURL as string ) as string
@@ -1557,7 +1566,7 @@ function hGetDatabaseDisplayName( dbDriverURL as string ) as string
dim oDriver as object
dim sDatabaseName as string
- const CFN = "global::tools::includes::optional::t_database.inc::hGetDatabaseDisplayName(): "
+ const CFN = "dbaccess::tools::dbcreatetools.inc::hGetDatabaseDisplayName(): "
' Path to the node, searches all files below "Drivers" for "Installed"
aPropertyValue( 0 ).Name = "nodepath"
@@ -1591,4 +1600,37 @@ function hGetDatabaseDisplayName( dbDriverURL as string ) as string
hGetDataBaseDisplayName() = sDatabaseName
end function
+'-------------------------------------------------------------------------
+function isDriverInstalled( dbDriverURL as string ) as string
+
+ ' This function return true or false if a driver for a given URL is installed
+
+ Dim myDriverList(20) as string
+ Dim i as integer
+ Dim sDriver as string
+ Dim breturn as boolean
+ breturn = false
+
+ const CFN = "dbaccess::tools::dbcreatetools.inc::isDriverInstalled(): "
+
+ if VERBOSE then
+ printlog CFN
+ printlog "url to search for : " + dbDriverURL
+ endif
+
+ hGetInstalledDatabaseDrivers( myDriverList() )
+
+ for i = 1 to ubound(myDriverList)
+ sDriver = myDriverList(i)
+ if VERBOSE then
+ printlog "found url : " + sDriver
+ endif
+ if sDriver = dbDriverURL then
+ breturn = true
+ endif
+ next
+
+ isDriverInstalled = breturn
+
+end function
diff --git a/testautomation/dbaccess/tools/dbtools.inc b/testautomation/dbaccess/tools/dbtools.inc
index 22e16211360c..0f37061b7ae4 100755
--- a/testautomation/dbaccess/tools/dbtools.inc
+++ b/testautomation/dbaccess/tools/dbtools.inc
@@ -46,6 +46,9 @@
' #1 tools_dbtools_fgetMySQLDatabaseProperties
'*
'\***********************************************************************************
+
+private const VERBOSE = true
+
'--------------------------------------------------------------------
function fSelectDatasourceInBeamer(sDSName1)
'/// select a datasource in the beamer with the given name
@@ -169,13 +172,20 @@ function fOpenDataBase ( sFileName , optional sPassword)
Dim DieDatei as String
DieDatei = ConvertPath ( sFileName )
+
+ if(VERBOSE) then
+ printlog "Filename : " + sFileName
+ if(NOT isMissing(sPassword)) then
+ printlog "Password : " + sPassword
+ endif
+ endif
+
'/// open the File Open dialog
printlog "open the File Open dialog"
FileOpen
sleep (1)
Kontext "OeffnenDlg"
- '/// open the given file
- printlog "open the given file: " + sFileName
+ '/// open the given file
Dateiname.SetText DieDatei
sleep (3)
Oeffnen.Click
@@ -195,7 +205,7 @@ function fOpenDataBase ( sFileName , optional sPassword)
printlog "set password : " + sPassword
Kontext "LoginDialog"
if LoginDialog.Exists then
- Password.setText sPassword
+ LoginPassword.setText sPassword
LoginDialog.OK
sleep(1)
endif
@@ -270,7 +280,7 @@ sub sCloseAllToolbars
end sub
'-------------------------------------------------------------------------
-function tools_dbtools_fgetMySQLJDBCDatabaseProperties()
+function tools_dbtools_fgetMySQLJDBCDatabaseProperties(sDBConfigFileName as string)
'/// return the databaseserver properties from the environment directory
'/// <u>parameter:</u>
'/// <br>
@@ -281,21 +291,10 @@ function tools_dbtools_fgetMySQLJDBCDatabaseProperties()
'/// entry 3 database name
'/// entry 4 database port
'/// entry 5 database user name
- '/// entry 6 database user password
+ '/// entry 6 database user password
+ '/// entry 7 jdbc driver file path
- dim i as integer
- dim b(10000) as String
- dim c
- c = hGetDataFileSection( gTesttoolPath + gPrivateEnvironmentLocation + "input/base.txt", b(), "mysql_jdbc" , "" , "" )
-
- ' split the string at = and return the right part
- for i = 1 to 6
- 'printlog b(i)
- b(i) = Right(b(i),len(b(i))-Instr(b(i),"="))
- 'printlog b(i)
- next
-
- tools_dbtools_fgetMySQLJDBCDatabaseProperties = b()
+ tools_dbtools_fgetMySQLJDBCDatabaseProperties = fgetGenericDatabaseProperties( sDBConfigFileName, "mysql_jdbc" )
end function
'-------------------------------------------------------------------------
@@ -353,3 +352,28 @@ function tools_dbtools_fgetAdabasDatabaseProperties()
tools_dbtools_fgetAdabasDatabaseProperties = b()
end function
+'-------------------------------------------------------------------------------
+function fgetGenericDatabaseProperties(sDBConfigFileName as string, sType as String)
+
+ dim i as integer
+ dim b(10000) as String
+ dim c
+ c = hGetDataFileSection( sDBConfigFileName, b(), sType , "" , "" )
+
+ ' split the string at = and return the right part
+ for i = 1 to 7
+ if(VERBOSE) then
+ printlog "orig. string : " + b(i)
+ endif
+ b(i) = Right(b(i),len(b(i))-Instr(b(i),"="))
+ if(VERBOSE) then
+ printlog "string after the '=' : " + b(i)
+ endif
+ next
+
+
+
+
+ fgetGenericDatabaseProperties = b()
+
+end function \ No newline at end of file