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 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.io
.XInputStream
;
24 import com
.sun
.star
.ucb
.XSimpleFileAccess2
;
27 * Testing <code>com.sun.star.ucb.XSimpleFileAccess2</code>
28 * interface methods. <p>
29 * @see com.sun.star.ucb.XSimpleFileAccess2
31 public class _XSimpleFileAccess2
extends MultiMethodTest
{
33 public static XSimpleFileAccess2 oObj
= null;
36 * Writes <b>XSimpleFileAccess_new.txt</b> to disk, checks
37 * if it was successfully created and then deletes it. <p>
38 * Has <b> OK </b> status if after method call the file
39 * exists and no exceptions were thrown. <p>
41 public void _writeFile() {
42 boolean result
= true;
44 String dirnameTo
= util
.utils
.getOfficeTemp(tParam
.getMSF()) ;
45 String fileURL
= dirnameTo
+ "XSimpleFileAccess_new.txt";
46 String dirname
= util
.utils
.getFullTestURL("XSimpleFileAccess");
47 String filename
= dirname
+"XSimpleFileAccess.txt";
48 XInputStream iStream
= oObj
.openFileRead(filename
);
49 oObj
.writeFile(fileURL
,iStream
);
50 util
.utils
.pause(1000);
51 result
= oObj
.exists(fileURL
);
53 tRes
.tested("writeFile()",result
);
55 catch (com
.sun
.star
.ucb
.CommandAbortedException ex
) {
56 log
.println("CommandAbortedException occurred while testing "+
58 ex
.printStackTrace(log
);
59 tRes
.tested("writeFile()",false);
61 catch (com
.sun
.star
.uno
.Exception ex
) {
62 log
.println("Exception occurred while testing 'writeFile()'");
63 ex
.printStackTrace(log
);
64 tRes
.tested("writeFile()",false);
69 } // finish class _XSimpleFileAccess