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
;
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 public class ScriptStorage
extends TestCase
{
34 String docPath
= null;
35 public void initialize( TestParameters tParam
, PrintWriter log
) {
36 // Get path to test documents
37 String rootDocPath
= ( String
)tParam
.get( "DOCPTH" );
38 System
.out
.println( "DOCPTH is " + rootDocPath
);
39 rootDocPath
= util
.utils
.getFullTestURL( "ExampleSpreadSheetLatest.sxc" );
40 if ( rootDocPath
!= null && rootDocPath
.length() > 1 ){
41 // convert all "\\" to "/", necessary for UCB
42 if ( rootDocPath
.indexOf( "\\" ) > 0 ){
43 rootDocPath
= rootDocPath
.replace( '\\','/' );
45 System
.out
.println("After processing the path is " + rootDocPath
);
46 // encode the ulr (for UCB)
47 String encodedPath
= URLEncoder
.encode( rootDocPath
);
48 System
.out
.println("The encoded path is " + encodedPath
);
49 docPath
= "vnd.sun.star.pkg://" + encodedPath
;
50 System
.out
.println( "docPath path is " + docPath
);
55 public synchronized TestEnvironment
createTestEnvironment(
56 TestParameters tParam
, PrintWriter log
) throws StatusException
{
58 log
.println("creating test environment");
59 if ( docPath
== null ){
60 log
.println("Testdata not set up, docPath is null");
61 throw new StatusException(
62 "Can't create object environment, no test document available",
66 XInterface oObj
= null;
67 XSimpleFileAccess access
= null;
69 XMultiServiceFactory xMSF
= (XMultiServiceFactory
) tParam
.getMSF();
71 xMSF
.createInstance( "com.sun.star.ucb.SimpleFileAccess" );
72 access
= UnoRuntime
.queryInterface( XSimpleFileAccess
.class, xInterface
);
73 oObj
= ( XInterface
)xMSF
.createInstanceWithArguments(
74 "drafts.com.sun.star.script.framework.storage.ScriptStorage",
75 new Object
[]{ access
, new Integer(99), docPath
} );
77 } catch (com
.sun
.star
.uno
.Exception e
) {
78 throw new StatusException("Can't create object environment", e
) ;
81 TestEnvironment tEnv
= new TestEnvironment(oObj
) ;
82 TestDataLoader
.setupData(tEnv
, "ScriptStorage");
87 public synchronized void disposeTestEnvironment( TestEnvironment tEnv
,
88 TestParameters tParam
) {