Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _dbpool / OConnectionPool.java
blob468d97966523874ac6bf3579c66839ed78f83f82
1 /*
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 .
19 package mod._dbpool;
21 import java.io.PrintWriter;
23 import lib.Status;
24 import lib.StatusException;
25 import lib.TestCase;
26 import lib.TestEnvironment;
27 import lib.TestParameters;
28 import util.DBTools;
30 import com.sun.star.beans.PropertyValue;
31 import com.sun.star.lang.XMultiServiceFactory;
32 import com.sun.star.uno.XInterface;
34 /**
35 * Test for object which is represented by service
36 * <code>com.sun.star.sdbc.ConnectionPool</code>. <p>
37 * Object implements the following interfaces :
38 * <ul>
39 * <li> <code>com::sun::star::sdbc::XDriverManager</code></li>
40 * </ul>
41 * @see com.sun.star.sdbc.XDriverManager
42 * @see ifc.sdbc._XDriverManager
44 public class OConnectionPool extends TestCase {
45 @Override
46 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
48 XMultiServiceFactory xMSF = Param.getMSF();
49 XInterface oObj = null;
51 try {
52 oObj = (XInterface)
53 xMSF.createInstance("com.sun.star.sdbc.ConnectionPool");
54 } catch(com.sun.star.uno.Exception e) {
55 throw new StatusException(e, Status.failed("Couldn't create instance"));
58 log.println("creating a new environment for object");
59 TestEnvironment tEnv = new TestEnvironment( oObj );
61 //adding relations for XDriverManager
62 String dbaseURL = (String) Param.get("dbase.url");
63 if (dbaseURL == null) {
64 throw new StatusException(
65 Status.failed("Couldn't get parameter 'dbase.url'"));
68 tEnv.addObjRelation("SDBC.URL", "sdbc:dbase:" + dbaseURL);
70 String jdbcURL = (String) Param.get("jdbc.url");
71 if (jdbcURL == null) {
72 throw new StatusException(
73 Status.failed("Couldn't get parameter 'jdbc.url'"));
76 tEnv.addObjRelation("JDBC.URL", "jdbc:" + jdbcURL);
78 String jdbcUser = (String) Param.get("jdbc.user");
79 if (jdbcUser == null) {
80 throw new StatusException(
81 Status.failed("Couldn't get parameter 'jdbc.user'"));
84 String jdbcPassword = (String) Param.get("jdbc.password");
85 if (jdbcPassword == null) {
86 throw new StatusException(
87 Status.failed("Couldn't get parameter 'jdbc.password'"));
90 PropertyValue[] jdbcInfo = new PropertyValue[3];
91 jdbcInfo[0] = new PropertyValue();
92 jdbcInfo[0].Name = "user";
93 jdbcInfo[0].Value = jdbcUser;
94 jdbcInfo[1] = new PropertyValue();
95 jdbcInfo[1].Name = "password";
96 jdbcInfo[1].Value = jdbcPassword;
97 jdbcInfo[2] = new PropertyValue();
98 jdbcInfo[2].Name = "JavaDriverClass";
99 jdbcInfo[2].Value = DBTools.TST_JDBC_DRIVER;
101 tEnv.addObjRelation("JDBC.INFO", jdbcInfo);
103 return tEnv;