merge the formfield patch from ooo-build
[ooovba.git] / testautomation / dbaccess / optional / includes / db_ADOAccess.inc
blobbe88f2162e1f3aca37c64e9633ca8b5368beabe2
1 'encoding UTF-8  Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 '* 
5 '* Copyright 2008 by Sun Microsystems, Inc.
6 '*
7 '* OpenOffice.org - a multi-platform office productivity suite
8 '*
9 '* $RCSfile: db_ADOAccess.inc,v $
11 '* $Revision: 1.1 $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 07:43:41 $
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 : Create ADO Access DS & Table & fill in Test
38 '\***********************************************************************
39 testcase db_ADOAccess
41     if gtSYSName = "Mac OS X" or gtSYSName = "Solaris SPARC" or gtSYSName = "Solaris x86" or gtSYSName = "Linux" then
42         printlog "This is an ADO test and works only on Windosen"
43         printlog "You have a: " + gtSYSName + " OS - Test Stopped !"
44         else 
45     
46         ' *********************************************************************
47         '   databases specific settings for ADO Access OLEDB 4.0 on Windosen
48         ' *********************************************************************
49             
50         Dim i_fieldcount as integer 'amount of field types - columns
51         i_fieldcount = 16
52             
53         Dim ifieldrow_amount as integer 'amount of inserted rows
54         ifieldrow_amount = 3
55         
56         Dim sFileName as string
57         sFileName = gOfficePath + ConvertPath("user/work/TT_Ado_Access.odb")
58         
59         Dim sDBURL as string
60         sDBURL = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
61         
62         Dim sTableName as string
63         sTableName = "tt_test_create-table"        
64         
65         Dim sPWD as string
66         sPWD = "ignore"
67         
68         dim sCatalog as string
69         sCatalog = " "                          ' not used in this ds
70         
71         dim sSchema as string
72         sSchema = " "                           ' not used in this ds
73         
74         dim sRelTable1 as string    'for relation test (tRelation1&2)
75         sRelTable1 = "TT_Rel1"
76         
77         dim sRelTable2 as string    'for relation test (tRelation1&2)
78         sRelTable2 = "TT_Rel2"
79         
80         dim sRelTable3 as string    'for relation test (tRelation2)
81         sRelTable3 = "TT_Rel3"
82         
83         
84         Dim aFields(i_fieldcount,2) as string
85                
86         aFields(1,1)="tt_bit"                   'name of fieldtype
87         aFields(1,2)="bit"                              'number of fieldtype (listbox entry)
88                 
89         aFields(2,1)="tt_byte"          
90         aFields(2,2)="byte"
91         
92         aFields(3,1)="tt_guid"          
93         aFields(3,2)="guid"
94         
95         aFields(4,1)="tt_bigbinary"             
96         aFields(4,2)="bigbinary"
97         
98         aFields(5,1)="tt_longbinary"            
99         aFields(5,2)="longbinary"
100         
101         aFields(6,1)="tt_varbinary"             
102         aFields(6,2)="varbinary"
103         
104         'SQL Null [ ] is a foult in metadata of driver bug: #108535 in OLEDB 4.0 (number without field -> field does not exist)
105         
106         aFields(7,1)="tt_decimal"       ' bug #108512 - should work after that
107         aFields(7,2)="decimal"
108         
109         aFields(8,1)="tt_long"          
110         aFields(8,2)="long"
111            
112         aFields(9,1)="tt_short"         
113         aFields(9,2)="short"
114         
115         aFields(10,1)="tt_single"               
116         aFields(10,2)="single"          
117         
118         aFields(11,1)="tt_double"               
119         aFields(11,2)="double"
120         
121         aFields(12,1)="tt_currency"             
122         aFields(12,2)="currency"
123         
124         aFields(13,1)="tt_longtext"             
125         aFields(13,2)="longtext"                
126         
127         aFields(14,1)="tt_varchar"              
128         aFields(14,2)="varchar"
129         
130         aFields(15,1)="tt_datetime"             
131         aFields(15,2)="datetime"
132         
133         
134         Dim aFieldsContent(1,16) as string
135                
136         aFieldsContent(1,1)="1"
137         aFieldsContent(1,2)="<space>"
138         aFieldsContent(1,3)="1"
139         aFieldsContent(1,4)="1"
140         aFieldsContent(1,5)=""
141         aFieldsContent(1,6)=""
142         aFieldsContent(1,7)=""
143         aFieldsContent(1,8)=""
144         aFieldsContent(1,9)="1"
145         aFieldsContent(1,10)="1"
146         aFieldsContent(1,11)="1"
147         aFieldsContent(1,12)="1"
148         aFieldsContent(1,13)="1"
149         aFieldsContent(1,14)="1"
150         aFieldsContent(1,15)="1"
151         aFieldsContent(1,16)="1"       
152           
153         dim dbok as boolean
154                 dbok = false
155         
156         ' restart the office to unlock the mdb file. Remember the Quickstarter
157         printlog "tart the office to unlock the mdb file. Remember the Quickstarter"
158         ExitRestartTheOffice
159         
160         app.FileCopy gTesttoolPath + ConvertPath("dbaccess/optional/input/ado_datasource/testdb.mdb"),gOfficePath + ConvertPath("user/work/testdb.mdb")
161         dbok =  fCreateADODatasource( sFileName, sDBURL + gOfficePath + ConvertPath("user/work/testdb.mdb"))
162         if dbok = true then
164                 call fOpendatabase(sFileName)
165             call fCreateTable(aFields(),sTableName)
166             call fInsertIntoTable( aFieldsContent(), sTableName)
167             call fDeleteTable(sTableName)       
168                 call fCloseDatabase
169                         
170             call tRelation( sFileName, sPWD, sRelTable1, sRelTable2 )
171             call tDoubleRelation( sFileName, sPWD, sRelTable1, sRelTable2, sRelTable3 )
172                         
173             call db_Query(sFileName)
175                 else 
176             warnlog "Data Source could not be created - beyond testcases stopped"
177                 endif
178         endif
179         
180 endcase