1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import lib
.StatusException
;
36 import com
.sun
.star
.sdbc
.SQLException
;
37 import com
.sun
.star
.sdbc
.XResultSetUpdate
;
38 import com
.sun
.star
.sdbc
.XRow
;
39 import com
.sun
.star
.sdbc
.XRowUpdate
;
40 import com
.sun
.star
.sdbc
.XWarningsSupplier
;
41 import com
.sun
.star
.uno
.UnoRuntime
;
44 * Testing <code>com.sun.star.sdbc.XWarningsSupplier</code>
47 * <li><code> getWarnings()</code></li>
48 * <li><code> clearWarnings()</code></li>
50 * @see com.sun.star.sdbc.XWarningsSupplier
52 public class _XWarningsSupplier
extends MultiMethodTest
{
54 // oObj filled by MultiMethodTest
55 public XWarningsSupplier oObj
= null ;
58 * Updates value of int column by value '9999999999999999'.
59 * Calls method and checks returned value. <p>
60 * Has OK status if the method return not empty value.
62 public void _getWarnings() {
63 final XRowUpdate rowUpdate
= UnoRuntime
.queryInterface(XRowUpdate
.class, oObj
);
64 final XResultSetUpdate resultSetUpdate
= UnoRuntime
.queryInterface(XResultSetUpdate
.class, rowUpdate
);
65 final XRow row
= UnoRuntime
.queryInterface(XRow
.class, resultSetUpdate
);
67 throw new StatusException(Status
.failed("Test must be modified"));
69 // not sure what the below test was intended to test, but it actually fails with an SQLException (which is
70 // correct for what is done there), and thus makes the complete interface test fail (which is not correct)
71 // So, for the moment, just let the test succeed all the time - until issue #i84235# is fixed
75 int oldVal
= 0, newVal
= 0;
76 String valToSet
= "9999999999999999";
79 oldVal
= row
.getInt(DBTools
.TST_INT
);
80 rowUpdate
.updateString(DBTools
.TST_INT
, valToSet
);
81 resultSetUpdate
.updateRow();
82 newVal
= row
.getInt(DBTools
.TST_INT
);
84 catch(com
.sun
.star
.sdbc
.SQLException e
)
86 log
.println("Unexpected SQL exception");
87 e
.printStackTrace(log
);
88 tRes
.tested("getWarnings()", false);
92 log
.println("Old INT value: " + oldVal
);
93 log
.println("Value that was set: " + valToSet
);
94 log
.println("New INT value: " + newVal
);
100 Object warns
= oObj
.getWarnings();
101 res
= (!utils
.isVoid(warns
));
103 catch (SQLException e
)
105 log
.println("Exception occurred :");
106 e
.printStackTrace(log
);
107 tRes
.tested("getWarnings()", res
);
110 tRes
.tested("getWarnings()", res
);
113 tRes
.tested( "getWarnings()", true );
117 * Calls method and checks value returned by the method
118 * <code>getWarnings()</code>. <p>
119 * Has OK status if the method <code>getWarnings()</code> return void value.
121 public void _clearWarnings() {
122 executeMethod("getWarnings()");
126 oObj
.clearWarnings();
127 Object warns
= oObj
.getWarnings();
128 res
= (utils
.isVoid(warns
));
129 } catch (SQLException e
) {
130 log
.println("Exception occurred :");
131 e
.printStackTrace(log
);
132 tRes
.tested("clearWarnings()", res
);
136 tRes
.tested("clearWarnings()", res
);