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 .
21 import java
.io
.PrintWriter
;
24 import lib
.StatusException
;
26 import lib
.TestEnvironment
;
27 import lib
.TestParameters
;
29 import com
.sun
.star
.beans
.PropertyValue
;
30 import com
.sun
.star
.uno
.XInterface
;
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 MozabDriver
extends TestCase
{
45 * Creates an instance of the service
46 * <code>com.sun.star.sdbc.Driver</code>. <p>
47 * Object relations created :
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>mozab.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.
61 protected synchronized TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
63 XInterface oObj
= null;
66 oObj
= (XInterface
)Param
.getMSF().
67 createInstance("com.sun.star.comp.sdbc.MozabDriver");
68 } catch (com
.sun
.star
.uno
.Exception e
) {
69 throw new StatusException(e
, Status
.failed("Couldn't create object"));
72 log
.println("creating a new environment for object");
73 TestEnvironment tEnv
= new TestEnvironment(oObj
);
75 //adding relation for sdbc.XDriver
76 String mozabURL
= (String
) Param
.get("mozab.url");
77 if (mozabURL
== null) {
78 throw new StatusException(Status
.failed(
79 "Couldn't get 'mozabURL' from ini-file"));
81 tEnv
.addObjRelation("XDriver.URL", "sdbc:address:" + mozabURL
);
83 PropertyValue
[] info
= new PropertyValue
[0];
84 tEnv
.addObjRelation("XDriver.INFO", info
);
86 String jdbcUrl
= (String
) Param
.get("jdbc.url");
87 if (jdbcUrl
== null) {
88 throw new StatusException(Status
.failed(
89 "Couldn't get 'jdbc.url' from ini-file"));
91 tEnv
.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl
);