1*b1cdbd2cSJim Jagielski<?xml version="1.0" encoding="UTF-8"?>
2*b1cdbd2cSJim Jagielski<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3*b1cdbd2cSJim Jagielski<script:module xmlns:script="http://openoffice.org/2000/script" script:name="sdbc_XRowUpdate" script:language="StarBasic">
4*b1cdbd2cSJim Jagielski
5*b1cdbd2cSJim Jagielski
6*b1cdbd2cSJim Jagielski'*************************************************************************
7*b1cdbd2cSJim Jagielski'
8*b1cdbd2cSJim Jagielski'  Licensed to the Apache Software Foundation (ASF) under one
9*b1cdbd2cSJim Jagielski'  or more contributor license agreements.  See the NOTICE file
10*b1cdbd2cSJim Jagielski'  distributed with this work for additional information
11*b1cdbd2cSJim Jagielski'  regarding copyright ownership.  The ASF licenses this file
12*b1cdbd2cSJim Jagielski'  to you under the Apache License, Version 2.0 (the
13*b1cdbd2cSJim Jagielski'  "License"); you may not use this file except in compliance
14*b1cdbd2cSJim Jagielski'  with the License.  You may obtain a copy of the License at
15*b1cdbd2cSJim Jagielski'
16*b1cdbd2cSJim Jagielski'    http://www.apache.org/licenses/LICENSE-2.0
17*b1cdbd2cSJim Jagielski'
18*b1cdbd2cSJim Jagielski'  Unless required by applicable law or agreed to in writing,
19*b1cdbd2cSJim Jagielski'  software distributed under the License is distributed on an
20*b1cdbd2cSJim Jagielski'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21*b1cdbd2cSJim Jagielski'  KIND, either express or implied.  See the License for the
22*b1cdbd2cSJim Jagielski'  specific language governing permissions and limitations
23*b1cdbd2cSJim Jagielski'  under the License.
24*b1cdbd2cSJim Jagielski'
25*b1cdbd2cSJim Jagielski'*************************************************************************
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski
28*b1cdbd2cSJim Jagielski
29*b1cdbd2cSJim Jagielski
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski' Be sure that all variables are dimensioned:
32*b1cdbd2cSJim Jagielskioption explicit
33*b1cdbd2cSJim Jagielski
34*b1cdbd2cSJim Jagielski'*************************************************************************
35*b1cdbd2cSJim Jagielski' This Interface/Service test depends on the following GLOBAL variables,
36*b1cdbd2cSJim Jagielski' which must be specified in the object creation:
37*b1cdbd2cSJim Jagielski
38*b1cdbd2cSJim Jagielski'     - Global rowTypes As Variant
39*b1cdbd2cSJim Jagielski'       must be an array of Strings with description of column types
40*b1cdbd2cSJim Jagielski'     - Global rowTypesCol As Variant
41*b1cdbd2cSJim Jagielski'       corresponding column numbers
42*b1cdbd2cSJim Jagielski
43*b1cdbd2cSJim Jagielski'*************************************************************************
44*b1cdbd2cSJim Jagielski
45*b1cdbd2cSJim Jagielski
46*b1cdbd2cSJim Jagielski
47*b1cdbd2cSJim Jagielski
48*b1cdbd2cSJim Jagielski
49*b1cdbd2cSJim Jagielski
50*b1cdbd2cSJim JagielskiSub RunTest()
51*b1cdbd2cSJim Jagielski
52*b1cdbd2cSJim Jagielski'*************************************************************************
53*b1cdbd2cSJim Jagielski' INTERFACE:
54*b1cdbd2cSJim Jagielski' com.sun.star.sdbc.XRowUpdate
55*b1cdbd2cSJim Jagielski'*************************************************************************
56*b1cdbd2cSJim JagielskiOn Error Goto ErrHndl
57*b1cdbd2cSJim Jagielski    Dim bOK As Boolean, bNullOK As Boolean
58*b1cdbd2cSJim Jagielski    Dim i As Integer
59*b1cdbd2cSJim Jagielski    Dim getV As Variant, newV As Variant, resV As Variant
60*b1cdbd2cSJim Jagielski    Dim colType As String
61*b1cdbd2cSJim Jagielski
62*b1cdbd2cSJim Jagielski    if NOT hasUnoInterfaces(oObj, "com.sun.star.sdbc.XRow") then
63*b1cdbd2cSJim Jagielski        Out.Log("The interface com.sun.star.sdbc.XRow isn't supported by the component.")
64*b1cdbd2cSJim Jagielski        Out.Log("The test must be upgraded !!!")
65*b1cdbd2cSJim Jagielski        exit Sub
66*b1cdbd2cSJim Jagielski    end if
67*b1cdbd2cSJim Jagielski
68*b1cdbd2cSJim Jagielski    Test.RecreateObj()
69*b1cdbd2cSJim Jagielski
70*b1cdbd2cSJim Jagielski    bNullOK = true
71*b1cdbd2cSJim Jagielski
72*b1cdbd2cSJim Jagielski    Test.StartMethod("updateBoolean()")
73*b1cdbd2cSJim Jagielski    colType = "boolean"
74*b1cdbd2cSJim Jagielski    i = findColumn(colType)
75*b1cdbd2cSJim Jagielski    if i >= 0 then
76*b1cdbd2cSJim Jagielski        bOK = true
77*b1cdbd2cSJim Jagielski        getV = oObj.getBoolean(i+1)
78*b1cdbd2cSJim Jagielski        newV = NOT getV
79*b1cdbd2cSJim Jagielski        oObj.updateBoolean(i+1, newV)
80*b1cdbd2cSJim Jagielski        resV = oObj.getBoolean(i+1)
81*b1cdbd2cSJim Jagielski        Out.Log("Was: " + getv + ", New: " + newV + ", Res: " + resV)
82*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV = newV)
83*b1cdbd2cSJim Jagielski        Test.MethodTested("updateBoolean()", bOK)
84*b1cdbd2cSJim Jagielski
85*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
86*b1cdbd2cSJim Jagielski        oObj.getBoolean(i+1)
87*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
88*b1cdbd2cSJim Jagielski    else
89*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
90*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
91*b1cdbd2cSJim Jagielski        Test.MethodTested("updateBoolean()", true)
92*b1cdbd2cSJim Jagielski    end if
93*b1cdbd2cSJim Jagielski
94*b1cdbd2cSJim Jagielski    Test.StartMethod("updateByte()")
95*b1cdbd2cSJim Jagielski    colType = "byte"
96*b1cdbd2cSJim Jagielski    i = findColumn(colType)
97*b1cdbd2cSJim Jagielski    if i >= 0 then
98*b1cdbd2cSJim Jagielski        bOK = true
99*b1cdbd2cSJim Jagielski        getV = oObj.getByte(i+1)
100*b1cdbd2cSJim Jagielski        newV = getV + 1
101*b1cdbd2cSJim Jagielski        oObj.updateByte(i+1, newV)
102*b1cdbd2cSJim Jagielski        resV = oObj.getByte(i+1)
103*b1cdbd2cSJim Jagielski        Out.Log("Was: " + getv + ", New: " + newV + ", Res: " + resV)
104*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV = newV)
105*b1cdbd2cSJim Jagielski        Test.MethodTested("updateByte()", bOK)
106*b1cdbd2cSJim Jagielski
107*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
108*b1cdbd2cSJim Jagielski        oObj.getByte(i+1)
109*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
110*b1cdbd2cSJim Jagielski    else
111*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
112*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
113*b1cdbd2cSJim Jagielski        Test.MethodTested("updateByte()", true)
114*b1cdbd2cSJim Jagielski    end if
115*b1cdbd2cSJim Jagielski
116*b1cdbd2cSJim Jagielski    Test.StartMethod("updateShort()")
117*b1cdbd2cSJim Jagielski    colType = "short"
118*b1cdbd2cSJim Jagielski    i = findColumn(colType)
119*b1cdbd2cSJim Jagielski    if i >= 0 then
120*b1cdbd2cSJim Jagielski        bOK = true
121*b1cdbd2cSJim Jagielski        getV = oObj.getShort(i+1)
122*b1cdbd2cSJim Jagielski        newV = getV + 1
123*b1cdbd2cSJim Jagielski        oObj.updateShort(i+1, newV)
124*b1cdbd2cSJim Jagielski        resV = oObj.getShort(i+1)
125*b1cdbd2cSJim Jagielski        Out.Log("Was: " + getv + ", New: " + newV + ", Res: " + resV)
126*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV = newV)
127*b1cdbd2cSJim Jagielski        Test.MethodTested("updateShort()", bOK)
128*b1cdbd2cSJim Jagielski
129*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
130*b1cdbd2cSJim Jagielski        oObj.getShort(i+1)
131*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
132*b1cdbd2cSJim Jagielski    else
133*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
134*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
135*b1cdbd2cSJim Jagielski        Test.MethodTested("updateShort()", true)
136*b1cdbd2cSJim Jagielski    end if
137*b1cdbd2cSJim Jagielski
138*b1cdbd2cSJim Jagielski    Test.StartMethod("updateInt()")
139*b1cdbd2cSJim Jagielski    colType = "int"
140*b1cdbd2cSJim Jagielski    i = findColumn(colType)
141*b1cdbd2cSJim Jagielski    if i >= 0 then
142*b1cdbd2cSJim Jagielski        bOK = true
143*b1cdbd2cSJim Jagielski        getV = oObj.getInt(i+1)
144*b1cdbd2cSJim Jagielski        newV = getV + 1
145*b1cdbd2cSJim Jagielski        oObj.updateInt(i+1, newV)
146*b1cdbd2cSJim Jagielski        resV = oObj.getInt(i+1)
147*b1cdbd2cSJim Jagielski        Out.Log("Was: " + getv + ", New: " + newV + ", Res: " + resV)
148*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV = newV)
149*b1cdbd2cSJim Jagielski        Test.MethodTested("updateInt()", bOK)
150*b1cdbd2cSJim Jagielski
151*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
152*b1cdbd2cSJim Jagielski        oObj.getInt(i+1)
153*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
154*b1cdbd2cSJim Jagielski    else
155*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
156*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
157*b1cdbd2cSJim Jagielski        Test.MethodTested("updateInt()", true)
158*b1cdbd2cSJim Jagielski    end if
159*b1cdbd2cSJim Jagielski
160*b1cdbd2cSJim Jagielski    Test.StartMethod("updateLong()")
161*b1cdbd2cSJim Jagielski    colType = "long"
162*b1cdbd2cSJim Jagielski    i = findColumn(colType)
163*b1cdbd2cSJim Jagielski    if i >= 0 then
164*b1cdbd2cSJim Jagielski        bOK = true
165*b1cdbd2cSJim Jagielski        getV = oObj.getLong(i+1)
166*b1cdbd2cSJim Jagielski        newV = getV + 1
167*b1cdbd2cSJim Jagielski        oObj.updateLong(i+1, newV)
168*b1cdbd2cSJim Jagielski        resV = oObj.getLong(i+1)
169*b1cdbd2cSJim Jagielski        Out.Log("Was: " + getv + ", New: " + newV + ", Res: " + resV)
170*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV = newV)
171*b1cdbd2cSJim Jagielski        Test.MethodTested("updateLong()", bOK)
172*b1cdbd2cSJim Jagielski
173*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
174*b1cdbd2cSJim Jagielski        oObj.getLong(i+1)
175*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
176*b1cdbd2cSJim Jagielski    else
177*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
178*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
179*b1cdbd2cSJim Jagielski        Test.MethodTested("updateLong()", true)
180*b1cdbd2cSJim Jagielski    end if
181*b1cdbd2cSJim Jagielski
182*b1cdbd2cSJim Jagielski    Test.StartMethod("updateFloat()")
183*b1cdbd2cSJim Jagielski    colType = "float"
184*b1cdbd2cSJim Jagielski    i = findColumn(colType)
185*b1cdbd2cSJim Jagielski    if i >= 0 then
186*b1cdbd2cSJim Jagielski        bOK = true
187*b1cdbd2cSJim Jagielski        getV = oObj.getFloat(i+1)
188*b1cdbd2cSJim Jagielski        newV = getV + 1.3
189*b1cdbd2cSJim Jagielski        oObj.updateFloat(i+1, newV)
190*b1cdbd2cSJim Jagielski        resV = oObj.getFloat(i+1)
191*b1cdbd2cSJim Jagielski        Out.Log("Was: " + getv + ", New: " + newV + ", Res: " + resV)
192*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV = newV)
193*b1cdbd2cSJim Jagielski        Test.MethodTested("updateFloat()", bOK)
194*b1cdbd2cSJim Jagielski
195*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
196*b1cdbd2cSJim Jagielski        oObj.getFloat(i+1)
197*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
198*b1cdbd2cSJim Jagielski    else
199*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
200*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
201*b1cdbd2cSJim Jagielski        Test.MethodTested("updateFloat()", true)
202*b1cdbd2cSJim Jagielski    end if
203*b1cdbd2cSJim Jagielski
204*b1cdbd2cSJim Jagielski    Test.StartMethod("updateDouble()")
205*b1cdbd2cSJim Jagielski    colType = "double"
206*b1cdbd2cSJim Jagielski    i = findColumn(colType)
207*b1cdbd2cSJim Jagielski    if i >= 0 then
208*b1cdbd2cSJim Jagielski        bOK = true
209*b1cdbd2cSJim Jagielski        getV = oObj.getDouble(i+1)
210*b1cdbd2cSJim Jagielski        newV = getV + 1.5
211*b1cdbd2cSJim Jagielski        oObj.updateDouble(i+1, newV)
212*b1cdbd2cSJim Jagielski        resV = oObj.getDouble(i+1)
213*b1cdbd2cSJim Jagielski        Out.Log("Was: " + getv + ", New: " + newV + ", Res: " + resV)
214*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV = newV)
215*b1cdbd2cSJim Jagielski        Test.MethodTested("updateDouble()", bOK)
216*b1cdbd2cSJim Jagielski
217*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
218*b1cdbd2cSJim Jagielski        oObj.getDouble(i+1)
219*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
220*b1cdbd2cSJim Jagielski    else
221*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
222*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
223*b1cdbd2cSJim Jagielski        Test.MethodTested("updateDouble()", true)
224*b1cdbd2cSJim Jagielski    end if
225*b1cdbd2cSJim Jagielski
226*b1cdbd2cSJim Jagielski    Test.StartMethod("updateString()")
227*b1cdbd2cSJim Jagielski    colType = "string"
228*b1cdbd2cSJim Jagielski    i = findColumn(colType)
229*b1cdbd2cSJim Jagielski    if i >= 0 then
230*b1cdbd2cSJim Jagielski        bOK = true
231*b1cdbd2cSJim Jagielski        getV = oObj.getString(i+1)
232*b1cdbd2cSJim Jagielski        newV = "_" + getV
233*b1cdbd2cSJim Jagielski        oObj.updateString(i+1, newV)
234*b1cdbd2cSJim Jagielski        resV = oObj.getString(i+1)
235*b1cdbd2cSJim Jagielski        Out.Log("Was: '" + getv + "', New: '" + newV + "', Res: '" + resV + "'")
236*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV = newV)
237*b1cdbd2cSJim Jagielski        Test.MethodTested("updateString()", bOK)
238*b1cdbd2cSJim Jagielski
239*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
240*b1cdbd2cSJim Jagielski        oObj.getString(i+1)
241*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
242*b1cdbd2cSJim Jagielski    else
243*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
244*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
245*b1cdbd2cSJim Jagielski        Test.MethodTested("updateString()", true)
246*b1cdbd2cSJim Jagielski    end if
247*b1cdbd2cSJim Jagielski
248*b1cdbd2cSJim Jagielski    Test.StartMethod("updateBytes()")
249*b1cdbd2cSJim Jagielski    colType = "bytes"
250*b1cdbd2cSJim Jagielski    i = findColumn(colType)
251*b1cdbd2cSJim Jagielski    if i >= 0 then
252*b1cdbd2cSJim Jagielski        bOK = true
253*b1cdbd2cSJim Jagielski        getV = oObj.getBytes(i+1)
254*b1cdbd2cSJim Jagielski
255*b1cdbd2cSJim Jagielski        if (oObj.wasNull() OR ubound(getV()) &lt; 0) then
256*b1cdbd2cSJim Jagielski            newV = Array(1,2,3)
257*b1cdbd2cSJim Jagielski        else
258*b1cdbd2cSJim Jagielski            newV = getV
259*b1cdbd2cSJim Jagielski            newV(0) = newV(0) + 1
260*b1cdbd2cSJim Jagielski        end if
261*b1cdbd2cSJim Jagielski
262*b1cdbd2cSJim Jagielski        oObj.updateBytes(i+1, newV)
263*b1cdbd2cSJim Jagielski        resV = oObj.getBytes(i+1)
264*b1cdbd2cSJim Jagielski
265*b1cdbd2cSJim Jagielski        Out.Log("Was: " + getv(0) + ", New: " + newV(0) + ", Res: " + resV(0))
266*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV(0) = newV(0))
267*b1cdbd2cSJim Jagielski        Test.MethodTested("updateBytes()", bOK)
268*b1cdbd2cSJim Jagielski
269*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
270*b1cdbd2cSJim Jagielski        oObj.getBytes(i+1)
271*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
272*b1cdbd2cSJim Jagielski    else
273*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
274*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
275*b1cdbd2cSJim Jagielski        Test.MethodTested("updateBytes()", true)
276*b1cdbd2cSJim Jagielski    end if
277*b1cdbd2cSJim Jagielski
278*b1cdbd2cSJim Jagielski
279*b1cdbd2cSJim Jagielski    Dim dat As com.sun.star.util.Date
280*b1cdbd2cSJim Jagielski    Test.StartMethod("updateDate()")
281*b1cdbd2cSJim Jagielski    colType = "date"
282*b1cdbd2cSJim Jagielski    i = findColumn(colType)
283*b1cdbd2cSJim Jagielski    if i >= 0 then
284*b1cdbd2cSJim Jagielski        bOK = true
285*b1cdbd2cSJim Jagielski        getV = oObj.getDate(i+1)
286*b1cdbd2cSJim Jagielski        if (oObj.wasNull() OR isNull(getV)) then
287*b1cdbd2cSJim Jagielski            newV = dat
288*b1cdbd2cSJim Jagielski        else
289*b1cdbd2cSJim Jagielski            newV = getV
290*b1cdbd2cSJim Jagielski            newV.Year = newV.Year + 1
291*b1cdbd2cSJim Jagielski        end if
292*b1cdbd2cSJim Jagielski
293*b1cdbd2cSJim Jagielski        oObj.updateDate(i+1, newV)
294*b1cdbd2cSJim Jagielski        resV = oObj.getDate(i+1)
295*b1cdbd2cSJim Jagielski        Out.Log("Was: '" + getv.Year + "', New: '" + newV.Year + "', Res: '" + resV.Year + "'")
296*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV.Year = newV.Year)
297*b1cdbd2cSJim Jagielski        Test.MethodTested("updateDate()", bOK)
298*b1cdbd2cSJim Jagielski
299*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
300*b1cdbd2cSJim Jagielski        oObj.getDate(i+1)
301*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
302*b1cdbd2cSJim Jagielski    else
303*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
304*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
305*b1cdbd2cSJim Jagielski        Test.MethodTested("updateDate()", true)
306*b1cdbd2cSJim Jagielski    end if
307*b1cdbd2cSJim Jagielski
308*b1cdbd2cSJim Jagielski    Dim tim As com.sun.star.util.Time
309*b1cdbd2cSJim Jagielski    Test.StartMethod("updateTime()")
310*b1cdbd2cSJim Jagielski    colType = "time"
311*b1cdbd2cSJim Jagielski    i = findColumn(colType)
312*b1cdbd2cSJim Jagielski    if i >= 0 then
313*b1cdbd2cSJim Jagielski        bOK = true
314*b1cdbd2cSJim Jagielski        getV = oObj.getTime(i+1)
315*b1cdbd2cSJim Jagielski        if (oObj.wasNull() OR isNull(getV)) then
316*b1cdbd2cSJim Jagielski            newV = tim
317*b1cdbd2cSJim Jagielski        else
318*b1cdbd2cSJim Jagielski            newV = getV
319*b1cdbd2cSJim Jagielski            newV.Seconds = newV.Seconds + 1
320*b1cdbd2cSJim Jagielski        end if
321*b1cdbd2cSJim Jagielski
322*b1cdbd2cSJim Jagielski        oObj.updateTime(i+1, newV)
323*b1cdbd2cSJim Jagielski        resV = oObj.getTime(i+1)
324*b1cdbd2cSJim Jagielski        Out.Log("Was: '" + getv.Seconds + "', New: '" + newV.Seconds + "', Res: '" + resV.Seconds + "'")
325*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV.Seconds = newV.Seconds)
326*b1cdbd2cSJim Jagielski        Test.MethodTested("updateTime()", bOK)
327*b1cdbd2cSJim Jagielski
328*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
329*b1cdbd2cSJim Jagielski        oObj.getTime(i+1)
330*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
331*b1cdbd2cSJim Jagielski    else
332*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
333*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
334*b1cdbd2cSJim Jagielski        Test.MethodTested("updateTime()", true)
335*b1cdbd2cSJim Jagielski    end if
336*b1cdbd2cSJim Jagielski
337*b1cdbd2cSJim Jagielski    Dim dattm As com.sun.star.util.DateTime
338*b1cdbd2cSJim Jagielski    Test.StartMethod("updateTimestamp()")
339*b1cdbd2cSJim Jagielski    colType = "timestamp"
340*b1cdbd2cSJim Jagielski    i = findColumn(colType)
341*b1cdbd2cSJim Jagielski    if i >= 0 then
342*b1cdbd2cSJim Jagielski        bOK = true
343*b1cdbd2cSJim Jagielski        getV = oObj.getTimestamp(i+1)
344*b1cdbd2cSJim Jagielski        if (oObj.wasNull() OR isNull(getV)) then
345*b1cdbd2cSJim Jagielski            newV = dattm
346*b1cdbd2cSJim Jagielski        else
347*b1cdbd2cSJim Jagielski            newV = getV
348*b1cdbd2cSJim Jagielski            newV.Year = newV.Year + 1
349*b1cdbd2cSJim Jagielski        end if
350*b1cdbd2cSJim Jagielski
351*b1cdbd2cSJim Jagielski        oObj.updateTimestamp(i+1, newV)
352*b1cdbd2cSJim Jagielski        resV = oObj.getTimestamp(i+1)
353*b1cdbd2cSJim Jagielski        Out.Log("Was: '" + getv.Year + "', New: '" + newV.Year + "', Res: '" + resV.Year + "'")
354*b1cdbd2cSJim Jagielski        bOK = bOK AND (resV.Year = newV.Year)
355*b1cdbd2cSJim Jagielski        Test.MethodTested("updateTimestamp()", bOK)
356*b1cdbd2cSJim Jagielski
357*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
358*b1cdbd2cSJim Jagielski        oObj.getTimestamp(i+1)
359*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
360*b1cdbd2cSJim Jagielski    else
361*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
362*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
363*b1cdbd2cSJim Jagielski        Test.MethodTested("updateTimestamp()", true)
364*b1cdbd2cSJim Jagielski    end if
365*b1cdbd2cSJim Jagielski
366*b1cdbd2cSJim Jagielski    Dim bytes As Variant, nBytes As Long
367*b1cdbd2cSJim Jagielski    Test.StartMethod("updateCharacterStream()")
368*b1cdbd2cSJim Jagielski    colType = "characterstream"
369*b1cdbd2cSJim Jagielski    i = findColumn(colType)
370*b1cdbd2cSJim Jagielski    if i >= 0 then
371*b1cdbd2cSJim Jagielski        bOK = true
372*b1cdbd2cSJim Jagielski        newV = createUnoService("com.sun.star.io.Pipe")
373*b1cdbd2cSJim Jagielski        newV.writeBytes(Array(123, 234))
374*b1cdbd2cSJim Jagielski        oObj.updateCharacterStream(i+1, newV)
375*b1cdbd2cSJim Jagielski        resV = oObj.getCharacterStream(i+1)
376*b1cdbd2cSJim Jagielski        'Out.Log("Was: '" + getv + "', New: '" + newV + "', Res: '" + resV + "'")
377*b1cdbd2cSJim Jagielski        bOK = bOK AND NOT oObj.wasNull() AND NOT isNull(resV)
378*b1cdbd2cSJim Jagielski
379*b1cdbd2cSJim Jagielski        if bOK then
380*b1cdbd2cSJim Jagielski            Out.Log("Testing further ...")
381*b1cdbd2cSJim Jagielski            nBytes = resV.readBytes(bytes, 2)
382*b1cdbd2cSJim Jagielski            bOK = bOK AND (nBytes = 2) AND (bytes(0) = 123) AND (bytes(1) = 234)
383*b1cdbd2cSJim Jagielski        end if
384*b1cdbd2cSJim Jagielski
385*b1cdbd2cSJim Jagielski        Test.MethodTested("updateCharacterStream()", bOK)
386*b1cdbd2cSJim Jagielski
387*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
388*b1cdbd2cSJim Jagielski        oObj.getCharacterStream(i+1)
389*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
390*b1cdbd2cSJim Jagielski    else
391*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
392*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
393*b1cdbd2cSJim Jagielski        Test.MethodTested("updateCharacterStream()", true)
394*b1cdbd2cSJim Jagielski    end if
395*b1cdbd2cSJim Jagielski
396*b1cdbd2cSJim Jagielski    Test.StartMethod("updateBinaryStream()")
397*b1cdbd2cSJim Jagielski    colType = "binarystream"
398*b1cdbd2cSJim Jagielski    i = findColumn(colType)
399*b1cdbd2cSJim Jagielski    if i >= 0 then
400*b1cdbd2cSJim Jagielski        bOK = true
401*b1cdbd2cSJim Jagielski        newV = createUnoService("com.sun.star.io.Pipe")
402*b1cdbd2cSJim Jagielski        newV.writeBytes(Array(123, 234))
403*b1cdbd2cSJim Jagielski        oObj.updateBinaryStream(i+1, newV)
404*b1cdbd2cSJim Jagielski        resV = oObj.getBinaryStream(i+1)
405*b1cdbd2cSJim Jagielski        'Out.Log("Was: '" + getv + "', New: '" + newV + "', Res: '" + resV + "'")
406*b1cdbd2cSJim Jagielski        bOK = bOK AND NOT oObj.wasNull() AND NOT isNull(resV)
407*b1cdbd2cSJim Jagielski
408*b1cdbd2cSJim Jagielski        if bOK then
409*b1cdbd2cSJim Jagielski            Out.Log("Testing further ...")
410*b1cdbd2cSJim Jagielski            nBytes = resV.readBytes(bytes, 2)
411*b1cdbd2cSJim Jagielski            bOK = bOK AND (nBytes = 2) AND (bytes(0) = 123) AND (bytes(1) = 234)
412*b1cdbd2cSJim Jagielski        end if
413*b1cdbd2cSJim Jagielski
414*b1cdbd2cSJim Jagielski        Test.MethodTested("updateBinaryStream()", bOK)
415*b1cdbd2cSJim Jagielski
416*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
417*b1cdbd2cSJim Jagielski        oObj.getBinaryStream(i+1)
418*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
419*b1cdbd2cSJim Jagielski    else
420*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
421*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
422*b1cdbd2cSJim Jagielski        Test.MethodTested("updateBinaryStream()", true)
423*b1cdbd2cSJim Jagielski    end if
424*b1cdbd2cSJim Jagielski
425*b1cdbd2cSJim Jagielski    Test.StartMethod("updateObject()")
426*b1cdbd2cSJim Jagielski    colType = "object"
427*b1cdbd2cSJim Jagielski    i = findColumn(colType)
428*b1cdbd2cSJim Jagielski    if i >= 0 then
429*b1cdbd2cSJim Jagielski        bOK = true
430*b1cdbd2cSJim Jagielski        getV = oObj.getObject(i+1)
431*b1cdbd2cSJim Jagielski        if (NOT hasUnoInterfaces(getV, "com.sun.star.io.XInputStream")) then
432*b1cdbd2cSJim Jagielski            newV = createUnoService("com.sun.star.io.DataInputStream")
433*b1cdbd2cSJim Jagielski        else
434*b1cdbd2cSJim Jagielski            newV = createUnoService("com.sun.star.io.DataOutputStream")
435*b1cdbd2cSJim Jagielski        end if
436*b1cdbd2cSJim Jagielski
437*b1cdbd2cSJim Jagielski        oObj.updateObject(i+1, newV)
438*b1cdbd2cSJim Jagielski        resV = oObj.getObject(i+1)
439*b1cdbd2cSJim Jagielski
440*b1cdbd2cSJim Jagielski        bOK = bOK AND (hasUnoInterfaces(newV, "com.sun.star.io.XInputStream") = _
441*b1cdbd2cSJim Jagielski                       hasUnoInterfaces(resV, "com.sun.star.io.XInputStream")) AND _
442*b1cdbd2cSJim Jagielski                      (hasUnoInterfaces(newV, "com.sun.star.io.XOutputStream") = _
443*b1cdbd2cSJim Jagielski                       hasUnoInterfaces(resV, "com.sun.star.io.XOutputStream"))
444*b1cdbd2cSJim Jagielski
445*b1cdbd2cSJim Jagielski        Test.MethodTested("updateObject()", bOK)
446*b1cdbd2cSJim Jagielski
447*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
448*b1cdbd2cSJim Jagielski        oObj.getObject(i+1)
449*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
450*b1cdbd2cSJim Jagielski    else
451*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
452*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
453*b1cdbd2cSJim Jagielski        Test.MethodTested("updateObject()", true)
454*b1cdbd2cSJim Jagielski    end if
455*b1cdbd2cSJim Jagielski
456*b1cdbd2cSJim Jagielski    Test.StartMethod("updateNumericObject()")
457*b1cdbd2cSJim Jagielski    colType = "numericobject"
458*b1cdbd2cSJim Jagielski    i = findColumn(colType)
459*b1cdbd2cSJim Jagielski    if i >= 0 then
460*b1cdbd2cSJim Jagielski        bOK = true
461*b1cdbd2cSJim Jagielski        getV = oObj.getNumericObject(i+1)
462*b1cdbd2cSJim Jagielski        if (NOT hasUnoInterfaces(getV, "com.sun.star.io.XInputStream")) then
463*b1cdbd2cSJim Jagielski            newV = createUnoService("com.sun.star.io.DataInputStream")
464*b1cdbd2cSJim Jagielski        else
465*b1cdbd2cSJim Jagielski            newV = createUnoService("com.sun.star.io.DataOutputStream")
466*b1cdbd2cSJim Jagielski        end if
467*b1cdbd2cSJim Jagielski
468*b1cdbd2cSJim Jagielski        oObj.updateNumericObject(i+1, newV, 0)
469*b1cdbd2cSJim Jagielski        resV = oObj.getNumericObject(i+1)
470*b1cdbd2cSJim Jagielski
471*b1cdbd2cSJim Jagielski        bOK = bOK AND (hasUnoInterfaces(newV, "com.sun.star.io.XInputStream") = _
472*b1cdbd2cSJim Jagielski                       hasUnoInterfaces(resV, "com.sun.star.io.XInputStream")) AND _
473*b1cdbd2cSJim Jagielski                      (hasUnoInterfaces(newV, "com.sun.star.io.XOutputStream") = _
474*b1cdbd2cSJim Jagielski                       hasUnoInterfaces(resV, "com.sun.star.io.XOutputStream"))
475*b1cdbd2cSJim Jagielski
476*b1cdbd2cSJim Jagielski        Test.MethodTested("updateNumericObject()", bOK)
477*b1cdbd2cSJim Jagielski
478*b1cdbd2cSJim Jagielski        oObj.updateNull(i+1)
479*b1cdbd2cSJim Jagielski        oObj.getNumericObject(i+1)
480*b1cdbd2cSJim Jagielski        bNullOK = bNullOK AND oObj.wasNull()
481*b1cdbd2cSJim Jagielski    else
482*b1cdbd2cSJim Jagielski        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
483*b1cdbd2cSJim Jagielski        Out.Log("Nevertheless status is OK")
484*b1cdbd2cSJim Jagielski        Test.MethodTested("updateNumericObject()", true)
485*b1cdbd2cSJim Jagielski    end if
486*b1cdbd2cSJim Jagielski
487*b1cdbd2cSJim Jagielski    Test.StartMethod("updateNull()")
488*b1cdbd2cSJim Jagielski    Test.MethodTested("updateNull()", bNullOK)
489*b1cdbd2cSJim Jagielski
490*b1cdbd2cSJim JagielskiExit Sub
491*b1cdbd2cSJim JagielskiErrHndl:
492*b1cdbd2cSJim Jagielski    Test.Exception()
493*b1cdbd2cSJim Jagielski    bOK = false
494*b1cdbd2cSJim Jagielski    resume next
495*b1cdbd2cSJim JagielskiEnd Sub
496*b1cdbd2cSJim Jagielski
497*b1cdbd2cSJim JagielskiFunction findColumn(cType As String) As Integer
498*b1cdbd2cSJim Jagielski    Dim i As Integer
499*b1cdbd2cSJim Jagielski
500*b1cdbd2cSJim Jagielski    for i = lbound(rowTypes()) to ubound(rowTypes())
501*b1cdbd2cSJim Jagielski        if rowTypes(i) = cType then
502*b1cdbd2cSJim Jagielski            findColumn() = rowTypesCol(i) - 1
503*b1cdbd2cSJim Jagielski            exit function
504*b1cdbd2cSJim Jagielski        end if
505*b1cdbd2cSJim Jagielski    next i
506*b1cdbd2cSJim Jagielski
507*b1cdbd2cSJim Jagielski    findColumn() = -1
508*b1cdbd2cSJim JagielskiEnd function
509*b1cdbd2cSJim Jagielski</script:module>
510