summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/inc/makefile.mk38
-rw-r--r--test/inc/pch/precompiled_test.cxx26
-rw-r--r--test/inc/pch/precompiled_test.hxx30
-rw-r--r--test/inc/test/detail/testdllapi.hxx39
-rw-r--r--test/inc/test/getargument.hxx44
-rw-r--r--test/inc/test/officeconnection.hxx65
-rw-r--r--test/inc/test/oustringostreaminserter.hxx48
-rw-r--r--test/inc/test/toabsolutefileurl.hxx44
-rw-r--r--test/prj/build.lst4
-rw-r--r--test/prj/d.lst12
-rw-r--r--test/source/cpp/getargument.cxx42
-rw-r--r--test/source/cpp/makefile.mk55
-rw-r--r--test/source/cpp/officeconnection.cxx173
-rw-r--r--test/source/cpp/toabsolutefileurl.cxx83
-rw-r--r--test/source/java/OfficeConnection.java221
-rw-r--r--test/source/java/makefile.mk49
16 files changed, 973 insertions, 0 deletions
diff --git a/test/inc/makefile.mk b/test/inc/makefile.mk
new file mode 100644
index 000000000000..c8428466005b
--- /dev/null
+++ b/test/inc/makefile.mk
@@ -0,0 +1,38 @@
+#*************************************************************************
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#***********************************************************************/
+
+PRJ = ..
+PRJNAME = test
+TARGET = inc
+
+ENABLE_EXCEPTIONS = TRUE
+VISIBILITY_HIDDEN = TRUE
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+
+.IF "$(ENABLE_PCH)" != ""
+ALLTAR: $(SLO)/precompiled.pch $(SLO)/precompiled_ex.pch
+.ENDIF
diff --git a/test/inc/pch/precompiled_test.cxx b/test/inc/pch/precompiled_test.cxx
new file mode 100644
index 000000000000..7077411c8fc5
--- /dev/null
+++ b/test/inc/pch/precompiled_test.cxx
@@ -0,0 +1,26 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#include "precompiled_test.hxx"
diff --git a/test/inc/pch/precompiled_test.hxx b/test/inc/pch/precompiled_test.hxx
new file mode 100644
index 000000000000..d4927944f9c7
--- /dev/null
+++ b/test/inc/pch/precompiled_test.hxx
@@ -0,0 +1,30 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#if defined PRECOMPILED_HEADERS
+
+#include "sal/config.h"
+
+#endif
diff --git a/test/inc/test/detail/testdllapi.hxx b/test/inc/test/detail/testdllapi.hxx
new file mode 100644
index 000000000000..41d5b4d69b8c
--- /dev/null
+++ b/test/inc/test/detail/testdllapi.hxx
@@ -0,0 +1,39 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef INCLUDED_TEST_DETAIL_TESTDLLAPI_HXX
+#define INCLUDED_TEST_DETAIL_TESTDLLAPI_HXX
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+#if defined OOO_DLLIMPLEMENTATION_TEST
+#define OOO_DLLPUBLIC_TEST SAL_DLLPUBLIC_EXPORT
+#else
+#define OOO_DLLPUBLIC_TEST SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
diff --git a/test/inc/test/getargument.hxx b/test/inc/test/getargument.hxx
new file mode 100644
index 000000000000..1b4df29d2115
--- /dev/null
+++ b/test/inc/test/getargument.hxx
@@ -0,0 +1,44 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef INCLUDED_TEST_GETARGUMENT_HXX
+#define INCLUDED_TEST_GETARGUMENT_HXX
+
+#include "sal/config.h"
+
+#include "test/detail/testdllapi.hxx"
+
+namespace rtl { class OUString; }
+
+namespace test {
+
+// Obtain the value of an argument tunneled in via an "arg-<name>" bootstrap
+// variable:
+OOO_DLLPUBLIC_TEST bool getArgument(
+ rtl::OUString const & name, rtl::OUString * value);
+
+}
+
+#endif
diff --git a/test/inc/test/officeconnection.hxx b/test/inc/test/officeconnection.hxx
new file mode 100644
index 000000000000..99a319d51a7e
--- /dev/null
+++ b/test/inc/test/officeconnection.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef INCLUDED_TEST_OFFICECONNECTION_HXX
+#define INCLUDED_TEST_OFFICECONNECTION_HXX
+
+#include "sal/config.h"
+
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "osl/process.h"
+#include "test/detail/testdllapi.hxx"
+
+namespace com { namespace sun { namespace star { namespace lang {
+ class XMultiServiceFactory;
+} } } }
+
+namespace test {
+
+// Start up and shut down an OOo instance (details about the OOo instance are
+// tunneled in via "arg-..." bootstrap variables):
+class OOO_DLLPUBLIC_TEST OfficeConnection: private boost::noncopyable {
+public:
+ OfficeConnection();
+
+ ~OfficeConnection();
+
+ void setUp();
+
+ void tearDown();
+
+ com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
+ getFactory() const;
+
+private:
+ oslProcess process_;
+ com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
+ factory_;
+};
+
+}
+
+#endif
diff --git a/test/inc/test/oustringostreaminserter.hxx b/test/inc/test/oustringostreaminserter.hxx
new file mode 100644
index 000000000000..187b0ebd5f83
--- /dev/null
+++ b/test/inc/test/oustringostreaminserter.hxx
@@ -0,0 +1,48 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef INCLUDED_TEST_OUSTRINGOSTREAMINSERTER_HXX
+#define INCLUDED_TEST_OUSTRINGOSTREAMINSERTER_HXX
+
+#include "sal/config.h"
+
+#include <ostream>
+
+#include "osl/thread.h"
+#include "rtl/ustring.hxx"
+
+// Include this header to support rtl::OUString in CPPUNIT_ASSERT macros.
+
+template< typename charT, typename traits > std::basic_ostream<charT, traits> &
+operator <<(
+ std::basic_ostream<charT, traits> & stream, rtl::OUString const & string)
+{
+ return stream <<
+ rtl::OUStringToOString(string, osl_getThreadTextEncoding()).getStr();
+ // best effort; potentially loses data due to conversion failures and
+ // embedded null characters
+}
+
+#endif
diff --git a/test/inc/test/toabsolutefileurl.hxx b/test/inc/test/toabsolutefileurl.hxx
new file mode 100644
index 000000000000..5828a050fb75
--- /dev/null
+++ b/test/inc/test/toabsolutefileurl.hxx
@@ -0,0 +1,44 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef INCLUDED_TEST_TOABSOLUTEFILEURL_HXX
+#define INCLUDED_TEST_TOABSOLUTEFILEURL_HXX
+
+#include "sal/config.h"
+
+#include "test/detail/testdllapi.hxx"
+
+namespace rtl { class OUString; }
+
+namespace test {
+
+// Convert a pathname in system notation, potentially relative to the process's
+// current working directory, to an absolute file URL:
+OOO_DLLPUBLIC_TEST rtl::OUString toAbsoluteFileUrl(
+ rtl::OUString const & relativePathname);
+
+}
+
+#endif
diff --git a/test/prj/build.lst b/test/prj/build.lst
new file mode 100644
index 000000000000..1bf76d664a7a
--- /dev/null
+++ b/test/prj/build.lst
@@ -0,0 +1,4 @@
+te test : BOOST:boost cppu cppuhelper CPPUNIT:cppunit javaunohelper offuh ridljar sal solenv unoil NULL
+te test\inc nmake - all inc NULL
+te test\source\cpp nmake - all source_cpp inc NULL
+te test\source\java nmake - all source_java NULL
diff --git a/test/prj/d.lst b/test/prj/d.lst
new file mode 100644
index 000000000000..bcea8bee46fe
--- /dev/null
+++ b/test/prj/d.lst
@@ -0,0 +1,12 @@
+mkdir: %_DEST%\inc%_EXT%\test
+mkdir: %_DEST%\inc%_EXT%\test\detail
+..\%__SRC%\bin\test.dll %_DEST%\bin%_EXT%\test.dll
+..\%__SRC%\lib\itest.lib %_DEST%\lib%_EXT%\itest.lib
+..\%__SRC%\lib\libtest.dylib %_DEST%\lib%_EXT%\libtest.dylib
+..\%__SRC%\lib\libtest.so %_DEST%\lib%_EXT%\libtest.so
+..\inc\test\detail\testdllapi.hxx %_DEST%\inc%_EXT%\test\detail\testdllapi.hxx
+..\inc\test\getargument.hxx %_DEST%\inc%_EXT%\test\getargument.hxx
+..\inc\test\officeconnection.hxx %_DEST%\inc%_EXT%\test\officeconnection.hxx
+..\inc\test\oustringostreaminserter.hxx %_DEST%\inc%_EXT%\test\oustringostreaminserter.hxx
+..\inc\test\toabsolutefileurl.hxx %_DEST%\inc%_EXT%\test\toabsolutefileurl.hxx
+..\%__SRC%\class\test.jar %_DEST%\bin%_EXT%\test.jar
diff --git a/test/source/cpp/getargument.cxx b/test/source/cpp/getargument.cxx
new file mode 100644
index 000000000000..339c5c9c797d
--- /dev/null
+++ b/test/source/cpp/getargument.cxx
@@ -0,0 +1,42 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#include "sal/config.h"
+
+#include "osl/diagnose.h"
+#include "rtl/bootstrap.hxx"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "test/getargument.hxx"
+
+namespace test {
+
+bool getArgument(rtl::OUString const & name, rtl::OUString * value) {
+ OSL_ASSERT(value != 0);
+ return rtl::Bootstrap::get(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("arg-")) + name, *value);
+}
+
+}
diff --git a/test/source/cpp/makefile.mk b/test/source/cpp/makefile.mk
new file mode 100644
index 000000000000..8494bd4aaa05
--- /dev/null
+++ b/test/source/cpp/makefile.mk
@@ -0,0 +1,55 @@
+#*************************************************************************
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#***********************************************************************/
+
+PRJ = ../..
+PRJNAME = test
+TARGET = cpp
+
+ENABLE_EXCEPTIONS = TRUE
+VISIBILITY_HIDDEN = TRUE
+
+.INCLUDE: settings.mk
+
+CDEFS += -DOOO_DLLIMPLEMENTATION_TEST
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+
+SLOFILES = \
+ $(SLO)/getargument.obj \
+ $(SLO)/officeconnection.obj \
+ $(SLO)/toabsolutefileurl.obj
+
+SHL1IMPLIB = i$(SHL1TARGET)
+SHL1OBJS = $(SLOFILES)
+SHL1RPATH = NONE
+SHL1STDLIBS = \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(CPPUNITLIB) \
+ $(SALLIB)
+SHL1TARGET = test
+SHL1USE_EXPORTS = name
+DEF1NAME = $(SHL1TARGET)
+
+.INCLUDE: target.mk
diff --git a/test/source/cpp/officeconnection.cxx b/test/source/cpp/officeconnection.cxx
new file mode 100644
index 000000000000..ccfd2cd0a069
--- /dev/null
+++ b/test/source/cpp/officeconnection.cxx
@@ -0,0 +1,173 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#include "sal/config.h"
+
+#include "com/sun/star/bridge/UnoUrlResolver.hpp"
+#include "com/sun/star/bridge/XUnoUrlResolver.hpp"
+#include "com/sun/star/connection/NoConnectException.hpp"
+#include "com/sun/star/frame/XDesktop.hpp"
+#include "com/sun/star/lang/DisposedException.hpp"
+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "cppuhelper/bootstrap.hxx"
+#include "cppunit/TestAssert.h"
+#include "osl/process.h"
+#include "osl/time.h"
+#include "sal/types.h"
+#include "test/getargument.hxx"
+#include "test/officeconnection.hxx"
+#include "test/toabsolutefileurl.hxx"
+
+namespace {
+
+namespace css = com::sun::star;
+
+}
+
+namespace test {
+
+OfficeConnection::OfficeConnection(): process_(0) {}
+
+OfficeConnection::~OfficeConnection() {}
+
+void OfficeConnection::setUp() {
+ rtl::OUString desc;
+ rtl::OUString argSoffice;
+ CPPUNIT_ASSERT(
+ getArgument(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("soffice")),
+ &argSoffice));
+ if (argSoffice.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("path:"))) {
+ oslProcessInfo info;
+ info.Size = sizeof info;
+ CPPUNIT_ASSERT_EQUAL(
+ osl_Process_E_None,
+ osl_getProcessInfo(0, osl_Process_IDENTIFIER, &info));
+ desc = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pipe,name=oootest")) +
+ rtl::OUString::valueOf(static_cast< sal_Int64 >(info.Ident));
+ rtl::OUString noquickArg(
+ RTL_CONSTASCII_USTRINGPARAM("-quickstart=no"));
+ rtl::OUString nofirstArg(
+ RTL_CONSTASCII_USTRINGPARAM("-nofirststartwizard"));
+ rtl::OUString norestoreArg(RTL_CONSTASCII_USTRINGPARAM("-norestore"));
+ rtl::OUString acceptArg(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-accept=")) + desc +
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";urp")));
+ rtl::OUString argUser;
+ CPPUNIT_ASSERT(
+ getArgument(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), &argUser));
+ rtl::OUString userArg(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("-env:UserInstallation=")) +
+ toAbsoluteFileUrl(argUser));
+ rtl::OUString jreArg(
+ RTL_CONSTASCII_USTRINGPARAM("-env:UNO_JAVA_JFW_ENV_JREHOME=true"));
+ rtl::OUString classpathArg(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "-env:UNO_JAVA_JFW_ENV_CLASSPATH=true"));
+ rtl_uString * args[] = {
+ noquickArg.pData, nofirstArg.pData, norestoreArg.pData,
+ acceptArg.pData, userArg.pData, jreArg.pData, classpathArg.pData };
+ rtl_uString ** envs = 0;
+ rtl::OUString argEnv;
+ if (getArgument(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env")), &argEnv))
+ {
+ envs = &argEnv.pData;
+ }
+ CPPUNIT_ASSERT_EQUAL(
+ osl_Process_E_None,
+ osl_executeProcess(
+ toAbsoluteFileUrl(
+ argSoffice.copy(RTL_CONSTASCII_LENGTH("path:"))).pData,
+ args, sizeof args / sizeof args[0], 0, 0, 0, envs,
+ envs == 0 ? 0 : 1, &process_));
+ } else if (argSoffice.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("connect:"))) {
+ desc = argSoffice.copy(RTL_CONSTASCII_LENGTH("connect:"));
+ } else {
+ CPPUNIT_FAIL(
+ "\"soffice\" argument starts with neither \"path:\" nor"
+ " \"connect:\"");
+ }
+ css::uno::Reference< css::bridge::XUnoUrlResolver > resolver(
+ css::bridge::UnoUrlResolver::create(
+ cppu::defaultBootstrap_InitialComponentContext()));
+ for (;;) {
+ try {
+ factory_ =
+ css::uno::Reference< css::lang::XMultiServiceFactory >(
+ resolver->resolve(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("uno:")) +
+ desc +
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ ";urp;StarOffice.ServiceManager"))),
+ css::uno::UNO_QUERY_THROW);
+ break;
+ } catch (css::connection::NoConnectException &) {}
+ if (process_ != 0) {
+ TimeValue delay = { 1, 0 }; // 1 sec
+ CPPUNIT_ASSERT_EQUAL(
+ osl_Process_E_TimedOut,
+ osl_joinProcessWithTimeout(process_, &delay));
+ }
+ }
+}
+
+void OfficeConnection::tearDown() {
+ if (factory_.is()) {
+ css::uno::Reference< css::frame::XDesktop > desktop(
+ factory_->createInstance(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))),
+ css::uno::UNO_QUERY_THROW);
+ factory_.clear();
+ try {
+ CPPUNIT_ASSERT(desktop->terminate());
+ desktop.clear();
+ } catch (css::lang::DisposedException &) {}
+ // it appears that DisposedExceptions can already happen while
+ // receiving the response of the terminate call
+ }
+ if (process_ != 0) {
+ CPPUNIT_ASSERT_EQUAL(osl_Process_E_None, osl_joinProcess(process_));
+ oslProcessInfo info;
+ info.Size = sizeof info;
+ CPPUNIT_ASSERT_EQUAL(
+ osl_Process_E_None,
+ osl_getProcessInfo(process_, osl_Process_EXITCODE, &info));
+ CPPUNIT_ASSERT_EQUAL(oslProcessExitCode(0), info.Code);
+ osl_freeProcessHandle(process_);
+ }
+}
+
+css::uno::Reference< css::lang::XMultiServiceFactory >
+OfficeConnection::getFactory() const {
+ return factory_;
+}
+
+}
diff --git a/test/source/cpp/toabsolutefileurl.cxx b/test/source/cpp/toabsolutefileurl.cxx
new file mode 100644
index 000000000000..be7f2ae20921
--- /dev/null
+++ b/test/source/cpp/toabsolutefileurl.cxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#include "sal/config.h"
+
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
+#include "osl/file.hxx"
+#include "osl/process.h"
+#include "rtl/ustring.hxx"
+#include "test/toabsolutefileurl.hxx"
+
+namespace {
+
+namespace css = com::sun::star;
+
+}
+
+namespace test {
+
+rtl::OUString toAbsoluteFileUrl(rtl::OUString const & relativePathname) {
+ rtl::OUString cwd;
+ oslProcessError e1 = osl_getProcessWorkingDir(&cwd.pData);
+ if (e1 != osl_Process_E_None) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "osl_getProcessWorkingDir failed with ")) +
+ rtl::OUString::valueOf(static_cast< sal_Int32 >(e1))),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ rtl::OUString url;
+ osl::FileBase::RC e2 = osl::FileBase::getFileURLFromSystemPath(
+ relativePathname, url);
+ if (e2 != osl::FileBase::E_None) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "osl::FileBase::getFileURLFromSystemPath(")) +
+ relativePathname +
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(") failed with ")) +
+ rtl::OUString::valueOf(static_cast< sal_Int32 >(e2))),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ rtl::OUString absUrl;
+ e2 = osl::FileBase::getAbsoluteFileURL(cwd, url, absUrl);
+ if (e2 != osl::FileBase::E_None) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "osl::FileBase::getAbsoluteFileURL(")) +
+ cwd + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(", ")) + url +
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(") failed with ")) +
+ rtl::OUString::valueOf(static_cast< sal_Int32 >(e2))),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ return absUrl;
+}
+
+}
diff --git a/test/source/java/OfficeConnection.java b/test/source/java/OfficeConnection.java
new file mode 100644
index 000000000000..6887c3bfa3cd
--- /dev/null
+++ b/test/source/java/OfficeConnection.java
@@ -0,0 +1,221 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+package org.openoffice.test;
+
+import com.sun.star.bridge.UnoUrlResolver;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.connection.NoConnectException;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.lang.DisposedException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.UUID;
+import static org.junit.Assert.*;
+
+/** Start up and shut down an OOo instance.
+
+ Details about the OOo instance are tunneled in via
+ org.openoffice.test.arg.... system properties.
+*/
+public final class OfficeConnection {
+ /** Start up an OOo instance.
+ */
+ public void setUp() throws Exception {
+ String sofficeArg = getArgument("soffice");
+ if (sofficeArg.startsWith("path:")) {
+ description = "pipe,name=oootest" + UUID.randomUUID();
+ ProcessBuilder pb = new ProcessBuilder(
+ sofficeArg.substring("path:".length()), "-quickstart=no",
+ "-nofirststartwizard", "-norestore",
+ "-accept=" + description + ";urp",
+ "-env:UserInstallation=" + getArgument("user"),
+ "-env:UNO_JAVA_JFW_ENV_JREHOME=true",
+ "-env:UNO_JAVA_JFW_ENV_CLASSPATH=true");
+ String envArg = getArgument("env");
+ if (envArg != null) {
+ Map<String, String> env = pb.environment();
+ int i = envArg.indexOf("=");
+ if (i == -1) {
+ env.remove(envArg);
+ } else {
+ env.put(envArg.substring(0, i), envArg.substring(i + 1));
+ }
+ }
+ process = pb.start();
+ outForward = new Forward(process.getInputStream(), System.out);
+ outForward.start();
+ errForward = new Forward(process.getErrorStream(), System.err);
+ errForward.start();
+ } else if (sofficeArg.startsWith("connect:")) {
+ description = sofficeArg.substring("connect:".length());
+ } else {
+ fail(
+ "\"soffice\" argument \"" + sofficeArg +
+ " starts with neither \"path:\" nor \"connect:\"");
+ }
+ XUnoUrlResolver resolver = UnoUrlResolver.create(
+ Bootstrap.createInitialComponentContext(null));
+ for (;;) {
+ try {
+ factory = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ resolver.resolve(
+ "uno:" + description +
+ ";urp;StarOffice.ServiceManager"));
+ break;
+ } catch (NoConnectException e) {}
+ if (process != null) {
+ assertNull(waitForProcess(process, 1000)); // 1 sec
+ }
+ }
+ }
+
+ /** Shut down the OOo instance.
+ */
+ public void tearDown()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ boolean desktopTerminated = true;
+ if (factory != null) {
+ XDesktop desktop = UnoRuntime.queryInterface(
+ XDesktop.class,
+ factory.createInstance("com.sun.star.frame.Desktop"));
+ factory = null;
+ try {
+ desktopTerminated = desktop.terminate();
+ } catch (DisposedException e) {}
+ // it appears that DisposedExceptions can already happen while
+ // receiving the response of the terminate call
+ desktop = null;
+ } else if (process != null) {
+ process.destroy();
+ }
+ int code = 0;
+ if (process != null) {
+ code = process.waitFor();
+ }
+ boolean outTerminated = outForward == null || outForward.terminated();
+ boolean errTerminated = errForward == null || errForward.terminated();
+ assertTrue(desktopTerminated);
+ assertEquals(0, code);
+ assertTrue(outTerminated);
+ assertTrue(errTerminated);
+ }
+
+ /** Obtain the service factory of the running OOo instance.
+ */
+ public XMultiServiceFactory getFactory() {
+ return factory;
+ }
+
+ //TODO: get rid of this hack for legacy qa/unoapi tests
+ public String getDescription() {
+ return description;
+ }
+
+ private static String getArgument(String name) {
+ return System.getProperty("org.openoffice.test.arg." + name);
+ }
+
+ private static Integer waitForProcess(Process process, final long millis)
+ throws InterruptedException
+ {
+ final Thread t1 = Thread.currentThread();
+ Thread t2 = new Thread("waitForProcess") {
+ public void run() {
+ try {
+ Thread.currentThread().sleep(millis);
+ } catch (InterruptedException e) {}
+ t1.interrupt();
+ }
+ };
+ boolean old = Thread.interrupted();
+ // clear interrupted status, get old status
+ t2.start();
+ int n = 0;
+ boolean done = false;
+ try {
+ n = process.waitFor();
+ done = true;
+ } catch (InterruptedException e) {}
+ t2.interrupt();
+ try {
+ t2.join();
+ } catch (InterruptedException e) {
+ t2.join();
+ }
+ Thread.interrupted(); // clear interrupted status
+ if (old) {
+ t1.interrupt(); // reset old status
+ }
+ return done ? new Integer(n) : null;
+ }
+
+ private static final class Forward extends Thread {
+ public Forward(InputStream in, PrintStream out) {
+ super("process output forwarder");
+ this.in = in;
+ this.out = out;
+ }
+
+ public void run() {
+ for (;;) {
+ byte[] buf = new byte[1024];
+ int n;
+ try {
+ n = in.read(buf);
+ } catch (IOException e) {
+ throw new RuntimeException("wrapping", e);
+ }
+ if (n == -1) {
+ break;
+ }
+ out.write(buf, 0, n);
+ }
+ done = true;
+ }
+
+ public boolean terminated() throws InterruptedException {
+ join();
+ return done;
+ }
+
+ private final InputStream in;
+ private final PrintStream out;
+ private boolean done = false;
+ }
+
+ private String description;
+ private Process process = null;
+ private Forward outForward = null;
+ private Forward errForward = null;
+ private XMultiServiceFactory factory = null;
+}
diff --git a/test/source/java/makefile.mk b/test/source/java/makefile.mk
new file mode 100644
index 000000000000..a541d532f158
--- /dev/null
+++ b/test/source/java/makefile.mk
@@ -0,0 +1,49 @@
+#*************************************************************************
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#***********************************************************************/
+
+PRJ = ../..
+PRJNAME = test
+TARGET = java
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+
+PACKAGE = org/openoffice/test
+JAVAFILES = OfficeConnection.java
+JARFILES = juh.jar ridl.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+JARTARGET = test.jar
+JARCLASSDIRS = $(PACKAGE)
+JARCLASSPATH = $(JARFILES)
+ # expect $(OOO_JUNIT_JAR) to be on CLASSPATH wherever test.jar is used (also,
+ # on Windows, $(OOO_JUNIT_JAR) could be an absolute pathname with drive letter
+ # like X:/path and some JVMs would refuse to load test.jar if its MANIFEST.MF
+ # Class-Path contained such a pathname that looks like an unknown URL with
+ # scheme X)
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk