Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / ifc / sdbc / _XCloseable.java
blobefd39fd1ffe2258870e6e0ae020795dbdbd2dc2b
1 /*
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 .
19 package ifc.sdbc;
21 import lib.MultiMethodTest;
22 import lib.StatusException;
24 import com.sun.star.sdbc.SQLException;
25 import com.sun.star.sdbc.XCloseable;
26 import com.sun.star.sdbc.XResultSet;
27 import com.sun.star.uno.UnoRuntime;
29 /**
30 * Testing <code>com.sun.star.sdbc.XCloseable</code>
31 * interface methods :
32 * <ul>
33 * <li><code> close()</code></li>
34 * </ul> <p>
35 * After test object must be recreated.
36 * @see com.sun.star.sdbc.XCloseable
38 public class _XCloseable extends MultiMethodTest {
40 // oObj filled by MultiMethodTest
41 public XCloseable oObj = null ;
43 /**
44 * Closes row set. If the component implements the interface
45 * <code>com.sun.star.sdbc.XResultSet</code> then tries to move
46 * the cursor to the first row in the result set.
47 * Has OK status if no exceptions were thrown during first call and
48 * if expected SQL exception was thrown during cursor moving.
50 public void _close() throws StatusException {
51 boolean res = false;
52 try {
53 oObj.close();
54 res = true;
55 } catch (SQLException e) {
56 log.println("Unexpected SQL Exception occurred:" + e) ;
57 res = false;
60 XResultSet resSet = UnoRuntime.queryInterface(XResultSet.class, oObj);
62 if (resSet != null) {
63 try {
64 resSet.first();
65 log.println("Expected SQLException not occurred !");
66 res = false;
67 } catch(SQLException e) {
68 log.println("Expected SQLException occurred");
69 res = true;
73 tRes.tested("close()", res);
76 /**
77 * Forces environment recreation.
79 @Override
80 public void after() {
81 disposeEnvironment() ;
84 } // finish class _XCloseable