merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _mozab / MozabDriver.java
blob6f7f287846863e133cff9b019a378f5afd57c254
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: MozabDriver.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._mozab;
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 MozabDriver 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>mozab.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 * </li>
71 * </ul>
73 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
75 XInterface oObj = null;
77 try {
78 oObj = (XInterface)((XMultiServiceFactory)Param.getMSF()).
79 createInstance("com.sun.star.comp.sdbc.MozabDriver");
80 } catch (com.sun.star.uno.Exception e) {
81 throw new StatusException(Status.failed("Couldn't create object"));
84 log.println("creating a new environment for object");
85 TestEnvironment tEnv = new TestEnvironment(oObj);
87 //adding relation for sdbc.XDriver
88 String mozabURL = (String) Param.get("mozab.url");
89 if (mozabURL == null) {
90 throw new StatusException(Status.failed(
91 "Couldn't get 'mozabURL' from ini-file"));
93 tEnv.addObjRelation("XDriver.URL", "sdbc:address:" + mozabURL);
95 PropertyValue[] info = new PropertyValue[0];
96 tEnv.addObjRelation("XDriver.INFO", info);
98 String jdbcUrl = (String) Param.get("jdbc.url");
99 if (jdbcUrl == null) {
100 throw new StatusException(Status.failed(
101 "Couldn't get 'jdbc.url' from ini-file"));
103 tEnv.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl);
105 return tEnv;