bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _adabas / ODriver.java
blobc1af17d5ad809fd4689ec18a0255bfa3cdf8c9c8
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._adabas;
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;
29 import com.sun.star.beans.PropertyValue;
30 import com.sun.star.uno.XInterface;
32 /**
33 * Here <code>com.sun.star.sdbc.Driver</code> service is tested.<p>
34 * Test allows to run object tests in several threads concurently.
35 * @see com.sun.star.sdbc.Driver
36 * @see com.sun.star.sdbc.XDriver
37 * @see com.sun.star.sdbcx.XCreateCatalog
38 * @see com.sun.star.sdbcx.XDropCatalog
39 * @see ifc.sdbc._XDriver
40 * @see ifc.sdbcx._XCreateCatalog
41 * @see ifc.sdbcx._XDropCatalog
43 public class ODriver extends TestCase {
44 /**
45 * Creates an instance of the service
46 * <code>com.sun.star.sdbc.Driver</code>. <p>
47 * Object relations created :
48 * <ul>
49 * <li> <code>'XDriver.URL'</code> for {@link ifc.sdbc._XDriver}:
50 * is the URL of the database to which to connect.
51 * The URL is obtained from the parameter <code>adabas.url</code></li>
52 * <li> <code>'XDriver.UNSUITABLE_URL'</code> for {@link ifc.sdbc._XDriver}:
53 * the wrong kind of URL to connect using given driver.
54 * The URL is obtained from the parameter <code>jdbc.url</code></li>
55 * <li> <code>'XDriver.INFO'</code> for {@link ifc.sdbc._XDriver}:
56 * a list of arbitrary string tag/value pairs as connection arguments.
57 * The values for list are obtained from the parameter
58 * <code>adabas.user</code> and <code>adabas.password</code>.</li>
59 * </ul>
61 @Override
62 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
64 XInterface oObj = null;
66 try {
67 oObj = (XInterface)Param.getMSF().
68 createInstance("com.sun.star.comp.sdbcx.adabas.ODriver");
69 } catch (com.sun.star.uno.Exception e) {
70 throw new StatusException(e, Status.failed("Couldn't create object"));
73 log.println("creating a new environment for object");
74 TestEnvironment tEnv = new TestEnvironment(oObj);
76 //adding relation for sdbc.XDriver
77 String adabasURL = (String) Param.get("adabas.url");
78 if (adabasURL == null) {
79 throw new StatusException(Status.failed(
80 "Couldn't get 'adabas.url' from ini-file"));
82 tEnv.addObjRelation("XDriver.URL", "sdbc:adabas:" + adabasURL);
85 String user = (String) Param.get("adabas.user");
86 if (user == null) {
87 throw new StatusException(Status.failed(
88 "Couldn't get 'adabas.user' from ini-file"));
90 String password = (String) Param.get("adabas.password");
91 if (password == null) {
92 throw new StatusException(Status.failed(
93 "Couldn't get 'adabas.password' from ini-file"));
95 PropertyValue[] info = new PropertyValue[2];
96 info[0] = new PropertyValue();
97 info[0].Name = "user"; info[0].Value = user;
98 info[1] = new PropertyValue();
99 info[1].Name = "password"; info[1].Value = password;
100 tEnv.addObjRelation("XDriver.INFO", info);
102 String jdbcUrl = (String) Param.get("jdbc.url");
103 if (jdbcUrl == null) {
104 throw new StatusException(Status.failed(
105 "Couldn't get 'jdbc.url' from ini-file"));
107 tEnv.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl);
109 return tEnv;