xref: /AOO42X/main/qadevOOo/tests/java/mod/_dbaccess/ConnectionLineAccessibility.java (revision 0b002b3d39521fd05c708aed9efc061fb8f5e93e)
1ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5ef39d40dSAndrew Rist  * distributed with this work for additional information
6ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18ef39d40dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20ef39d40dSAndrew Rist  *************************************************************/
21ef39d40dSAndrew Rist 
22ef39d40dSAndrew Rist 
23*084e0718Smseidel 
24cdf0e10cSrcweir package mod._dbaccess;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import java.io.PrintWriter;
27cdf0e10cSrcweir 
28cdf0e10cSrcweir import lib.Status;
29cdf0e10cSrcweir import lib.StatusException;
30cdf0e10cSrcweir import lib.TestCase;
31cdf0e10cSrcweir import lib.TestEnvironment;
32cdf0e10cSrcweir import lib.TestParameters;
33cdf0e10cSrcweir import util.AccessibilityTools;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir import com.sun.star.accessibility.AccessibleRole;
36cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible;
37cdf0e10cSrcweir import com.sun.star.awt.PosSize;
38cdf0e10cSrcweir import com.sun.star.awt.Rectangle;
39cdf0e10cSrcweir import com.sun.star.awt.XWindow;
40cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
41cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
42cdf0e10cSrcweir import com.sun.star.container.XNameAccess;
43cdf0e10cSrcweir import com.sun.star.container.XNameContainer;
44cdf0e10cSrcweir import com.sun.star.frame.XModel;
45cdf0e10cSrcweir import com.sun.star.frame.XStorable;
46cdf0e10cSrcweir import com.sun.star.lang.XComponent;
47cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
48cdf0e10cSrcweir import com.sun.star.sdb.XDocumentDataSource;
49cdf0e10cSrcweir import com.sun.star.sdb.XQueryDefinitionsSupplier;
50cdf0e10cSrcweir import com.sun.star.sdbc.XConnection;
51cdf0e10cSrcweir import com.sun.star.sdbc.XIsolatedConnection;
52cdf0e10cSrcweir import com.sun.star.sdbc.XStatement;
53cdf0e10cSrcweir import com.sun.star.ucb.XSimpleFileAccess;
54cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
55cdf0e10cSrcweir import com.sun.star.uno.XInterface;
56cdf0e10cSrcweir import util.DesktopTools;
57cdf0e10cSrcweir import util.utils;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 
60cdf0e10cSrcweir /**
61cdf0e10cSrcweir  * Object implements the following interfaces :
62cdf0e10cSrcweir  * <ul>
63cdf0e10cSrcweir  *   <li><code>::com::sun::star::accessibility::XAccessible</code></li>
64cdf0e10cSrcweir  *   <li><code>::com::sun::star::accessibility::XAccessibleContext
65cdf0e10cSrcweir  *   </code></li>
66cdf0e10cSrcweir  *   <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
67cdf0e10cSrcweir  *   </code></li>
68cdf0e10cSrcweir  * </ul><p>
69cdf0e10cSrcweir  * @see com.sun.star.accessibility.XAccessible
70cdf0e10cSrcweir  * @see com.sun.star.accessibility.XAccessibleContext
71cdf0e10cSrcweir  * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
72cdf0e10cSrcweir  * @see ifc.accessibility._XAccessible
73cdf0e10cSrcweir  * @see ifc.accessibility._XAccessibleContext
74cdf0e10cSrcweir  * @see ifc.accessibility._XAccessibleEventBroadcaster
75cdf0e10cSrcweir  */
76cdf0e10cSrcweir public class ConnectionLineAccessibility extends TestCase
77cdf0e10cSrcweir {
78cdf0e10cSrcweir     XWindow xWindow = null;
79cdf0e10cSrcweir     Object oDBSource = null;
80cdf0e10cSrcweir     String aFile = "";
81cdf0e10cSrcweir     XConnection connection = null;
82cdf0e10cSrcweir     XIsolatedConnection isolConnection = null;
83cdf0e10cSrcweir     XComponent QueryComponent = null;
84cdf0e10cSrcweir     String user = "";
85cdf0e10cSrcweir     String password="";
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     /**
88cdf0e10cSrcweir      * Creates a new DataSource and stores it.
89cdf0e10cSrcweir      * Creates a connection and using it
90cdf0e10cSrcweir      * creates two tables in database.
91cdf0e10cSrcweir      * Creates a new query and adds it to DefinitionContainer.
92cdf0e10cSrcweir      * Opens the QueryComponent.with loadComponentFromURL
93*084e0718Smseidel      * and gets the object with the role UNKNOWN and the Implementation
94cdf0e10cSrcweir      * name that contains ConnectionLine
95cdf0e10cSrcweir      * @param Param test parameters
96cdf0e10cSrcweir      * @param log writer to log information while testing
97cdf0e10cSrcweir      * @return
98cdf0e10cSrcweir      * @throws StatusException
99cdf0e10cSrcweir      * @see TestEnvironment
100cdf0e10cSrcweir      */
createTestEnvironment(TestParameters Param, PrintWriter log)101cdf0e10cSrcweir     protected TestEnvironment createTestEnvironment(TestParameters Param,
102cdf0e10cSrcweir             PrintWriter log)
103cdf0e10cSrcweir     {
104cdf0e10cSrcweir         XInterface oObj = null;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         Object oDBContext = null;
107cdf0e10cSrcweir         Object oDBSource = null;
108cdf0e10cSrcweir         Object newQuery = null;
109cdf0e10cSrcweir         Object toolkit = null;
110cdf0e10cSrcweir         XStorable store = null;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir         try
113cdf0e10cSrcweir         {
114cdf0e10cSrcweir             oDBContext = ((XMultiServiceFactory) Param.getMSF())
115cdf0e10cSrcweir             .createInstance("com.sun.star.sdb.DatabaseContext");
116cdf0e10cSrcweir             oDBSource = ((XMultiServiceFactory) Param.getMSF())
117cdf0e10cSrcweir             .createInstance("com.sun.star.sdb.DataSource");
118cdf0e10cSrcweir             newQuery = ((XMultiServiceFactory) Param.getMSF())
119cdf0e10cSrcweir             .createInstance("com.sun.star.sdb.QueryDefinition");
120cdf0e10cSrcweir             toolkit = ((XMultiServiceFactory) Param.getMSF())
121cdf0e10cSrcweir             .createInstance("com.sun.star.awt.Toolkit");
122cdf0e10cSrcweir         }
123cdf0e10cSrcweir         catch (com.sun.star.uno.Exception e)
124cdf0e10cSrcweir         {
125cdf0e10cSrcweir             e.printStackTrace(log);
126cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't create instance"));
127cdf0e10cSrcweir         }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir         String mysqlURL = (String) Param.get("mysql.url");
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         if (mysqlURL == null)
132cdf0e10cSrcweir         {
133cdf0e10cSrcweir             throw new StatusException(Status.failed(
134cdf0e10cSrcweir                     "Couldn't get 'mysql.url' from ini-file"));
135cdf0e10cSrcweir         }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         user = (String) Param.get("jdbc.user");
138cdf0e10cSrcweir         password = (String) Param.get("jdbc.password");
139cdf0e10cSrcweir 
140cdf0e10cSrcweir         if ((user == null) || (password == null))
141cdf0e10cSrcweir         {
142cdf0e10cSrcweir             throw new StatusException(Status.failed(
143cdf0e10cSrcweir                     "Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file"));
144cdf0e10cSrcweir         }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir         PropertyValue[] info = new PropertyValue[2];
147cdf0e10cSrcweir         info[0] = new PropertyValue();
148cdf0e10cSrcweir         info[0].Name = "user";
149cdf0e10cSrcweir         info[0].Value = user;
150cdf0e10cSrcweir         info[1] = new PropertyValue();
151cdf0e10cSrcweir         info[1].Name = "password";
152cdf0e10cSrcweir         info[1].Value = password;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir         XPropertySet propSetDBSource = (XPropertySet) UnoRuntime.queryInterface(
155cdf0e10cSrcweir                 XPropertySet.class, oDBSource);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir         try
158cdf0e10cSrcweir         {
159cdf0e10cSrcweir             propSetDBSource.setPropertyValue("URL", mysqlURL);
160cdf0e10cSrcweir             propSetDBSource.setPropertyValue("Info", info);
161cdf0e10cSrcweir         }
162cdf0e10cSrcweir         catch (com.sun.star.lang.WrappedTargetException e)
163cdf0e10cSrcweir         {
164cdf0e10cSrcweir             e.printStackTrace(log);
165cdf0e10cSrcweir             throw new StatusException(Status.failed(
166cdf0e10cSrcweir                     "Couldn't set property value"));
167cdf0e10cSrcweir         }
168cdf0e10cSrcweir         catch (com.sun.star.lang.IllegalArgumentException e)
169cdf0e10cSrcweir         {
170cdf0e10cSrcweir             e.printStackTrace(log);
171cdf0e10cSrcweir             throw new StatusException(Status.failed(
172cdf0e10cSrcweir                     "Couldn't set property value"));
173cdf0e10cSrcweir         }
174cdf0e10cSrcweir         catch (com.sun.star.beans.PropertyVetoException e)
175cdf0e10cSrcweir         {
176cdf0e10cSrcweir             e.printStackTrace(log);
177cdf0e10cSrcweir             throw new StatusException(Status.failed(
178cdf0e10cSrcweir                     "Couldn't set property value"));
179cdf0e10cSrcweir         }
180cdf0e10cSrcweir         catch (com.sun.star.beans.UnknownPropertyException e)
181cdf0e10cSrcweir         {
182cdf0e10cSrcweir             e.printStackTrace(log);
183cdf0e10cSrcweir             throw new StatusException(Status.failed(
184cdf0e10cSrcweir                     "Couldn't set property value"));
185cdf0e10cSrcweir         }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir         try
188cdf0e10cSrcweir         {
189cdf0e10cSrcweir             log.println("writing database file ...");
190cdf0e10cSrcweir             XDocumentDataSource xDDS = (XDocumentDataSource)
191cdf0e10cSrcweir             UnoRuntime.queryInterface(XDocumentDataSource.class, oDBSource);
192cdf0e10cSrcweir             store = (XStorable) UnoRuntime.queryInterface(XStorable.class,
193cdf0e10cSrcweir                     xDDS.getDatabaseDocument());
194cdf0e10cSrcweir 
195cdf0e10cSrcweir             aFile = utils.getOfficeTemp((XMultiServiceFactory) Param.getMSF())+"ConnectionLine.odb";
196cdf0e10cSrcweir             log.println("... filename will be "+aFile);
197cdf0e10cSrcweir             store.storeAsURL(aFile,new PropertyValue[]
198cdf0e10cSrcweir             {});
199cdf0e10cSrcweir             log.println("... done");
200cdf0e10cSrcweir         }
201cdf0e10cSrcweir         catch (com.sun.star.uno.Exception e)
202cdf0e10cSrcweir         {
203cdf0e10cSrcweir             e.printStackTrace(log);
204cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't register object"));
205cdf0e10cSrcweir         }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir         isolConnection = (XIsolatedConnection) UnoRuntime.queryInterface(
208cdf0e10cSrcweir                 XIsolatedConnection.class,
209cdf0e10cSrcweir                 oDBSource);
210cdf0e10cSrcweir 
211cdf0e10cSrcweir         XConnection connection = null;
212cdf0e10cSrcweir         XStatement statement = null;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir         final String tbl_name1 = "tst_table1";
215cdf0e10cSrcweir         final String tbl_name2 = "tst_table2";
216cdf0e10cSrcweir         final String col_name1 = "id1";
217cdf0e10cSrcweir         final String col_name2 = "id2";
218cdf0e10cSrcweir 
219cdf0e10cSrcweir         try
220cdf0e10cSrcweir         {
221cdf0e10cSrcweir             connection = isolConnection.getIsolatedConnection(user, password);
222cdf0e10cSrcweir             statement = connection.createStatement();
223cdf0e10cSrcweir             statement.executeUpdate("drop table if exists " + tbl_name1);
224cdf0e10cSrcweir             statement.executeUpdate("drop table if exists " + tbl_name2);
225cdf0e10cSrcweir             statement.executeUpdate("create table " + tbl_name1 + " (" +
226cdf0e10cSrcweir                     col_name1 + " int)");
227cdf0e10cSrcweir             statement.executeUpdate("create table " + tbl_name2 + " (" +
228cdf0e10cSrcweir                     col_name2 + " int)");
229cdf0e10cSrcweir         }
230cdf0e10cSrcweir         catch (com.sun.star.sdbc.SQLException e)
231cdf0e10cSrcweir         {
232cdf0e10cSrcweir             try
233cdf0e10cSrcweir             {
234cdf0e10cSrcweir                 shortWait();
235cdf0e10cSrcweir                 connection = isolConnection.getIsolatedConnection(user,
236cdf0e10cSrcweir                         password);
237cdf0e10cSrcweir                 statement = connection.createStatement();
238cdf0e10cSrcweir                 statement.executeUpdate("drop table if exists " + tbl_name1);
239cdf0e10cSrcweir                 statement.executeUpdate("drop table if exists " + tbl_name2);
240cdf0e10cSrcweir                 statement.executeUpdate("create table " + tbl_name1 + " (" +
241cdf0e10cSrcweir                         col_name1 + " int)");
242cdf0e10cSrcweir                 statement.executeUpdate("create table " + tbl_name2 + " (" +
243cdf0e10cSrcweir                         col_name2 + " int)");
244cdf0e10cSrcweir             }
245cdf0e10cSrcweir             catch (com.sun.star.sdbc.SQLException e2)
246cdf0e10cSrcweir             {
247cdf0e10cSrcweir                 e2.printStackTrace(log);
248cdf0e10cSrcweir                 throw new StatusException(Status.failed("SQLException"));
249cdf0e10cSrcweir             }
250cdf0e10cSrcweir         }
251cdf0e10cSrcweir 
252cdf0e10cSrcweir         XQueryDefinitionsSupplier querySuppl = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface(
253cdf0e10cSrcweir                 XQueryDefinitionsSupplier.class,
254cdf0e10cSrcweir                 oDBSource);
255cdf0e10cSrcweir 
256cdf0e10cSrcweir         XNameAccess defContainer = querySuppl.getQueryDefinitions();
257cdf0e10cSrcweir 
258cdf0e10cSrcweir         XPropertySet queryProp = (XPropertySet) UnoRuntime.queryInterface(
259cdf0e10cSrcweir                 XPropertySet.class, newQuery);
260cdf0e10cSrcweir 
261cdf0e10cSrcweir         try
262cdf0e10cSrcweir         {
263cdf0e10cSrcweir             final String query = "select * from " + tbl_name1 + ", " +
264cdf0e10cSrcweir                     tbl_name2 + " where " + tbl_name1 + "." +
265cdf0e10cSrcweir                     col_name1 + "=" + tbl_name2 + "." +
266cdf0e10cSrcweir                     col_name2;
267cdf0e10cSrcweir             queryProp.setPropertyValue("Command", query);
268cdf0e10cSrcweir         }
269cdf0e10cSrcweir         catch (com.sun.star.lang.WrappedTargetException e)
270cdf0e10cSrcweir         {
271cdf0e10cSrcweir             e.printStackTrace(log);
272cdf0e10cSrcweir             throw new StatusException(Status.failed(
273cdf0e10cSrcweir                     "Couldn't set property value"));
274cdf0e10cSrcweir         }
275cdf0e10cSrcweir         catch (com.sun.star.lang.IllegalArgumentException e)
276cdf0e10cSrcweir         {
277cdf0e10cSrcweir             e.printStackTrace(log);
278cdf0e10cSrcweir             throw new StatusException(Status.failed(
279cdf0e10cSrcweir                     "Couldn't set property value"));
280cdf0e10cSrcweir         }
281cdf0e10cSrcweir         catch (com.sun.star.beans.PropertyVetoException e)
282cdf0e10cSrcweir         {
283cdf0e10cSrcweir             e.printStackTrace(log);
284cdf0e10cSrcweir             throw new StatusException(Status.failed(
285cdf0e10cSrcweir                     "Couldn't set property value"));
286cdf0e10cSrcweir         }
287cdf0e10cSrcweir         catch (com.sun.star.beans.UnknownPropertyException e)
288cdf0e10cSrcweir         {
289cdf0e10cSrcweir             e.printStackTrace(log);
290cdf0e10cSrcweir             throw new StatusException(Status.failed(
291cdf0e10cSrcweir                     "Couldn't set property value"));
292cdf0e10cSrcweir         }
293cdf0e10cSrcweir 
294cdf0e10cSrcweir         XNameContainer queryContainer = (XNameContainer) UnoRuntime.queryInterface(
295cdf0e10cSrcweir                 XNameContainer.class,
296cdf0e10cSrcweir                 defContainer);
297cdf0e10cSrcweir 
298cdf0e10cSrcweir         try
299cdf0e10cSrcweir         {
300cdf0e10cSrcweir             queryContainer.insertByName("Query1", newQuery);
301cdf0e10cSrcweir             store.store();
302cdf0e10cSrcweir             connection.close();
303cdf0e10cSrcweir         }
304cdf0e10cSrcweir         catch (com.sun.star.lang.WrappedTargetException e)
305cdf0e10cSrcweir         {
306cdf0e10cSrcweir             e.printStackTrace(log);
307cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't insert query"));
308cdf0e10cSrcweir         }
309cdf0e10cSrcweir         catch (com.sun.star.container.ElementExistException e)
310cdf0e10cSrcweir         {
311cdf0e10cSrcweir             e.printStackTrace(log);
312cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't insert query"));
313cdf0e10cSrcweir         }
314cdf0e10cSrcweir         catch (com.sun.star.lang.IllegalArgumentException e)
315cdf0e10cSrcweir         {
316cdf0e10cSrcweir             e.printStackTrace(log);
317cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't insert query"));
318cdf0e10cSrcweir         }
319cdf0e10cSrcweir         catch (com.sun.star.io.IOException e)
320cdf0e10cSrcweir         {
321cdf0e10cSrcweir             e.printStackTrace(log);
322cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't insert query"));
323cdf0e10cSrcweir         }
324cdf0e10cSrcweir         catch (com.sun.star.sdbc.SQLException e)
325cdf0e10cSrcweir         {
326cdf0e10cSrcweir             e.printStackTrace(log);
327cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't insert query"));
328cdf0e10cSrcweir         }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir         PropertyValue[] loadProps = new PropertyValue[3];
331cdf0e10cSrcweir         loadProps[0] = new PropertyValue();
332cdf0e10cSrcweir         loadProps[0].Name = "QueryDesignView";
333cdf0e10cSrcweir         loadProps[0].Value = Boolean.TRUE;
334cdf0e10cSrcweir 
335cdf0e10cSrcweir         loadProps[1] = new PropertyValue();
336cdf0e10cSrcweir         loadProps[1].Name = "CurrentQuery";
337cdf0e10cSrcweir         loadProps[1].Value = "Query1";
338cdf0e10cSrcweir 
339cdf0e10cSrcweir         loadProps[2] = new PropertyValue();
340cdf0e10cSrcweir         loadProps[2].Name = "DataSource";
341cdf0e10cSrcweir         loadProps[2].Value = oDBSource;
342cdf0e10cSrcweir 
343cdf0e10cSrcweir         QueryComponent = DesktopTools.loadDoc((XMultiServiceFactory) Param.getMSF(),".component:DB/QueryDesign",loadProps);
344cdf0e10cSrcweir 
345cdf0e10cSrcweir         util.utils.shortWait(1000);
346cdf0e10cSrcweir 
347cdf0e10cSrcweir         xWindow = UnoRuntime.queryInterface(XModel.class, QueryComponent).
348cdf0e10cSrcweir             getCurrentController().getFrame().getContainerWindow();
349cdf0e10cSrcweir 
350cdf0e10cSrcweir         XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
351cdf0e10cSrcweir 
352cdf0e10cSrcweir         AccessibilityTools.printAccessibleTree (log,xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
353cdf0e10cSrcweir 
354cdf0e10cSrcweir         oObj = AccessibilityTools.getAccessibleObjectForRoleIgnoreShowing(xRoot, AccessibleRole.UNKNOWN, "", "ConnectionLine");
355cdf0e10cSrcweir 
356cdf0e10cSrcweir         log.println("ImplementationName " + util.utils.getImplName(oObj));
357cdf0e10cSrcweir 
358cdf0e10cSrcweir         log.println("creating TestEnvironment");
359cdf0e10cSrcweir 
360cdf0e10cSrcweir         TestEnvironment tEnv = new TestEnvironment(oObj);
361cdf0e10cSrcweir 
362cdf0e10cSrcweir         shortWait();
363cdf0e10cSrcweir 
364cdf0e10cSrcweir         final XWindow queryWin = xWindow;
365cdf0e10cSrcweir 
366cdf0e10cSrcweir         tEnv.addObjRelation("EventProducer",
367cdf0e10cSrcweir                 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer()
368cdf0e10cSrcweir         {
369cdf0e10cSrcweir             public void fireEvent()
370cdf0e10cSrcweir             {
371cdf0e10cSrcweir                 Rectangle rect = queryWin.getPosSize();
372cdf0e10cSrcweir                 queryWin.setPosSize(rect.X, rect.Y, rect.Height-5, rect.Width-5, PosSize.POSSIZE);
373cdf0e10cSrcweir             }
374cdf0e10cSrcweir         });
375cdf0e10cSrcweir 
376cdf0e10cSrcweir         return tEnv;
377cdf0e10cSrcweir     } // finish method getTestEnvironment
378cdf0e10cSrcweir 
379cdf0e10cSrcweir     /**
380cdf0e10cSrcweir      * Closes the DatasourceAdministration dialog and Query Dialog.
381cdf0e10cSrcweir      */
cleanup(TestParameters Param, PrintWriter log)382cdf0e10cSrcweir     protected void cleanup(TestParameters Param, PrintWriter log)
383cdf0e10cSrcweir     {
384cdf0e10cSrcweir         try
385cdf0e10cSrcweir         {
386cdf0e10cSrcweir 
387cdf0e10cSrcweir             log.println("closing QueryComponent ...");
388cdf0e10cSrcweir             DesktopTools.closeDoc(QueryComponent);
389cdf0e10cSrcweir             log.println("... done");
390cdf0e10cSrcweir             XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
391cdf0e10cSrcweir             Object sfa = xMSF.createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
392cdf0e10cSrcweir             XSimpleFileAccess xSFA = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, sfa);
393cdf0e10cSrcweir             log.println("deleting database file");
394cdf0e10cSrcweir             xSFA.kill(aFile);
395cdf0e10cSrcweir             log.println("Could delete file "+aFile+": "+!xSFA.exists(aFile));
396cdf0e10cSrcweir         }
397cdf0e10cSrcweir         catch (Exception e)
398cdf0e10cSrcweir         {
399cdf0e10cSrcweir             e.printStackTrace();
400cdf0e10cSrcweir         }
401cdf0e10cSrcweir     }
402cdf0e10cSrcweir 
403cdf0e10cSrcweir     /**
404*084e0718Smseidel      * Sleeps for 1.5 sec. to allow OpenOffice to react on <code>
405cdf0e10cSrcweir      * reset</code> call.
406cdf0e10cSrcweir      */
shortWait()407cdf0e10cSrcweir     private void shortWait()
408cdf0e10cSrcweir     {
409cdf0e10cSrcweir         try
410cdf0e10cSrcweir         {
411cdf0e10cSrcweir             Thread.sleep(1500);
412cdf0e10cSrcweir         }
413cdf0e10cSrcweir         catch (InterruptedException e)
414cdf0e10cSrcweir         {
415cdf0e10cSrcweir             log.println("While waiting :" + e);
416cdf0e10cSrcweir         }
417cdf0e10cSrcweir     }
418cdf0e10cSrcweir }
419