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