1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: db_hsqldb.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 07:43:42 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/************************************************************************
34 '* owner : marc.neumann@sun.com
36 '* short description : hsqldb test
38 '\***********************************************************************
43 call tOpenDatabaseWithViews
44 call tRenameTableWhichUsedInViews
46 call tQueryOpenInSQLMode
48 app.FileCopy gTesttoolPath + ConvertPath("dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb") , gOfficePath + ConvertPath("user/work/TT_hsqldb.odb")
49 call db_Query(gOfficePath + "user/work/TT_hsqldb.odb" ,"hsqldb")
55 ' *********************************************************************
56 ' databases specific settings for hsqldb
57 ' *********************************************************************
59 Dim i_fieldcount as integer 'amount of field types - columns
60 i_fieldcount = 8 'amount of field types (no primary key supported in dBase) normally: 7
62 Dim ifieldrow_amount as integer 'amount of inserted rows
65 Dim sFileName as string
66 sFileName = gOfficePath + ConvertPath("user/work/tt_hsqldb.odb")
68 Dim sTableName as string
69 sTableName = "tt_test_create-table"
74 Dim sCatalog as string
75 sCatalog = " " ' not used in this ds
78 sSchema = " " ' not used in this ds
81 Dim aFieldTypeContent(i_fieldcount,2) as string 'database specific data matrix
83 aFieldTypeContent(1,1)="tt_boolean" 'name of fieldtype
84 aFieldTypeContent(1,2)="boolean" 'number of fieldtype (listbox entry)
86 aFieldTypeContent(2,1)="tt_longvarchar"
87 aFieldTypeContent(2,2)="longvarchar"
89 aFieldTypeContent(3,1)="tt_char"
90 aFieldTypeContent(3,2)="char"
92 aFieldTypeContent(4,1)="tt_decimal"
93 aFieldTypeContent(4,2)="decimal"
95 aFieldTypeContent(5,1)="tt_varchar"
96 aFieldTypeContent(5,2)="varchar"
98 aFieldTypeContent(6,1)="tt_date"
99 aFieldTypeContent(6,2)="date"
101 aFieldTypeContent(7,1)="tt_time_stamp"
102 aFieldTypeContent(7,2)="timestamp"
104 Dim aFieldContent(1,7) as string 'database specific data matrix
106 aFieldContent(1,1)="<space>"
107 aFieldContent(1,2)="this is a memo field"
108 aFieldContent(1,3)="char"
109 aFieldContent(1,4)="1"
110 aFieldContent(1,5)="this is a text field"
111 aFieldContent(1,6)="13.05.2004 "
112 aFieldContent(1,7)="0"
115 dbok = fCreateHSQLDatasource(sFileName)
119 call fOpendatabase(sFileName)
120 dim bCreateTable as boolean
121 bCreateTable = fCreateTable( aFieldTypeContent(), sTableName)
122 if bCreateTable = true then 'the table was created
123 call fInsertIntoTable( aFieldContent(), sTableName)
127 if bCreateTable = true then
128 'test the index design
129 call tIndex(sFileName, sTableName)
132 'outcomment because of some bugs in forms
133 'use "dbaccess/optional/includes/b_lvl1_Forms.inc"
134 'call b_lvl1_Forms ("TT_dBase")
138 warnlog "Data Source could not be created - beyond testcases stopped"
142 '-------------------------------------------------------------------------
143 testcase tRenameTable
145 app.FileCopy ConvertPath(gTesttoolPath + "dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb"),ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb")
146 call fOpenDatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb"))
150 printlog "rename the selected table"
153 call hMenuSelectNr(2)
154 call hMenuSelectNr(7)
156 printlog "insert any new name"
157 Kontext "FormFolderNameDialog"
158 FolderReName.setText("newname")
159 printlog "and close the rename dialog with OK"
160 FormFolderNameDialog.OK
162 printlog "check if a message box appear"
164 if (MessageBox.exists()) then
165 warnlog MessageBox.GetFixedText(1)
168 printlog "Save and Close the database"
171 call fOpenDatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb"))
173 fOpenTable("newname")
180 '-------------------------------------------------------------------------
181 testcase tOpenDatabaseWithViews
183 app.FileCopy ConvertPath(gTesttoolPath + "dbaccess/optional/input/hsql_datasource/TT_hsqldb_2.0.0.odb"),ConvertPath(gOfficePath + "user/work/TT_hsqldb_2.0.0.odb")
185 call fOpenDatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb_2.0.0.odb"))
187 if fOpenTable("View 1") then
188 printlog "View 1 successful open"
189 call fCloseTableView()
191 warnlog "View 1 not successful open"
195 call fCloseDatabase()
198 '-------------------------------------------------------------------------
199 testcase tRenameTableWhichUsedInViews
201 '/// check is issue 64885 occurr
204 printlog "copy the file $TesttoolPath/dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb to a locale place"
205 app.FileCopy ConvertPath(gTesttoolPath + "dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb"),ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb")
207 printlog "open the data base TT_hsqldb.odb"
208 call fOpenDatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb"))
210 '/// select the table TT_TableForView
211 printlog "select the table TT_TableForView"
212 fFindTable("TT_TableForView")
214 '/// rename the selcted table
215 printlog "rename the selcted table"
218 call hMenuSelectNr(2)
219 call hMenuSelectNr(7)
221 '/// insert any new name
222 printlog "insert any new name"
223 Kontext "FormFolderNameDialog"
224 FolderReName.setText("newname")
225 '///+ and close the rename dialog with OK
226 printlog "and close the rename dialog with OK"
227 FormFolderNameDialog.OK
229 '/// check if a message box appear that the table is used inside a view
230 printlog "check if a message box appear that the table is used inside a view"
232 if (MessageBox.exists()) then
233 s = MessageBox.GetFixedText(1)
234 if ( InStr(s,"Table is referenced by view") = 0 ) then
235 warnlog "There is a messagebox but the message $chr(13) does not tell something about the view $chr(13)"
236 printlog "The content of the messages box is: " + s
238 printlog "OK. The right messge box appear"
240 '/// close the message box with OK
241 printlog "close the message box with OK"
243 '/// cancel the rename dialog
244 printlog "cancel the rename dialog"
245 Kontext "FormFolderNameDialog"
246 FormFolderNameDialog.Cancel
248 warnlog "There is no messages box, but there should one."
251 '/// close the database
252 printlog "close the database"
253 call fCloseDatabase()
256 '-------------------------------------------------------------------------
257 testcase tQueryOpeninSQLMode
259 '/// check feature issue 64651
262 printlog "copy the file $TesttoolPath/dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb to a locale place"
263 app.FileCopy ConvertPath(gTesttoolPath + "dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb"),ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb")
265 printlog "open the data base TT_hsqldb.odb"
266 call fOpenDatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb"))
268 '/// open a ew Query SQL Design
269 call fOpenNewSQLQueryDesign
273 Kontext "QueryEditWindow"
274 QueryEditWindow.typeKeys ("Select * from TT_Query1" ,true)
276 '/// save the sql query design
277 call fSaveSQLQueryDesign("q1")
279 '/// close the sql query design
280 call fCloseSQLQueryDesign()
282 '/// open the query in sql mode
283 call fOpenQueryInSQLDesign("q1")
285 '/// close the sql query design
286 call fCloseSQLQueryDesign()
287 '/// close the database
288 printlog "close the database"
289 call fCloseDatabase()