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.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_ucb.hxx"
34 /**************************************************************************
36 **************************************************************************
38 *************************************************************************/
40 #include "test_ftpurl.hxx"
44 // #include <osl/process.h>
45 // #include <osl/thread.hxx>
47 // #include <ucbhelper/configurationkeys.hxx>
48 // #include <cppuhelper/bootstrap.hxx>
49 // #include <cppuhelper/servicefactory.hxx>
50 // #include <comphelper/processfactory.hxx>
51 // #include <comphelper/regpathhelper.hxx>
52 // #include <com/sun/star/lang/XComponent.hpp>
53 // #include <com/sun/star/lang/XMultiServiceFactory.hpp>
54 // #include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
55 // #include <com/sun/star/ucb/XContent.hpp>
56 // #include <com/sun/star/ucb/XContentProvider.hpp>
57 // #include <com/sun/star/ucb/XCommandProcessor.hpp>
58 // #include <com/sun/star/ucb/OpenMode.hpp>
59 // #include <com/sun/star/ucb/Command.hpp>
60 // #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
61 // #include <com/sun/star/io/XActiveDataSink.hpp>
62 // #include <com/sun/star/beans/Property.hpp>
65 // #include "debughelper.hxx"
66 // #include "test_activedatasink.hxx"
67 // #include "test_ftpurl.hxx"
68 // #include "test_multiservicefac.hxx"
69 // #include "ftpcontentprovider.hxx"
70 // #include "ftpcontentidentifier.hxx"
73 // using namespace test_ftp;
74 // using namespace rtl;
75 // using namespace com::sun::star::uno;
76 // using namespace com::sun::star::lang;
77 // using namespace com::sun::star::ucb;
78 // using namespace com::sun::star::beans;
79 // using namespace com::sun::star::io;
84 // : public osl::Thread
90 // int number_of_errors() { return _number_of_errors; }
94 // void SAL_CALL run();
99 // ftp::FTPContentProvider *pProvider;
100 // Reference<XContentProvider> xProvider;
101 // Reference<XMultiServiceFactory> xFac;
103 // int _number_of_errors;
107 // Reference< XMultiServiceFactory > createApplicationServiceManager()
111 // Reference<XComponentContext> xComponentContext =
112 // ::cppu::defaultBootstrap_InitialComponentContext();
113 // Reference<XMultiServiceFactory> xMS(
114 // xComponentContext->getServiceManager(),
119 // catch( ::com::sun::star::uno::Exception& )
121 // return Reference< XMultiServiceFactory >();
126 // FTPThread::FTPThread()
127 // : _number_of_errors(0),
128 // xFac(createApplicationServiceManager())
130 // pProvider = new ftp::FTPContentProvider(xFac);
131 // xProvider = Reference<XContentProvider>(pProvider);
133 // if(!xProvider.is())
134 // ++_number_of_errors;
138 // void FTPThread::run() {
140 // ++_number_of_errors;
144 // Reference<XContentIdentifier> xIdent(
145 // new ftp::FTPContentIdentifier(
146 // rtl::OUString::createFromAscii("ftp://abi:psswd@abi-1/file"),
149 // Reference<XContent> xContent = xProvider->queryContent(xIdent);
150 // if(!xContent.is())
152 // err_msg("no content",OUString());
157 // Reference<XActiveDataSink> xActDS(new Test_ActiveDataSink());
158 // OpenCommandArgument2 aOpenCommand(OpenMode::DOCUMENT,
160 // Reference<XInterface>(xActDS,UNO_QUERY),
161 // Sequence<Property>(0),
162 // Sequence<NumberedSortingInfo>(0));
163 // Any aAny; aAny <<= aOpenCommand;
165 // Command aCommand(OUString::createFromAscii("open"),
169 // Reference<XCommandProcessor> xCommandProcessor(xContent,UNO_QUERY);
170 // if(!xCommandProcessor.is())
172 // err_msg("no command_processor",OUString());
175 // xCommandProcessor->execute(aCommand,
176 // 0,Reference<XCommandEnvironment>(0));
178 // Reference<XInputStream> xInputStream = xActDS->getInputStream();
179 // if(!xInputStream.is())
184 int main(int argc
,char* argv
[])
186 // FTPThread aThread;
190 typedef int (*INT_FUNC
)(void);
191 INT_FUNC tests
[] = { test_ftpurl
,
196 0 }; // don't remove ending zero
200 fprintf(stderr
,"------- Testing ----------\n");
204 INT_FUNC f
= tests
[++i
];
213 fprintf(stderr
,"number of failed tests: %d\n",err_level
);
214 fprintf(stderr
,"----------------------------------\n");
216 fprintf(stderr
,"no errors\n");
223 // char *scefile = 0;
224 // if(strcmp(argv[1],"-sce") == 0)
225 // scefile = argv[2];
228 // fprintf(stderr,"usage: ftptest -sce filename\n");
232 // rtl::OUString sceurl;
233 // osl::FileBase::RC err =
234 // osl::FileBase::getFileURLFromSystemPath(
235 // rtl::OUString(scefile,
237 // RTL_TEXTENCODING_UTF8),
240 // osl::File aFile(sceurl);
241 // err = aFile.open(OpenFlag_Read);
242 // if(err != osl::FileBase::E_None) {
243 // fprintf(stderr,"could not open sce-file %s\n",scefile);
249 // rtl::OUStringBuffer bff;
251 // err = aFile.read((void*)buffer,256,n);
252 // bff.appendAscii(buffer,sal_Int32(n));
253 // } while(err == osl::FileBase::E_None && n == 256);
257 // rtl::OUString sce = bff.makeStringAndClear();
259 // fprintf(stderr,rtl::OString(sce.getStr(),
261 // RTL_TEXTENCODING_UTF8).getStr());
263 // rtl::OUString lib,tmp,testlib;
264 // std::vector<rtl::OUString> tests;
265 // sal_Int32 TEST = sce.indexOf(rtl::OUString::createFromAscii("TEST"));
266 // sal_Int32 WITH = sce.indexOf(rtl::OUString::createFromAscii("WITH"));
267 // sal_Int32 FROM = sce.indexOf(rtl::OUString::createFromAscii("FROM"));
268 // lib = sce.copy(TEST+4,WITH-TEST-4).trim();
270 // tmp = sce.copy(WITH+4,FROM-WITH-4).trim();
271 // sal_Int32 nIndex = 0;
274 // rtl::OUString token = tmp.getToken(0,';',nIndex).trim();
275 // if(token.getLength())
276 // tests.push_back(token);
277 // } while(nIndex >= 0);
279 // testlib = sce.copy(FROM+4).trim();
281 // // fprintf(stderr,"%s\n",
282 // // rtl::OString(token.getStr(),
283 // // token.getLength(),
284 // // RTL_TEXTENCODING_UTF8).getStr());
286 // osl::Module testLib;
287 // if(!testLib.load(testlib)) {
288 // fprintf(stderr,"library not found: %s\n",
289 // rtl::OString(testlib.getStr(),
290 // testlib.getLength(),
291 // RTL_TEXTENCODING_UTF8).getStr());
295 // osl::Module mathLib;
296 // mathLib.load(rtl::OUString::createFromAscii("libm.so"));
297 // typedef double (*DF)(double);
298 // DF func = (DF)mathLib.getSymbol(rtl::OUString::createFromAscii("cos"));
299 // fprintf(stderr,"-------double %f ----------\n",(*func)(2.0));
301 // fprintf(stderr,"-------testing %s ----------\n",scefile);