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_XResultSet" 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'************************************************************************* 32cdf0e10cSrcweir' This Interface/Service test depends on the following GLOBAL variables, 33cdf0e10cSrcweir' which must be specified in the object creation: 34cdf0e10cSrcweir 35cdf0e10cSrcweir' - Global cXResultSetFirstRecord as String 36cdf0e10cSrcweir' Global cXResultSetLastRecord as String 37cdf0e10cSrcweir' Global cXResultSetRecord1 as String 38cdf0e10cSrcweir' Global cXResultSetRecord2 as String 39cdf0e10cSrcweir' Global cXResultSet2BeforeLastRecord as String 40cdf0e10cSrcweir 41cdf0e10cSrcweir'************************************************************************* 42cdf0e10cSrcweir 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir 46cdf0e10cSrcweir 47cdf0e10cSrcweirSub RunTest() 48cdf0e10cSrcweir 49cdf0e10cSrcweir'************************************************************************* 50cdf0e10cSrcweir' INTERFACE: 51cdf0e10cSrcweir' com.sun.star.sdbc.XResultSet 52cdf0e10cSrcweir'************************************************************************* 53cdf0e10cSrcweirOn Error Goto ErrHndl 54cdf0e10cSrcweir Dim bOK As Boolean 55cdf0e10cSrcweir 56cdf0e10cSrcweir 57cdf0e10cSrcweir Out.Log("ReCreating Object, to be shure that it is in initial state.") 58cdf0e10cSrcweir 59cdf0e10cSrcweir Test.StartMethod("beforeFirst()") 60cdf0e10cSrcweir Test.StartMethod("isBeforeFirst()") 61cdf0e10cSrcweir Test.StartMethod("isFirst()") 62cdf0e10cSrcweir Test.StartMethod("first()") 63cdf0e10cSrcweir Test.StartMethod("next()") 64cdf0e10cSrcweir 65cdf0e10cSrcweir Test.StartMethod("afterLast()") 66cdf0e10cSrcweir Test.StartMethod("isAfterLast()") 67cdf0e10cSrcweir Test.StartMethod("isLast()") 68cdf0e10cSrcweir Test.StartMethod("last()") 69cdf0e10cSrcweir Test.StartMethod("previous()") 70cdf0e10cSrcweir 71cdf0e10cSrcweir Test.StartMethod("getRow()") 72cdf0e10cSrcweir 73cdf0e10cSrcweir Dim bBeforeFirst As Boolean 74cdf0e10cSrcweir Dim bIsBeforeFirst As Boolean 75cdf0e10cSrcweir Dim bIsBeforeFirstLoop As Boolean 76cdf0e10cSrcweir Dim bIsFirst As Boolean 77cdf0e10cSrcweir Dim bFirst As Boolean 78cdf0e10cSrcweir Dim bNext As Boolean 79cdf0e10cSrcweir Dim bAfterLast As Boolean 80cdf0e10cSrcweir Dim bIsAfterLast As Boolean 81cdf0e10cSrcweir Dim bIsAfterLastLoop As Boolean 82cdf0e10cSrcweir Dim bIsLast As Boolean 83cdf0e10cSrcweir Dim bLast As Boolean 84cdf0e10cSrcweir Dim bPrevious As Boolean 85cdf0e10cSrcweir Dim bGetRow As Boolean 86cdf0e10cSrcweir Dim bLoopError as Boolean 87cdf0e10cSrcweir 88cdf0e10cSrcweir bLoopError = false 89cdf0e10cSrcweir bBeforeFirst = true 90cdf0e10cSrcweir bIsBeforeFirst = true 91cdf0e10cSrcweir bIsFirst = true 92cdf0e10cSrcweir bFirst = true 93cdf0e10cSrcweir bNext = true 94cdf0e10cSrcweir bAfterLast = true 95cdf0e10cSrcweir bIsAfterLast = true 96cdf0e10cSrcweir bIsLast = true 97cdf0e10cSrcweir bLast = true 98cdf0e10cSrcweir bPrevious = true 99cdf0e10cSrcweir bGetRow = true 100cdf0e10cSrcweir 101cdf0e10cSrcweir oObj.beforeFirst() 102cdf0e10cSrcweir 103cdf0e10cSrcweir Out.Log("Initially the cursor should be before first record.") 104cdf0e10cSrcweir Out.Log("getRow(): expected : 0, actual: " + oObj.getRow()) 105cdf0e10cSrcweir if (oObj.getRow() = 0) then 106cdf0e10cSrcweir Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") 107cdf0e10cSrcweir bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() 108cdf0e10cSrcweir end if 109cdf0e10cSrcweir 110cdf0e10cSrcweir Out.Log("Go to not first record...") 111cdf0e10cSrcweir oObj.next 112cdf0e10cSrcweir oObj.next 113cdf0e10cSrcweir Out.Log("isBeforeFirst(): expected: 'false', actual '" + oObj.isBeforeFirst() + "'") 114cdf0e10cSrcweir bIsBeforeFirst = bIsBeforeFirst AND NOT oObj.isBeforeFirst() 115cdf0e10cSrcweir 116cdf0e10cSrcweir Out.Log("Go to before first record...") 117cdf0e10cSrcweir oObj.beforeFirst() 118cdf0e10cSrcweir Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") 119cdf0e10cSrcweir bBeforeFirst = bBeforeFirst AND oObj.isBeforeFirst() 120cdf0e10cSrcweir bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() 121cdf0e10cSrcweir 122cdf0e10cSrcweir Out.Log("Go to previous position") 123cdf0e10cSrcweir oObj.previous() 124cdf0e10cSrcweir Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") 125cdf0e10cSrcweir bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() 126cdf0e10cSrcweir bPrevious = bPrevious AND oObj.isBeforeFirst() 127cdf0e10cSrcweir 128cdf0e10cSrcweir Out.Log("Go to first record...") 129cdf0e10cSrcweir oObj.first() 130cdf0e10cSrcweir Out.Log("isBeforeFirst(): expected: 'false', actual '" + oObj.isBeforeFirst() + "'") 131cdf0e10cSrcweir bIsBeforeFirst = bIsBeforeFirst AND NOT oObj.isBeforeFirst() 132cdf0e10cSrcweir Out.Log("isFirst(): expected: 'true', actual '" + oObj.isFirst() + "'") 133cdf0e10cSrcweir bIsFirst = bIsFirst AND oObj.isFirst() 134cdf0e10cSrcweir Out.Log("getRow(): expected : 1, actual: " + oObj.getRow()) 135cdf0e10cSrcweir bIsFirst = bIsFirst AND oObj.getRow() = 1 136cdf0e10cSrcweir Out.Log("RowDsc should contain " + cXResultSetFirstRecord) 137cdf0e10cSrcweir Out.Log("RowDsc is '" + oObj.getString(1) + "'") 138cdf0e10cSrcweir bFirst = bFirst AND inStr(1, oObj.getString(1), cXResultSetFirstRecord) 139cdf0e10cSrcweir 140cdf0e10cSrcweir Out.Log("Go to previous position") 141cdf0e10cSrcweir oObj.previous() 142cdf0e10cSrcweir Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") 143cdf0e10cSrcweir bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() 144cdf0e10cSrcweir bPrevious = bPrevious AND oObj.isBeforeFirst() 145cdf0e10cSrcweir Out.Log("isFirst(): expected: 'false', actual '" + oObj.isFirst() + "'") 146cdf0e10cSrcweir bIsFirst = bIsFirst AND NOT oObj.isFirst() 147cdf0e10cSrcweir 148cdf0e10cSrcweir Out.Log("Go to beforeFirst()") 149cdf0e10cSrcweir oObj.beforeFirst() 150cdf0e10cSrcweir Out.Log("Iterate through all records form first to last") 151cdf0e10cSrcweir Dim n As Integer 152cdf0e10cSrcweir n = 0 153cdf0e10cSrcweir bLoopError = false 154cdf0e10cSrcweir bIsAfterLastLoop = oObj.isAfterLast() 155cdf0e10cSrcweir while (n < 1000 AND NOT bIsAfterLastLoop) 156cdf0e10cSrcweir oObj.next() 157cdf0e10cSrcweir n = n + 1 158cdf0e10cSrcweir bIsAfterLastLoop = oObj.isAfterLast() 159cdf0e10cSrcweir if bLoopError then 160cdf0e10cSrcweir bLoopError = false 161cdf0e10cSrcweir n = 1000 162cdf0e10cSrcweir end if 163cdf0e10cSrcweir wend 164cdf0e10cSrcweir 165cdf0e10cSrcweir Out.Log("IsAfterLast(): expected: 'true', actual '" + oObj.IsAfterLast() + "'") 166cdf0e10cSrcweir bIsAfterLast = bIsAfterLast AND oObj.isAfterLast() 167cdf0e10cSrcweir Out.Log("IsLast(): expected: 'false', actual '" + oObj.IsLast() + "'") 168cdf0e10cSrcweir bIsLast = bIsLast AND NOT oObj.isLast() 169cdf0e10cSrcweir Out.Log("Amount of records is " + n) 170cdf0e10cSrcweir Out.Log("Trying to go to next record") 171cdf0e10cSrcweir oObj.next() 172cdf0e10cSrcweir Out.Log("IsAfterLast(): expected: 'true', actual '" + oObj.IsAfterLast() + "'") 173cdf0e10cSrcweir bIsAfterLast = bIsAfterLast AND oObj.isAfterLast() 174cdf0e10cSrcweir 175cdf0e10cSrcweir Out.Log("Go to previous position.") 176cdf0e10cSrcweir oObj.previous() 177cdf0e10cSrcweir Out.Log("IsLast(): expected: 'true', actual '" + oObj.IsLast() + "'") 178cdf0e10cSrcweir bIsLast = bIsLast AND oObj.isLast() 179cdf0e10cSrcweir Out.Log("RowDsc should contain " + cXResultSetLastRecord) 180cdf0e10cSrcweir Out.Log("RowDsc is '" + oObj.getString(1) + "'") 181cdf0e10cSrcweir bIsLast = bIsLast AND inStr(1, oObj.getString(1), cXResultSetLastRecord) 182cdf0e10cSrcweir 183cdf0e10cSrcweir Out.Log("Iterate through all records form last to first") 184cdf0e10cSrcweir bLoopError = false 185cdf0e10cSrcweir bIsBeforeFirstLoop = oObj.isBeforeFirst() 186cdf0e10cSrcweir while (n > 0 AND NOT bIsBeforeFirstLoop) 187cdf0e10cSrcweir oObj.previous() 188cdf0e10cSrcweir n = n - 1 189cdf0e10cSrcweir bIsBeforeFirstLoop = oObj.isBeforeFirst() 190cdf0e10cSrcweir if bLoopError then 191cdf0e10cSrcweir bLoopError = false 192cdf0e10cSrcweir n = 0 193cdf0e10cSrcweir end if 194cdf0e10cSrcweir wend 195cdf0e10cSrcweir 196cdf0e10cSrcweir Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") 197cdf0e10cSrcweir bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() 198cdf0e10cSrcweir 199cdf0e10cSrcweir Out.Log("Trying to go to previous record") 200cdf0e10cSrcweir oObj.previous() 201cdf0e10cSrcweir Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") 202cdf0e10cSrcweir bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() 203cdf0e10cSrcweir 204cdf0e10cSrcweir 205cdf0e10cSrcweir Test.MethodTested("beforeFirst()", bBeforeFirst) 206cdf0e10cSrcweir Test.MethodTested("isBeforeFirst()", bIsBeforeFirst) 207cdf0e10cSrcweir Test.MethodTested("isFirst()", bIsFirst) 208cdf0e10cSrcweir Test.MethodTested("first()", bFirst) 209cdf0e10cSrcweir Test.MethodTested("next()", bNext) 210cdf0e10cSrcweir 211cdf0e10cSrcweir Test.MethodTested("afterLast()", bAfterLast) 212cdf0e10cSrcweir Test.MethodTested("isAfterLast()", bIsAfterLast) 213cdf0e10cSrcweir Test.MethodTested("isLast()", bIsLast) 214cdf0e10cSrcweir Test.MethodTested("last()", bLast) 215cdf0e10cSrcweir Test.MethodTested("previous()", bPrevious) 216cdf0e10cSrcweir 217cdf0e10cSrcweir Test.MethodTested("getRow()", bGetRow) 218cdf0e10cSrcweir 219cdf0e10cSrcweir 220cdf0e10cSrcweir Test.StartMethod("absolute()") 221cdf0e10cSrcweir bOK = true 222cdf0e10cSrcweir Out.Log("Go to second record") 223cdf0e10cSrcweir oObj.absolute(2) 224cdf0e10cSrcweir Out.Log("RowDsc should contain " + cXResultSetRecord2) 225cdf0e10cSrcweir Out.Log("RowDsc is '" + oObj.getString(1) + "'") 226cdf0e10cSrcweir bOK = bOK AND inStr(1, oObj.getString(1), cXResultSetRecord2) 227cdf0e10cSrcweir Out.Log("Go to record -1") 228cdf0e10cSrcweir oObj.absolute(-1) 229cdf0e10cSrcweir Out.Log("RowDsc is '" + oObj.getString(1) + "'") 230cdf0e10cSrcweir Out.Log("IsLast(): expected: 'true', actual '" + oObj.IsLast() + "'") 231cdf0e10cSrcweir bOK = bOK AND oObj.isLast() 232cdf0e10cSrcweir Out.Log("Go to record -2") 233cdf0e10cSrcweir oObj.absolute(-2) 234cdf0e10cSrcweir Out.Log("IsLast(): expected: 'false', actual '" + oObj.IsLast() + "'") 235cdf0e10cSrcweir bOK = bOK AND NOT oObj.isLast() 236cdf0e10cSrcweir Out.Log("RowDsc should contain " + cXResultSet2BeforeLastRecord) 237cdf0e10cSrcweir Out.Log("RowDsc is '" + oObj.getString(1) + "'") 238cdf0e10cSrcweir bOK = bOK AND inStr(1, oObj.getString(1), cXResultSet2BeforeLastRecord) 239cdf0e10cSrcweir Test.MethodTested("absolute()", bOK) 240cdf0e10cSrcweir 241cdf0e10cSrcweir Test.StartMethod("relative()") 242cdf0e10cSrcweir bOK = true 243cdf0e10cSrcweir Out.Log("Go to before first record") 244cdf0e10cSrcweir oObj.beforeFirst() 245cdf0e10cSrcweir on error goto RelativeErrHndl 246cdf0e10cSrcweir oObj.relative(1) 247cdf0e10cSrcweir Out.Log("Exception expected!") 248cdf0e10cSrcweir bOK = false 249cdf0e10cSrcweir goto ContRelative 250cdf0e10cSrcweir RelativeErrHndl: 251cdf0e10cSrcweir Out.Log("Expected exception.") 252cdf0e10cSrcweir 253cdf0e10cSrcweir ContRelative: 254cdf0e10cSrcweir On Error Goto NewErrHndl 255cdf0e10cSrcweir Out.Log("Go to first record and relative(1)") 256cdf0e10cSrcweir oObj.next() 257cdf0e10cSrcweir oObj.relative(1) 258cdf0e10cSrcweir Out.Log("RowDsc should contain " + cXResultSetRecord2) 259cdf0e10cSrcweir Out.Log("RowDsc is '" + oObj.getString(1) + "'") 260cdf0e10cSrcweir bOK = bOK AND inStr(1, oObj.getString(1), cXResultSetRecord2) 261cdf0e10cSrcweir Out.Log("Go to relative(-1)") 262cdf0e10cSrcweir oObj.relative(-1) 263cdf0e10cSrcweir Out.Log("RowDsc should contain " + cXResultSetRecord1) 264cdf0e10cSrcweir Out.Log("RowDsc is '" + oObj.getString(1) + "'") 265cdf0e10cSrcweir bOK = bOK AND inStr(1, oObj.getString(1), cXResultSetRecord1) 266cdf0e10cSrcweir Out.Log("RowDsc is '" + oObj.getString(1) + "'") 267cdf0e10cSrcweir Test.MethodTested("relative()", bOK) 268cdf0e10cSrcweir 269cdf0e10cSrcweir Test.StartMethod("refreshRow()") 270cdf0e10cSrcweir bOK = true 271cdf0e10cSrcweir oObj.refreshRow() 272cdf0e10cSrcweir Test.MethodTested("refreshRow()", bOK) 273cdf0e10cSrcweir 274cdf0e10cSrcweir Test.StartMethod("rowUpdated()") 275cdf0e10cSrcweir bOK = true 276cdf0e10cSrcweir Out.Log("rowUpdated() is " + oObj.rowUpdated()) 277cdf0e10cSrcweir bOK = bOK AND NOT oObj.rowUpdated() 278cdf0e10cSrcweir Test.MethodTested("rowUpdated()", bOK) 279cdf0e10cSrcweir 280cdf0e10cSrcweir Test.StartMethod("rowInserted()") 281cdf0e10cSrcweir bOK = true 282cdf0e10cSrcweir Out.Log("rowInserted() is " + oObj.rowInserted()) 283cdf0e10cSrcweir bOK = bOK AND NOT oObj.rowInserted() 284cdf0e10cSrcweir Test.MethodTested("rowInserted()", bOK) 285cdf0e10cSrcweir 286cdf0e10cSrcweir Test.StartMethod("rowDeleted()") 287cdf0e10cSrcweir bOK = true 288cdf0e10cSrcweir Out.Log("rowDeleted() is " + oObj.rowDeleted()) 289cdf0e10cSrcweir bOK = bOK AND NOT oObj.rowDeleted() 290cdf0e10cSrcweir Test.MethodTested("rowDeleted()", bOK) 291cdf0e10cSrcweir 292cdf0e10cSrcweir Test.StartMethod("getStatement()") 293cdf0e10cSrcweir bOK = true 294cdf0e10cSrcweir oStatement = oObj.getStatement() 295cdf0e10cSrcweir bOK = bOK AND NOT isNULL(oStatement) 296cdf0e10cSrcweir Test.MethodTested("getStatement()", bOK) 297cdf0e10cSrcweir 298cdf0e10cSrcweirExit Sub 299cdf0e10cSrcweirNewErrHndl: 300cdf0e10cSrcweirErrHndl: 301cdf0e10cSrcweir Test.Exception() 302cdf0e10cSrcweir bOK = false 303cdf0e10cSrcweir bLoopError = true 304cdf0e10cSrcweir resume next 305cdf0e10cSrcweirEnd Sub 306cdf0e10cSrcweir</script:module> 307