1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="sdbc_XRow" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31' Be sure that all variables are dimensioned:
32option explicit
33
34'*************************************************************************
35' This Interface/Service test depends on the following GLOBAL variables,
36' which must be specified in the object creation:
37
38'     - Global rowTypes As Variant
39'       Array of Strings with description of column types
40
41'*************************************************************************
42
43
44
45
46
47
48Sub RunTest()
49
50'*************************************************************************
51' INTERFACE:
52' com.sun.star.sdbc.XRow
53'*************************************************************************
54On Error Goto ErrHndl
55    Dim bOK As Boolean
56    Dim i As Integer
57    Dim colType As String
58
59    Test.StartMethod("getBoolean()")
60    bOK = true
61    colType = "boolean"
62    i = findColumn(colType)
63    if i >= 0 then
64        oObj.getBoolean(i)
65    else
66        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
67        Out.Log("Nevertheless status is OK")
68    end if
69    Test.MethodTested("getBoolean()", bOK)
70
71    Test.StartMethod("getByte()")
72    bOK = true
73    colType = "byte"
74    i = findColumn(colType)
75    if i >= 0 then
76        oObj.getByte(i + 1)
77    else
78        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
79        Out.Log("Nevertheless status is OK")
80    end if
81    Test.MethodTested("getByte()", bOK)
82
83    Test.StartMethod("getShort()")
84    bOK = true
85    colType = "short"
86    i = findColumn(colType)
87    if i >= 0 then
88        oObj.getShort(i + 1)
89    else
90        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
91        Out.Log("Nevertheless status is OK")
92    end if
93    Test.MethodTested("getShort()", bOK)
94
95    Test.StartMethod("getInt()")
96    bOK = true
97    colType = "int"
98    i = findColumn(colType)
99    if i >= 0 then
100        oObj.getInt(i + 1)
101    else
102        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
103        Out.Log("Nevertheless status is OK")
104    end if
105    Test.MethodTested("getInt()", bOK)
106
107    Test.StartMethod("getLong()")
108    bOK = true
109    colType = "long"
110    i = findColumn(colType)
111    if i >= 0 then
112        oObj.getLong(i + 1)
113    else
114        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
115        Out.Log("Nevertheless status is OK")
116    end if
117    Test.MethodTested("getLong()", bOK)
118
119    Test.StartMethod("getFloat()")
120    bOK = true
121    colType = "float"
122    i = findColumn(colType)
123    if i >= 0 then
124        oObj.getFloat(i + 1)
125    else
126        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
127        Out.Log("Nevertheless status is OK")
128    end if
129    Test.MethodTested("getFloat()", bOK)
130
131    Test.StartMethod("getDouble()")
132    bOK = true
133    colType = "double"
134    i = findColumn(colType)
135    if i >= 0 then
136        oObj.getDouble(i + 1)
137    else
138        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
139        Out.Log("Nevertheless status is OK")
140    end if
141    Test.MethodTested("getDouble()", bOK)
142
143    Test.StartMethod("getString()")
144    bOK = true
145    colType = "string"
146    i = findColumn(colType)
147    if i >= 0 then
148        oObj.getString(i + 1)
149    else
150        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
151        Out.Log("Nevertheless status is OK")
152    end if
153    Test.MethodTested("getString()", bOK)
154
155    Test.StartMethod("getBytes()")
156    bOK = true
157    colType = "bytes"
158    i = findColumn(colType)
159    if i >= 0 then
160        oObj.getBytes(i + 1)
161    else
162        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
163        Out.Log("Nevertheless status is OK")
164    end if
165    Test.MethodTested("getBytes()", bOK)
166
167    Test.StartMethod("getDate()")
168    bOK = true
169    colType = "date"
170    i = findColumn(colType)
171    if i >= 0 then
172        oObj.getDate(i + 1)
173    else
174        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
175        Out.Log("Nevertheless status is OK")
176    end if
177    Test.MethodTested("getDate()", bOK)
178
179    Test.StartMethod("getTime()")
180    bOK = true
181    colType = "time"
182    i = findColumn(colType)
183    if i >= 0 then
184        oObj.getTime(i + 1)
185    else
186        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
187        Out.Log("Nevertheless status is OK")
188    end if
189    Test.MethodTested("getTime()", bOK)
190
191    Test.StartMethod("getTimestamp()")
192    bOK = true
193    colType = "timestamp"
194    i = findColumn(colType)
195    if i >= 0 then
196        oObj.getTimestamp(i + 1)
197    else
198        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
199        Out.Log("Nevertheless status is OK")
200    end if
201    Test.MethodTested("getTimestamp()", bOK)
202
203    Test.StartMethod("getBinaryStream()")
204    bOK = true
205    colType = "binarystream"
206    i = findColumn(colType)
207    if i >= 0 then
208        oObj.getBinaryStream(i + 1)
209    else
210        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
211        Out.Log("Nevertheless status is OK")
212    end if
213    Test.MethodTested("getBinaryStream()", bOK)
214
215    Test.StartMethod("getCharacterStream()")
216    bOK = true
217    colType = "characterstream"
218    i = findColumn(colType)
219    if i >= 0 then
220        oObj.getCharacterStream(i + 1)
221    else
222        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
223        Out.Log("Nevertheless status is OK")
224    end if
225    Test.MethodTested("getCharacterStream()", bOK)
226
227    Test.StartMethod("getObject()")
228    bOK = true
229    colType = "object"
230    i = findColumn(colType)
231    if i >= 0 then
232        oObj.getObject(i + 1)
233    else
234        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
235        Out.Log("Nevertheless status is OK")
236    end if
237    Test.MethodTested("getObject()", bOK)
238
239    Test.StartMethod("getRef()")
240    bOK = true
241    colType = "ref"
242    i = findColumn(colType)
243    if i >= 0 then
244        oObj.getRef(i + 1)
245    else
246        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
247        Out.Log("Nevertheless status is OK")
248    end if
249    Test.MethodTested("getRef()", bOK)
250
251    Test.StartMethod("getBlob()")
252    bOK = true
253    colType = "blob"
254    i = findColumn(colType)
255    if i >= 0 then
256        oObj.getBlob(i + 1)
257    else
258        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
259        Out.Log("Nevertheless status is OK")
260    end if
261    Test.MethodTested("getBlob()", bOK)
262
263    Test.StartMethod("getClob()")
264    bOK = true
265    colType = "clob"
266    i = findColumn(colType)
267    if i >= 0 then
268        oObj.getClob(i + 1)
269    else
270        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
271        Out.Log("Nevertheless status is OK")
272    end if
273    Test.MethodTested("getClob()", bOK)
274
275    Test.StartMethod("getArray()")
276    bOK = true
277    colType = "array"
278    i = findColumn(colType)
279    if i >= 0 then
280        oObj.getArray(i + 1)
281    else
282        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
283        Out.Log("Nevertheless status is OK")
284    end if
285    Test.MethodTested("getArray()", bOK)
286
287
288    Test.StartMethod("wasNull()")
289    bOK = true
290    oObj.wasNull()
291    Test.MethodTested("wasNull()", bOK)
292
293Exit Sub
294ErrHndl:
295    Test.Exception()
296    bOK = false
297    resume next
298End Sub
299
300Function findColumn(cType As String) As Integer
301    Dim i As Integer
302
303    for i = lbound(rowTypes()) to ubound(rowTypes())
304        if rowTypes(i) = cType then
305            findColumn() = rowTypesCol(i)
306            exit function
307        end if
308    next i
309
310    findColumn() = -1
311End function
312</script:module>
313