tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _cached / CachedDynamicResultSetStubFactory.java
blob5249b8e26096660a81ec4c026c1ef65b61191f3d
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._cached;
21 import com.sun.star.beans.Property;
22 import com.sun.star.lang.XMultiServiceFactory;
23 import com.sun.star.ucb.Command;
24 import com.sun.star.ucb.NumberedSortingInfo;
25 import com.sun.star.ucb.OpenCommandArgument2;
26 import com.sun.star.ucb.OpenMode;
27 import com.sun.star.ucb.XCommandProcessor;
28 import com.sun.star.ucb.XContent;
29 import com.sun.star.ucb.XContentIdentifier;
30 import com.sun.star.ucb.XContentIdentifierFactory;
31 import com.sun.star.ucb.XContentProvider;
32 import com.sun.star.ucb.XDynamicResultSet;
33 import com.sun.star.uno.UnoRuntime;
34 import com.sun.star.uno.XInterface;
35 import com.sun.star.uno.Type;
36 import com.sun.star.uno.AnyConverter;
37 import java.io.PrintWriter;
38 import lib.TestCase;
39 import lib.TestEnvironment;
40 import lib.TestParameters;
42 /**
43 * Test for object which is represented by service
44 * <code>com.sun.star.ucb.CachedDynamicResultSetStubFactory</code>. <p>
45 * Object implements the following interfaces :
46 * <ul>
47 * <li> <code>com::sun::star::ucb::XCachedDynamicResultSetStubFactory</code></li>
48 * </ul> <p>
49 * This object test <b> is NOT </b> designed to be run in several
50 * threads concurrently.
51 * @see com.sun.star.ucb.XCachedDynamicResultSetStubFactory
52 * @see com.sun.star.ucb.CachedDynamicResultSetStubFactory
53 * @see ifc.ucb._XCachedDynamicResultSetStubFactory
55 public class CachedDynamicResultSetStubFactory extends TestCase {
57 /**
58 * Creating a TestEnvironment for the interfaces to be tested.
59 * Creates an instance of the service
60 * <code>com.sun.star.ucb.CachedDynamicResultSetStubFactory</code>. <p>
61 * Object relations created :
62 * <ul>
63 * <li> <code>'DynamicResultSet'</code> for
64 * {@link ifc.ucb._XCachedDynamicResultSetStubFactory} : the destination
65 * interface requires as its parameter an instance of
66 * <code>DynamicResultSet</code> service. It is created
67 * using <code>UniversalContentBroker</code> and querying it for
68 * <code>PackageContent</code> which represents JAR file mentioned
69 * above. Then the dynamic list of file contents (entries) is retrieved.
70 * </li>
71 * </ul>
73 @Override
74 public TestEnvironment createTestEnvironment( TestParameters Param,
75 PrintWriter log )
76 throws Exception {
77 XMultiServiceFactory xMSF = Param.getMSF();
78 Object oInterface = xMSF.createInstance
79 ( "com.sun.star.ucb.CachedDynamicResultSetStubFactory" );
80 XInterface oObj = (XInterface) oInterface;
82 TestEnvironment tEnv = new TestEnvironment( oObj );
84 // creating relation for XCachedDynamicResultSetStubFactory
85 XDynamicResultSet dynResSet = null ;
86 Object oUCB = xMSF.createInstanceWithArguments
87 ("com.sun.star.ucb.UniversalContentBroker",
88 new Object[0]) ;
90 XContentIdentifierFactory ciFac = UnoRuntime.queryInterface(XContentIdentifierFactory.class, oUCB) ;
92 String url = util.utils.getFullTestURL("SwXTextEmbeddedObject.sxw") ;
93 StringBuilder escUrl = new StringBuilder();
95 // In base URL of a JAR file in content URL all directory
96 // separators ('/') must be replaced with escape symbol '%2F'.
97 int idx = url.indexOf("/") ;
98 int lastIdx = -1 ;
99 while (idx >= 0) {
100 escUrl.append(url.substring(lastIdx + 1, idx)).append("%2F");
101 lastIdx = idx ;
102 idx = url.indexOf("/", idx + 1) ;
104 escUrl.append(url.substring(lastIdx + 1));
105 String cntUrl = "vnd.sun.star.pkg://" + escUrl.toString() + "/" ;
107 XContentIdentifier CI = ciFac.createContentIdentifier(cntUrl) ;
109 XContentProvider cntProv = UnoRuntime.queryInterface(XContentProvider.class, oUCB) ;
111 XContent cnt = cntProv.queryContent(CI) ;
113 XCommandProcessor cmdProc = UnoRuntime.queryInterface(XCommandProcessor.class, cnt) ;
115 Property prop = new Property() ;
116 prop.Name = "Title" ;
118 Command cmd = new Command("open", -1, new OpenCommandArgument2
119 (OpenMode.ALL, 10000, null, new Property[] {prop},
120 new NumberedSortingInfo[0])) ;
122 dynResSet = (XDynamicResultSet)
123 AnyConverter.toObject(new Type(XDynamicResultSet.class),
124 cmdProc.execute(cmd, 0, null));
126 tEnv.addObjRelation("DynamicResultSet", dynResSet) ;
128 return tEnv;
129 } // finish method getTestEnvironment