'************************************************************************* '* '* $RCSfile: sdbc_XResultSet.xba,v $ '* '* $Revision: 1.1 $ '* '* last change:$Date: 2003-01-27 17:52:01 $ '* '* The Contents of this file are made available subject to the terms of '* either of the following licenses '* '* - GNU Lesser General Public License Version 2.1 '* - Sun Industry Standards Source License Version 1.1 '* '* Sun Microsystems Inc., October, 2000 '* '* GNU Lesser General Public License Version 2.1 '* ============================================= '* Copyright 2000 by Sun Microsystems, Inc. '* 901 San Antonio Road, Palo Alto, CA 94303, USA '* '* This library is free software; you can redistribute it and/or '* modify it under the terms of the GNU Lesser General Public '* License version 2.1, as published by the Free Software Foundation. '* '* This library is distributed in the hope that it will be useful, '* but WITHOUT ANY WARRANTY; without even the implied warranty of '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU '* Lesser General Public License for more details. '* '* You should have received a copy of the GNU Lesser General Public '* License along with this library; if not, write to the Free Software '* Foundation, Inc., 59 Temple Place, Suite 330, Boston, '* MA 02111-1307 USA '* '* '* Sun Industry Standards Source License Version 1.1 '* ================================================= '* The contents of this file are subject to the Sun Industry Standards '* Source License Version 1.1 (the "License"); You may not use this file '* except in compliance with the License. You may obtain a copy of the '* License at http://www.openoffice.org/license.html. '* '* Software provided under this License is provided on an "AS IS" basis, '* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, '* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, '* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. '* See the License for the specific provisions governing your rights and '* obligations concerning the Software. '* '* The Initial Developer of the Original Code is: Sun Microsystems, Inc. '* '* Copyright: 2000 by Sun Microsystems, Inc. '* '* All Rights Reserved. '* '* Contributor(s): _______________________________________ '* '* '************************************************************************* '************************************************************************* '************************************************************************* ' This Interface/Service test depends on the following GLOBAL variables, ' which must be specified in the object creation: ' - Global cXResultSetFirstRecord as String ' Global cXResultSetLastRecord as String ' Global cXResultSetRecord1 as String ' Global cXResultSetRecord2 as String ' Global cXResultSet2BeforeLastRecord as String '************************************************************************* Sub RunTest() '************************************************************************* ' INTERFACE: ' com.sun.star.sdbc.XResultSet '************************************************************************* On Error Goto ErrHndl Dim bOK As Boolean Out.Log("ReCreating Object, to be shure that it is in initial state.") Test.StartMethod("beforeFirst()") Test.StartMethod("isBeforeFirst()") Test.StartMethod("isFirst()") Test.StartMethod("first()") Test.StartMethod("next()") Test.StartMethod("afterLast()") Test.StartMethod("isAfterLast()") Test.StartMethod("isLast()") Test.StartMethod("last()") Test.StartMethod("previous()") Test.StartMethod("getRow()") Dim bBeforeFirst As Boolean Dim bIsBeforeFirst As Boolean Dim bIsBeforeFirstLoop As Boolean Dim bIsFirst As Boolean Dim bFirst As Boolean Dim bNext As Boolean Dim bAfterLast As Boolean Dim bIsAfterLast As Boolean Dim bIsAfterLastLoop As Boolean Dim bIsLast As Boolean Dim bLast As Boolean Dim bPrevious As Boolean Dim bGetRow As Boolean Dim bLoopError as Boolean bLoopError = false bBeforeFirst = true bIsBeforeFirst = true bIsFirst = true bFirst = true bNext = true bAfterLast = true bIsAfterLast = true bIsLast = true bLast = true bPrevious = true bGetRow = true oObj.beforeFirst() Out.Log("Initially the cursor should be before first record.") Out.Log("getRow(): expected : 0, actual: " + oObj.getRow()) if (oObj.getRow() = 0) then Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() end if Out.Log("Go to not first record...") oObj.next oObj.next Out.Log("isBeforeFirst(): expected: 'false', actual '" + oObj.isBeforeFirst() + "'") bIsBeforeFirst = bIsBeforeFirst AND NOT oObj.isBeforeFirst() Out.Log("Go to before first record...") oObj.beforeFirst() Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") bBeforeFirst = bBeforeFirst AND oObj.isBeforeFirst() bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() Out.Log("Go to previous position") oObj.previous() Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() bPrevious = bPrevious AND oObj.isBeforeFirst() Out.Log("Go to first record...") oObj.first() Out.Log("isBeforeFirst(): expected: 'false', actual '" + oObj.isBeforeFirst() + "'") bIsBeforeFirst = bIsBeforeFirst AND NOT oObj.isBeforeFirst() Out.Log("isFirst(): expected: 'true', actual '" + oObj.isFirst() + "'") bIsFirst = bIsFirst AND oObj.isFirst() Out.Log("getRow(): expected : 1, actual: " + oObj.getRow()) bIsFirst = bIsFirst AND oObj.getRow() = 1 Out.Log("RowDsc should contain " + cXResultSetFirstRecord) Out.Log("RowDsc is '" + oObj.getString(1) + "'") bFirst = bFirst AND inStr(1, oObj.getString(1), cXResultSetFirstRecord) Out.Log("Go to previous position") oObj.previous() Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() bPrevious = bPrevious AND oObj.isBeforeFirst() Out.Log("isFirst(): expected: 'false', actual '" + oObj.isFirst() + "'") bIsFirst = bIsFirst AND NOT oObj.isFirst() Out.Log("Go to beforeFirst()") oObj.beforeFirst() Out.Log("Iterate through all records form first to last") Dim n As Integer n = 0 bLoopError = false bIsAfterLastLoop = oObj.isAfterLast() while (n < 1000 AND NOT bIsAfterLastLoop) oObj.next() n = n + 1 bIsAfterLastLoop = oObj.isAfterLast() if bLoopError then bLoopError = false n = 1000 end if wend Out.Log("IsAfterLast(): expected: 'true', actual '" + oObj.IsAfterLast() + "'") bIsAfterLast = bIsAfterLast AND oObj.isAfterLast() Out.Log("IsLast(): expected: 'false', actual '" + oObj.IsLast() + "'") bIsLast = bIsLast AND NOT oObj.isLast() Out.Log("Amount of records is " + n) Out.Log("Trying to go to next record") oObj.next() Out.Log("IsAfterLast(): expected: 'true', actual '" + oObj.IsAfterLast() + "'") bIsAfterLast = bIsAfterLast AND oObj.isAfterLast() Out.Log("Go to previous position.") oObj.previous() Out.Log("IsLast(): expected: 'true', actual '" + oObj.IsLast() + "'") bIsLast = bIsLast AND oObj.isLast() Out.Log("RowDsc should contain " + cXResultSetLastRecord) Out.Log("RowDsc is '" + oObj.getString(1) + "'") bIsLast = bIsLast AND inStr(1, oObj.getString(1), cXResultSetLastRecord) Out.Log("Iterate through all records form last to first") bLoopError = false bIsBeforeFirstLoop = oObj.isBeforeFirst() while (n > 0 AND NOT bIsBeforeFirstLoop) oObj.previous() n = n - 1 bIsBeforeFirstLoop = oObj.isBeforeFirst() if bLoopError then bLoopError = false n = 0 end if wend Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() Out.Log("Trying to go to previous record") oObj.previous() Out.Log("isBeforeFirst(): expected: 'true', actual '" + oObj.isBeforeFirst() + "'") bIsBeforeFirst = bIsBeforeFirst AND oObj.isBeforeFirst() Test.MethodTested("beforeFirst()", bBeforeFirst) Test.MethodTested("isBeforeFirst()", bIsBeforeFirst) Test.MethodTested("isFirst()", bIsFirst) Test.MethodTested("first()", bFirst) Test.MethodTested("next()", bNext) Test.MethodTested("afterLast()", bAfterLast) Test.MethodTested("isAfterLast()", bIsAfterLast) Test.MethodTested("isLast()", bIsLast) Test.MethodTested("last()", bLast) Test.MethodTested("previous()", bPrevious) Test.MethodTested("getRow()", bGetRow) Test.StartMethod("absolute()") bOK = true Out.Log("Go to second record") oObj.absolute(2) Out.Log("RowDsc should contain " + cXResultSetRecord2) Out.Log("RowDsc is '" + oObj.getString(1) + "'") bOK = bOK AND inStr(1, oObj.getString(1), cXResultSetRecord2) Out.Log("Go to record -1") oObj.absolute(-1) Out.Log("RowDsc is '" + oObj.getString(1) + "'") Out.Log("IsLast(): expected: 'true', actual '" + oObj.IsLast() + "'") bOK = bOK AND oObj.isLast() Out.Log("Go to record -2") oObj.absolute(-2) Out.Log("IsLast(): expected: 'false', actual '" + oObj.IsLast() + "'") bOK = bOK AND NOT oObj.isLast() Out.Log("RowDsc should contain " + cXResultSet2BeforeLastRecord) Out.Log("RowDsc is '" + oObj.getString(1) + "'") bOK = bOK AND inStr(1, oObj.getString(1), cXResultSet2BeforeLastRecord) Test.MethodTested("absolute()", bOK) Test.StartMethod("relative()") bOK = true Out.Log("Go to before first record") oObj.beforeFirst() on error goto RelativeErrHndl oObj.relative(1) Out.Log("Exception expected!") bOK = false goto ContRelative RelativeErrHndl: Out.Log("Expected exception.") ContRelative: On Error Goto NewErrHndl Out.Log("Go to first record and relative(1)") oObj.next() oObj.relative(1) Out.Log("RowDsc should contain " + cXResultSetRecord2) Out.Log("RowDsc is '" + oObj.getString(1) + "'") bOK = bOK AND inStr(1, oObj.getString(1), cXResultSetRecord2) Out.Log("Go to relative(-1)") oObj.relative(-1) Out.Log("RowDsc should contain " + cXResultSetRecord1) Out.Log("RowDsc is '" + oObj.getString(1) + "'") bOK = bOK AND inStr(1, oObj.getString(1), cXResultSetRecord1) Out.Log("RowDsc is '" + oObj.getString(1) + "'") Test.MethodTested("relative()", bOK) Test.StartMethod("refreshRow()") bOK = true oObj.refreshRow() Test.MethodTested("refreshRow()", bOK) Test.StartMethod("rowUpdated()") bOK = true Out.Log("rowUpdated() is " + oObj.rowUpdated()) bOK = bOK AND NOT oObj.rowUpdated() Test.MethodTested("rowUpdated()", bOK) Test.StartMethod("rowInserted()") bOK = true Out.Log("rowInserted() is " + oObj.rowInserted()) bOK = bOK AND NOT oObj.rowInserted() Test.MethodTested("rowInserted()", bOK) Test.StartMethod("rowDeleted()") bOK = true Out.Log("rowDeleted() is " + oObj.rowDeleted()) bOK = bOK AND NOT oObj.rowDeleted() Test.MethodTested("rowDeleted()", bOK) Test.StartMethod("getStatement()") bOK = true oStatement = oObj.getStatement() bOK = bOK AND NOT isNULL(oStatement) Test.MethodTested("getStatement()", bOK) Exit Sub NewErrHndl: ErrHndl: Test.Exception() bOK = false bLoopError = true resume next End Sub