1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 package ifc.sdbc; 29 30 import lib.MultiMethodTest; 31 import lib.StatusException; 32 33 import com.sun.star.sdbc.XConnection; 34 import com.sun.star.sdbc.XIsolatedConnection; 35 import com.sun.star.task.XInteractionHandler; 36 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 52 */ 53 public class _XIsolatedConnection extends MultiMethodTest { 54 55 // oObj filled by MultiMethodTest 56 public XIsolatedConnection oObj = null ; 57 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. < > 62 * FAILED if exception occured, null value returned or object 63 * relation was not found. 64 */ 65 public void _getIsolatedConnectionWithCompletion() throws StatusException { 66 XInteractionHandler handler = (XInteractionHandler) 67 tEnv.getObjRelation("XCompletedConnection.Handler") ; 68 69 if (handler == null) { 70 log.println("Required object relation not found !") ; 71 tRes.tested("getIsolatedConnectionWithCompletion()", false) ; 72 return ; 73 } 74 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) ; 80 } 81 82 tRes.tested("getIsolatedConnectionWithCompletion()", con != null) ; 83 } 84 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. < > 89 * FAILED if exception occured, null value returned or object 90 * relation was not found. 91 */ 92 public void _getIsolatedConnection() throws StatusException { 93 String[] userSettings = (String[]) 94 tEnv.getObjRelation("UserAndPassword") ; 95 96 String user = null; 97 String pwd = null; 98 if (userSettings == null) { 99 log.println("Required object relation not found !") ; 100 } 101 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>"; 110 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) ; 118 } 119 120 tRes.tested("getIsolatedConnection()", con != null) ; 121 } 122 } // finish class _XIsolatedConnection 123 124