bump product version to 4.1.6.2
[LibreOffice.git] / scripting / workben / mod / _scripting / ScriptInfo.java
blobf822fd5cb329098f521f6e686e0edaf19ed37b12
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._scripting;
21 import com.sun.star.uno.XInterface;
22 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import java.net.URLEncoder;
28 import com.sun.star.lang.XMultiServiceFactory;
29 import com.sun.star.ucb.XSimpleFileAccess;
30 import com.sun.star.uno.UnoRuntime;
32 import drafts.com.sun.star.script.framework.storage.XScriptInfoAccess;
33 import drafts.com.sun.star.script.framework.storage.XScriptInfo;
35 public class ScriptInfo extends TestCase {
37 String docPath = null;
38 public void initialize( TestParameters tParam, PrintWriter log ) {
39 // Get path to test documents
40 String rootDocPath = ( String )tParam.get( "DOCPTH" );
41 System.out.println( "DOCPTH is " + rootDocPath );
42 rootDocPath = util.utils.getFullTestURL( "ExampleSpreadSheetLatest.sxc" );
43 if ( rootDocPath != null && rootDocPath.length() > 1 ){
44 // convert all "\\" to "/", necessary for UCB
45 if ( rootDocPath.indexOf( "\\" ) > 0 ){
46 rootDocPath = rootDocPath.replace( '\\','/' );
48 System.out.println("After processing the path is " + rootDocPath);
49 // encode the ulr (for UCB)
50 String encodedPath = URLEncoder.encode( rootDocPath );
51 System.out.println("The encoded path is " + encodedPath );
52 docPath = "vnd.sun.star.pkg://" + encodedPath;
53 System.out.println( "docPath path is " + docPath );
58 public synchronized TestEnvironment createTestEnvironment(
59 TestParameters tParam, PrintWriter log ) throws StatusException {
61 log.println("creating test environment");
62 if ( docPath == null ){
63 log.println("Testdata not set up, docPath is null");
64 throw new StatusException(
65 "Can't create object environment, no test document available",
66 new Exception() ) ;
69 XInterface oObj = null;
70 XSimpleFileAccess access = null;
71 try {
72 XMultiServiceFactory xMSF = (XMultiServiceFactory) tParam.getMSF();
73 Object xInterface =
74 xMSF.createInstance( "com.sun.star.ucb.SimpleFileAccess" );
75 access = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface );
76 Object storageObj = xMSF.createInstanceWithArguments(
77 "drafts.com.sun.star.script.framework.storage.ScriptStorage",
78 new Object[]{ access, new Integer(99), docPath } );
79 XScriptInfoAccess infoAccess = UnoRuntime.queryInterface(XScriptInfoAccess.class, storageObj);
80 XScriptInfo[] infos = infoAccess.getImplementations("script://MemoryUtils.MemUsage?location=document");
81 oObj = infos[0];
82 } catch (com.sun.star.uno.Exception e) {
83 throw new StatusException("Can't create object environment", e) ;
86 TestEnvironment tEnv = new TestEnvironment(oObj) ;
87 TestDataLoader.setupData(tEnv, "ScriptInfo");
89 return tEnv ;
92 public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
93 TestParameters tParam) {