2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
22 import lib
.StatusException
;
24 import com
.sun
.star
.sdbc
.XConnection
;
25 import com
.sun
.star
.sdbc
.XIsolatedConnection
;
26 import com
.sun
.star
.task
.XInteractionHandler
;
29 * Testing <code>com.sun.star.sdb.XCompletedConnection</code>
32 * <li><code> getIsolatedConnectionWithCompletion()</code></li>
33 * <li><code> getIsolatedConnection()</code></li>
35 * The following object relations required :
37 * <li> <code>'XCompletedConnection.Handler'</code> : passed as parameter
38 * to <code>connectWithCompletion</code> method. </li>
40 * @see com.sun.star.sdb.XIsolatedConnection
41 * @see com.sun.star.task.XInteractionHandler
42 * @see com.sun.star.sdbc.XConnection
44 public class _XIsolatedConnection
extends MultiMethodTest
{
46 // oObj filled by MultiMethodTest
47 public XIsolatedConnection oObj
= null ;
50 * Test call the method with handler passed as object relation.
51 * Then value returned is checked.<p>
52 * Has OK status if not null value returned. < >
53 * FAILED if exception occurred, null value returned or object
54 * relation was not found.
56 public void _getIsolatedConnectionWithCompletion() throws StatusException
{
57 XInteractionHandler handler
= (XInteractionHandler
)
58 tEnv
.getObjRelation("XCompletedConnection.Handler") ;
60 if (handler
== null) {
61 log
.println("Required object relation not found !") ;
62 tRes
.tested("getIsolatedConnectionWithCompletion()", false) ;
66 XConnection con
= null ;
68 con
= oObj
.getIsolatedConnectionWithCompletion(handler
) ;
69 } catch (com
.sun
.star
.sdbc
.SQLException e
) {
70 throw new StatusException("Exception while method calling", e
) ;
73 tRes
.tested("getIsolatedConnectionWithCompletion()", con
!= null) ;
77 * Test call the method with handler passed as object relation.
78 * Then value returned is checked.<p>
79 * Has OK status if not null value returned. < >
80 * FAILED if exception occurred, null value returned or object
81 * relation was not found.
83 public void _getIsolatedConnection() throws StatusException
{
84 String
[] userSettings
= (String
[])
85 tEnv
.getObjRelation("UserAndPassword") ;
89 if (userSettings
== null) {
90 log
.println("Required object relation not found !") ;
93 if (userSettings
[0] != null)
94 user
= userSettings
[0].equals("")?
"<empty>":userSettings
[0];
97 if (userSettings
[1] != null)
98 pwd
= userSettings
[1].equals("")?
"<empty>":userSettings
[1];
102 log
.println("Testing \"getIsolatedConnection('user', 'password')\"\n" +
103 "with user = '" + user
+ "'; password = '" + pwd
+ "'");
104 XConnection con
= null ;
106 con
= oObj
.getIsolatedConnection(user
, pwd
) ;
107 } catch (com
.sun
.star
.sdbc
.SQLException e
) {
108 throw new StatusException("Exception while method calling", e
) ;
111 tRes
.tested("getIsolatedConnection()", con
!= null) ;
113 } // finish class _XIsolatedConnection