1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ODriver.java,v $
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
._file
.calc
;
33 import java
.io
.PrintWriter
;
36 import lib
.StatusException
;
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
;
47 * Here <code>com.sun.star.sdbc.Driver</code> service is tested.<p>
48 * Test allows to run object tests in several threads concurently.
49 * @see com.sun.star.sdbc.Driver
50 * @see com.sun.star.sdbc.XDriver
51 * @see com.sun.star.sdbcx.XCreateCatalog
52 * @see com.sun.star.sdbcx.XDropCatalog
53 * @see ifc.sdbc._XDriver
54 * @see ifc.sdbcx._XCreateCatalog
55 * @see ifc.sdbcx._XDropCatalog
57 public class ODriver
extends TestCase
{
59 * Creating a Testenvironment for the interfaces to be tested.
60 * Creates an instance of the service
61 * <code>com.sun.star.sdbc.Driver</code>. <p>
62 * Object relations created :
64 * <li> <code>'XDriver.URL'</code> for {@link ifc.sdbc._XDriver}:
65 * is the URL of the Spreadsheet document to which to connect.
66 * The URL is obtained from the parameter <code>calc.url</code></li>
67 * <li> <code>'XDriver.UNSUITABLE_URL'</code> for
68 * {@link ifc.sdbc._XDriver}:
69 * the wrong kind of URL to connect using given driver.
70 * The URL is obtained from the parameter <code>jdbc.url</code></li>
71 * <li> <code>'XDriver.INFO'</code> for {@link ifc.sdbc._XDriver}:
72 * a list of arbitrary string tag/value pairs as connection arguments
76 public synchronized TestEnvironment
createTestEnvironment(
77 TestParameters Param
, PrintWriter log
) throws StatusException
{
79 XInterface oObj
= null;
83 (XMultiServiceFactory
)Param
.getMSF()).createInstance(
84 "com.sun.star.comp.sdbc.calc.ODriver");
85 } catch (com
.sun
.star
.uno
.Exception e
) {
86 e
.printStackTrace(log
);
87 throw new StatusException(Status
.failed("Couldn't create object"));
90 log
.println("creating a new environment for calc.ODriver object");
91 TestEnvironment tEnv
= new TestEnvironment(oObj
);
93 //adding relation for sdbc.XDriver
94 String calcURL
= (String
) Param
.get("calc.url");
95 if (calcURL
== null) {
96 throw new StatusException(Status
.failed(
97 "Couldn't get 'calc.url' from ini-file"));
99 tEnv
.addObjRelation("XDriver.URL", "sdbc:calc:" + calcURL
);
101 PropertyValue
[] info
= new PropertyValue
[0];
102 tEnv
.addObjRelation("XDriver.INFO", info
);
104 String jdbcUrl
= (String
) Param
.get("jdbc.url");
105 if (jdbcUrl
== null) {
106 throw new StatusException(Status
.failed(
107 "Couldn't get 'jdbc.url' from ini-file"));
109 tEnv
.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl
);
111 tEnv
.addObjRelation("NoBadURL", "TRUE");