1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
'encoding UTF-8 Do not remove or change this line!
'**************************************************************************
' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'
' Copyright 2000, 2010 Oracle and/or its affiliates.
'
' OpenOffice.org - a multi-platform office productivity suite
'
' This file is part of OpenOffice.org.
'
' OpenOffice.org is free software: you can redistribute it and/or modify
' it under the terms of the GNU Lesser General Public License version 3
' only, as published by the Free Software Foundation.
'
' OpenOffice.org 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
' GNU Lesser General Public License version 3 for more details
' (a copy is included in the LICENSE file that accompanied this code).
'
' You should have received a copy of the GNU Lesser General Public License
' version 3 along with OpenOffice.org. If not, see
' <http://www.openoffice.org/license.html>
' for a copy of the LGPLv3 License.
'
'/************************************************************************
'*
'* owner : marc.neumann@oracle.com
'*
'* short description : hsqldb test
'*
'\***********************************************************************
sub db_hsqldb
call tGeneral
call ExitRestartTheOffice
call tRenameTable
call tOpenDatabaseWithViews
call tRenameTableWhichUsedInViews
call tQueryOpenInSQLMode
call ExitRestartTheOffice
app.FileCopy gTesttoolPath + ConvertPath("dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb") , gOfficePath + ConvertPath("user/work/TT_hsqldb.odb")
call db_Query(gOfficePath + "user/work/TT_hsqldb.odb" ,"hsqldb")
end sub
testcase tGeneral
' *********************************************************************
' databases specific settings for hsqldb
' *********************************************************************
Dim i_fieldcount as integer 'amount of field types - columns
i_fieldcount = 8 'amount of field types (no primary key supported in dBase) normally: 7
Dim ifieldrow_amount as integer 'amount of inserted rows
ifieldrow_amount = 3
Dim sFileName as string
sFileName = gOfficePath + ConvertPath("user/work/tt_hsqldb.odb")
Dim sTableName as string
sTableName = "tt_test_create-table"
Dim sPWD as string
sPWD = "ignore"
Dim sCatalog as string
sCatalog = " " ' not used in this ds
Dim sSchema as string
sSchema = " " ' not used in this ds
Dim aFieldTypeContent(i_fieldcount,2) as string 'database specific data matrix
aFieldTypeContent(1,1)="tt_boolean" 'name of fieldtype
aFieldTypeContent(1,2)="boolean" 'number of fieldtype (listbox entry)
aFieldTypeContent(2,1)="tt_longvarchar"
aFieldTypeContent(2,2)="longvarchar"
aFieldTypeContent(3,1)="tt_char"
aFieldTypeContent(3,2)="char"
aFieldTypeContent(4,1)="tt_decimal"
aFieldTypeContent(4,2)="decimal"
aFieldTypeContent(5,1)="tt_varchar"
aFieldTypeContent(5,2)="varchar"
aFieldTypeContent(6,1)="tt_date"
aFieldTypeContent(6,2)="date"
aFieldTypeContent(7,1)="tt_time_stamp"
aFieldTypeContent(7,2)="timestamp"
Dim aFieldContent(1,7) as string 'database specific data matrix
aFieldContent(1,1)="<space>"
aFieldContent(1,2)="this is a memo field"
aFieldContent(1,3)="char"
aFieldContent(1,4)="1"
aFieldContent(1,5)="this is a text field"
aFieldContent(1,6)="13.05.2004 "
aFieldContent(1,7)="0"
dim dbok as boolean
dbok = fCreateHSQLDatasource(sFileName)
'dbok = true
if dbok = true then
call fOpendatabase(sFileName)
dim bCreateTable as boolean
bCreateTable = fCreateTable( aFieldTypeContent(), sTableName)
if bCreateTable = true then 'the table was created
call fInsertIntoTable( aFieldContent(), sTableName)
end if
call fCloseDatabase
if bCreateTable = true then
'test the index design
call tIndex(sFileName, sTableName)
end if
'outcomment because of some bugs in forms
'use "dbaccess/optional/includes/b_lvl1_Forms.inc"
'call b_lvl1_Forms ("TT_dBase")
else
warnlog "Data Source could not be created - beyond testcases stopped"
endif
endcase
'-------------------------------------------------------------------------
testcase tRenameTable
app.FileCopy ConvertPath(gTesttoolPath + "dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb"),ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb")
call fOpenDatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb"))
fFindTable("TT_1")
printlog "rename the selected table"
Kontext "DATABASE"
Database.UseMenu
call hMenuSelectNr(2)
call hMenuSelectNr(7)
printlog "insert any new name"
Kontext "FormFolderNameDialog"
FolderReName.setText("newname")
printlog "and close the rename dialog with OK"
FormFolderNameDialog.OK
printlog "check if a message box appear"
Kontext "MessageBox"
if (MessageBox.exists()) then
warnlog MessageBox.GetFixedText(1)
endif
printlog "Save and Close the database"
fCloseDatabase(true)
call fOpenDatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb"))
fOpenTable("newname")
fCloseTableView()
fCloseDatabase()
endcase
'-------------------------------------------------------------------------
testcase tOpenDatabaseWithViews
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")
call fOpenDatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb_2.0.0.odb"))
if fOpenTable("View 1") then
printlog "View 1 successful open"
call fCloseTableView()
else
warnlog "View 1 not successful open"
endif
call fCloseDatabase()
endcase
'-------------------------------------------------------------------------
testcase tRenameTableWhichUsedInViews
'/// check is issue 64885 occurr
Dim s as String
printlog "copy the file $TesttoolPath/dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb to a locale place"
app.FileCopy ConvertPath(gTesttoolPath + "dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb"),ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb")
printlog "open the data base TT_hsqldb.odb"
call fOpenDatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb"))
'/// select the table TT_TableForView
printlog "select the table TT_TableForView"
fFindTable("TT_TableForView")
'/// rename the selcted table
printlog "rename the selcted table"
Kontext "DATABASE"
Database.UseMenu
call hMenuSelectNr(2)
call hMenuSelectNr(7)
'/// insert any new name
printlog "insert any new name"
Kontext "FormFolderNameDialog"
FolderReName.setText("newname")
'///+ and close the rename dialog with OK
printlog "and close the rename dialog with OK"
FormFolderNameDialog.OK
'/// check if a message box appear that the table is used inside a view
printlog "check if a message box appear that the table is used inside a view"
Kontext "MessageBox"
if (MessageBox.exists()) then
s = MessageBox.GetFixedText(1)
if ( InStr(s,"Table is referenced by view") = 0 ) then
warnlog "There is a messagebox but the message $chr(13) does not tell something about the view $chr(13)"
printlog "The content of the messages box is: " + s
else
printlog "OK. The right messge box appear"
endif
'/// close the message box with OK
printlog "close the message box with OK"
MessageBox.OK
'/// cancel the rename dialog
printlog "cancel the rename dialog"
Kontext "FormFolderNameDialog"
FormFolderNameDialog.Cancel
else
warnlog "There is no messages box, but there should one."
endif
'/// close the database
printlog "close the database"
call fCloseDatabase()
endcase
'-------------------------------------------------------------------------
testcase tQueryOpeninSQLMode
'/// check feature issue 64651
Dim s as String
printlog "copy the file $TesttoolPath/dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb to a locale place"
app.FileCopy ConvertPath(gTesttoolPath + "dbaccess/optional/input/hsql_datasource/TT_hsqldb.odb"),ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb")
printlog "open the data base TT_hsqldb.odb"
call fOpenDatabase(ConvertPath(gOfficePath + "user/work/TT_hsqldb.odb"))
'/// open a ew Query SQL Design
call fOpenNewSQLQueryDesign
sleep(2)
Kontext "QueryEditWindow"
QueryEditWindow.typeKeys ("Select * from TT_Query1" ,true)
'/// save the sql query design
call fSaveSQLQueryDesign("q1")
'/// close the sql query design
call fCloseSQLQueryDesign()
'/// open the query in sql mode
call fOpenQueryInSQLDesign("q1")
'/// close the sql query design
call fCloseSQLQueryDesign()
'/// close the database
printlog "close the database"
call fCloseDatabase()
endcase
|