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