xref: /AOO41X/main/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir  package complex.loadAllDocuments;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
31*cdf0e10cSrcweir import com.sun.star.frame.FrameSearchFlag;
32*cdf0e10cSrcweir import com.sun.star.frame.XComponentLoader;
33*cdf0e10cSrcweir import com.sun.star.frame.XFrame;
34*cdf0e10cSrcweir import com.sun.star.frame.XStorable;
35*cdf0e10cSrcweir import com.sun.star.io.XInputStream;
36*cdf0e10cSrcweir import com.sun.star.lang.XComponent;
37*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
38*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
39*cdf0e10cSrcweir import com.sun.star.util.XCloseable;
40*cdf0e10cSrcweir import com.sun.star.ucb.XSimpleFileAccess;
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir import helper.URLHelper;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir import java.io.File;
46*cdf0e10cSrcweir import java.io.InputStreamReader;
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir import java.util.Enumeration;
49*cdf0e10cSrcweir import java.util.Vector;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir // ---------- junit imports -----------------
52*cdf0e10cSrcweir import org.junit.After;
53*cdf0e10cSrcweir import org.junit.AfterClass;
54*cdf0e10cSrcweir import org.junit.Before;
55*cdf0e10cSrcweir import org.junit.BeforeClass;
56*cdf0e10cSrcweir import org.junit.Test;
57*cdf0e10cSrcweir import org.openoffice.test.OfficeConnection;
58*cdf0e10cSrcweir import org.openoffice.test.OfficeFileUrl;
59*cdf0e10cSrcweir import static org.junit.Assert.*;
60*cdf0e10cSrcweir // ------------------------------------------
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir //-----------------------------------------------
63*cdf0e10cSrcweir /** @short  Check the interface method XComponentLoader.loadComponentFromURL()
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir     @descr  A prerequisite for this test is a server which allows access to files
66*cdf0e10cSrcweir             that will be loaded via three different access methods:
67*cdf0e10cSrcweir             <ul>
68*cdf0e10cSrcweir                 <li>1. nfs (mounted directory / mapped network drive)</li>
69*cdf0e10cSrcweir                 <li>2. ftp</li>
70*cdf0e10cSrcweir                 <li>3. http</li>
71*cdf0e10cSrcweir             </ul>
72*cdf0e10cSrcweir             <p>
73*cdf0e10cSrcweir             The test will look for a list of files from the <i>TestDocumentPath</i>
74*cdf0e10cSrcweir             on and load these files from the mounted directory, via ftp and http.
75*cdf0e10cSrcweir             The parameters for this have to be "ftp_access" and "http_access".
76*cdf0e10cSrcweir             If they are not given, tests for ftp and http will fail.
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     @todo   We need a further test for accessing UNC pathes on windows!
79*cdf0e10cSrcweir  */
80*cdf0e10cSrcweir public class CheckXComponentLoader
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir     //-------------------------------------------
83*cdf0e10cSrcweir     // some const
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     /** used to classify the result of a loadComponentFromURL() request. */
86*cdf0e10cSrcweir     private static final int RESULT_UNKNOWN                  = 0;
87*cdf0e10cSrcweir     private static final int RESULT_VALID_DOC                = 1;
88*cdf0e10cSrcweir     private static final int RESULT_EMPTY_DOC                = 2;
89*cdf0e10cSrcweir     private static final int RESULT_ILLEGALARGUMENTEXCEPTION = 3;
90*cdf0e10cSrcweir     private static final int RESULT_IOEXCEPTION              = 4;
91*cdf0e10cSrcweir     private static final int RESULT_RUNTIMEEXCEPTION         = 5;
92*cdf0e10cSrcweir     private static final int RESULT_EXCEPTION                = 6;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     /** File/URL separators. */
95*cdf0e10cSrcweir     private static final String fs_url = "/";
96*cdf0e10cSrcweir     // private static final String fs_sys = System.getProperty("file.separator");
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir     /** used for testing password protected files. */
99*cdf0e10cSrcweir     private static final String SUFFIX_PASSWORD_TEMPFILE = "password_";
100*cdf0e10cSrcweir     private static final String PREFIX_PASSWORD_TEMPFILE = ".sxw";
101*cdf0e10cSrcweir     private static final String DEFAULT_PASSWORD         = "DefaultPasswordForComponentLoaderTest";
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir     //-------------------------------------------
104*cdf0e10cSrcweir     // member
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     /** points to the global uno service manager. */
107*cdf0e10cSrcweir     private XMultiServiceFactory m_xMSF = null;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     /** provides XComponentLoader interface. */
110*cdf0e10cSrcweir     private XFrame m_xDesktop = null;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     /** provides XComponentLoader interface too. */
113*cdf0e10cSrcweir     private XFrame m_xFrame = null;
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     /** will be set to xDesktop OR xFrame. */
116*cdf0e10cSrcweir     private XComponentLoader m_xLoader = null;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     /** can be used to open local files as stream. */
119*cdf0e10cSrcweir     private XSimpleFileAccess m_xStreamProvider = null;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     /** directory for creating temp. files. */
122*cdf0e10cSrcweir     private String m_sTempPath = null;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     /** directory for searching files to load */
125*cdf0e10cSrcweir     private String m_sTestDocPath = null;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     /** files of m_sTestDocPath to test. */
128*cdf0e10cSrcweir     private static Vector m_lTestFiles = null;
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     //-------------------------------------------
131*cdf0e10cSrcweir     // test environment
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     //-------------------------------------------
134*cdf0e10cSrcweir     /** @short  A function to tell the framework,
135*cdf0e10cSrcweir                 which test functions are available.
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir         @return All test methods.
138*cdf0e10cSrcweir         @todo   Think about selection of tests from outside ...
139*cdf0e10cSrcweir      */
140*cdf0e10cSrcweir //    public String[] getTestMethodNames()
141*cdf0e10cSrcweir //    {
142*cdf0e10cSrcweir //        // TODO think about trigger of sub-tests from outside
143*cdf0e10cSrcweir //        return new String[]
144*cdf0e10cSrcweir //        {
145*cdf0e10cSrcweir //            "checkURLEncoding"           ,
146*cdf0e10cSrcweir //            "checkURLHandling"           ,
147*cdf0e10cSrcweir //            "checkUsingOfMediaDescriptor",
148*cdf0e10cSrcweir //            "checkStreamLoading"         ,
149*cdf0e10cSrcweir //            "checkLoadingWithPassword"
150*cdf0e10cSrcweir //        };
151*cdf0e10cSrcweir //    }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir     //-------------------------------------------
154*cdf0e10cSrcweir     /** @short  Create the environment for following tests.
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir         @descr  Use either a component loader from desktop or
157*cdf0e10cSrcweir                 from frame
158*cdf0e10cSrcweir      */
159*cdf0e10cSrcweir     @Before public void before()
160*cdf0e10cSrcweir     {
161*cdf0e10cSrcweir         // get uno service manager from global test environment
162*cdf0e10cSrcweir         m_xMSF = getMSF();
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir         // create stream provider
165*cdf0e10cSrcweir         try
166*cdf0e10cSrcweir         {
167*cdf0e10cSrcweir             m_xStreamProvider = UnoRuntime.queryInterface(XSimpleFileAccess.class, m_xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"));
168*cdf0e10cSrcweir         }
169*cdf0e10cSrcweir         catch(java.lang.Throwable ex)
170*cdf0e10cSrcweir         {
171*cdf0e10cSrcweir             fail("Could not create a stream provider instance.");
172*cdf0e10cSrcweir         }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir         // create desktop instance
175*cdf0e10cSrcweir         try
176*cdf0e10cSrcweir         {
177*cdf0e10cSrcweir             m_xDesktop = UnoRuntime.queryInterface(XFrame.class, m_xMSF.createInstance("com.sun.star.frame.Desktop"));
178*cdf0e10cSrcweir         }
179*cdf0e10cSrcweir         catch(java.lang.Throwable ex)
180*cdf0e10cSrcweir         {
181*cdf0e10cSrcweir             fail("Could not create the desktop instance.");
182*cdf0e10cSrcweir         }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir         // create frame instance
185*cdf0e10cSrcweir         m_xFrame = m_xDesktop.findFrame("testFrame_componentLoader",
186*cdf0e10cSrcweir                                         FrameSearchFlag.TASKS | FrameSearchFlag.CREATE);
187*cdf0e10cSrcweir         assertNotNull("Couldn't create test frame.", m_xFrame);
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir         // define default loader for testing
190*cdf0e10cSrcweir         // TODO think about using of bot loader instances!
191*cdf0e10cSrcweir         m_xLoader = UnoRuntime.queryInterface(XComponentLoader.class, m_xDesktop);
192*cdf0e10cSrcweir         assertNotNull("Desktop service doesnt support needed component loader interface.", m_xLoader);
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir         // get temp path for this environment
195*cdf0e10cSrcweir         final String tempDirURL = util.utils.getOfficeTemp/*Dir*/(getMSF());
196*cdf0e10cSrcweir         m_sTempPath = graphical.FileHelper.getSystemPathFromFileURL(tempDirURL);
197*cdf0e10cSrcweir         // m_sTempPath = "."+fs_sys;
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir         // get all files from the given directory
200*cdf0e10cSrcweir         // TODO URLHelper should ignore directories!
201*cdf0e10cSrcweir         m_lTestFiles = new Vector();
202*cdf0e10cSrcweir         final String sTestDocURL = OfficeFileUrl.getAbsolute(new File("testdocuments"));
203*cdf0e10cSrcweir         m_sTestDocPath = graphical.FileHelper.getSystemPathFromFileURL(sTestDocURL);
204*cdf0e10cSrcweir         try
205*cdf0e10cSrcweir         {
206*cdf0e10cSrcweir             File        aBaseDir        = new File(m_sTestDocPath);
207*cdf0e10cSrcweir             Vector      lDirContent     = URLHelper.getSystemFilesFromDir(aBaseDir.getPath());
208*cdf0e10cSrcweir             Enumeration lList           = lDirContent.elements();
209*cdf0e10cSrcweir             int         nBasePathLength = m_sTestDocPath.length();
210*cdf0e10cSrcweir             while(lList.hasMoreElements())
211*cdf0e10cSrcweir             {
212*cdf0e10cSrcweir                 File aFile = (File)lList.nextElement();
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir                 // ignore broken links and directories at all
215*cdf0e10cSrcweir                 if (
216*cdf0e10cSrcweir                     (!aFile.exists()) ||
217*cdf0e10cSrcweir                     (!aFile.isFile())
218*cdf0e10cSrcweir                    )
219*cdf0e10cSrcweir                 {
220*cdf0e10cSrcweir                     continue;
221*cdf0e10cSrcweir                 }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir                 String sCompletePath = aFile.getAbsolutePath();
224*cdf0e10cSrcweir                 String sSubPath      = sCompletePath.substring(nBasePathLength);
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir                 // Some test files are checked into CVS. ignore CVS  helper files!
227*cdf0e10cSrcweir //                if (sSubPath.indexOf("CVS") > -1)
228*cdf0e10cSrcweir //                {
229*cdf0e10cSrcweir //                    continue;
230*cdf0e10cSrcweir //                }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir                 m_lTestFiles.add(sSubPath);
233*cdf0e10cSrcweir             }
234*cdf0e10cSrcweir         }
235*cdf0e10cSrcweir         catch(java.lang.Throwable ex)
236*cdf0e10cSrcweir         {
237*cdf0e10cSrcweir             fail("Couldn't find test documents.");
238*cdf0e10cSrcweir         }
239*cdf0e10cSrcweir     }
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir     //-------------------------------------------
242*cdf0e10cSrcweir     /** @short  close the environment.
243*cdf0e10cSrcweir      */
244*cdf0e10cSrcweir     @After public void after()
245*cdf0e10cSrcweir     {
246*cdf0e10cSrcweir         XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, m_xFrame);
247*cdf0e10cSrcweir         try
248*cdf0e10cSrcweir         {
249*cdf0e10cSrcweir             xClose.close(false);
250*cdf0e10cSrcweir         }
251*cdf0e10cSrcweir         catch(com.sun.star.util.CloseVetoException exVeto)
252*cdf0e10cSrcweir             { fail("Test frame couldn't be closed successfully."); }
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir         m_xFrame  = null;
255*cdf0e10cSrcweir         m_xLoader = null;
256*cdf0e10cSrcweir     }
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir     //-------------------------------------------
259*cdf0e10cSrcweir     /** @short  Look for files in the given directory for loading.
260*cdf0e10cSrcweir      */
261*cdf0e10cSrcweir     @Test public void checkUsingOfMediaDescriptor()
262*cdf0e10cSrcweir     {
263*cdf0e10cSrcweir         InteractionHandler xHandler   = new InteractionHandler();
264*cdf0e10cSrcweir         StatusIndicator    xIndicator = new StatusIndicator(StatusIndicator.SHOWSTATUS_LOG);
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir         PropertyValue[] lProps = new PropertyValue[3];
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir         lProps[0] = new PropertyValue();
269*cdf0e10cSrcweir         lProps[0].Name  = "Hidden";
270*cdf0e10cSrcweir         lProps[0].Value = Boolean.TRUE;
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir         lProps[1] = new PropertyValue();
273*cdf0e10cSrcweir         lProps[1].Name  = "InteractionHandler";
274*cdf0e10cSrcweir         lProps[1].Value = xHandler;
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir         lProps[2] = new PropertyValue();
277*cdf0e10cSrcweir         lProps[2].Name  = "StatusIndicator";
278*cdf0e10cSrcweir         lProps[2].Value = xIndicator;
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir         Enumeration aSnapshot = m_lTestFiles.elements();
281*cdf0e10cSrcweir         while (aSnapshot.hasMoreElements())
282*cdf0e10cSrcweir         {
283*cdf0e10cSrcweir             File   aSysFile = new File(m_sTestDocPath, (String)aSnapshot.nextElement());
284*cdf0e10cSrcweir             String sURL     = URLHelper.getFileURLFromSystemPath(aSysFile);
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir             if (/*! (sURL.endsWith(".jpg") ||
287*cdf0e10cSrcweir                    sURL.endsWith(".gif"))*/
288*cdf0e10cSrcweir                     true
289*cdf0e10cSrcweir                   )
290*cdf0e10cSrcweir             {
291*cdf0e10cSrcweir                 loadURL(m_xLoader, RESULT_VALID_DOC, sURL, "_blank", 0, lProps);
292*cdf0e10cSrcweir                 // Its not needed to reset this using states!
293*cdf0e10cSrcweir                 // Its done internaly ...
294*cdf0e10cSrcweir                 if (!xIndicator.wasUsed())
295*cdf0e10cSrcweir                 {
296*cdf0e10cSrcweir                     System.out.println("External progress was not used for loading.");
297*cdf0e10cSrcweir                 }
298*cdf0e10cSrcweir                 if (xHandler.wasUsed())
299*cdf0e10cSrcweir                 {
300*cdf0e10cSrcweir                     System.out.println("External interaction handler was not used for loading.");
301*cdf0e10cSrcweir                 }
302*cdf0e10cSrcweir             }
303*cdf0e10cSrcweir         }
304*cdf0e10cSrcweir     }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir     //-------------------------------------------
307*cdf0e10cSrcweir     /** TODO document me and move this method to a more global helper! */
308*cdf0e10cSrcweir     private String impl_getTempFileName(String sTempPath,
309*cdf0e10cSrcweir                                         String sSuffix  ,
310*cdf0e10cSrcweir                                         String sPrefix  )
311*cdf0e10cSrcweir     {
312*cdf0e10cSrcweir         File aDir = new File(sTempPath);
313*cdf0e10cSrcweir         aDir.mkdirs();
314*cdf0e10cSrcweir //        if (!aDir.exists())
315*cdf0e10cSrcweir //        {
316*cdf0e10cSrcweir //            fail("Could not access temp directory \"" + sTempPath + "\".");
317*cdf0e10cSrcweir //        }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir     // TODO: create a temp file which not exist!
320*cdf0e10cSrcweir         for (int i=0; i<999999; ++i)
321*cdf0e10cSrcweir         {
322*cdf0e10cSrcweir             File aTempFile = new File(aDir, sSuffix+i+sPrefix);
323*cdf0e10cSrcweir             if (!aTempFile.exists())
324*cdf0e10cSrcweir             {
325*cdf0e10cSrcweir                 return aTempFile.getAbsolutePath();
326*cdf0e10cSrcweir             }
327*cdf0e10cSrcweir         }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir         fail("Seems that all temp file names are currently in use!");
330*cdf0e10cSrcweir         return null;
331*cdf0e10cSrcweir     }
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir     //-------------------------------------------
334*cdf0e10cSrcweir     /** TODO document me and move this method to a more global helper! */
335*cdf0e10cSrcweir     private void impl_createTempOfficeDocument(XComponentLoader xLoader   ,
336*cdf0e10cSrcweir                                                String           sSourceURL,
337*cdf0e10cSrcweir                                                String           sTargetURL,
338*cdf0e10cSrcweir                                                String           sFilter   ,
339*cdf0e10cSrcweir                                                String           sPassword )
340*cdf0e10cSrcweir     {
341*cdf0e10cSrcweir         PropertyValue[] lLoadProps = new PropertyValue[1];
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir         lLoadProps[0] = new PropertyValue();
344*cdf0e10cSrcweir         lLoadProps[0].Name = "Hidden";
345*cdf0e10cSrcweir         lLoadProps[0].Value = Boolean.TRUE;
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir         PropertyValue[] lSaveProps = new PropertyValue[3];
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir         lSaveProps[0] = new PropertyValue();
350*cdf0e10cSrcweir         lSaveProps[0].Name = "FilterName";
351*cdf0e10cSrcweir         lSaveProps[0].Value = sFilter;
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir         lSaveProps[1] = new PropertyValue();
354*cdf0e10cSrcweir         lSaveProps[1].Name = "PassWord";
355*cdf0e10cSrcweir         lSaveProps[1].Value = sPassword;
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir         lSaveProps[2] = new PropertyValue();
358*cdf0e10cSrcweir         lSaveProps[2].Name = "Overwrite";
359*cdf0e10cSrcweir         lSaveProps[2].Value = Boolean.TRUE;
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir         XComponent xDoc = null;
362*cdf0e10cSrcweir         try
363*cdf0e10cSrcweir         {
364*cdf0e10cSrcweir             // load it
365*cdf0e10cSrcweir             xDoc = xLoader.loadComponentFromURL(sSourceURL, "_blank", 0, lLoadProps);
366*cdf0e10cSrcweir             assertNotNull("Could create office document, which should be saved as temp one.", xDoc);
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir             // save it as temp file
369*cdf0e10cSrcweir             XStorable xStore = UnoRuntime.queryInterface(XStorable.class, xDoc);
370*cdf0e10cSrcweir             xStore.storeAsURL(sTargetURL, lSaveProps);
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir             // Dont forget to close this file. Otherwise the temp file is locked!
373*cdf0e10cSrcweir             XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xDoc);
374*cdf0e10cSrcweir             xClose.close(false);
375*cdf0e10cSrcweir         }
376*cdf0e10cSrcweir         catch(java.lang.Throwable ex)
377*cdf0e10cSrcweir         {
378*cdf0e10cSrcweir             fail("Could not create temp office document.");
379*cdf0e10cSrcweir         }
380*cdf0e10cSrcweir     }
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir     //-------------------------------------------
383*cdf0e10cSrcweir     /** @short  Check the password handling.
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir         @descr  The used password is the one given
386*cdf0e10cSrcweir                 as password for the ftp connection,
387*cdf0e10cSrcweir                 or - if none given a default one.
388*cdf0e10cSrcweir      */
389*cdf0e10cSrcweir     @Test public void checkLoadingWithPassword()
390*cdf0e10cSrcweir     {
391*cdf0e10cSrcweir         String sTempFile = impl_getTempFileName(m_sTempPath, SUFFIX_PASSWORD_TEMPFILE, PREFIX_PASSWORD_TEMPFILE);
392*cdf0e10cSrcweir         File   aTestFile = new File(sTempFile);
393*cdf0e10cSrcweir         String sTestURL  = URLHelper.getFileURLFromSystemPath(aTestFile);
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir         impl_createTempOfficeDocument(m_xLoader, "private:factory/swriter", sTestURL, "StarOffice XML (Writer)", DEFAULT_PASSWORD);
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir         PropertyValue[] lArgs1 = new PropertyValue[2];
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir         lArgs1[0] = new PropertyValue();
400*cdf0e10cSrcweir         lArgs1[0].Name  = "Hidden";
401*cdf0e10cSrcweir         lArgs1[0].Value = Boolean.TRUE;
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir         lArgs1[1] = new PropertyValue();
404*cdf0e10cSrcweir         lArgs1[1].Name  = "Password";
405*cdf0e10cSrcweir         lArgs1[1].Value = DEFAULT_PASSWORD;
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir         PropertyValue[] lArgs2 = new PropertyValue[1];
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir         lArgs2[0] = new PropertyValue();
410*cdf0e10cSrcweir         lArgs2[0].Name  = "Hidden";
411*cdf0e10cSrcweir         lArgs2[0].Value = Boolean.TRUE;
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir         loadURL(m_xLoader, RESULT_VALID_DOC, sTestURL, "_blank", 0, lArgs1);
414*cdf0e10cSrcweir // TODO: wrong?        loadURL(m_xLoader, RESULT_EMPTY_DOC, sTestURL, "_blank", 0, lArgs2);
415*cdf0e10cSrcweir     }
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir     /**
418*cdf0e10cSrcweir      * Check URL encoding. The first filename that matches "*.sxw"
419*cdf0e10cSrcweir      * is used as source for several encodings.
420*cdf0e10cSrcweir      */
421*cdf0e10cSrcweir     @Test public void checkURLEncoding() {
422*cdf0e10cSrcweir         PropertyValue[] lProps = new PropertyValue[1];
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir         lProps[0] = new PropertyValue();
425*cdf0e10cSrcweir         lProps[0].Name = "Hidden";
426*cdf0e10cSrcweir         lProps[0].Value = Boolean.TRUE;
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir         // first get encoding of this system
429*cdf0e10cSrcweir         InputStreamReader in = new InputStreamReader(System.in);
430*cdf0e10cSrcweir         String sSystemEncoding = in.getEncoding();
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir         System.out.println("This system's encoding: " + sSystemEncoding);
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir         assertNotNull("Found an empty directory. There are no files for testing.", m_lTestFiles);
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir         // get a file name as byte array
438*cdf0e10cSrcweir         Enumeration aSnapshot = m_lTestFiles.elements();
439*cdf0e10cSrcweir         byte[] baURL = null;
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir         while (aSnapshot.hasMoreElements()) {
442*cdf0e10cSrcweir             File aFile = new File(m_sTestDocPath, (String)aSnapshot.nextElement());
443*cdf0e10cSrcweir             String sFile = URLHelper.getFileURLFromSystemPath(aFile);
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir             // take the first sxw file as stream
446*cdf0e10cSrcweir             if (sFile.endsWith(".sxw")) {
447*cdf0e10cSrcweir                 baURL = sFile.getBytes();
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir                 break;
450*cdf0e10cSrcweir             }
451*cdf0e10cSrcweir         }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir         assertNotNull("Found no file to load. Cannot test.", baURL);
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir         //construct several different encoded strings
456*cdf0e10cSrcweir         String[] sEncoding = new String[] {
457*cdf0e10cSrcweir             "US-ASCII", "TRUE", // us ascii encoding
458*cdf0e10cSrcweir             "ISO-8859-1", "TRUE", // iso encoding
459*cdf0e10cSrcweir             "UTF-8", "TRUE", // 8 bit utf encoding
460*cdf0e10cSrcweir             "UTF-16BE", "FALSE", // 16 bit big endian utf
461*cdf0e10cSrcweir             "UTF-16LE", "FALSE", // 16 bit little endian utf
462*cdf0e10cSrcweir             "UTF-16", "FALSE" // 16 bit, order specified by byte order mark
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir         };
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir         for (int i = 0; i < sEncoding.length; i = i + 2) {
467*cdf0e10cSrcweir             try {
468*cdf0e10cSrcweir                 String encURL = new String(baURL, sEncoding[i]);
469*cdf0e10cSrcweir                 System.out.println("ENC[" + sEncoding[i] + "]");
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir                 if (sEncoding[i + 1].equals("TRUE")) {
472*cdf0e10cSrcweir                     loadURL(m_xLoader, RESULT_VALID_DOC, encURL, "_blank", 0,
473*cdf0e10cSrcweir                             lProps);
474*cdf0e10cSrcweir                 } else {
475*cdf0e10cSrcweir                     //with cws_loadenv01 changed to IllegalArgumentException
476*cdf0e10cSrcweir                     loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, encURL, "_blank", 0,
477*cdf0e10cSrcweir                             lProps);
478*cdf0e10cSrcweir                 }
479*cdf0e10cSrcweir             } catch (java.io.UnsupportedEncodingException e) {
480*cdf0e10cSrcweir                 fail("Unsopported Encoding: " + sEncoding[i] +
481*cdf0e10cSrcweir                        "\n Not able to test encoding on this platform.");
482*cdf0e10cSrcweir             }
483*cdf0e10cSrcweir         }
484*cdf0e10cSrcweir     }
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir     /**
487*cdf0e10cSrcweir      * Check url handling with a load of URLs.
488*cdf0e10cSrcweir      * 1. unsupported URLs.
489*cdf0e10cSrcweir      * 2. "stupid" URLs
490*cdf0e10cSrcweir      * 3. case sensitive URLs
491*cdf0e10cSrcweir      * 4. FTP URLs
492*cdf0e10cSrcweir      * 5. HTTP URLs
493*cdf0e10cSrcweir      */
494*cdf0e10cSrcweir //    public void checkURLHandling() {
495*cdf0e10cSrcweir //        PropertyValue[] lProps = new PropertyValue[1];
496*cdf0e10cSrcweir //
497*cdf0e10cSrcweir //        lProps[0] = new PropertyValue();
498*cdf0e10cSrcweir //        lProps[0].Name = "Hidden";
499*cdf0e10cSrcweir //        lProps[0].Value = Boolean.TRUE;
500*cdf0e10cSrcweir //
501*cdf0e10cSrcweir //        System.out.println("check possible but unsupported URLs");
502*cdf0e10cSrcweir //
503*cdf0e10cSrcweir //        String[] sIllegalArgs = new String[] {
504*cdf0e10cSrcweir //            "slot:5000", "slot:10909", ".uno:SaveAs", ".uno:Open",
505*cdf0e10cSrcweir //        };
506*cdf0e10cSrcweir //        loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, sIllegalArgs,
507*cdf0e10cSrcweir //                "_blank", 0, lProps);
508*cdf0e10cSrcweir //
509*cdf0e10cSrcweir //        System.out.println("check stupid URLs");
510*cdf0e10cSrcweir //
511*cdf0e10cSrcweir //        sIllegalArgs = new String[] {
512*cdf0e10cSrcweir //            "slot:xxx", "slot:111111111", ".uno:save_as", ".uno:open_this",
513*cdf0e10cSrcweir //            ".UnO:*",
514*cdf0e10cSrcweir //        };
515*cdf0e10cSrcweir //        loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, sIllegalArgs,
516*cdf0e10cSrcweir //                "_blank", 0, lProps);
517*cdf0e10cSrcweir //
518*cdf0e10cSrcweir //        String[] sEmptyDocs = new String[] {
519*cdf0e10cSrcweir //            "mailo:hansi.meier@germany.sun.com", "file:/c:\\test/file.cxx",
520*cdf0e10cSrcweir //            "file:///c|:\\test/file.cxx", "http_server://staroffice-doc\\",
521*cdf0e10cSrcweir //            "c:\\\\test///\\test.sxw", "news_:staroffice-doc",
522*cdf0e10cSrcweir //            "newsletter@blubber", "private_factory/swriter",
523*cdf0e10cSrcweir //            "private:factory//swriter", "private:factory/swriter/___",
524*cdf0e10cSrcweir //            "c:\\test\\test.sxw", "macro:///ImportWizard.Main.Main",
525*cdf0e10cSrcweir //            "macro:///Euro.AutoPilotRun.StartAutoPilot",
526*cdf0e10cSrcweir //            "service:com.sun.star.frame.Frame",
527*cdf0e10cSrcweir //            "mailto:steffen.grund@germany.sun.com", "news:staroffice-doc",
528*cdf0e10cSrcweir //            "macro:/ExportWizard", "macro://Euro.AutoPilotRun.StartAutoPilot",
529*cdf0e10cSrcweir //            "service:com.sun.star.frame."
530*cdf0e10cSrcweir //        };
531*cdf0e10cSrcweir //
532*cdf0e10cSrcweir //        //with cws_loadenv01 changed to IllegalArgumentException
533*cdf0e10cSrcweir //        loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, sEmptyDocs, "_blank", 0,
534*cdf0e10cSrcweir //                lProps);
535*cdf0e10cSrcweir //
536*cdf0e10cSrcweir //        System.out.println("check case senstive URLs");
537*cdf0e10cSrcweir //
538*cdf0e10cSrcweir //        sIllegalArgs = new String[] {
539*cdf0e10cSrcweir //            "sLot:5000", "sloT:10909", ".unO:SaveAs", ".uno:OPEN",
540*cdf0e10cSrcweir //        };
541*cdf0e10cSrcweir //        loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, sIllegalArgs,
542*cdf0e10cSrcweir //                "_blank", 0, lProps);
543*cdf0e10cSrcweir //
544*cdf0e10cSrcweir //        sEmptyDocs = new String[] {
545*cdf0e10cSrcweir //            "private:factory/SWRITER", "private:factory/SWRITER/WEB",
546*cdf0e10cSrcweir //            "macro:///importwizard.main.main",
547*cdf0e10cSrcweir //            "Macro:///euro.autopilotrun.startautopilot",
548*cdf0e10cSrcweir //            "Service:Com.Sun.Star.Frame.Frame",
549*cdf0e10cSrcweir //            "Mailto:andreas.schluens@germany.sun.com", "neWs:staroffice-doc",
550*cdf0e10cSrcweir //            "News:Staroffice-doc"
551*cdf0e10cSrcweir //        };
552*cdf0e10cSrcweir //
553*cdf0e10cSrcweir //        //with cws_loadenv01 changed to IllegalArgumentException
554*cdf0e10cSrcweir //        loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, sEmptyDocs, "_blank", 0,
555*cdf0e10cSrcweir //                lProps);
556*cdf0e10cSrcweir //
557*cdf0e10cSrcweir //        System.out.println("check FTP URLs");
558*cdf0e10cSrcweir //
559*cdf0e10cSrcweir //        String sFTPURL = (String) param.get("FtpAccess");
560*cdf0e10cSrcweir //        Enumeration aSnapshot = m_lTestFiles.elements();
561*cdf0e10cSrcweir //
562*cdf0e10cSrcweir //        while (aSnapshot.hasMoreElements()) {
563*cdf0e10cSrcweir //            String doc = (String) aSnapshot.nextElement();
564*cdf0e10cSrcweir //
565*cdf0e10cSrcweir //
566*cdf0e10cSrcweir //            // if os is windows
567*cdf0e10cSrcweir //            doc = doc.replace('\\', '/');
568*cdf0e10cSrcweir //	    if (doc.indexOf("CVS")<0) {
569*cdf0e10cSrcweir //		    loadURL(m_xLoader, RESULT_VALID_DOC, sFTPURL + "/" + doc,
570*cdf0e10cSrcweir //                    "_blank", 0, lProps);
571*cdf0e10cSrcweir //	    }
572*cdf0e10cSrcweir //        }
573*cdf0e10cSrcweir //
574*cdf0e10cSrcweir //        System.out.println("check HTTP URLs");
575*cdf0e10cSrcweir //
576*cdf0e10cSrcweir //        String sHTTPURL = (String) param.get("HttpAccess");
577*cdf0e10cSrcweir //        aSnapshot = m_lTestFiles.elements();
578*cdf0e10cSrcweir //
579*cdf0e10cSrcweir //        while (aSnapshot.hasMoreElements()) {
580*cdf0e10cSrcweir //            String doc = (String) aSnapshot.nextElement();
581*cdf0e10cSrcweir //
582*cdf0e10cSrcweir //
583*cdf0e10cSrcweir //            // if os is windows
584*cdf0e10cSrcweir //            doc = doc.replace('\\', '/');
585*cdf0e10cSrcweir //	    if (doc.indexOf("CVS")<0) {
586*cdf0e10cSrcweir //		    loadURL(m_xLoader, RESULT_VALID_DOC, sHTTPURL + "/" + doc,
587*cdf0e10cSrcweir //                    "_blank", 0, lProps);
588*cdf0e10cSrcweir //	    }
589*cdf0e10cSrcweir //        }
590*cdf0e10cSrcweir //    }
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir     /** TODo document me
593*cdf0e10cSrcweir      */
594*cdf0e10cSrcweir     @Test public void checkStreamLoading()
595*cdf0e10cSrcweir     {
596*cdf0e10cSrcweir         PropertyValue[] lProps = new PropertyValue[2];
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir         lProps[0] = new PropertyValue();
599*cdf0e10cSrcweir         lProps[0].Name = "Hidden";
600*cdf0e10cSrcweir         lProps[0].Value = Boolean.TRUE;
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir         lProps[1] = new PropertyValue();
603*cdf0e10cSrcweir         lProps[1].Name = "InputStream";
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir         Enumeration aSnapshot = m_lTestFiles.elements();
606*cdf0e10cSrcweir         while (aSnapshot.hasMoreElements())
607*cdf0e10cSrcweir         {
608*cdf0e10cSrcweir             File   aFile = new File(m_sTestDocPath, (String) aSnapshot.nextElement());
609*cdf0e10cSrcweir             String sURL  = URLHelper.getFileURLFromSystemPath(aFile);
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir //            if (sURL.indexOf("CVS") > -1)
612*cdf0e10cSrcweir //            {
613*cdf0e10cSrcweir //                continue;
614*cdf0e10cSrcweir //            }
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir             try
617*cdf0e10cSrcweir             {
618*cdf0e10cSrcweir                 XInputStream xStream = m_xStreamProvider.openFileRead(sURL);
619*cdf0e10cSrcweir                 lProps[1].Value = xStream;
620*cdf0e10cSrcweir             }
621*cdf0e10cSrcweir             catch(com.sun.star.uno.Exception e)
622*cdf0e10cSrcweir             {
623*cdf0e10cSrcweir                 fail("Could not open test file \""+sURL+"\" for stream test.");
624*cdf0e10cSrcweir             }
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir             // check different version of "private:stream" URL!
627*cdf0e10cSrcweir             loadURL(m_xLoader, RESULT_VALID_DOC, "private:stream" , "_blank", 0, lProps);
628*cdf0e10cSrcweir             // loadURL(m_xLoader, RESULT_VALID_DOC, "private:stream" , "_blank", 0, lProps);
629*cdf0e10cSrcweir             // loadURL(m_xLoader, RESULT_VALID_DOC, "private:stream/", "_blank", 0, lProps);
630*cdf0e10cSrcweir 	}
631*cdf0e10cSrcweir     }
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir     /**
634*cdf0e10cSrcweir      * Loads one URL with the given parameters using the method
635*cdf0e10cSrcweir      * loadComponentFromURL(). Further it's possible to specify, whch result is
636*cdf0e10cSrcweir      * required and we check internally if it was reached. Logging of errors
637*cdf0e10cSrcweir      * and success stories is done inside this method too. Of course we catch
638*cdf0e10cSrcweir      * all possible exceptions and try to leave the office without any forgotten
639*cdf0e10cSrcweir      * but opened documents.
640*cdf0e10cSrcweir      */
641*cdf0e10cSrcweir     private void loadURL(XComponentLoader m_xLoader, int nRequiredResult,
642*cdf0e10cSrcweir                          String sURL, String sTarget, int nFlags,
643*cdf0e10cSrcweir                          PropertyValue[] lProps) {
644*cdf0e10cSrcweir         int nResult = RESULT_EMPTY_DOC;
645*cdf0e10cSrcweir         XComponent xDoc = null;
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir         try {
648*cdf0e10cSrcweir             xDoc = m_xLoader.loadComponentFromURL(sURL, sTarget, nFlags,
649*cdf0e10cSrcweir                                                      lProps);
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir             if (xDoc != null) {
652*cdf0e10cSrcweir                 nResult = RESULT_VALID_DOC;
653*cdf0e10cSrcweir             } else {
654*cdf0e10cSrcweir                 nResult = RESULT_EMPTY_DOC;
655*cdf0e10cSrcweir             }
656*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException exArgument) {
657*cdf0e10cSrcweir             nResult = RESULT_ILLEGALARGUMENTEXCEPTION;
658*cdf0e10cSrcweir         } catch (com.sun.star.io.IOException exIO) {
659*cdf0e10cSrcweir             nResult = RESULT_IOEXCEPTION;
660*cdf0e10cSrcweir         } catch (com.sun.star.uno.RuntimeException exRuntime) {
661*cdf0e10cSrcweir             nResult = RESULT_RUNTIMEEXCEPTION;
662*cdf0e10cSrcweir         } catch (Exception e) {
663*cdf0e10cSrcweir             nResult = RESULT_EXCEPTION;
664*cdf0e10cSrcweir         }
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir         try {
667*cdf0e10cSrcweir             if (xDoc != null) {
668*cdf0e10cSrcweir                 xDoc.dispose();
669*cdf0e10cSrcweir                 xDoc = null;
670*cdf0e10cSrcweir             }
671*cdf0e10cSrcweir         } catch (com.sun.star.uno.RuntimeException exClosing) {
672*cdf0e10cSrcweir             System.out.println("exception during disposing of a document found!" +
673*cdf0e10cSrcweir                         " Doesn't influence test - but should be checked.");
674*cdf0e10cSrcweir         }
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir         String sMessage = "URL[\"" + sURL + "\"]";
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir         if (nResult == nRequiredResult) {
679*cdf0e10cSrcweir             System.out.println(sMessage + " expected result [" +
680*cdf0e10cSrcweir                         convertResult2String(nResult) + "] ");
681*cdf0e10cSrcweir         } else {
682*cdf0e10cSrcweir             fail(sMessage + " unexpected result [" +
683*cdf0e10cSrcweir                    convertResult2String(nResult) + "] " +
684*cdf0e10cSrcweir                    "\nrequired was [" +
685*cdf0e10cSrcweir                    convertResult2String(nRequiredResult) + "]" +
686*cdf0e10cSrcweir                    "\nwe got       [" + convertResult2String(nResult) + "]"
687*cdf0e10cSrcweir                    );
688*cdf0e10cSrcweir         }
689*cdf0e10cSrcweir     }
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir     private void loadURL(XComponentLoader m_xLoader, int nRequiredResult,
692*cdf0e10cSrcweir                          String[] sURL, String sTarget, int nFlags,
693*cdf0e10cSrcweir                          PropertyValue[] lProps) {
694*cdf0e10cSrcweir         for (int i = 0; i < sURL.length; i++)
695*cdf0e10cSrcweir         {
696*cdf0e10cSrcweir             loadURL(m_xLoader, nRequiredResult, sURL[i], sTarget, nFlags, lProps);
697*cdf0e10cSrcweir         }
698*cdf0e10cSrcweir     }
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir     /**
701*cdf0e10cSrcweir      * it match the int result value to a string, which can be used for logging
702*cdf0e10cSrcweir      */
703*cdf0e10cSrcweir     private static String convertResult2String(int nResult) {
704*cdf0e10cSrcweir         switch (nResult) {
705*cdf0e10cSrcweir         case RESULT_VALID_DOC:
706*cdf0e10cSrcweir             return "VALID_DOC";
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir         case RESULT_EMPTY_DOC:
709*cdf0e10cSrcweir             return "EMPTY_DOC";
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir         case RESULT_ILLEGALARGUMENTEXCEPTION:
712*cdf0e10cSrcweir             return "ILLEGALARGUMENTEXCEPTION";
713*cdf0e10cSrcweir 
714*cdf0e10cSrcweir         case RESULT_IOEXCEPTION:
715*cdf0e10cSrcweir             return "IOEXCEPTION";
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir         case RESULT_RUNTIMEEXCEPTION:
718*cdf0e10cSrcweir             return "RUNTIMEEXCEPTION";
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir         case RESULT_EXCEPTION:
721*cdf0e10cSrcweir             return "ALLOTHEREXCEPTION";
722*cdf0e10cSrcweir         }
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir         return "unknown!";
725*cdf0e10cSrcweir     }
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir     private XMultiServiceFactory getMSF()
728*cdf0e10cSrcweir     {
729*cdf0e10cSrcweir         final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
730*cdf0e10cSrcweir         return xMSF1;
731*cdf0e10cSrcweir     }
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir     // setup and close connections
734*cdf0e10cSrcweir     @BeforeClass
735*cdf0e10cSrcweir     public static void setUpConnection() throws Exception
736*cdf0e10cSrcweir     {
737*cdf0e10cSrcweir         System.out.println("setUpConnection()");
738*cdf0e10cSrcweir         connection.setUp();
739*cdf0e10cSrcweir     }
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir     @AfterClass
742*cdf0e10cSrcweir     public static void tearDownConnection()
743*cdf0e10cSrcweir             throws InterruptedException, com.sun.star.uno.Exception
744*cdf0e10cSrcweir     {
745*cdf0e10cSrcweir         System.out.println("tearDownConnection()");
746*cdf0e10cSrcweir         connection.tearDown();
747*cdf0e10cSrcweir     }
748*cdf0e10cSrcweir     private static final OfficeConnection connection = new OfficeConnection();
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir }
751