Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sdbc / _XIsolatedConnection.java
blobf8795163937fa9e14e968850b4a97647c935dbd5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc.sdbc;
30 import lib.MultiMethodTest;
31 import lib.StatusException;
33 import com.sun.star.sdbc.XConnection;
34 import com.sun.star.sdbc.XIsolatedConnection;
35 import com.sun.star.task.XInteractionHandler;
37 /**
38 * Testing <code>com.sun.star.sdb.XCompletedConnection</code>
39 * interface methods :
40 * <ul>
41 * <li><code> getIsolatedConnectionWithCompletion()</code></li>
42 * <li><code> getIsolatedConnection()</code></li>
43 * </ul> <p>
44 * The following object relations required :
45 * <ul>
46 * <li> <code>'XCompletedConnection.Handler'</code> : passed as parameter
47 * to <code>connectWithCompletion</code> method. </li>
48 * </ul>
49 * @see com.sun.star.sdb.XIsolatedConnection
50 * @see com.sun.star.task.XInteractionHandler
51 * @see com.sun.star.sdbc.XConnection
53 public class _XIsolatedConnection extends MultiMethodTest {
55 // oObj filled by MultiMethodTest
56 public XIsolatedConnection oObj = null ;
58 /**
59 * Test call the method with handler passed as object relation.
60 * Then value returned is checked.<p>
61 * Has OK status if not null value returned. <&nbsp>
62 * FAILED if exception occurred, null value returned or object
63 * relation was not found.
65 public void _getIsolatedConnectionWithCompletion() throws StatusException {
66 XInteractionHandler handler = (XInteractionHandler)
67 tEnv.getObjRelation("XCompletedConnection.Handler") ;
69 if (handler == null) {
70 log.println("Required object relation not found !") ;
71 tRes.tested("getIsolatedConnectionWithCompletion()", false) ;
72 return ;
75 XConnection con = null ;
76 try {
77 con = oObj.getIsolatedConnectionWithCompletion(handler) ;
78 } catch (com.sun.star.sdbc.SQLException e) {
79 throw new StatusException("Exception while method calling", e) ;
82 tRes.tested("getIsolatedConnectionWithCompletion()", con != null) ;
85 /**
86 * Test call the method with handler passed as object relation.
87 * Then value returned is checked.<p>
88 * Has OK status if not null value returned. <&nbsp>
89 * FAILED if exception occurred, null value returned or object
90 * relation was not found.
92 public void _getIsolatedConnection() throws StatusException {
93 String[] userSettings = (String[])
94 tEnv.getObjRelation("UserAndPassword") ;
96 String user = null;
97 String pwd = null;
98 if (userSettings == null) {
99 log.println("Required object relation not found !") ;
102 if (userSettings[0] != null)
103 user = userSettings[0].equals("")?"<empty>":userSettings[0];
104 else
105 user = "<null>";
106 if (userSettings[1] != null)
107 pwd = userSettings[1].equals("")?"<empty>":userSettings[1];
108 else
109 pwd = "<null>";
111 log.println("Testing \"getIsolatedConnection('user', 'password')\"\n" +
112 "with user = '" + user + "'; password = '" + pwd + "'");
113 XConnection con = null ;
114 try {
115 con = oObj.getIsolatedConnection(user, pwd) ;
116 } catch (com.sun.star.sdbc.SQLException e) {
117 throw new StatusException("Exception while method calling", e) ;
120 tRes.tested("getIsolatedConnection()", con != null) ;
122 } // finish class _XIsolatedConnection