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