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: _XWarningsSupplier.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
;
39 import com
.sun
.star
.sdbc
.SQLException
;
40 import com
.sun
.star
.sdbc
.XResultSetUpdate
;
41 import com
.sun
.star
.sdbc
.XRow
;
42 import com
.sun
.star
.sdbc
.XRowUpdate
;
43 import com
.sun
.star
.sdbc
.XWarningsSupplier
;
44 import com
.sun
.star
.uno
.UnoRuntime
;
47 * Testing <code>com.sun.star.sdbc.XWarningsSupplier</code>
50 * <li><code> getWarnings()</code></li>
51 * <li><code> clearWarnings()</code></li>
53 * @see com.sun.star.sdbc.XWarningsSupplier
55 public class _XWarningsSupplier
extends MultiMethodTest
{
57 // oObj filled by MultiMethodTest
58 public XWarningsSupplier oObj
= null ;
61 * Updates value of int column by value '9999999999999999'.
62 * Calls method and checks returned value. <p>
63 * Has OK status if the method return not empty value.
65 public void _getWarnings() {
66 final XRowUpdate xRowUpdate
= (XRowUpdate
)
67 UnoRuntime
.queryInterface(XRowUpdate
.class, oObj
);
68 final XResultSetUpdate xResSetUpdate
= (XResultSetUpdate
)
69 UnoRuntime
.queryInterface(XResultSetUpdate
.class, oObj
);
70 final XRow xRow
= (XRow
)
71 UnoRuntime
.queryInterface(XRow
.class, oObj
);
72 if (xRowUpdate
== null || xResSetUpdate
== null || xRow
== null) {
73 throw new StatusException(Status
.failed("Test must be modified"));
75 int oldVal
= 0, newVal
= 0;
76 String valToSet
= "9999999999999999";
78 oldVal
= xRow
.getInt(DBTools
.TST_INT
);
79 xRowUpdate
.updateString(DBTools
.TST_INT
, valToSet
);
80 xResSetUpdate
.updateRow();
81 newVal
= xRow
.getInt(DBTools
.TST_INT
);
82 } catch(com
.sun
.star
.sdbc
.SQLException e
) {
83 log
.println("Unexpected SQL exception");
84 e
.printStackTrace(log
);
85 tRes
.tested("getWarnings()", false);
89 log
.println("Old INT value: " + oldVal
);
90 log
.println("Value that was set: " + valToSet
);
91 log
.println("New INT value: " + newVal
);
96 Object warns
= oObj
.getWarnings();
97 res
= (!utils
.isVoid(warns
));
98 } catch (SQLException e
) {
99 log
.println("Exception occured :");
100 e
.printStackTrace(log
);
101 tRes
.tested("getWarnings()", res
);
105 tRes
.tested("getWarnings()", res
);
109 * Calls method and checks value returned by the method
110 * <code>getWarnings()</code>. <p>
111 * Has OK status if the method <code>getWarnings()</code> return void value.
113 public void _clearWarnings() {
114 executeMethod("getWarnings()");
118 oObj
.clearWarnings();
119 Object warns
= oObj
.getWarnings();
120 res
= (utils
.isVoid(warns
));
121 } catch (SQLException e
) {
122 log
.println("Exception occured :");
123 e
.printStackTrace(log
);
124 tRes
.tested("clearWarnings()", res
);
128 tRes
.tested("clearWarnings()", res
);