Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / ifc / sdbc / _XDataSource.java
blob304ea7ded4f1d53dbc722508016039957f00552c
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;
23 import com.sun.star.sdbc.XConnection;
24 import com.sun.star.sdbc.XDataSource;
26 /**
27 * Testing <code>com.sun.star.sdbc.XDataSource</code>
28 * interface methods :
29 * <ul>
30 * <li><code>getConnection()</code></li>
31 * <li><code>setLoginTimeout()</code></li>
32 * <li><code>getLoginTimeout()</code></li>
33 * </ul> <p>
34 * @see com.sun.star.sdbc.XDataSource
36 public class _XDataSource extends MultiMethodTest {
37 // oObj filled by MultiMethodTest
38 public XDataSource oObj = null;
40 /**
41 * Calls the method and checks returned value.
42 * Has OK status if exception wasn't thrown and
43 * if returned value isn't null.
45 public void _getConnection() {
46 boolean res = true;
48 try {
49 XConnection connection = oObj.getConnection("", "");
50 res = connection != null;
51 } catch(com.sun.star.sdbc.SQLException e) {
52 log.println("Unexpected exception:");
53 e.printStackTrace(log);
54 res = false;
57 tRes.tested("getConnection()", res);
60 /**
61 * Sets new timeout, compares with timeout returned by the method
62 * <code>getLoginTimeout()</code>.
63 * Has OK status if exception wasn't thrown and if timeout values are equal.
65 public void _setLoginTimeout() {
66 requiredMethod("getLoginTimeout()");
67 boolean res = true;
69 try {
70 final int TO = 111;
71 log.println("setLoginTimeout(" + TO + ")");
72 oObj.setLoginTimeout(TO);
73 int timeout = oObj.getLoginTimeout();
74 res = timeout == TO;
75 log.println("getLoginTimeout(): " + timeout);
76 } catch(com.sun.star.sdbc.SQLException e) {
77 log.println("Unexpected exception:");
78 e.printStackTrace(log);
79 res = false;
82 tRes.tested("setLoginTimeout()", res);
85 /**
86 * Calls the method and checks returned value.
87 * Has OK status if exception wasn't thrown and
88 * if returned value is equal to zero.
90 public void _getLoginTimeout() {
91 boolean res = true;
93 try {
94 int timeout = oObj.getLoginTimeout();
95 log.println("getLoginTimeout(): " + timeout);
96 res = timeout == 0;
97 } catch(com.sun.star.sdbc.SQLException e) {
98 log.println("Unexpected exception:");
99 e.printStackTrace(log);
100 res = false;
103 tRes.tested("getLoginTimeout()", res);