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: _XIsolatedConnection.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
;
34 import lib
.StatusException
;
36 import com
.sun
.star
.sdbc
.XConnection
;
37 import com
.sun
.star
.sdbc
.XIsolatedConnection
;
38 import com
.sun
.star
.task
.XInteractionHandler
;
41 * Testing <code>com.sun.star.sdb.XCompletedConnection</code>
44 * <li><code> getIsolatedConnectionWithCompletion()</code></li>
45 * <li><code> getIsolatedConnection()</code></li>
47 * The following object relations required :
49 * <li> <code>'XCompletedConnection.Handler'</code> : passed as parameter
50 * to <code>connectWithCompletion</code> method. </li>
52 * @see com.sun.star.sdb.XIsolatedConnection
53 * @see com.sun.star.task.XInteractionHandler
54 * @see com.sun.star.sdbc.XConnection
56 public class _XIsolatedConnection
extends MultiMethodTest
{
58 // oObj filled by MultiMethodTest
59 public XIsolatedConnection oObj
= null ;
62 * Test call the method with handler passed as object relation.
63 * Then value returned is checked.<p>
64 * Has OK status if not null value returned. < >
65 * FAILED if exception occured, null value returned or object
66 * relation was not found.
68 public void _getIsolatedConnectionWithCompletion() throws StatusException
{
69 XInteractionHandler handler
= (XInteractionHandler
)
70 tEnv
.getObjRelation("XCompletedConnection.Handler") ;
72 if (handler
== null) {
73 log
.println("Required object relation not found !") ;
74 tRes
.tested("getIsolatedConnectionWithCompletion()", false) ;
78 XConnection con
= null ;
80 con
= oObj
.getIsolatedConnectionWithCompletion(handler
) ;
81 } catch (com
.sun
.star
.sdbc
.SQLException e
) {
82 throw new StatusException("Exception while method calling", e
) ;
85 tRes
.tested("getIsolatedConnectionWithCompletion()", con
!= null) ;
89 * Test call the method with handler passed as object relation.
90 * Then value returned is checked.<p>
91 * Has OK status if not null value returned. < >
92 * FAILED if exception occured, null value returned or object
93 * relation was not found.
95 public void _getIsolatedConnection() throws StatusException
{
96 String
[] userSettings
= (String
[])
97 tEnv
.getObjRelation("UserAndPassword") ;
101 if (userSettings
== null) {
102 log
.println("Required object relation not found !") ;
105 if (userSettings
[0] != null)
106 user
= userSettings
[0].equals("")?
"<empty>":userSettings
[0];
109 if (userSettings
[1] != null)
110 pwd
= userSettings
[1].equals("")?
"<empty>":userSettings
[1];
114 log
.println("Testing \"getIsolatedConnection('user', 'password')\"\n" +
115 "with user = '" + user
+ "'; password = '" + pwd
+ "'");
116 XConnection con
= null ;
118 con
= oObj
.getIsolatedConnection(user
, pwd
) ;
119 } catch (com
.sun
.star
.sdbc
.SQLException e
) {
120 throw new StatusException("Exception while method calling", e
) ;
123 tRes
.tested("getIsolatedConnection()", con
!= null) ;
125 } // finish class _XIsolatedConnection