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_XRow" 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 rowTypes As Variant 45' Array of Strings with description of column types 46 47'************************************************************************* 48 49 50 51 52 53 54Sub RunTest() 55 56'************************************************************************* 57' INTERFACE: 58' com.sun.star.sdbc.XRow 59'************************************************************************* 60On Error Goto ErrHndl 61 Dim bOK As Boolean 62 Dim i As Integer 63 Dim colType As String 64 65 Test.StartMethod("getBoolean()") 66 bOK = true 67 colType = "boolean" 68 i = findColumn(colType) 69 if i >= 0 then 70 oObj.getBoolean(i) 71 else 72 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 73 Out.Log("Nevertheless status is OK") 74 end if 75 Test.MethodTested("getBoolean()", bOK) 76 77 Test.StartMethod("getByte()") 78 bOK = true 79 colType = "byte" 80 i = findColumn(colType) 81 if i >= 0 then 82 oObj.getByte(i + 1) 83 else 84 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 85 Out.Log("Nevertheless status is OK") 86 end if 87 Test.MethodTested("getByte()", bOK) 88 89 Test.StartMethod("getShort()") 90 bOK = true 91 colType = "short" 92 i = findColumn(colType) 93 if i >= 0 then 94 oObj.getShort(i + 1) 95 else 96 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 97 Out.Log("Nevertheless status is OK") 98 end if 99 Test.MethodTested("getShort()", bOK) 100 101 Test.StartMethod("getInt()") 102 bOK = true 103 colType = "int" 104 i = findColumn(colType) 105 if i >= 0 then 106 oObj.getInt(i + 1) 107 else 108 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 109 Out.Log("Nevertheless status is OK") 110 end if 111 Test.MethodTested("getInt()", bOK) 112 113 Test.StartMethod("getLong()") 114 bOK = true 115 colType = "long" 116 i = findColumn(colType) 117 if i >= 0 then 118 oObj.getLong(i + 1) 119 else 120 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 121 Out.Log("Nevertheless status is OK") 122 end if 123 Test.MethodTested("getLong()", bOK) 124 125 Test.StartMethod("getFloat()") 126 bOK = true 127 colType = "float" 128 i = findColumn(colType) 129 if i >= 0 then 130 oObj.getFloat(i + 1) 131 else 132 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 133 Out.Log("Nevertheless status is OK") 134 end if 135 Test.MethodTested("getFloat()", bOK) 136 137 Test.StartMethod("getDouble()") 138 bOK = true 139 colType = "double" 140 i = findColumn(colType) 141 if i >= 0 then 142 oObj.getDouble(i + 1) 143 else 144 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 145 Out.Log("Nevertheless status is OK") 146 end if 147 Test.MethodTested("getDouble()", bOK) 148 149 Test.StartMethod("getString()") 150 bOK = true 151 colType = "string" 152 i = findColumn(colType) 153 if i >= 0 then 154 oObj.getString(i + 1) 155 else 156 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 157 Out.Log("Nevertheless status is OK") 158 end if 159 Test.MethodTested("getString()", bOK) 160 161 Test.StartMethod("getBytes()") 162 bOK = true 163 colType = "bytes" 164 i = findColumn(colType) 165 if i >= 0 then 166 oObj.getBytes(i + 1) 167 else 168 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 169 Out.Log("Nevertheless status is OK") 170 end if 171 Test.MethodTested("getBytes()", bOK) 172 173 Test.StartMethod("getDate()") 174 bOK = true 175 colType = "date" 176 i = findColumn(colType) 177 if i >= 0 then 178 oObj.getDate(i + 1) 179 else 180 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 181 Out.Log("Nevertheless status is OK") 182 end if 183 Test.MethodTested("getDate()", bOK) 184 185 Test.StartMethod("getTime()") 186 bOK = true 187 colType = "time" 188 i = findColumn(colType) 189 if i >= 0 then 190 oObj.getTime(i + 1) 191 else 192 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 193 Out.Log("Nevertheless status is OK") 194 end if 195 Test.MethodTested("getTime()", bOK) 196 197 Test.StartMethod("getTimestamp()") 198 bOK = true 199 colType = "timestamp" 200 i = findColumn(colType) 201 if i >= 0 then 202 oObj.getTimestamp(i + 1) 203 else 204 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 205 Out.Log("Nevertheless status is OK") 206 end if 207 Test.MethodTested("getTimestamp()", bOK) 208 209 Test.StartMethod("getBinaryStream()") 210 bOK = true 211 colType = "binarystream" 212 i = findColumn(colType) 213 if i >= 0 then 214 oObj.getBinaryStream(i + 1) 215 else 216 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 217 Out.Log("Nevertheless status is OK") 218 end if 219 Test.MethodTested("getBinaryStream()", bOK) 220 221 Test.StartMethod("getCharacterStream()") 222 bOK = true 223 colType = "characterstream" 224 i = findColumn(colType) 225 if i >= 0 then 226 oObj.getCharacterStream(i + 1) 227 else 228 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 229 Out.Log("Nevertheless status is OK") 230 end if 231 Test.MethodTested("getCharacterStream()", bOK) 232 233 Test.StartMethod("getObject()") 234 bOK = true 235 colType = "object" 236 i = findColumn(colType) 237 if i >= 0 then 238 oObj.getObject(i + 1) 239 else 240 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 241 Out.Log("Nevertheless status is OK") 242 end if 243 Test.MethodTested("getObject()", bOK) 244 245 Test.StartMethod("getRef()") 246 bOK = true 247 colType = "ref" 248 i = findColumn(colType) 249 if i >= 0 then 250 oObj.getRef(i + 1) 251 else 252 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 253 Out.Log("Nevertheless status is OK") 254 end if 255 Test.MethodTested("getRef()", bOK) 256 257 Test.StartMethod("getBlob()") 258 bOK = true 259 colType = "blob" 260 i = findColumn(colType) 261 if i >= 0 then 262 oObj.getBlob(i + 1) 263 else 264 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 265 Out.Log("Nevertheless status is OK") 266 end if 267 Test.MethodTested("getBlob()", bOK) 268 269 Test.StartMethod("getClob()") 270 bOK = true 271 colType = "clob" 272 i = findColumn(colType) 273 if i >= 0 then 274 oObj.getClob(i + 1) 275 else 276 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 277 Out.Log("Nevertheless status is OK") 278 end if 279 Test.MethodTested("getClob()", bOK) 280 281 Test.StartMethod("getArray()") 282 bOK = true 283 colType = "array" 284 i = findColumn(colType) 285 if i >= 0 then 286 oObj.getArray(i + 1) 287 else 288 Out.Log("!!! Column of type '" + colType + "' is not found. No test performed.") 289 Out.Log("Nevertheless status is OK") 290 end if 291 Test.MethodTested("getArray()", bOK) 292 293 294 Test.StartMethod("wasNull()") 295 bOK = true 296 oObj.wasNull() 297 Test.MethodTested("wasNull()", bOK) 298 299Exit Sub 300ErrHndl: 301 Test.Exception() 302 bOK = false 303 resume next 304End Sub 305 306Function findColumn(cType As String) As Integer 307 Dim i As Integer 308 309 for i = lbound(rowTypes()) to ubound(rowTypes()) 310 if rowTypes(i) = cType then 311 findColumn() = rowTypesCol(i) 312 exit function 313 end if 314 next i 315 316 findColumn() = -1 317End function 318</script:module> 319