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
;
27 import com
.sun
.star
.sdbc
.SQLException
;
28 import com
.sun
.star
.sdbc
.XResultSetUpdate
;
29 import com
.sun
.star
.sdbc
.XRow
;
30 import com
.sun
.star
.sdbc
.XRowUpdate
;
31 import com
.sun
.star
.sdbc
.XWarningsSupplier
;
32 import com
.sun
.star
.uno
.UnoRuntime
;
35 * Testing <code>com.sun.star.sdbc.XWarningsSupplier</code>
38 * <li><code> getWarnings()</code></li>
39 * <li><code> clearWarnings()</code></li>
41 * @see com.sun.star.sdbc.XWarningsSupplier
43 public class _XWarningsSupplier
extends MultiMethodTest
{
45 // oObj filled by MultiMethodTest
46 public XWarningsSupplier oObj
= null ;
49 * Updates value of int column by value '9999999999999999'.
50 * Calls method and checks returned value. <p>
51 * Has OK status if the method return not empty value.
53 public void _getWarnings() {
54 final XRowUpdate rowUpdate
= UnoRuntime
.queryInterface(XRowUpdate
.class, oObj
);
55 final XResultSetUpdate resultSetUpdate
= UnoRuntime
.queryInterface(XResultSetUpdate
.class, rowUpdate
);
56 final XRow row
= UnoRuntime
.queryInterface(XRow
.class, resultSetUpdate
);
58 throw new StatusException(Status
.failed("Test must be modified"));
60 // not sure what the below test was intended to test, but it actually fails with an SQLException (which is
61 // correct for what is done there), and thus makes the complete interface test fail (which is not correct)
62 // So, for the moment, just let the test succeed all the time - until issue #i84235# is fixed
66 int oldVal
= 0, newVal
= 0;
67 String valToSet
= "9999999999999999";
70 oldVal
= row
.getInt(DBTools
.TST_INT
);
71 rowUpdate
.updateString(DBTools
.TST_INT
, valToSet
);
72 resultSetUpdate
.updateRow();
73 newVal
= row
.getInt(DBTools
.TST_INT
);
75 catch(com
.sun
.star
.sdbc
.SQLException e
)
77 log
.println("Unexpected SQL exception");
78 e
.printStackTrace(log
);
79 tRes
.tested("getWarnings()", false);
83 log
.println("Old INT value: " + oldVal
);
84 log
.println("Value that was set: " + valToSet
);
85 log
.println("New INT value: " + newVal
);
91 Object warns
= oObj
.getWarnings();
92 res
= (!utils
.isVoid(warns
));
94 catch (SQLException e
)
96 log
.println("Exception occurred :");
97 e
.printStackTrace(log
);
98 tRes
.tested("getWarnings()", res
);
101 tRes
.tested("getWarnings()", res
);
104 tRes
.tested( "getWarnings()", true );
108 * Calls method and checks value returned by the method
109 * <code>getWarnings()</code>. <p>
110 * Has OK status if the method <code>getWarnings()</code> return void value.
112 public void _clearWarnings() {
113 executeMethod("getWarnings()");
117 oObj
.clearWarnings();
118 Object warns
= oObj
.getWarnings();
119 res
= (utils
.isVoid(warns
));
120 } catch (SQLException e
) {
121 log
.println("Exception occurred :");
122 e
.printStackTrace(log
);
123 tRes
.tested("clearWarnings()", res
);
127 tRes
.tested("clearWarnings()", res
);