1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: test_cpy_wrt_file.cxx,v $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sal.hxx"
34 #include <cppunit/simpleheader.hxx>
35 #include <osl/file.hxx>
36 #include <osl/thread.h>
37 #include <rtl/ustring.hxx>
42 //########################################
44 # define COPY_SOURCE_PATH "/home/tr109510/ucbhelper.cxx"
45 # define COPY_DEST_PATH "/mnt/mercury08/ucbhelper.cxx"
47 # define COPY_SOURCE_PATH "d:\\msvcr70.dll"
48 # define COPY_DEST_PATH "x:\\tra\\msvcr70.dll"
51 class test_osl_copyFile
: public CppUnit::TestFixture
56 rtl::OUString src_url
;
57 FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii(COPY_SOURCE_PATH
), src_url
);
59 rtl::OUString dest_url
;
60 FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii(COPY_DEST_PATH
), dest_url
);
62 FileBase::RC err
= File::copy(src_url
, dest_url
);
63 CPPUNIT_ASSERT_MESSAGE("Copy didn't recognized disk full", err
!= FileBase::E_None
);
66 CPPUNIT_TEST_SUITE(test_osl_copyFile
);
67 CPPUNIT_TEST(cp_file
);
68 CPPUNIT_TEST_SUITE_END();
71 //########################################
73 # define WRITE_DEST_PATH "/mnt/mercury08/muell.tmp"
75 # define WRITE_DEST_PATH "d:\\tmp_data.tmp"
78 class test_osl_writeFile
: public CppUnit::TestFixture
83 rtl::OUString dest_url
;
84 FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii(WRITE_DEST_PATH
), dest_url
);
86 File
tmp_file(dest_url
);
87 rtl::OUString suErrorMsg
= rtl::OUString::createFromAscii("File creation failed: ")+ dest_url
;
88 FileBase::RC err
= tmp_file
.open(osl_File_OpenFlag_Write
| osl_File_OpenFlag_Create
);
90 CPPUNIT_ASSERT_MESSAGE( suErrorMsg
, err
== FileBase::E_None
|| err
== FileBase::E_EXIST
);
93 sal_uInt64 written
= 0;
94 err
= tmp_file
.write((void*)buffer
, sizeof(buffer
), written
);
96 err
= tmp_file
.sync();
98 CPPUNIT_ASSERT_MESSAGE("Write didn't recognized disk full", err
!= FileBase::E_None
);
103 CPPUNIT_TEST_SUITE(test_osl_writeFile
);
104 CPPUNIT_TEST(wrt_file
);
105 CPPUNIT_TEST_SUITE_END();
108 //#####################################
109 // register test suites
110 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_osl_writeFile
, "test_osl_writeFile");
111 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_osl_copyFile
, "test_osl_copyFile");