merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _adabas / ODriver.java
blobaab91be105d65bd8d9d6fe1bd08904e7b95fc4af
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: ODriver.java,v $
10 * $Revision: 1.5 $
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._adabas;
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;
41 import com.sun.star.beans.PropertyValue;
42 import com.sun.star.lang.XMultiServiceFactory;
43 import com.sun.star.uno.XInterface;
45 /**
46 * Here <code>com.sun.star.sdbc.Driver</code> service is tested.<p>
47 * Test allows to run object tests in several threads concurently.
48 * @see com.sun.star.sdbc.Driver
49 * @see com.sun.star.sdbc.XDriver
50 * @see com.sun.star.sdbcx.XCreateCatalog
51 * @see com.sun.star.sdbcx.XDropCatalog
52 * @see ifc.sdbc._XDriver
53 * @see ifc.sdbcx._XCreateCatalog
54 * @see ifc.sdbcx._XDropCatalog
56 public class ODriver extends TestCase {
57 /**
58 * Creates an instance of the service
59 * <code>com.sun.star.sdbc.Driver</code>. <p>
60 * Object relations created :
61 * <ul>
62 * <li> <code>'XDriver.URL'</code> for {@link ifc.sdbc._XDriver}:
63 * is the URL of the database to which to connect.
64 * The URL is obtained from the parameter <code>adabas.url</code></li>
65 * <li> <code>'XDriver.UNSUITABLE_URL'</code> for {@link ifc.sdbc._XDriver}:
66 * the wrong kind of URL to connect using given driver.
67 * The URL is obtained from the parameter <code>jdbc.url</code></li>
68 * <li> <code>'XDriver.INFO'</code> for {@link ifc.sdbc._XDriver}:
69 * a list of arbitrary string tag/value pairs as connection arguments.
70 * The values for list are obtained from the parameter
71 * <code>adabas.user</code> and <code>adabas.password</code>.</li>
72 * </ul>
74 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
76 XInterface oObj = null;
78 try {
79 oObj = (XInterface)((XMultiServiceFactory)Param.getMSF()).
80 createInstance("com.sun.star.comp.sdbcx.adabas.ODriver");
81 } catch (com.sun.star.uno.Exception e) {
82 e.printStackTrace(log);
83 throw new StatusException(Status.failed("Couldn't create object"));
86 log.println("creating a new environment for object");
87 TestEnvironment tEnv = new TestEnvironment(oObj);
89 //adding relation for sdbc.XDriver
90 String adabasURL = (String) Param.get("adabas.url");
91 if (adabasURL == null) {
92 throw new StatusException(Status.failed(
93 "Couldn't get 'adabas.url' from ini-file"));
95 tEnv.addObjRelation("XDriver.URL", "sdbc:adabas:" + adabasURL);
98 String user = (String) Param.get("adabas.user");
99 if (user == null) {
100 throw new StatusException(Status.failed(
101 "Couldn't get 'adabas.user' from ini-file"));
103 String password = (String) Param.get("adabas.password");
104 if (password == null) {
105 throw new StatusException(Status.failed(
106 "Couldn't get 'adabas.password' from ini-file"));
108 PropertyValue[] info = new PropertyValue[2];
109 info[0] = new PropertyValue();
110 info[0].Name = "user"; info[0].Value = user;
111 info[1] = new PropertyValue();
112 info[1].Name = "password"; info[1].Value = password;
113 tEnv.addObjRelation("XDriver.INFO", info);
115 String jdbcUrl = (String) Param.get("jdbc.url");
116 if (jdbcUrl == null) {
117 throw new StatusException(Status.failed(
118 "Couldn't get 'jdbc.url' from ini-file"));
120 tEnv.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl);
122 return tEnv;