1*b1cdbd2cSJim Jagielski<?xml version="1.0" encoding="UTF-8"?>
2*b1cdbd2cSJim Jagielski<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3*b1cdbd2cSJim Jagielski<script:module xmlns:script="http://openoffice.org/2000/script" script:name="sdbc_XParameters" script:language="StarBasic">
4*b1cdbd2cSJim Jagielski
5*b1cdbd2cSJim Jagielski
6*b1cdbd2cSJim Jagielski'*************************************************************************
7*b1cdbd2cSJim Jagielski'
8*b1cdbd2cSJim Jagielski'  Licensed to the Apache Software Foundation (ASF) under one
9*b1cdbd2cSJim Jagielski'  or more contributor license agreements.  See the NOTICE file
10*b1cdbd2cSJim Jagielski'  distributed with this work for additional information
11*b1cdbd2cSJim Jagielski'  regarding copyright ownership.  The ASF licenses this file
12*b1cdbd2cSJim Jagielski'  to you under the Apache License, Version 2.0 (the
13*b1cdbd2cSJim Jagielski'  "License"); you may not use this file except in compliance
14*b1cdbd2cSJim Jagielski'  with the License.  You may obtain a copy of the License at
15*b1cdbd2cSJim Jagielski'
16*b1cdbd2cSJim Jagielski'    http://www.apache.org/licenses/LICENSE-2.0
17*b1cdbd2cSJim Jagielski'
18*b1cdbd2cSJim Jagielski'  Unless required by applicable law or agreed to in writing,
19*b1cdbd2cSJim Jagielski'  software distributed under the License is distributed on an
20*b1cdbd2cSJim Jagielski'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21*b1cdbd2cSJim Jagielski'  KIND, either express or implied.  See the License for the
22*b1cdbd2cSJim Jagielski'  specific language governing permissions and limitations
23*b1cdbd2cSJim Jagielski'  under the License.
24*b1cdbd2cSJim Jagielski'
25*b1cdbd2cSJim Jagielski'*************************************************************************
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski
28*b1cdbd2cSJim Jagielski
29*b1cdbd2cSJim Jagielski
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski' Be sure that all variables are dimensioned:
32*b1cdbd2cSJim Jagielskioption explicit
33*b1cdbd2cSJim Jagielski
34*b1cdbd2cSJim Jagielski'*************************************************************************
35*b1cdbd2cSJim Jagielski' This Interface/Service test depends on the following GLOBAL variables,
36*b1cdbd2cSJim Jagielski' which must be specified in the object creation:
37*b1cdbd2cSJim Jagielski
38*b1cdbd2cSJim Jagielski'     - Global paramTypes As Variant
39*b1cdbd2cSJim Jagielski'       Array of Strings which describes the types of the query parameters
40*b1cdbd2cSJim Jagielski
41*b1cdbd2cSJim Jagielski'*************************************************************************
42*b1cdbd2cSJim Jagielski
43*b1cdbd2cSJim Jagielski
44*b1cdbd2cSJim Jagielski
45*b1cdbd2cSJim Jagielski
46*b1cdbd2cSJim Jagielski
47*b1cdbd2cSJim Jagielski
48*b1cdbd2cSJim JagielskiSub RunTest()
49*b1cdbd2cSJim Jagielski
50*b1cdbd2cSJim Jagielski'*************************************************************************
51*b1cdbd2cSJim Jagielski' INTERFACE:
52*b1cdbd2cSJim Jagielski' com.sun.star.sdbc.XParameters
53*b1cdbd2cSJim Jagielski'*************************************************************************
54*b1cdbd2cSJim JagielskiOn Error Goto ErrHndl
55*b1cdbd2cSJim Jagielski    Dim bOK As Boolean
56*b1cdbd2cSJim Jagielski    Dim i As Integer
57*b1cdbd2cSJim Jagielski
58*b1cdbd2cSJim Jagielski    for i = 0 to ubound(paramTypes())
59*b1cdbd2cSJim Jagielski        if (paramTypes(i) = "boolean") OR (paramTypes(i) = "byte") OR (paramTypes(i) = "short") OR _
60*b1cdbd2cSJim Jagielski           (paramTypes(i) = "int") OR (paramTypes(i) = "long") OR (paramTypes(i) = "float") OR _
61*b1cdbd2cSJim Jagielski           (paramTypes(i) = "double") OR (paramTypes(i) = "string") OR (paramTypes(i) = "bytes") OR _
62*b1cdbd2cSJim Jagielski           (paramTypes(i) = "date") OR (paramTypes(i) = "time") OR (paramTypes(i) = "timestamp") OR _
63*b1cdbd2cSJim Jagielski           (paramTypes(i) = "binarystream") OR (paramTypes(i) = "characterstream") then
64*b1cdbd2cSJim Jagielski
65*b1cdbd2cSJim Jagielski            bOK = true
66*b1cdbd2cSJim Jagielski            oObj.setNull(i + 1, paramTypes(i))
67*b1cdbd2cSJim Jagielski            Test.MethodTested("setNull()", bOK)
68*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "ref" then
69*b1cdbd2cSJim Jagielski            Out.Log("Don't know how to test this :(")
70*b1cdbd2cSJim Jagielski'            bOK = true
71*b1cdbd2cSJim Jagielski'            oObj.setObjectNull(i)
72*b1cdbd2cSJim Jagielski'            Test.MethodTested("setNull()", bOK)
73*b1cdbd2cSJim Jagielski        end if
74*b1cdbd2cSJim Jagielski
75*b1cdbd2cSJim Jagielski
76*b1cdbd2cSJim Jagielski        if paramTypes(i) = "boolean" then
77*b1cdbd2cSJim Jagielski            Test.StartMethod("setBoolean()")
78*b1cdbd2cSJim Jagielski            bOK = true
79*b1cdbd2cSJim Jagielski            oObj.setBoolean(i + 1, true)
80*b1cdbd2cSJim Jagielski            Test.MethodTested("setBoolean()", bOK)
81*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "byte" then
82*b1cdbd2cSJim Jagielski            Test.StartMethod("setByte()")
83*b1cdbd2cSJim Jagielski            bOK = true
84*b1cdbd2cSJim Jagielski            oObj.setByte(i + 1, 5)
85*b1cdbd2cSJim Jagielski            Test.MethodTested("setByte()", bOK)
86*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "short" then
87*b1cdbd2cSJim Jagielski            Test.StartMethod("setShort()")
88*b1cdbd2cSJim Jagielski            bOK = true
89*b1cdbd2cSJim Jagielski            oObj.setShort(i + 1, 6)
90*b1cdbd2cSJim Jagielski            Test.MethodTested("setShort()", bOK)
91*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "int" then
92*b1cdbd2cSJim Jagielski            Test.StartMethod("setInt()")
93*b1cdbd2cSJim Jagielski            bOK = true
94*b1cdbd2cSJim Jagielski            oObj.setInt(i + 1, 234)
95*b1cdbd2cSJim Jagielski            Test.MethodTested("setInt()", bOK)
96*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "long" then
97*b1cdbd2cSJim Jagielski            Test.StartMethod("setLong()")
98*b1cdbd2cSJim Jagielski            bOK = true
99*b1cdbd2cSJim Jagielski            oObj.setLong(i + 1, 34656)
100*b1cdbd2cSJim Jagielski            Test.MethodTested("setLong()", bOK)
101*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "float" then
102*b1cdbd2cSJim Jagielski            Test.StartMethod("setFloat()")
103*b1cdbd2cSJim Jagielski            bOK = true
104*b1cdbd2cSJim Jagielski            oObj.setFloat(i + 1, 98.765)
105*b1cdbd2cSJim Jagielski            Test.MethodTested("setFloat()", bOK)
106*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "double" then
107*b1cdbd2cSJim Jagielski            Test.StartMethod("setDouble()")
108*b1cdbd2cSJim Jagielski            bOK = true
109*b1cdbd2cSJim Jagielski            oObj.setDouble(i + 1, 54.432)
110*b1cdbd2cSJim Jagielski            Test.MethodTested("setDouble()", bOK)
111*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "string" then
112*b1cdbd2cSJim Jagielski            Test.StartMethod("setString()")
113*b1cdbd2cSJim Jagielski            bOK = true
114*b1cdbd2cSJim Jagielski            oObj.setString(i + 1, "XParameters")
115*b1cdbd2cSJim Jagielski            Test.MethodTested("setString()", bOK)
116*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "bytes" then
117*b1cdbd2cSJim Jagielski            Test.StartMethod("setBytes()")
118*b1cdbd2cSJim Jagielski            bOK = true
119*b1cdbd2cSJim Jagielski            oObj.setBytes(i + 1, Array(1,2,3))
120*b1cdbd2cSJim Jagielski            Test.MethodTested("setBytes()", bOK)
121*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "date" then
122*b1cdbd2cSJim Jagielski            Dim dat As new com.sun.star.util.Date
123*b1cdbd2cSJim Jagielski
124*b1cdbd2cSJim Jagielski            Test.StartMethod("setDate()")
125*b1cdbd2cSJim Jagielski            bOK = true
126*b1cdbd2cSJim Jagielski            oObj.setDate(i + 1, dat)
127*b1cdbd2cSJim Jagielski            Test.MethodTested("setDate()", bOK)
128*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "time" then
129*b1cdbd2cSJim Jagielski            Dim tim As new com.sun.star.util.Time
130*b1cdbd2cSJim Jagielski
131*b1cdbd2cSJim Jagielski            Test.StartMethod("setTime()")
132*b1cdbd2cSJim Jagielski            bOK = true
133*b1cdbd2cSJim Jagielski            oObj.setTime(i + 1, tim)
134*b1cdbd2cSJim Jagielski            Test.MethodTested("setTime()", bOK)
135*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "timestamp" then
136*b1cdbd2cSJim Jagielski            Dim timstmp As new com.sun.star.util.DateTime
137*b1cdbd2cSJim Jagielski
138*b1cdbd2cSJim Jagielski            Test.StartMethod("setTimestamp()")
139*b1cdbd2cSJim Jagielski            bOK = true
140*b1cdbd2cSJim Jagielski            oObj.setTimestamp(i + 1, timstmp)
141*b1cdbd2cSJim Jagielski            Test.MethodTested("setTimestamp()", bOK)
142*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "binarystream" then
143*b1cdbd2cSJim Jagielski            Test.StartMethod("setBinaryStream()")
144*b1cdbd2cSJim Jagielski            bOK = true
145*b1cdbd2cSJim Jagielski            oObj.setBinaryStream(i + 1, ceateUnoService("com.sun.star.io.Pipe"))
146*b1cdbd2cSJim Jagielski            Test.MethodTested("setBinaryStream()", bOK)
147*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "characterstream" then
148*b1cdbd2cSJim Jagielski            Test.StartMethod("setCharacterStream()")
149*b1cdbd2cSJim Jagielski            bOK = true
150*b1cdbd2cSJim Jagielski            oObj.setCharacterStream(i + 1, ceateUnoService("com.sun.star.io.Pipe"))
151*b1cdbd2cSJim Jagielski            Test.MethodTested("setCharacterStream()", bOK)
152*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "object" then
153*b1cdbd2cSJim Jagielski            Test.StartMethod("setObject()")
154*b1cdbd2cSJim Jagielski            bOK = true
155*b1cdbd2cSJim Jagielski            oObj.setObject(i + 1, ceateUnoService("com.sun.star.io.Pipe"))
156*b1cdbd2cSJim Jagielski            Test.MethodTested("setObject()", bOK)
157*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "objectwithinfo" then
158*b1cdbd2cSJim Jagielski            Out.Log("Don't know how to test this type :(")
159*b1cdbd2cSJim Jagielski'            Test.StartMethod("setObjectWithInfo()")
160*b1cdbd2cSJim Jagielski'            bOK = true
161*b1cdbd2cSJim Jagielski'            oObj.setObjectWithInfo()
162*b1cdbd2cSJim Jagielski'            bOK = bOK AND false
163*b1cdbd2cSJim Jagielski'            Test.MethodTested("setObjectWithInfo()", bOK)
164*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "ref" then
165*b1cdbd2cSJim Jagielski            Out.Log("Don't know how to test this type :(")
166*b1cdbd2cSJim Jagielski'            Test.StartMethod("setRef()")
167*b1cdbd2cSJim Jagielski'            bOK = true
168*b1cdbd2cSJim Jagielski'            oObj.setRef()
169*b1cdbd2cSJim Jagielski'            bOK = bOK AND false
170*b1cdbd2cSJim Jagielski'            Test.MethodTested("setRef()", bOK)
171*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "blob" then
172*b1cdbd2cSJim Jagielski            Out.Log("Don't know how to test this type :(")
173*b1cdbd2cSJim Jagielski'            Test.StartMethod("setBlob()")
174*b1cdbd2cSJim Jagielski'            bOK = true
175*b1cdbd2cSJim Jagielski'            oObj.setBlob()
176*b1cdbd2cSJim Jagielski'            bOK = bOK AND false
177*b1cdbd2cSJim Jagielski'            Test.MethodTested("setBlob()", bOK)
178*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "clob" then
179*b1cdbd2cSJim Jagielski            Out.Log("Don't know how to test this type :(")
180*b1cdbd2cSJim Jagielski'            Test.StartMethod("setClob()")
181*b1cdbd2cSJim Jagielski'            bOK = true
182*b1cdbd2cSJim Jagielski'            oObj.setClob()
183*b1cdbd2cSJim Jagielski'            bOK = bOK AND false
184*b1cdbd2cSJim Jagielski'            Test.MethodTested("setClob()", bOK)
185*b1cdbd2cSJim Jagielski        elseif paramTypes(i) = "array" then
186*b1cdbd2cSJim Jagielski            Out.Log("Don't know how to test this type :(")
187*b1cdbd2cSJim Jagielski'            Test.StartMethod("setArray()")
188*b1cdbd2cSJim Jagielski'            bOK = true
189*b1cdbd2cSJim Jagielski'            oObj.setArray()
190*b1cdbd2cSJim Jagielski'            bOK = bOK AND false
191*b1cdbd2cSJim Jagielski'            Test.MethodTested("setArray()", bOK)
192*b1cdbd2cSJim Jagielski        end if
193*b1cdbd2cSJim Jagielski    next i
194*b1cdbd2cSJim Jagielski
195*b1cdbd2cSJim Jagielski    Test.StartMethod("clearParameters()")
196*b1cdbd2cSJim Jagielski    bOK = true
197*b1cdbd2cSJim Jagielski    oObj.clearParameters()
198*b1cdbd2cSJim Jagielski    Test.MethodTested("clearParameters()", bOK)
199*b1cdbd2cSJim Jagielski
200*b1cdbd2cSJim JagielskiExit Sub
201*b1cdbd2cSJim JagielskiErrHndl:
202*b1cdbd2cSJim Jagielski    Test.Exception()
203*b1cdbd2cSJim Jagielski    bOK = false
204*b1cdbd2cSJim Jagielski    resume next
205*b1cdbd2cSJim JagielskiEnd Sub
206*b1cdbd2cSJim Jagielski</script:module>
207