1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="system_XSystemShellExecute" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31' Be sure that all variables are dimensioned:
32option explicit
33
34'*************************************************************************
35' This Interface/Service test depends on the following GLOBAL variables,
36' which must be specified in the object creation:
37
38'     - java existing in PATH system var and
39'       SystemShellExecute.class file in docs dir
40
41'*************************************************************************
42
43
44
45
46
47
48Sub RunTest()
49
50'*************************************************************************
51' INTERFACE:
52' com.sun.star.system.XSystemShellExecute
53'*************************************************************************
54On Error Goto ErrHndl
55    Dim bOK As Boolean
56    Dim cResFile As String, cResURL As String, cClassPath As String
57    Dim oFacc As Object
58    Dim bExist As Boolean, i As Integer
59    Dim cArgs As String
60
61    Test.StartMethod("execute()")
62    cClassPath = utils.URL2Path(utils.Path2URL(cTestDocsDir))
63    cResURL = utils.getTempFileURL("SystemShellExecute.txt", true)
64    cResFile = utils.URL2Path(cResURL)
65    bOK = true
66
67    cArgs = "-classpath " + cClassPath + " SystemShellExecute " + cResFile
68    Out.Log("Executing : 'java " + cArgs + "'")
69    oObj.execute("java", cArgs, 1)
70
71    oFacc = createUnoService("com.sun.star.ucb.SimpleFileAccess")
72
73    if bOK then
74        Out.Log("Waiting while the file will be created or timeout reached ...")
75        bExist = false
76        i = 0
77        while i &lt; 20 AND NOT bExist
78            bExist = oFacc.exists(cResURL)
79            wait(1000)
80            i = i + 1
81        wend
82
83        if bExist then
84            Out.Log("The command was executed and file created in " + i + " sec.")
85        else
86            Out.Log("File was not created.")
87        endif
88
89        bOK = bOK AND bExist
90    endif
91
92    Test.MethodTested("execute()", bOK)
93
94Exit Sub
95ErrHndl:
96    Test.Exception()
97    bOK = false
98    resume next
99End Sub
100</script:module>
101