merge the formfield patch from ooo-build
[ooovba.git] / ucb / source / ucp / ftp / test.cxx
blob9fd7b0281a0d256a1cf7d3b04c82fc229a947683
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: test.cxx,v $
10 * $Revision: 1.9 $
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 /**************************************************************************
35 TODO
36 **************************************************************************
38 *************************************************************************/
40 #include "test_ftpurl.hxx"
41 #include <stdio.h>
42 #include <unistd.h>
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;
83 // class FTPThread
84 // : public osl::Thread
85 // {
86 // public:
88 // FTPThread();
90 // int number_of_errors() { return _number_of_errors; }
92 // protected:
94 // void SAL_CALL run();
97 // private:
99 // ftp::FTPContentProvider *pProvider;
100 // Reference<XContentProvider> xProvider;
101 // Reference<XMultiServiceFactory> xFac;
103 // int _number_of_errors;
104 // };
107 // Reference< XMultiServiceFactory > createApplicationServiceManager()
108 // {
109 // try
110 // {
111 // Reference<XComponentContext> xComponentContext =
112 // ::cppu::defaultBootstrap_InitialComponentContext();
113 // Reference<XMultiServiceFactory> xMS(
114 // xComponentContext->getServiceManager(),
115 // UNO_QUERY);
117 // return xMS;
118 // }
119 // catch( ::com::sun::star::uno::Exception& )
120 // {
121 // return Reference< XMultiServiceFactory >();
122 // }
123 // }
126 // FTPThread::FTPThread()
127 // : _number_of_errors(0),
128 // xFac(createApplicationServiceManager())
129 // {
130 // pProvider = new ftp::FTPContentProvider(xFac);
131 // xProvider = Reference<XContentProvider>(pProvider);
133 // if(!xProvider.is())
134 // ++_number_of_errors;
135 // }
138 // void FTPThread::run() {
139 // if(!xFac.is()) {
140 // ++_number_of_errors;
141 // exit(1);
142 // }
144 // Reference<XContentIdentifier> xIdent(
145 // new ftp::FTPContentIdentifier(
146 // rtl::OUString::createFromAscii("ftp://abi:psswd@abi-1/file"),
147 // pProvider));
149 // Reference<XContent> xContent = xProvider->queryContent(xIdent);
150 // if(!xContent.is())
151 // {
152 // err_msg("no content",OUString());
153 // exit(1);
154 // }
157 // Reference<XActiveDataSink> xActDS(new Test_ActiveDataSink());
158 // OpenCommandArgument2 aOpenCommand(OpenMode::DOCUMENT,
159 // 0,
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"),
166 // -1,
167 // aAny);
169 // Reference<XCommandProcessor> xCommandProcessor(xContent,UNO_QUERY);
170 // if(!xCommandProcessor.is())
171 // {
172 // err_msg("no command_processor",OUString());
173 // exit(1);
174 // }
175 // xCommandProcessor->execute(aCommand,
176 // 0,Reference<XCommandEnvironment>(0));
178 // Reference<XInputStream> xInputStream = xActDS->getInputStream();
179 // if(!xInputStream.is())
180 // ;
181 // }
184 int main(int argc,char* argv[])
186 // FTPThread aThread;
187 // aThread.create();
188 // aThread.join();
190 typedef int (*INT_FUNC)(void);
191 INT_FUNC tests[] = { test_ftpurl,
192 test_ftpparent,
193 test_ftpproperties,
194 test_ftpopen,
195 test_ftplist,
196 0 }; // don't remove ending zero
198 int err_level = 0;
200 fprintf(stderr,"------- Testing ----------\n");
202 int i = -1;
203 do {
204 INT_FUNC f = tests[++i];
205 if(f) {
206 err_level += (*f)();
207 fprintf(stderr,".");
208 } else
209 break;
210 } while(true);
212 if(err_level) {
213 fprintf(stderr,"number of failed tests: %d\n",err_level);
214 fprintf(stderr,"----------------------------------\n");
215 } else
216 fprintf(stderr,"no errors\n");
218 return err_level;
223 // char *scefile = 0;
224 // if(strcmp(argv[1],"-sce") == 0)
225 // scefile = argv[2];
227 // if(!scefile) {
228 // fprintf(stderr,"usage: ftptest -sce filename\n");
229 // return 1;
230 // }
232 // rtl::OUString sceurl;
233 // osl::FileBase::RC err =
234 // osl::FileBase::getFileURLFromSystemPath(
235 // rtl::OUString(scefile,
236 // strlen(scefile),
237 // RTL_TEXTENCODING_UTF8),
238 // sceurl);
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);
244 // return 1;
245 // }
247 // sal_uInt64 n;
248 // char buffer[256];
249 // rtl::OUStringBuffer bff;
250 // do {
251 // err = aFile.read((void*)buffer,256,n);
252 // bff.appendAscii(buffer,sal_Int32(n));
253 // } while(err == osl::FileBase::E_None && n == 256);
255 // aFile.close();
257 // rtl::OUString sce = bff.makeStringAndClear();
259 // fprintf(stderr,rtl::OString(sce.getStr(),
260 // sce.getLength(),
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;
272 // do
273 // {
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());
292 // return 1;
293 // }
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);