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 mod._dbpool; 29 30 import java.io.PrintWriter; 31 32 import lib.Status; 33 import lib.StatusException; 34 import lib.TestCase; 35 import lib.TestEnvironment; 36 import lib.TestParameters; 37 import util.DBTools; 38 39 import com.sun.star.beans.PropertyValue; 40 import com.sun.star.lang.XMultiServiceFactory; 41 import com.sun.star.uno.XInterface; 42 43 /** 44 * Test for object which is represented by service 45 * <code>com.sun.star.sdbc.ConnectionPool</code>. <p> 46 * Object implements the following interfaces : 47 * <ul> 48 * <li> <code>com::sun::star::sdbc::XDriverManager</code></li> 49 * </ul> 50 * @see com.sun.star.sdbc.XDriverManager 51 * @see ifc.sdbc.XDriverManager 52 */ 53 public class OConnectionPool extends TestCase { 54 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { 55 56 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF(); 57 XInterface oObj = null; 58 59 try { 60 oObj = (XInterface) 61 xMSF.createInstance("com.sun.star.sdbc.ConnectionPool"); 62 } catch(com.sun.star.uno.Exception e) { 63 throw new StatusException( 64 Status.failed("Couldn't create instance")); 65 } 66 67 log.println("creating a new environment for object"); 68 TestEnvironment tEnv = new TestEnvironment( oObj ); 69 70 //adding relations for XDriverManager 71 String dbaseURL = (String) Param.get("dbase.url"); 72 if (dbaseURL == null) { 73 throw new StatusException( 74 Status.failed("Couldn't get parameter 'dbase.url'")); 75 } 76 77 tEnv.addObjRelation("SDBC.URL", "sdbc:dbase:" + dbaseURL); 78 79 String jdbcURL = (String) Param.get("jdbc.url"); 80 if (jdbcURL == null) { 81 throw new StatusException( 82 Status.failed("Couldn't get parameter 'jdbc.url'")); 83 } 84 85 tEnv.addObjRelation("JDBC.URL", "jdbc:" + jdbcURL); 86 87 String jdbcUser = (String) Param.get("jdbc.user"); 88 if (jdbcUser == null) { 89 throw new StatusException( 90 Status.failed("Couldn't get parameter 'jdbc.user'")); 91 } 92 93 String jdbcPassword = (String) Param.get("jdbc.password"); 94 if (jdbcPassword == null) { 95 throw new StatusException( 96 Status.failed("Couldn't get parameter 'jdbc.password'")); 97 } 98 99 PropertyValue[] jdbcInfo = new PropertyValue[3]; 100 jdbcInfo[0] = new PropertyValue(); 101 jdbcInfo[0].Name = "user"; 102 jdbcInfo[0].Value = jdbcUser; 103 jdbcInfo[1] = new PropertyValue(); 104 jdbcInfo[1].Name = "password"; 105 jdbcInfo[1].Value = jdbcPassword; 106 jdbcInfo[2] = new PropertyValue(); 107 jdbcInfo[2].Name = "JavaDriverClass"; 108 jdbcInfo[2].Value = DBTools.TST_JDBC_DRIVER; 109 110 tEnv.addObjRelation("JDBC.INFO", jdbcInfo); 111 112 return tEnv; 113 } 114 } 115