merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / ucb / _XSimpleFileAccess2.java
blobfa0979ee361ce1b43c56cf9085f55e259a91899c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XSimpleFileAccess2.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.ucb;
33 import lib.MultiMethodTest;
35 import com.sun.star.io.XInputStream;
36 import com.sun.star.lang.XMultiServiceFactory;
37 import com.sun.star.ucb.XSimpleFileAccess2;
39 /**
40 * Testing <code>com.sun.star.ucb.XSimpleFileAccess2</code>
41 * interface methods. <p>
42 * @see com.sun.star.ucb.XSimpleFileAccess2
44 public class _XSimpleFileAccess2 extends MultiMethodTest {
46 public static XSimpleFileAccess2 oObj = null;
48 /**
49 * Writes <b>XSimpleFileAccess_new.txt</b> to disk, checks
50 * if it was successfully created and then deletes it. <p>
51 * Has <b> OK </b> status if after method call the file
52 * exists and no exceptions were thrown. <p>
54 public void _writeFile() {
55 boolean result = true;
56 try {
57 String dirnameTo = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF()) ;
58 String fileURL = dirnameTo + "XSimpleFileAccess_new.txt";
59 String dirname = util.utils.getFullTestURL("XSimpleFileAccess");
60 String filename = dirname+"XSimpleFileAccess.txt";
61 XInputStream iStream = oObj.openFileRead(filename);
62 oObj.writeFile(fileURL,iStream);
63 shortWait();
64 result = oObj.exists(fileURL);
65 oObj.kill(fileURL);
66 tRes.tested("writeFile()",result);
68 catch (com.sun.star.ucb.CommandAbortedException ex) {
69 log.println("CommandAbortedException occured while testing "+
70 "'writeFile()'");
71 ex.printStackTrace(log);
72 tRes.tested("writeFile()",false);
74 catch (com.sun.star.uno.Exception ex) {
75 log.println("Exception occured while testing 'writeFile()'");
76 ex.printStackTrace(log);
77 tRes.tested("writeFile()",false);
80 } //EOF writeFile()
82 /**
83 * Sleeps for 1 sec. to allow StarOffice to react on <code>
84 * reset</code> call.
86 private void shortWait() {
87 try {
88 Thread.sleep(1000) ;
89 } catch (InterruptedException e) {
90 log.println("While waiting :" + e) ;
94 } // finish class _XSimpleFileAccess