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