1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XDeleteRows.java,v $
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 ************************************************************************/
33 import lib
.MultiMethodTest
;
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
;
43 * Testing <code>com.sun.star.sdbcx.XDeleteRows</code>
46 * <li><code> deleteRows()</code></li>
48 * @see com.sun.star.sdbcx.XDeleteRows
50 public class _XDeleteRows
extends MultiMethodTest
{
51 // oObj filled by MultiMethodTest
52 public XDeleteRows oObj
= null ;
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;
77 rowsBefore
= xResultSet
.getRow();
79 bkmrk
= xRowLocate
.getBookmark();
80 oObj
.deleteRows(new Object
[] {bkmrk
});
82 rowsAfter
= xResultSet
.getRow();
83 } catch(com
.sun
.star
.sdbc
.SQLException e
) {
84 log
.println("SQLException:" + e
);
85 tRes
.tested("deleteRows()", false);
89 log
.println("Rows before: " + rowsBefore
+ ", after: " + rowsAfter
);
90 tRes
.tested("deleteRows()", rowsBefore
- 1 == rowsAfter
);
93 protected void after() {
96 } // finish class _XDeleteRows