Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / sdbc / _XIsolatedConnection.java
blob1a29345cbd82116d10dee17d5c5eaff23cae046e
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: _XIsolatedConnection.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;
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;
40 /**
41 * Testing <code>com.sun.star.sdb.XCompletedConnection</code>
42 * interface methods :
43 * <ul>
44 * <li><code> getIsolatedConnectionWithCompletion()</code></li>
45 * <li><code> getIsolatedConnection()</code></li>
46 * </ul> <p>
47 * The following object relations required :
48 * <ul>
49 * <li> <code>'XCompletedConnection.Handler'</code> : passed as parameter
50 * to <code>connectWithCompletion</code> method. </li>
51 * </ul>
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 ;
61 /**
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. <&nbsp>
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) ;
75 return ;
78 XConnection con = null ;
79 try {
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) ;
88 /**
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. <&nbsp>
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") ;
99 String user = null;
100 String pwd = null;
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];
107 else
108 user = "<null>";
109 if (userSettings[1] != null)
110 pwd = userSettings[1].equals("")?"<empty>":userSettings[1];
111 else
112 pwd = "<null>";
114 log.println("Testing \"getIsolatedConnection('user', 'password')\"\n" +
115 "with user = '" + user + "'; password = '" + pwd + "'");
116 XConnection con = null ;
117 try {
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