merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _dbpool / OConnectionPool.java
blobd33ccee6a2f1e3b4626dad26155c8890b2874c06
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OConnectionPool.java,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package mod._dbpool;
33 import java.io.PrintWriter;
35 import lib.Status;
36 import lib.StatusException;
37 import lib.TestCase;
38 import lib.TestEnvironment;
39 import lib.TestParameters;
40 import util.DBTools;
42 import com.sun.star.beans.PropertyValue;
43 import com.sun.star.lang.XMultiServiceFactory;
44 import com.sun.star.uno.XInterface;
46 /**
47 * Test for object which is represented by service
48 * <code>com.sun.star.sdbc.ConnectionPool</code>. <p>
49 * Object implements the following interfaces :
50 * <ul>
51 * <li> <code>com::sun::star::sdbc::XDriverManager</code></li>
52 * </ul>
53 * @see com.sun.star.sdbc.XDriverManager
54 * @see ifc.sdbc.XDriverManager
56 public class OConnectionPool extends TestCase {
57 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
59 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
60 XInterface oObj = null;
62 try {
63 oObj = (XInterface)
64 xMSF.createInstance("com.sun.star.sdbc.ConnectionPool");
65 } catch(com.sun.star.uno.Exception e) {
66 throw new StatusException(
67 Status.failed("Couldn't create instance"));
70 log.println("creating a new environment for object");
71 TestEnvironment tEnv = new TestEnvironment( oObj );
73 //adding relations for XDriverManager
74 String dbaseURL = (String) Param.get("dbase.url");
75 if (dbaseURL == null) {
76 throw new StatusException(
77 Status.failed("Couldn't get parameter 'dbase.url'"));
80 tEnv.addObjRelation("SDBC.URL", "sdbc:dbase:" + dbaseURL);
82 String jdbcURL = (String) Param.get("jdbc.url");
83 if (jdbcURL == null) {
84 throw new StatusException(
85 Status.failed("Couldn't get parameter 'jdbc.url'"));
88 tEnv.addObjRelation("JDBC.URL", "jdbc:" + jdbcURL);
90 String jdbcUser = (String) Param.get("jdbc.user");
91 if (jdbcUser == null) {
92 throw new StatusException(
93 Status.failed("Couldn't get parameter 'jdbc.user'"));
96 String jdbcPassword = (String) Param.get("jdbc.password");
97 if (jdbcPassword == null) {
98 throw new StatusException(
99 Status.failed("Couldn't get parameter 'jdbc.password'"));
102 PropertyValue[] jdbcInfo = new PropertyValue[3];
103 jdbcInfo[0] = new PropertyValue();
104 jdbcInfo[0].Name = "user";
105 jdbcInfo[0].Value = jdbcUser;
106 jdbcInfo[1] = new PropertyValue();
107 jdbcInfo[1].Name = "password";
108 jdbcInfo[1].Value = jdbcPassword;
109 jdbcInfo[2] = new PropertyValue();
110 jdbcInfo[2].Name = "JavaDriverClass";
111 jdbcInfo[2].Value = DBTools.TST_JDBC_DRIVER;
113 tEnv.addObjRelation("JDBC.INFO", jdbcInfo);
115 return tEnv;