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' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9'
10' Copyright 2000, 2010 Oracle and/or its affiliates.
11'
12' OpenOffice.org - a multi-platform office productivity suite
13'
14' This file is part of OpenOffice.org.
15'
16' OpenOffice.org is free software: you can redistribute it and/or modify
17' it under the terms of the GNU Lesser General Public License version 3
18' only, as published by the Free Software Foundation.
19'
20' OpenOffice.org is distributed in the hope that it will be useful,
21' but WITHOUT ANY WARRANTY; without even the implied warranty of
22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23' GNU Lesser General Public License version 3 for more details
24' (a copy is included in the LICENSE file that accompanied this code).
25'
26' You should have received a copy of the GNU Lesser General Public License
27' version 3 along with OpenOffice.org.  If not, see
28' <http://www.openoffice.org/license.html>
29' for a copy of the LGPLv3 License.
30'
31'*************************************************************************
32'*************************************************************************
33
34
35
36' Be sure that all variables are dimensioned:
37option explicit
38
39'*************************************************************************
40' This Interface/Service test depends on the following GLOBAL variables,
41' which must be specified in the object creation:
42
43'     - Global rowTypes As Variant
44'       Array of Strings with description of column types
45
46'*************************************************************************
47
48
49
50
51
52
53Sub RunTest()
54
55'*************************************************************************
56' INTERFACE:
57' com.sun.star.sdbc.XRow
58'*************************************************************************
59On Error Goto ErrHndl
60    Dim bOK As Boolean
61    Dim i As Integer
62    Dim colType As String
63
64    Test.StartMethod("getBoolean()")
65    bOK = true
66    colType = "boolean"
67    i = findColumn(colType)
68    if i >= 0 then
69        oObj.getBoolean(i)
70    else
71        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
72        Out.Log("Nevertheless status is OK")
73    end if
74    Test.MethodTested("getBoolean()", bOK)
75
76    Test.StartMethod("getByte()")
77    bOK = true
78    colType = "byte"
79    i = findColumn(colType)
80    if i >= 0 then
81        oObj.getByte(i + 1)
82    else
83        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
84        Out.Log("Nevertheless status is OK")
85    end if
86    Test.MethodTested("getByte()", bOK)
87
88    Test.StartMethod("getShort()")
89    bOK = true
90    colType = "short"
91    i = findColumn(colType)
92    if i >= 0 then
93        oObj.getShort(i + 1)
94    else
95        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
96        Out.Log("Nevertheless status is OK")
97    end if
98    Test.MethodTested("getShort()", bOK)
99
100    Test.StartMethod("getInt()")
101    bOK = true
102    colType = "int"
103    i = findColumn(colType)
104    if i >= 0 then
105        oObj.getInt(i + 1)
106    else
107        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
108        Out.Log("Nevertheless status is OK")
109    end if
110    Test.MethodTested("getInt()", bOK)
111
112    Test.StartMethod("getLong()")
113    bOK = true
114    colType = "long"
115    i = findColumn(colType)
116    if i >= 0 then
117        oObj.getLong(i + 1)
118    else
119        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
120        Out.Log("Nevertheless status is OK")
121    end if
122    Test.MethodTested("getLong()", bOK)
123
124    Test.StartMethod("getFloat()")
125    bOK = true
126    colType = "float"
127    i = findColumn(colType)
128    if i >= 0 then
129        oObj.getFloat(i + 1)
130    else
131        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
132        Out.Log("Nevertheless status is OK")
133    end if
134    Test.MethodTested("getFloat()", bOK)
135
136    Test.StartMethod("getDouble()")
137    bOK = true
138    colType = "double"
139    i = findColumn(colType)
140    if i >= 0 then
141        oObj.getDouble(i + 1)
142    else
143        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
144        Out.Log("Nevertheless status is OK")
145    end if
146    Test.MethodTested("getDouble()", bOK)
147
148    Test.StartMethod("getString()")
149    bOK = true
150    colType = "string"
151    i = findColumn(colType)
152    if i >= 0 then
153        oObj.getString(i + 1)
154    else
155        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
156        Out.Log("Nevertheless status is OK")
157    end if
158    Test.MethodTested("getString()", bOK)
159
160    Test.StartMethod("getBytes()")
161    bOK = true
162    colType = "bytes"
163    i = findColumn(colType)
164    if i >= 0 then
165        oObj.getBytes(i + 1)
166    else
167        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
168        Out.Log("Nevertheless status is OK")
169    end if
170    Test.MethodTested("getBytes()", bOK)
171
172    Test.StartMethod("getDate()")
173    bOK = true
174    colType = "date"
175    i = findColumn(colType)
176    if i >= 0 then
177        oObj.getDate(i + 1)
178    else
179        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
180        Out.Log("Nevertheless status is OK")
181    end if
182    Test.MethodTested("getDate()", bOK)
183
184    Test.StartMethod("getTime()")
185    bOK = true
186    colType = "time"
187    i = findColumn(colType)
188    if i >= 0 then
189        oObj.getTime(i + 1)
190    else
191        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
192        Out.Log("Nevertheless status is OK")
193    end if
194    Test.MethodTested("getTime()", bOK)
195
196    Test.StartMethod("getTimestamp()")
197    bOK = true
198    colType = "timestamp"
199    i = findColumn(colType)
200    if i >= 0 then
201        oObj.getTimestamp(i + 1)
202    else
203        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
204        Out.Log("Nevertheless status is OK")
205    end if
206    Test.MethodTested("getTimestamp()", bOK)
207
208    Test.StartMethod("getBinaryStream()")
209    bOK = true
210    colType = "binarystream"
211    i = findColumn(colType)
212    if i >= 0 then
213        oObj.getBinaryStream(i + 1)
214    else
215        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
216        Out.Log("Nevertheless status is OK")
217    end if
218    Test.MethodTested("getBinaryStream()", bOK)
219
220    Test.StartMethod("getCharacterStream()")
221    bOK = true
222    colType = "characterstream"
223    i = findColumn(colType)
224    if i >= 0 then
225        oObj.getCharacterStream(i + 1)
226    else
227        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
228        Out.Log("Nevertheless status is OK")
229    end if
230    Test.MethodTested("getCharacterStream()", bOK)
231
232    Test.StartMethod("getObject()")
233    bOK = true
234    colType = "object"
235    i = findColumn(colType)
236    if i >= 0 then
237        oObj.getObject(i + 1)
238    else
239        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
240        Out.Log("Nevertheless status is OK")
241    end if
242    Test.MethodTested("getObject()", bOK)
243
244    Test.StartMethod("getRef()")
245    bOK = true
246    colType = "ref"
247    i = findColumn(colType)
248    if i >= 0 then
249        oObj.getRef(i + 1)
250    else
251        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
252        Out.Log("Nevertheless status is OK")
253    end if
254    Test.MethodTested("getRef()", bOK)
255
256    Test.StartMethod("getBlob()")
257    bOK = true
258    colType = "blob"
259    i = findColumn(colType)
260    if i >= 0 then
261        oObj.getBlob(i + 1)
262    else
263        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
264        Out.Log("Nevertheless status is OK")
265    end if
266    Test.MethodTested("getBlob()", bOK)
267
268    Test.StartMethod("getClob()")
269    bOK = true
270    colType = "clob"
271    i = findColumn(colType)
272    if i >= 0 then
273        oObj.getClob(i + 1)
274    else
275        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
276        Out.Log("Nevertheless status is OK")
277    end if
278    Test.MethodTested("getClob()", bOK)
279
280    Test.StartMethod("getArray()")
281    bOK = true
282    colType = "array"
283    i = findColumn(colType)
284    if i >= 0 then
285        oObj.getArray(i + 1)
286    else
287        Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.")
288        Out.Log("Nevertheless status is OK")
289    end if
290    Test.MethodTested("getArray()", bOK)
291
292
293    Test.StartMethod("wasNull()")
294    bOK = true
295    oObj.wasNull()
296    Test.MethodTested("wasNull()", bOK)
297
298Exit Sub
299ErrHndl:
300    Test.Exception()
301    bOK = false
302    resume next
303End Sub
304
305Function findColumn(cType As String) As Integer
306    Dim i As Integer
307
308    for i = lbound(rowTypes()) to ubound(rowTypes())
309        if rowTypes(i) = cType then
310            findColumn() = rowTypesCol(i)
311            exit function
312        end if
313    next i
314
315    findColumn() = -1
316End function
317</script:module>
318