merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / sdbcx / _XDeleteRows.java
bloba8ca6ae1466cc1e597eeb89d53c5f75f65a31926
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XDeleteRows.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.sdbcx;
33 import lib.MultiMethodTest;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.sdbc.XResultSet;
38 import com.sun.star.sdbcx.XDeleteRows;
39 import com.sun.star.sdbcx.XRowLocate;
40 import com.sun.star.uno.UnoRuntime;
42 /**
43 * Testing <code>com.sun.star.sdbcx.XDeleteRows</code>
44 * interface methods :
45 * <ul>
46 * <li><code> deleteRows()</code></li>
47 * </ul> <p>
48 * @see com.sun.star.sdbcx.XDeleteRows
50 public class _XDeleteRows extends MultiMethodTest {
51 // oObj filled by MultiMethodTest
52 public XDeleteRows oObj = null ;
54 /**
55 * Retrieves bookmark using XRowLocate and deletes
56 * row pointed by this bookmark. <p>
57 * Has OK status if number of rows after deleting is less than before
58 * and no exception rizes while method call, FAILED otherwise. <p>
60 public void _deleteRows() {
61 XRowLocate xRowLocate = (XRowLocate)
62 UnoRuntime.queryInterface(XRowLocate.class, oObj);
63 XResultSet xResultSet = (XResultSet)
64 UnoRuntime.queryInterface(XResultSet.class, oObj);
65 if (xRowLocate == null || xResultSet == null) {
66 log.println("The test must be modified according to "+
67 "component testcase");
68 throw new StatusException(Status.failed(
69 "The component doesn't support one of the "+
70 "required interfaces"));
73 int rowsBefore = 0, rowsAfter = 0;
74 Object bkmrk = null;
75 try {
76 xResultSet.last();
77 rowsBefore = xResultSet.getRow();
78 xResultSet.first();
79 bkmrk = xRowLocate.getBookmark();
80 oObj.deleteRows(new Object[] {bkmrk});
81 xResultSet.last();
82 rowsAfter = xResultSet.getRow();
83 } catch(com.sun.star.sdbc.SQLException e) {
84 log.println("SQLException:" + e);
85 tRes.tested("deleteRows()", false);
86 return;
89 log.println("Rows before: " + rowsBefore + ", after: " + rowsAfter);
90 tRes.tested("deleteRows()", rowsBefore - 1 == rowsAfter);
93 protected void after() {
94 disposeEnvironment();
96 } // finish class _XDeleteRows