1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski package ifc.sdbc; 25*b1cdbd2cSJim Jagielski 26*b1cdbd2cSJim Jagielski import lib.MultiMethodTest; 27*b1cdbd2cSJim Jagielski 28*b1cdbd2cSJim Jagielski import com.sun.star.sdbc.SQLException; 29*b1cdbd2cSJim Jagielski import com.sun.star.sdbc.XResultSet; 30*b1cdbd2cSJim Jagielski import com.sun.star.sdbc.XRow; 31*b1cdbd2cSJim Jagielski import com.sun.star.sdbc.XRowUpdate; 32*b1cdbd2cSJim Jagielski import com.sun.star.uno.UnoRuntime; 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski /** 35*b1cdbd2cSJim Jagielski /** 36*b1cdbd2cSJim Jagielski * Testing <code>com.sun.star.sdbc.XResultSet</code> 37*b1cdbd2cSJim Jagielski * interface methods : 38*b1cdbd2cSJim Jagielski * <ul> 39*b1cdbd2cSJim Jagielski * <li><code> next()</code></li> 40*b1cdbd2cSJim Jagielski * <li><code> isBeforeFirst()</code></li> 41*b1cdbd2cSJim Jagielski * <li><code> isAfterLast()</code></li> 42*b1cdbd2cSJim Jagielski * <li><code> isFirst()</code></li> 43*b1cdbd2cSJim Jagielski * <li><code> isLast()</code></li> 44*b1cdbd2cSJim Jagielski * <li><code> beforeFirst()</code></li> 45*b1cdbd2cSJim Jagielski * <li><code> afterLast()</code></li> 46*b1cdbd2cSJim Jagielski * <li><code> first()</code></li> 47*b1cdbd2cSJim Jagielski * <li><code> last()</code></li> 48*b1cdbd2cSJim Jagielski * <li><code> getRow()</code></li> 49*b1cdbd2cSJim Jagielski * <li><code> absolute()</code></li> 50*b1cdbd2cSJim Jagielski * <li><code> relative()</code></li> 51*b1cdbd2cSJim Jagielski * <li><code> previous()</code></li> 52*b1cdbd2cSJim Jagielski * <li><code> refreshRow()</code></li> 53*b1cdbd2cSJim Jagielski * <li><code> rowUpdated()</code></li> 54*b1cdbd2cSJim Jagielski * <li><code> rowInserted()</code></li> 55*b1cdbd2cSJim Jagielski * <li><code> rowDeleted()</code></li> 56*b1cdbd2cSJim Jagielski * <li><code> getStatement()</code></li> 57*b1cdbd2cSJim Jagielski * </ul> <p> 58*b1cdbd2cSJim Jagielski * This test needs the following object relations : 59*b1cdbd2cSJim Jagielski * <ul> 60*b1cdbd2cSJim Jagielski * <li> <code>'XResultSet.hasStatement'</code> (<b>optional</b> of type 61*b1cdbd2cSJim Jagielski * <code>Object</code>): 62*b1cdbd2cSJim Jagielski * it the relation exists than <code>getStatement</code> method 63*b1cdbd2cSJim Jagielski * must not return <code>null</code> </li> 64*b1cdbd2cSJim Jagielski * <ul> <p> 65*b1cdbd2cSJim Jagielski * Test places DB cursor to different positions and then checks 66*b1cdbd2cSJim Jagielski * its current position. <p> 67*b1cdbd2cSJim Jagielski * Test is <b> NOT </b> multithread compilant. <p> 68*b1cdbd2cSJim Jagielski * @see com.sun.star.sdbc.XResultSet 69*b1cdbd2cSJim Jagielski */ 70*b1cdbd2cSJim Jagielski public class _XResultSet extends MultiMethodTest { 71*b1cdbd2cSJim Jagielski 72*b1cdbd2cSJim Jagielski // oObj filled by MultiMethodTest 73*b1cdbd2cSJim Jagielski public XResultSet oObj = null ; 74*b1cdbd2cSJim Jagielski 75*b1cdbd2cSJim Jagielski /** 76*b1cdbd2cSJim Jagielski * Positions the cursor to the first row. 77*b1cdbd2cSJim Jagielski * Forces method tests to be executed in definite order. 78*b1cdbd2cSJim Jagielski */ before()79*b1cdbd2cSJim Jagielski public void before() { 80*b1cdbd2cSJim Jagielski try { 81*b1cdbd2cSJim Jagielski oObj.last() ; 82*b1cdbd2cSJim Jagielski log.println("Totally number of rows is " + oObj.getRow()) ; 83*b1cdbd2cSJim Jagielski oObj.first() ; 84*b1cdbd2cSJim Jagielski } catch (SQLException e) { 85*b1cdbd2cSJim Jagielski log.println("Ignored exception :") ; 86*b1cdbd2cSJim Jagielski e.printStackTrace(log); 87*b1cdbd2cSJim Jagielski } 88*b1cdbd2cSJim Jagielski 89*b1cdbd2cSJim Jagielski executeMethod("isBeforeFirst()") ; 90*b1cdbd2cSJim Jagielski executeMethod("isAfterLast()") ; 91*b1cdbd2cSJim Jagielski executeMethod("isLast()") ; 92*b1cdbd2cSJim Jagielski executeMethod("isFirst()") ; 93*b1cdbd2cSJim Jagielski executeMethod("next()") ; 94*b1cdbd2cSJim Jagielski executeMethod("previous()") ; 95*b1cdbd2cSJim Jagielski } 96*b1cdbd2cSJim Jagielski 97*b1cdbd2cSJim Jagielski /** 98*b1cdbd2cSJim Jagielski * Places the cursor before the first row. <p> 99*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if no exceptions were thrown. 100*b1cdbd2cSJim Jagielski */ _beforeFirst()101*b1cdbd2cSJim Jagielski public void _beforeFirst() { 102*b1cdbd2cSJim Jagielski try { 103*b1cdbd2cSJim Jagielski oObj.beforeFirst() ; 104*b1cdbd2cSJim Jagielski } catch (SQLException e) { 105*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 106*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 107*b1cdbd2cSJim Jagielski tRes.tested("beforeFirst()", false) ; 108*b1cdbd2cSJim Jagielski return ; 109*b1cdbd2cSJim Jagielski } 110*b1cdbd2cSJim Jagielski tRes.tested("beforeFirst()", true) ; 111*b1cdbd2cSJim Jagielski } 112*b1cdbd2cSJim Jagielski 113*b1cdbd2cSJim Jagielski /** 114*b1cdbd2cSJim Jagielski * The method is called immediatly after <code>beforeFirst</code> 115*b1cdbd2cSJim Jagielski * method test. <p> 116*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if method returns <code>true</code>. <p> 117*b1cdbd2cSJim Jagielski * The following method tests are to be completed successfully before : 118*b1cdbd2cSJim Jagielski * <ul> 119*b1cdbd2cSJim Jagielski * <li> <code> beforeFirst </code> : to position cursor before 120*b1cdbd2cSJim Jagielski * the first row. </li> 121*b1cdbd2cSJim Jagielski * </ul> 122*b1cdbd2cSJim Jagielski */ _isBeforeFirst()123*b1cdbd2cSJim Jagielski public void _isBeforeFirst() { 124*b1cdbd2cSJim Jagielski requiredMethod("beforeFirst()") ; 125*b1cdbd2cSJim Jagielski 126*b1cdbd2cSJim Jagielski boolean result = true ; 127*b1cdbd2cSJim Jagielski 128*b1cdbd2cSJim Jagielski try { 129*b1cdbd2cSJim Jagielski result = oObj.isBeforeFirst() ; 130*b1cdbd2cSJim Jagielski } catch (SQLException e) { 131*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 132*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 133*b1cdbd2cSJim Jagielski result = false ; 134*b1cdbd2cSJim Jagielski } 135*b1cdbd2cSJim Jagielski tRes.tested("isBeforeFirst()", result) ; 136*b1cdbd2cSJim Jagielski } 137*b1cdbd2cSJim Jagielski 138*b1cdbd2cSJim Jagielski /** 139*b1cdbd2cSJim Jagielski * Places the cursor after the last row. <p> 140*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if no exceptions were thrown. 141*b1cdbd2cSJim Jagielski */ _afterLast()142*b1cdbd2cSJim Jagielski public void _afterLast() { 143*b1cdbd2cSJim Jagielski try { 144*b1cdbd2cSJim Jagielski oObj.afterLast() ; 145*b1cdbd2cSJim Jagielski } catch (SQLException e) { 146*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 147*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 148*b1cdbd2cSJim Jagielski tRes.tested("afterLast()", false) ; 149*b1cdbd2cSJim Jagielski return ; 150*b1cdbd2cSJim Jagielski } 151*b1cdbd2cSJim Jagielski tRes.tested("afterLast()", true) ; 152*b1cdbd2cSJim Jagielski } 153*b1cdbd2cSJim Jagielski 154*b1cdbd2cSJim Jagielski /** 155*b1cdbd2cSJim Jagielski * The method is called immediatly after <code>afterLast</code> 156*b1cdbd2cSJim Jagielski * method test. <p> 157*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if method returns <code>true</code> <p> 158*b1cdbd2cSJim Jagielski * The following method tests are to be completed successfully before : 159*b1cdbd2cSJim Jagielski * <ul> 160*b1cdbd2cSJim Jagielski * <li> <code> afterLast </code> : to position cursor after 161*b1cdbd2cSJim Jagielski * the last row. </li> 162*b1cdbd2cSJim Jagielski * </ul> 163*b1cdbd2cSJim Jagielski */ _isAfterLast()164*b1cdbd2cSJim Jagielski public void _isAfterLast() { 165*b1cdbd2cSJim Jagielski requiredMethod("afterLast()") ; 166*b1cdbd2cSJim Jagielski 167*b1cdbd2cSJim Jagielski boolean result = true ; 168*b1cdbd2cSJim Jagielski 169*b1cdbd2cSJim Jagielski try { 170*b1cdbd2cSJim Jagielski result = oObj.isAfterLast() ; 171*b1cdbd2cSJim Jagielski } catch (SQLException e) { 172*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 173*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 174*b1cdbd2cSJim Jagielski result = false ; 175*b1cdbd2cSJim Jagielski } 176*b1cdbd2cSJim Jagielski tRes.tested("isAfterLast()", result) ; 177*b1cdbd2cSJim Jagielski } 178*b1cdbd2cSJim Jagielski 179*b1cdbd2cSJim Jagielski /** 180*b1cdbd2cSJim Jagielski * Places the cursor on the first row. <p> 181*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if no exceptions were thrown. 182*b1cdbd2cSJim Jagielski */ _first()183*b1cdbd2cSJim Jagielski public void _first() { 184*b1cdbd2cSJim Jagielski try { 185*b1cdbd2cSJim Jagielski oObj.first() ; 186*b1cdbd2cSJim Jagielski } catch (SQLException e) { 187*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 188*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 189*b1cdbd2cSJim Jagielski tRes.tested("first()", false) ; 190*b1cdbd2cSJim Jagielski return ; 191*b1cdbd2cSJim Jagielski } 192*b1cdbd2cSJim Jagielski tRes.tested("first()", true) ; 193*b1cdbd2cSJim Jagielski } 194*b1cdbd2cSJim Jagielski 195*b1cdbd2cSJim Jagielski /** 196*b1cdbd2cSJim Jagielski * The method is called immediatly after <code>first</code> 197*b1cdbd2cSJim Jagielski * method test. <p> 198*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if method returns <code>true</code>. <p> 199*b1cdbd2cSJim Jagielski * The following method tests are to be completed successfully before : 200*b1cdbd2cSJim Jagielski * <ul> 201*b1cdbd2cSJim Jagielski * <li> <code> first </code> : to position cursor on 202*b1cdbd2cSJim Jagielski * the first row. </li> 203*b1cdbd2cSJim Jagielski * </ul> 204*b1cdbd2cSJim Jagielski */ _isFirst()205*b1cdbd2cSJim Jagielski public void _isFirst() { 206*b1cdbd2cSJim Jagielski requiredMethod("first()") ; 207*b1cdbd2cSJim Jagielski 208*b1cdbd2cSJim Jagielski boolean result = true ; 209*b1cdbd2cSJim Jagielski 210*b1cdbd2cSJim Jagielski try { 211*b1cdbd2cSJim Jagielski result = oObj.isFirst() ; 212*b1cdbd2cSJim Jagielski } catch (SQLException e) { 213*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 214*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 215*b1cdbd2cSJim Jagielski result = false ; 216*b1cdbd2cSJim Jagielski } 217*b1cdbd2cSJim Jagielski tRes.tested("isFirst()", result) ; 218*b1cdbd2cSJim Jagielski } 219*b1cdbd2cSJim Jagielski 220*b1cdbd2cSJim Jagielski /** 221*b1cdbd2cSJim Jagielski * Places the cursor on the last row. <p> 222*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if no exceptions were thrown. 223*b1cdbd2cSJim Jagielski */ _last()224*b1cdbd2cSJim Jagielski public void _last() { 225*b1cdbd2cSJim Jagielski try { 226*b1cdbd2cSJim Jagielski oObj.last() ; 227*b1cdbd2cSJim Jagielski } catch (SQLException e) { 228*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 229*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 230*b1cdbd2cSJim Jagielski tRes.tested("last()", false) ; 231*b1cdbd2cSJim Jagielski return ; 232*b1cdbd2cSJim Jagielski } 233*b1cdbd2cSJim Jagielski tRes.tested("last()", true) ; 234*b1cdbd2cSJim Jagielski } 235*b1cdbd2cSJim Jagielski 236*b1cdbd2cSJim Jagielski /** 237*b1cdbd2cSJim Jagielski * The method is called immediatly after <code>last</code> 238*b1cdbd2cSJim Jagielski * method test. <p> 239*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if method returns <code>true</code>. <p> 240*b1cdbd2cSJim Jagielski * The following method tests are to be completed successfully before : 241*b1cdbd2cSJim Jagielski * <ul> 242*b1cdbd2cSJim Jagielski * <li> <code> last </code> : to position cursor on 243*b1cdbd2cSJim Jagielski * the last row. </li> 244*b1cdbd2cSJim Jagielski * </ul> 245*b1cdbd2cSJim Jagielski */ _isLast()246*b1cdbd2cSJim Jagielski public void _isLast() { 247*b1cdbd2cSJim Jagielski requiredMethod("last()") ; 248*b1cdbd2cSJim Jagielski boolean result = true ; 249*b1cdbd2cSJim Jagielski 250*b1cdbd2cSJim Jagielski try { 251*b1cdbd2cSJim Jagielski result = oObj.isLast() ; 252*b1cdbd2cSJim Jagielski } catch (SQLException e) { 253*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 254*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 255*b1cdbd2cSJim Jagielski result = false ; 256*b1cdbd2cSJim Jagielski } 257*b1cdbd2cSJim Jagielski tRes.tested("isLast()", result) ; 258*b1cdbd2cSJim Jagielski } 259*b1cdbd2cSJim Jagielski 260*b1cdbd2cSJim Jagielski /** 261*b1cdbd2cSJim Jagielski * Places the cursor on the row number 1. <p> 262*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if no exceptions were thrown. 263*b1cdbd2cSJim Jagielski */ _absolute()264*b1cdbd2cSJim Jagielski public void _absolute() { 265*b1cdbd2cSJim Jagielski boolean result = true ; 266*b1cdbd2cSJim Jagielski 267*b1cdbd2cSJim Jagielski try { 268*b1cdbd2cSJim Jagielski oObj.absolute(1) ; 269*b1cdbd2cSJim Jagielski } catch (SQLException e) { 270*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 271*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 272*b1cdbd2cSJim Jagielski result = false ; 273*b1cdbd2cSJim Jagielski } 274*b1cdbd2cSJim Jagielski tRes.tested("absolute()", result) ; 275*b1cdbd2cSJim Jagielski } 276*b1cdbd2cSJim Jagielski 277*b1cdbd2cSJim Jagielski /** 278*b1cdbd2cSJim Jagielski * The method is called immediatly after <code>absolute</code> 279*b1cdbd2cSJim Jagielski * method test. <p> 280*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if method returns 1. <p> 281*b1cdbd2cSJim Jagielski * The following method tests are to be completed successfully before : 282*b1cdbd2cSJim Jagielski * <ul> 283*b1cdbd2cSJim Jagielski * <li> <code> absolute </code> : to position cursor on 284*b1cdbd2cSJim Jagielski * the row number 1. </li> 285*b1cdbd2cSJim Jagielski * </ul> 286*b1cdbd2cSJim Jagielski */ _getRow()287*b1cdbd2cSJim Jagielski public void _getRow() { 288*b1cdbd2cSJim Jagielski requiredMethod("absolute()"); 289*b1cdbd2cSJim Jagielski boolean result = true; 290*b1cdbd2cSJim Jagielski 291*b1cdbd2cSJim Jagielski try { 292*b1cdbd2cSJim Jagielski result &= oObj.getRow() == 1; 293*b1cdbd2cSJim Jagielski } catch (SQLException e) { 294*b1cdbd2cSJim Jagielski log.println("Exception occured:"); 295*b1cdbd2cSJim Jagielski e.printStackTrace(log); 296*b1cdbd2cSJim Jagielski result = false; 297*b1cdbd2cSJim Jagielski } 298*b1cdbd2cSJim Jagielski 299*b1cdbd2cSJim Jagielski tRes.tested("getRow()", result); 300*b1cdbd2cSJim Jagielski } 301*b1cdbd2cSJim Jagielski 302*b1cdbd2cSJim Jagielski /** 303*b1cdbd2cSJim Jagielski * Positions the cursor to the next row. Current row 304*b1cdbd2cSJim Jagielski * number is retrieved before and after method call. <p> 305*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if current row number increases 306*b1cdbd2cSJim Jagielski * by 1 after method call. 307*b1cdbd2cSJim Jagielski */ _next()308*b1cdbd2cSJim Jagielski public void _next() { 309*b1cdbd2cSJim Jagielski boolean result = true ; 310*b1cdbd2cSJim Jagielski 311*b1cdbd2cSJim Jagielski try { 312*b1cdbd2cSJim Jagielski int prevRow = oObj.getRow() ; 313*b1cdbd2cSJim Jagielski oObj.next() ; 314*b1cdbd2cSJim Jagielski 315*b1cdbd2cSJim Jagielski log.println("Row was : " + prevRow + ", row is : " + oObj.getRow()); 316*b1cdbd2cSJim Jagielski result &= prevRow + 1 == oObj.getRow() ; 317*b1cdbd2cSJim Jagielski } catch (SQLException e) { 318*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 319*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 320*b1cdbd2cSJim Jagielski result = false ; 321*b1cdbd2cSJim Jagielski } 322*b1cdbd2cSJim Jagielski tRes.tested("next()", result) ; 323*b1cdbd2cSJim Jagielski } 324*b1cdbd2cSJim Jagielski 325*b1cdbd2cSJim Jagielski /** 326*b1cdbd2cSJim Jagielski * Positions the cursor to the previous row. Current row 327*b1cdbd2cSJim Jagielski * number is retrieved before and after method call. <p> 328*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if current row number decreases 329*b1cdbd2cSJim Jagielski * by 1 after method call. 330*b1cdbd2cSJim Jagielski */ _previous()331*b1cdbd2cSJim Jagielski public void _previous() { 332*b1cdbd2cSJim Jagielski boolean result = true ; 333*b1cdbd2cSJim Jagielski 334*b1cdbd2cSJim Jagielski try { 335*b1cdbd2cSJim Jagielski int prevRow = oObj.getRow() ; 336*b1cdbd2cSJim Jagielski oObj.previous() ; 337*b1cdbd2cSJim Jagielski 338*b1cdbd2cSJim Jagielski log.println("Row was : " + prevRow + ", row is : " + oObj.getRow()); 339*b1cdbd2cSJim Jagielski result &= prevRow - 1 == oObj.getRow() ; 340*b1cdbd2cSJim Jagielski } catch (SQLException e) { 341*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 342*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 343*b1cdbd2cSJim Jagielski result = false ; 344*b1cdbd2cSJim Jagielski } 345*b1cdbd2cSJim Jagielski tRes.tested("previous()", result) ; 346*b1cdbd2cSJim Jagielski } 347*b1cdbd2cSJim Jagielski 348*b1cdbd2cSJim Jagielski /** 349*b1cdbd2cSJim Jagielski * Positions the cursor relatively by 2 rows forward. 350*b1cdbd2cSJim Jagielski * Current row number is retrieved before and after method call. <p> 351*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if current row number increases 352*b1cdbd2cSJim Jagielski * by 2 after method call. 353*b1cdbd2cSJim Jagielski */ _relative()354*b1cdbd2cSJim Jagielski public void _relative() { 355*b1cdbd2cSJim Jagielski boolean result = true ; 356*b1cdbd2cSJim Jagielski 357*b1cdbd2cSJim Jagielski try { 358*b1cdbd2cSJim Jagielski oObj.first() ; 359*b1cdbd2cSJim Jagielski int prevRow = oObj.getRow() ; 360*b1cdbd2cSJim Jagielski oObj.relative(2) ; 361*b1cdbd2cSJim Jagielski 362*b1cdbd2cSJim Jagielski log.println("Row was : " + prevRow + ", row is : " + oObj.getRow()); 363*b1cdbd2cSJim Jagielski 364*b1cdbd2cSJim Jagielski result &= prevRow + 2 == oObj.getRow() ; 365*b1cdbd2cSJim Jagielski } catch (SQLException e) { 366*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 367*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 368*b1cdbd2cSJim Jagielski result = false ; 369*b1cdbd2cSJim Jagielski } 370*b1cdbd2cSJim Jagielski tRes.tested("relative()", result) ; 371*b1cdbd2cSJim Jagielski } 372*b1cdbd2cSJim Jagielski 373*b1cdbd2cSJim Jagielski /** 374*b1cdbd2cSJim Jagielski * If component supports XRow and XRowUpdate then: 375*b1cdbd2cSJim Jagielski * test saves current value of string field, updates string, 376*b1cdbd2cSJim Jagielski * calls refreshRow() and checks that value of 377*b1cdbd2cSJim Jagielski * string field was refetched from DB 378*b1cdbd2cSJim Jagielski * else: just calls method.<p> 379*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if no exceptions were thrown and value after 380*b1cdbd2cSJim Jagielski * refreshRow() equals to saved value. 381*b1cdbd2cSJim Jagielski */ _refreshRow()382*b1cdbd2cSJim Jagielski public void _refreshRow() { 383*b1cdbd2cSJim Jagielski XRowUpdate xRowUpdate = (XRowUpdate) 384*b1cdbd2cSJim Jagielski UnoRuntime.queryInterface(XRowUpdate.class, oObj); 385*b1cdbd2cSJim Jagielski XRow xRow = (XRow)UnoRuntime.queryInterface(XRow.class, oObj); 386*b1cdbd2cSJim Jagielski 387*b1cdbd2cSJim Jagielski if (xRowUpdate == null || xRow == null) { 388*b1cdbd2cSJim Jagielski log.println("Test must be modified because XRow or XRowUpdate is't supported"); 389*b1cdbd2cSJim Jagielski log.println("Only call method"); 390*b1cdbd2cSJim Jagielski try { 391*b1cdbd2cSJim Jagielski oObj.refreshRow() ; 392*b1cdbd2cSJim Jagielski tRes.tested("refreshRow()", true) ; 393*b1cdbd2cSJim Jagielski } catch (SQLException e) { 394*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 395*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 396*b1cdbd2cSJim Jagielski tRes.tested("refreshRow()", false) ; 397*b1cdbd2cSJim Jagielski } 398*b1cdbd2cSJim Jagielski } else { 399*b1cdbd2cSJim Jagielski log.println("Testing of refreshRow()..."); 400*b1cdbd2cSJim Jagielski try { 401*b1cdbd2cSJim Jagielski String oldValue = xRow.getString(util.DBTools.TST_STRING); 402*b1cdbd2cSJim Jagielski log.println("Old value: " + oldValue); 403*b1cdbd2cSJim Jagielski xRowUpdate.updateString(util.DBTools.TST_STRING, 404*b1cdbd2cSJim Jagielski "Test method refreshRow"); 405*b1cdbd2cSJim Jagielski log.println("New value: " 406*b1cdbd2cSJim Jagielski + xRow.getString(util.DBTools.TST_STRING)); 407*b1cdbd2cSJim Jagielski oObj.refreshRow(); 408*b1cdbd2cSJim Jagielski String valAfterRefresh = 409*b1cdbd2cSJim Jagielski xRow.getString(util.DBTools.TST_STRING); 410*b1cdbd2cSJim Jagielski log.println("Value after refresh: " + valAfterRefresh); 411*b1cdbd2cSJim Jagielski tRes.tested("refreshRow()", valAfterRefresh.equals(oldValue)); 412*b1cdbd2cSJim Jagielski } catch(SQLException e) { 413*b1cdbd2cSJim Jagielski log.println("Exception occured :"); 414*b1cdbd2cSJim Jagielski e.printStackTrace(log); 415*b1cdbd2cSJim Jagielski tRes.tested("refreshRow()", false); 416*b1cdbd2cSJim Jagielski } 417*b1cdbd2cSJim Jagielski } 418*b1cdbd2cSJim Jagielski } 419*b1cdbd2cSJim Jagielski 420*b1cdbd2cSJim Jagielski /** 421*b1cdbd2cSJim Jagielski * Just the method is called. <p> 422*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if no exceptions were thrown. 423*b1cdbd2cSJim Jagielski */ _rowUpdated()424*b1cdbd2cSJim Jagielski public void _rowUpdated() { 425*b1cdbd2cSJim Jagielski 426*b1cdbd2cSJim Jagielski try { 427*b1cdbd2cSJim Jagielski boolean res = oObj.rowUpdated() ; 428*b1cdbd2cSJim Jagielski tRes.tested("rowUpdated()", true) ; 429*b1cdbd2cSJim Jagielski } catch (SQLException e) { 430*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 431*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 432*b1cdbd2cSJim Jagielski tRes.tested("rowUpdated()", false) ; 433*b1cdbd2cSJim Jagielski } 434*b1cdbd2cSJim Jagielski } 435*b1cdbd2cSJim Jagielski 436*b1cdbd2cSJim Jagielski /** 437*b1cdbd2cSJim Jagielski * Just the method is called. <p> 438*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if no exceptions were thrown. 439*b1cdbd2cSJim Jagielski */ _rowInserted()440*b1cdbd2cSJim Jagielski public void _rowInserted() { 441*b1cdbd2cSJim Jagielski try { 442*b1cdbd2cSJim Jagielski boolean res = oObj.rowInserted() ; 443*b1cdbd2cSJim Jagielski tRes.tested("rowInserted()", true) ; 444*b1cdbd2cSJim Jagielski } catch (SQLException e) { 445*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 446*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 447*b1cdbd2cSJim Jagielski tRes.tested("rowInserted()", false) ; 448*b1cdbd2cSJim Jagielski } 449*b1cdbd2cSJim Jagielski } 450*b1cdbd2cSJim Jagielski 451*b1cdbd2cSJim Jagielski /** 452*b1cdbd2cSJim Jagielski * Just the method is called. <p> 453*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if no exceptions were thrown. 454*b1cdbd2cSJim Jagielski */ _rowDeleted()455*b1cdbd2cSJim Jagielski public void _rowDeleted() { 456*b1cdbd2cSJim Jagielski try { 457*b1cdbd2cSJim Jagielski boolean res = oObj.rowDeleted() ; 458*b1cdbd2cSJim Jagielski tRes.tested("rowDeleted()", true) ; 459*b1cdbd2cSJim Jagielski } catch (SQLException e) { 460*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 461*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 462*b1cdbd2cSJim Jagielski tRes.tested("rowDeleted()", false) ; 463*b1cdbd2cSJim Jagielski } 464*b1cdbd2cSJim Jagielski } 465*b1cdbd2cSJim Jagielski 466*b1cdbd2cSJim Jagielski /** 467*b1cdbd2cSJim Jagielski * Just the method is called. <p> 468*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if the statement returned isn't null or 469*b1cdbd2cSJim Jagielski * the relation exists that informs that statement absent (e.g. for 470*b1cdbd2cSJim Jagielski * MetaData row set). 471*b1cdbd2cSJim Jagielski */ _getStatement()472*b1cdbd2cSJim Jagielski public void _getStatement() { 473*b1cdbd2cSJim Jagielski try { 474*b1cdbd2cSJim Jagielski boolean hasStatement = 475*b1cdbd2cSJim Jagielski tEnv.getObjRelation("XResultSet.hasStatement") != null ; 476*b1cdbd2cSJim Jagielski Object res = oObj.getStatement() ; 477*b1cdbd2cSJim Jagielski tRes.tested("getStatement()", 478*b1cdbd2cSJim Jagielski (hasStatement && res != null) || !hasStatement) ; 479*b1cdbd2cSJim Jagielski } catch (SQLException e) { 480*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 481*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 482*b1cdbd2cSJim Jagielski tRes.tested("getStatement()", false) ; 483*b1cdbd2cSJim Jagielski } 484*b1cdbd2cSJim Jagielski } 485*b1cdbd2cSJim Jagielski 486*b1cdbd2cSJim Jagielski /** 487*b1cdbd2cSJim Jagielski * Moves the cursor to the first row to avoid affection to 488*b1cdbd2cSJim Jagielski * the following interfaces tests 489*b1cdbd2cSJim Jagielski */ after()490*b1cdbd2cSJim Jagielski public void after() { 491*b1cdbd2cSJim Jagielski log.println("Finally moving cursor to the first row ..."); 492*b1cdbd2cSJim Jagielski try { 493*b1cdbd2cSJim Jagielski oObj.first(); 494*b1cdbd2cSJim Jagielski } catch (SQLException e) { 495*b1cdbd2cSJim Jagielski log.println("Exception occured :") ; 496*b1cdbd2cSJim Jagielski e.printStackTrace(log) ; 497*b1cdbd2cSJim Jagielski } 498*b1cdbd2cSJim Jagielski } 499*b1cdbd2cSJim Jagielski 500*b1cdbd2cSJim Jagielski } // finish class _XResultSet 501*b1cdbd2cSJim Jagielski 502