tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _dbaccess / ODatabaseContext.java
blob24b69854b26a7c740db8843b8f8e1c491a367be4
1 /*
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._dbaccess;
21 import com.sun.star.beans.PropertyValue;
22 import java.io.PrintWriter;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
28 import com.sun.star.beans.XPropertySet;
29 import com.sun.star.lang.XMultiServiceFactory;
30 import com.sun.star.uno.UnoRuntime;
31 import com.sun.star.uno.XInterface;
32 import com.sun.star.uno.XNamingService;
33 import com.sun.star.frame.XStorable;
34 import com.sun.star.sdb.XDocumentDataSource;
35 import util.utils;
37 /**
38 * Test for object which is represented by service
39 * <code>com.sun.star.sdb.DatabaseContext</code>. <p>
41 * Object implements the following interfaces :
42 * <ul>
43 * <li> <code>com::sun::star::container::XEnumerationAccess</code></li>
44 * <li> <code>com::sun::star::container::XNameAccess</code></li>
45 * <li> <code>com::sun::star::container::XElementAccess</code></li>
46 * <li> <code>com::sun::star::uno::XNamingService</code></li>
47 * </ul>
49 * @see com.sun.star.container.XNameAccess
50 * @see com.sun.star.container.XEnumerationAccess
51 * @see com.sun.star.container.XElementAccess
52 * @see com.sun.star.uno.XNamingService
53 * @see com.sun.star.sdb.DatabaseContext
54 * @see ifc.container._XNameAccess
55 * @see ifc.container._XEnumerationAccess
56 * @see ifc.container._XElementAccess
57 * @see ifc.uno._XNamingService
59 public class ODatabaseContext extends TestCase {
61 /**
62 * Creating a TestEnvironment for the interfaces to be tested.
63 * Creates service <code>com.sun.star.sdb.DatabaseContext</code>.
64 * Needed object relations :
65 * <ul>
66 * <li> <code>'XNamingService.RegisterObject'</code> for
67 * {@link ifc.uno._XNamingService} as an
68 * instance of <code>com.sun.star.sdb.DataSource</code>
69 * service. </li>
70 * </ul>
72 @Override
73 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
74 XMultiServiceFactory xMSF = Param.getMSF();
75 Object oInterface = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" );
76 XInterface oObj = (XInterface) oInterface;
78 log.println( " creating a new environment for object" );
79 TestEnvironment tEnv = new TestEnvironment( oObj );
81 // adding obj relation for XNamingService
82 oInterface = xMSF.createInstance( "com.sun.star.sdb.DataSource" );
84 XPropertySet xDSProps = UnoRuntime.queryInterface(XPropertySet.class, oInterface) ;
86 xDSProps.setPropertyValue("URL", "sdbc:dbase:file:///.") ;
88 XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, oInterface);
89 XStorable store = UnoRuntime.queryInterface(XStorable.class,
90 xDDS.getDatabaseDocument ());
91 String aFile = utils.getOfficeTemp (Param.getMSF ())+"DatabaseContext.odb";
92 log.println("store to '" + aFile + "'");
93 store.storeAsURL(aFile,new PropertyValue[]{});
95 tEnv.addObjRelation("XNamingService.RegisterObject", oInterface) ;
97 tEnv.addObjRelation("INSTANCE", oInterface);
99 tEnv.addObjRelation("XContainer.Container",
100 UnoRuntime.queryInterface(
101 XNamingService.class, oObj));
103 return tEnv;
104 } // finish method getTestEnvironment