2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
23 import lib
.StatusException
;
25 import com
.sun
.star
.sdbc
.XResultSet
;
26 import com
.sun
.star
.sdbcx
.XDeleteRows
;
27 import com
.sun
.star
.sdbcx
.XRowLocate
;
28 import com
.sun
.star
.uno
.UnoRuntime
;
31 * Testing <code>com.sun.star.sdbcx.XDeleteRows</code>
34 * <li><code> deleteRows()</code></li>
36 * @see com.sun.star.sdbcx.XDeleteRows
38 public class _XDeleteRows
extends MultiMethodTest
{
39 // oObj filled by MultiMethodTest
40 public XDeleteRows oObj
= null ;
43 * Retrieves bookmark using XRowLocate and deletes
44 * row pointed by this bookmark. <p>
45 * Has OK status if number of rows after deleting is less than before
46 * and no exception rizes while method call, FAILED otherwise. <p>
48 public void _deleteRows() {
49 XRowLocate xRowLocate
= UnoRuntime
.queryInterface(XRowLocate
.class, oObj
);
50 XResultSet xResultSet
= UnoRuntime
.queryInterface(XResultSet
.class, oObj
);
51 if (xRowLocate
== null || xResultSet
== null) {
52 log
.println("The test must be modified according to "+
53 "component testcase");
54 throw new StatusException(Status
.failed(
55 "The component doesn't support one of the "+
56 "required interfaces"));
59 int rowsBefore
= 0, rowsAfter
= 0;
63 rowsBefore
= xResultSet
.getRow();
65 bkmrk
= xRowLocate
.getBookmark();
66 oObj
.deleteRows(new Object
[] {bkmrk
});
68 rowsAfter
= xResultSet
.getRow();
69 } catch(com
.sun
.star
.sdbc
.SQLException e
) {
70 log
.println("SQLException:" + e
);
71 tRes
.tested("deleteRows()", false);
75 log
.println("Rows before: " + rowsBefore
+ ", after: " + rowsAfter
);
76 tRes
.tested("deleteRows()", rowsBefore
- 1 == rowsAfter
);
80 protected void after() {
83 } // finish class _XDeleteRows