1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XDataSource.java,v $
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 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.sdbc
.XConnection
;
36 import com
.sun
.star
.sdbc
.XDataSource
;
39 * Testing <code>com.sun.star.sdbc.XDataSource</code>
42 * <li><code>getConnection()</code></li>
43 * <li><code>setLoginTimeout()</code></li>
44 * <li><code>getLoginTimeout()</code></li>
46 * @see com.sun.star.sdbc.XDataSource
48 public class _XDataSource
extends MultiMethodTest
{
49 // oObj filled by MultiMethodTest
50 public XDataSource oObj
= null;
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() {
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
);
69 tRes
.tested("getConnection()", res
);
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()");
83 log
.println("setLoginTimeout(" + TO
+ ")");
84 oObj
.setLoginTimeout(TO
);
85 int timeout
= oObj
.getLoginTimeout();
87 log
.println("getLoginTimeout(): " + timeout
);
88 } catch(com
.sun
.star
.sdbc
.SQLException e
) {
89 log
.println("Unexpected exception:");
90 e
.printStackTrace(log
);
94 tRes
.tested("setLoginTimeout()", res
);
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() {
106 int timeout
= oObj
.getLoginTimeout();
107 log
.println("getLoginTimeout(): " + timeout
);
109 } catch(com
.sun
.star
.sdbc
.SQLException e
) {
110 log
.println("Unexpected exception:");
111 e
.printStackTrace(log
);
115 tRes
.tested("getLoginTimeout()", res
);