bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / ucb / _XSimpleFileAccess2.java
bloba10dbb0592dd84502ba8c545accd33e4e108967b
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 ifc.ucb;
21 import lib.MultiMethodTest;
23 import com.sun.star.io.XInputStream;
24 import com.sun.star.lang.XMultiServiceFactory;
25 import com.sun.star.ucb.XSimpleFileAccess2;
27 /**
28 * Testing <code>com.sun.star.ucb.XSimpleFileAccess2</code>
29 * interface methods. <p>
30 * @see com.sun.star.ucb.XSimpleFileAccess2
32 public class _XSimpleFileAccess2 extends MultiMethodTest {
34 public static XSimpleFileAccess2 oObj = null;
36 /**
37 * Writes <b>XSimpleFileAccess_new.txt</b> to disk, checks
38 * if it was successfully created and then deletes it. <p>
39 * Has <b> OK </b> status if after method call the file
40 * exists and no exceptions were thrown. <p>
42 public void _writeFile() {
43 boolean result = true;
44 try {
45 String dirnameTo = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF()) ;
46 String fileURL = dirnameTo + "XSimpleFileAccess_new.txt";
47 String dirname = util.utils.getFullTestURL("XSimpleFileAccess");
48 String filename = dirname+"XSimpleFileAccess.txt";
49 XInputStream iStream = oObj.openFileRead(filename);
50 oObj.writeFile(fileURL,iStream);
51 shortWait();
52 result = oObj.exists(fileURL);
53 oObj.kill(fileURL);
54 tRes.tested("writeFile()",result);
56 catch (com.sun.star.ucb.CommandAbortedException ex) {
57 log.println("CommandAbortedException occurred while testing "+
58 "'writeFile()'");
59 ex.printStackTrace(log);
60 tRes.tested("writeFile()",false);
62 catch (com.sun.star.uno.Exception ex) {
63 log.println("Exception occurred while testing 'writeFile()'");
64 ex.printStackTrace(log);
65 tRes.tested("writeFile()",false);
68 } //EOF writeFile()
70 /**
71 * Sleeps for 1 sec. to allow StarOffice to react on <code>
72 * reset</code> call.
74 private void shortWait() {
75 try {
76 Thread.sleep(1000) ;
77 } catch (InterruptedException e) {
78 log.println("While waiting :" + e) ;
82 } // finish class _XSimpleFileAccess