1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package mod._file.calc; 25 26 import java.io.PrintWriter; 27 28 import lib.Status; 29 import lib.StatusException; 30 import lib.TestCase; 31 import lib.TestEnvironment; 32 import lib.TestParameters; 33 34 import com.sun.star.beans.PropertyValue; 35 import com.sun.star.lang.XMultiServiceFactory; 36 import com.sun.star.uno.XInterface; 37 38 39 /** 40 * Here <code>com.sun.star.sdbc.Driver</code> service is tested.<p> 41 * Test allows to run object tests in several threads concurently. 42 * @see com.sun.star.sdbc.Driver 43 * @see com.sun.star.sdbc.XDriver 44 * @see com.sun.star.sdbcx.XCreateCatalog 45 * @see com.sun.star.sdbcx.XDropCatalog 46 * @see ifc.sdbc._XDriver 47 * @see ifc.sdbcx._XCreateCatalog 48 * @see ifc.sdbcx._XDropCatalog 49 */ 50 public class ODriver extends TestCase { 51 /** 52 * Creating a Testenvironment for the interfaces to be tested. 53 * Creates an instance of the service 54 * <code>com.sun.star.sdbc.Driver</code>. <p> 55 * Object relations created : 56 * <ul> 57 * <li> <code>'XDriver.URL'</code> for {@link ifc.sdbc._XDriver}: 58 * is the URL of the Spreadsheet document to which to connect. 59 * The URL is obtained from the parameter <code>calc.url</code></li> 60 * <li> <code>'XDriver.UNSUITABLE_URL'</code> for 61 * {@link ifc.sdbc._XDriver}: 62 * the wrong kind of URL to connect using given driver. 63 * The URL is obtained from the parameter <code>jdbc.url</code></li> 64 * <li> <code>'XDriver.INFO'</code> for {@link ifc.sdbc._XDriver}: 65 * a list of arbitrary string tag/value pairs as connection arguments 66 * </li> 67 * </ul> 68 */ createTestEnvironment( TestParameters Param, PrintWriter log )69 public synchronized TestEnvironment createTestEnvironment( 70 TestParameters Param, PrintWriter log ) throws StatusException { 71 72 XInterface oObj = null; 73 74 try { 75 oObj = (XInterface)( 76 (XMultiServiceFactory)Param.getMSF()).createInstance( 77 "com.sun.star.comp.sdbc.calc.ODriver"); 78 } catch (com.sun.star.uno.Exception e) { 79 e.printStackTrace(log); 80 throw new StatusException(Status.failed("Couldn't create object")); 81 } 82 83 log.println("creating a new environment for calc.ODriver object"); 84 TestEnvironment tEnv = new TestEnvironment(oObj); 85 86 //adding relation for sdbc.XDriver 87 String calcURL = (String) Param.get("calc.url"); 88 if (calcURL == null) { 89 throw new StatusException(Status.failed( 90 "Couldn't get 'calc.url' from ini-file")); 91 } 92 tEnv.addObjRelation("XDriver.URL", "sdbc:calc:" + calcURL); 93 94 PropertyValue[] info = new PropertyValue[0]; 95 tEnv.addObjRelation("XDriver.INFO", info); 96 97 String jdbcUrl = (String) Param.get("jdbc.url"); 98 if (jdbcUrl == null) { 99 throw new StatusException(Status.failed( 100 "Couldn't get 'jdbc.url' from ini-file")); 101 } 102 tEnv.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl); 103 104 tEnv.addObjRelation("NoBadURL", "TRUE"); 105 106 return tEnv; 107 } 108 } 109