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_XParameters" 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 paramTypes As Variant
44'       Array of Strings which describes the types of the query parameters
45
46'*************************************************************************
47
48
49
50
51
52
53Sub RunTest()
54
55'*************************************************************************
56' INTERFACE:
57' com.sun.star.sdbc.XParameters
58'*************************************************************************
59On Error Goto ErrHndl
60    Dim bOK As Boolean
61    Dim i As Integer
62
63    for i = 0 to ubound(paramTypes())
64        if (paramTypes(i) = "boolean") OR (paramTypes(i) = "byte") OR (paramTypes(i) = "short") OR _
65           (paramTypes(i) = "int") OR (paramTypes(i) = "long") OR (paramTypes(i) = "float") OR _
66           (paramTypes(i) = "double") OR (paramTypes(i) = "string") OR (paramTypes(i) = "bytes") OR _
67           (paramTypes(i) = "date") OR (paramTypes(i) = "time") OR (paramTypes(i) = "timestamp") OR _
68           (paramTypes(i) = "binarystream") OR (paramTypes(i) = "characterstream") then
69
70            bOK = true
71            oObj.setNull(i + 1, paramTypes(i))
72            Test.MethodTested("setNull()", bOK)
73        elseif paramTypes(i) = "ref" then
74            Out.Log("Don't know how to test this :(")
75'            bOK = true
76'            oObj.setObjectNull(i)
77'            Test.MethodTested("setNull()", bOK)
78        end if
79
80
81        if paramTypes(i) = "boolean" then
82            Test.StartMethod("setBoolean()")
83            bOK = true
84            oObj.setBoolean(i + 1, true)
85            Test.MethodTested("setBoolean()", bOK)
86        elseif paramTypes(i) = "byte" then
87            Test.StartMethod("setByte()")
88            bOK = true
89            oObj.setByte(i + 1, 5)
90            Test.MethodTested("setByte()", bOK)
91        elseif paramTypes(i) = "short" then
92            Test.StartMethod("setShort()")
93            bOK = true
94            oObj.setShort(i + 1, 6)
95            Test.MethodTested("setShort()", bOK)
96        elseif paramTypes(i) = "int" then
97            Test.StartMethod("setInt()")
98            bOK = true
99            oObj.setInt(i + 1, 234)
100            Test.MethodTested("setInt()", bOK)
101        elseif paramTypes(i) = "long" then
102            Test.StartMethod("setLong()")
103            bOK = true
104            oObj.setLong(i + 1, 34656)
105            Test.MethodTested("setLong()", bOK)
106        elseif paramTypes(i) = "float" then
107            Test.StartMethod("setFloat()")
108            bOK = true
109            oObj.setFloat(i + 1, 98.765)
110            Test.MethodTested("setFloat()", bOK)
111        elseif paramTypes(i) = "double" then
112            Test.StartMethod("setDouble()")
113            bOK = true
114            oObj.setDouble(i + 1, 54.432)
115            Test.MethodTested("setDouble()", bOK)
116        elseif paramTypes(i) = "string" then
117            Test.StartMethod("setString()")
118            bOK = true
119            oObj.setString(i + 1, "XParameters")
120            Test.MethodTested("setString()", bOK)
121        elseif paramTypes(i) = "bytes" then
122            Test.StartMethod("setBytes()")
123            bOK = true
124            oObj.setBytes(i + 1, Array(1,2,3))
125            Test.MethodTested("setBytes()", bOK)
126        elseif paramTypes(i) = "date" then
127            Dim dat As new com.sun.star.util.Date
128
129            Test.StartMethod("setDate()")
130            bOK = true
131            oObj.setDate(i + 1, dat)
132            Test.MethodTested("setDate()", bOK)
133        elseif paramTypes(i) = "time" then
134            Dim tim As new com.sun.star.util.Time
135
136            Test.StartMethod("setTime()")
137            bOK = true
138            oObj.setTime(i + 1, tim)
139            Test.MethodTested("setTime()", bOK)
140        elseif paramTypes(i) = "timestamp" then
141            Dim timstmp As new com.sun.star.util.DateTime
142
143            Test.StartMethod("setTimestamp()")
144            bOK = true
145            oObj.setTimestamp(i + 1, timstmp)
146            Test.MethodTested("setTimestamp()", bOK)
147        elseif paramTypes(i) = "binarystream" then
148            Test.StartMethod("setBinaryStream()")
149            bOK = true
150            oObj.setBinaryStream(i + 1, ceateUnoService("com.sun.star.io.Pipe"))
151            Test.MethodTested("setBinaryStream()", bOK)
152        elseif paramTypes(i) = "characterstream" then
153            Test.StartMethod("setCharacterStream()")
154            bOK = true
155            oObj.setCharacterStream(i + 1, ceateUnoService("com.sun.star.io.Pipe"))
156            Test.MethodTested("setCharacterStream()", bOK)
157        elseif paramTypes(i) = "object" then
158            Test.StartMethod("setObject()")
159            bOK = true
160            oObj.setObject(i + 1, ceateUnoService("com.sun.star.io.Pipe"))
161            Test.MethodTested("setObject()", bOK)
162        elseif paramTypes(i) = "objectwithinfo" then
163            Out.Log("Don't know how to test this type :(")
164'            Test.StartMethod("setObjectWithInfo()")
165'            bOK = true
166'            oObj.setObjectWithInfo()
167'            bOK = bOK AND false
168'            Test.MethodTested("setObjectWithInfo()", bOK)
169        elseif paramTypes(i) = "ref" then
170            Out.Log("Don't know how to test this type :(")
171'            Test.StartMethod("setRef()")
172'            bOK = true
173'            oObj.setRef()
174'            bOK = bOK AND false
175'            Test.MethodTested("setRef()", bOK)
176        elseif paramTypes(i) = "blob" then
177            Out.Log("Don't know how to test this type :(")
178'            Test.StartMethod("setBlob()")
179'            bOK = true
180'            oObj.setBlob()
181'            bOK = bOK AND false
182'            Test.MethodTested("setBlob()", bOK)
183        elseif paramTypes(i) = "clob" then
184            Out.Log("Don't know how to test this type :(")
185'            Test.StartMethod("setClob()")
186'            bOK = true
187'            oObj.setClob()
188'            bOK = bOK AND false
189'            Test.MethodTested("setClob()", bOK)
190        elseif paramTypes(i) = "array" then
191            Out.Log("Don't know how to test this type :(")
192'            Test.StartMethod("setArray()")
193'            bOK = true
194'            oObj.setArray()
195'            bOK = bOK AND false
196'            Test.MethodTested("setArray()", bOK)
197        end if
198    next i
199
200    Test.StartMethod("clearParameters()")
201    bOK = true
202    oObj.clearParameters()
203    Test.MethodTested("clearParameters()", bOK)
204
205Exit Sub
206ErrHndl:
207    Test.Exception()
208    bOK = false
209    resume next
210End Sub
211</script:module>
212