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
._file
.calc
;
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
;
34 * Here <code>com.sun.star.sdbc.Driver</code> service is tested.<p>
35 * Test allows to run object tests in several threads concurently.
36 * @see com.sun.star.sdbc.Driver
37 * @see com.sun.star.sdbc.XDriver
38 * @see com.sun.star.sdbcx.XCreateCatalog
39 * @see com.sun.star.sdbcx.XDropCatalog
40 * @see ifc.sdbc._XDriver
41 * @see ifc.sdbcx._XCreateCatalog
42 * @see ifc.sdbcx._XDropCatalog
44 public class ODriver
extends TestCase
{
46 * Creating a Testenvironment for the interfaces to be tested.
47 * Creates an instance of the service
48 * <code>com.sun.star.sdbc.Driver</code>. <p>
49 * Object relations created :
51 * <li> <code>'XDriver.URL'</code> for {@link ifc.sdbc._XDriver}:
52 * is the URL of the Spreadsheet document to which to connect.
53 * The URL is obtained from the parameter <code>calc.url</code></li>
54 * <li> <code>'XDriver.UNSUITABLE_URL'</code> for
55 * {@link ifc.sdbc._XDriver}:
56 * the wrong kind of URL to connect using given driver.
57 * The URL is obtained from the parameter <code>jdbc.url</code></li>
58 * <li> <code>'XDriver.INFO'</code> for {@link ifc.sdbc._XDriver}:
59 * a list of arbitrary string tag/value pairs as connection arguments
64 public synchronized TestEnvironment
createTestEnvironment(
65 TestParameters Param
, PrintWriter log
) throws StatusException
{
67 XInterface oObj
= null;
70 oObj
= (XInterface
)Param
.getMSF().createInstance(
71 "com.sun.star.comp.sdbc.calc.ODriver");
72 } catch (com
.sun
.star
.uno
.Exception e
) {
73 throw new StatusException(e
, Status
.failed("Couldn't create object"));
76 log
.println("creating a new environment for calc.ODriver object");
77 TestEnvironment tEnv
= new TestEnvironment(oObj
);
79 //adding relation for sdbc.XDriver
80 String calcURL
= (String
) Param
.get("calc.url");
81 if (calcURL
== null) {
82 throw new StatusException(Status
.failed(
83 "Couldn't get 'calc.url' from ini-file"));
85 tEnv
.addObjRelation("XDriver.URL", "sdbc:calc:" + calcURL
);
87 PropertyValue
[] info
= new PropertyValue
[0];
88 tEnv
.addObjRelation("XDriver.INFO", info
);
90 String jdbcUrl
= (String
) Param
.get("jdbc.url");
91 if (jdbcUrl
== null) {
92 throw new StatusException(Status
.failed(
93 "Couldn't get 'jdbc.url' from ini-file"));
95 tEnv
.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl
);
97 tEnv
.addObjRelation("NoBadURL", "TRUE");