1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package ifc.sdbc; 25 26 import lib.MultiMethodTest; 27 import lib.StatusException; 28 29 import com.sun.star.sdbc.XConnection; 30 import com.sun.star.sdbc.XIsolatedConnection; 31 import com.sun.star.task.XInteractionHandler; 32 33 /** 34 * Testing <code>com.sun.star.sdb.XCompletedConnection</code> 35 * interface methods : 36 * <ul> 37 * <li><code> getIsolatedConnectionWithCompletion()</code></li> 38 * <li><code> getIsolatedConnection()</code></li> 39 * </ul> <p> 40 * The following object relations required : 41 * <ul> 42 * <li> <code>'XCompletedConnection.Handler'</code> : passed as parameter 43 * to <code>connectWithCompletion</code> method. </li> 44 * </ul> 45 * @see com.sun.star.sdb.XIsolatedConnection 46 * @see com.sun.star.task.XInteractionHandler 47 * @see com.sun.star.sdbc.XConnection 48 */ 49 public class _XIsolatedConnection extends MultiMethodTest { 50 51 // oObj filled by MultiMethodTest 52 public XIsolatedConnection oObj = null ; 53 54 /** 55 * Test call the method with handler passed as object relation. 56 * Then value returned is checked.<p> 57 * Has OK status if not null value returned. < > 58 * FAILED if exception occured, null value returned or object 59 * relation was not found. 60 */ _getIsolatedConnectionWithCompletion()61 public void _getIsolatedConnectionWithCompletion() throws StatusException { 62 XInteractionHandler handler = (XInteractionHandler) 63 tEnv.getObjRelation("XCompletedConnection.Handler") ; 64 65 if (handler == null) { 66 log.println("Required object relation not found !") ; 67 tRes.tested("getIsolatedConnectionWithCompletion()", false) ; 68 return ; 69 } 70 71 XConnection con = null ; 72 try { 73 con = oObj.getIsolatedConnectionWithCompletion(handler) ; 74 } catch (com.sun.star.sdbc.SQLException e) { 75 throw new StatusException("Exception while method calling", e) ; 76 } 77 78 tRes.tested("getIsolatedConnectionWithCompletion()", con != null) ; 79 } 80 81 /** 82 * Test call the method with handler passed as object relation. 83 * Then value returned is checked.<p> 84 * Has OK status if not null value returned. < > 85 * FAILED if exception occured, null value returned or object 86 * relation was not found. 87 */ _getIsolatedConnection()88 public void _getIsolatedConnection() throws StatusException { 89 String[] userSettings = (String[]) 90 tEnv.getObjRelation("UserAndPassword") ; 91 92 String user = null; 93 String pwd = null; 94 if (userSettings == null) { 95 log.println("Required object relation not found !") ; 96 } 97 98 if (userSettings[0] != null) 99 user = userSettings[0].equals("")?"<empty>":userSettings[0]; 100 else 101 user = "<null>"; 102 if (userSettings[1] != null) 103 pwd = userSettings[1].equals("")?"<empty>":userSettings[1]; 104 else 105 pwd = "<null>"; 106 107 log.println("Testing \"getIsolatedConnection('user', 'password')\"\n" + 108 "with user = '" + user + "'; password = '" + pwd + "'"); 109 XConnection con = null ; 110 try { 111 con = oObj.getIsolatedConnection(user, pwd) ; 112 } catch (com.sun.star.sdbc.SQLException e) { 113 throw new StatusException("Exception while method calling", e) ; 114 } 115 116 tRes.tested("getIsolatedConnection()", con != null) ; 117 } 118 } // finish class _XIsolatedConnection 119 120