merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / sdbc / _XDataSource.java
blobb1429056d7abea4f6bb81bd3fed5923b2950d437
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XDataSource.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.sdbc;
33 import lib.MultiMethodTest;
35 import com.sun.star.sdbc.XConnection;
36 import com.sun.star.sdbc.XDataSource;
38 /**
39 * Testing <code>com.sun.star.sdbc.XDataSource</code>
40 * interface methods :
41 * <ul>
42 * <li><code>getConnection()</code></li>
43 * <li><code>setLoginTimeout()</code></li>
44 * <li><code>getLoginTimeout()</code></li>
45 * </ul> <p>
46 * @see com.sun.star.sdbc.XDataSource
48 public class _XDataSource extends MultiMethodTest {
49 // oObj filled by MultiMethodTest
50 public XDataSource oObj = null;
52 /**
53 * Calls the method and checks returned value.
54 * Has OK status if exception wasn't thrown and
55 * if returned value isn't null.
57 public void _getConnection() {
58 boolean res = true;
60 try {
61 XConnection connection = oObj.getConnection("", "");
62 res = connection != null;
63 } catch(com.sun.star.sdbc.SQLException e) {
64 log.println("Unexpected exception:");
65 e.printStackTrace(log);
66 res = false;
69 tRes.tested("getConnection()", res);
72 /**
73 * Sets new timeout, compares with timeout returned by the method
74 * <code>getLoginTimeout()</code>.
75 * Has OK status if exception wasn't thrown and if timeout values are equal.
77 public void _setLoginTimeout() {
78 requiredMethod("getLoginTimeout()");
79 boolean res = true;
81 try {
82 final int TO = 111;
83 log.println("setLoginTimeout(" + TO + ")");
84 oObj.setLoginTimeout(TO);
85 int timeout = oObj.getLoginTimeout();
86 res = timeout == TO;
87 log.println("getLoginTimeout(): " + timeout);
88 } catch(com.sun.star.sdbc.SQLException e) {
89 log.println("Unexpected exception:");
90 e.printStackTrace(log);
91 res = false;
94 tRes.tested("setLoginTimeout()", res);
97 /**
98 * Calls the method and checks returned value.
99 * Has OK status if exception wasn't thrown and
100 * if returned value is equal to zero.
102 public void _getLoginTimeout() {
103 boolean res = true;
105 try {
106 int timeout = oObj.getLoginTimeout();
107 log.println("getLoginTimeout(): " + timeout);
108 res = timeout == 0;
109 } catch(com.sun.star.sdbc.SQLException e) {
110 log.println("Unexpected exception:");
111 e.printStackTrace(log);
112 res = false;
115 tRes.tested("getLoginTimeout()", res);