diff options
Diffstat (limited to 'test/source')
-rw-r--r-- | test/source/cpp/getargument.cxx | 7 | ||||
-rw-r--r-- | test/source/cpp/getargument.hxx | 44 | ||||
-rw-r--r-- | test/source/cpp/gettestargument.cxx | 43 | ||||
-rw-r--r-- | test/source/cpp/makefile.mk | 1 | ||||
-rw-r--r-- | test/source/cpp/officeconnection.cxx | 58 | ||||
-rw-r--r-- | test/source/java/org/openoffice/test/Argument.java | 36 | ||||
-rw-r--r-- | test/source/java/org/openoffice/test/FileHelper.java | 62 | ||||
-rw-r--r-- | test/source/java/org/openoffice/test/OfficeConnection.java (renamed from test/source/java/OfficeConnection.java) | 61 | ||||
-rw-r--r-- | test/source/java/org/openoffice/test/OfficeFileUrl.java | 42 | ||||
-rw-r--r-- | test/source/java/org/openoffice/test/TestArgument.java | 39 | ||||
-rw-r--r-- | test/source/java/org/openoffice/test/makefile.mk (renamed from test/source/java/makefile.mk) | 9 |
11 files changed, 340 insertions, 62 deletions
diff --git a/test/source/cpp/getargument.cxx b/test/source/cpp/getargument.cxx index 339c5c9c797d..0db144679d92 100644 --- a/test/source/cpp/getargument.cxx +++ b/test/source/cpp/getargument.cxx @@ -29,10 +29,13 @@ #include "rtl/bootstrap.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" -#include "test/getargument.hxx" + +#include "getargument.hxx" namespace test { +namespace detail { + bool getArgument(rtl::OUString const & name, rtl::OUString * value) { OSL_ASSERT(value != 0); return rtl::Bootstrap::get( @@ -40,3 +43,5 @@ bool getArgument(rtl::OUString const & name, rtl::OUString * value) { } } + +} diff --git a/test/source/cpp/getargument.hxx b/test/source/cpp/getargument.hxx new file mode 100644 index 000000000000..4ba7e0f47827 --- /dev/null +++ b/test/source/cpp/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_SOURCE_CPP_GETARGUMENT_HXX +#define INCLUDED_TEST_SOURCE_CPP_GETARGUMENT_HXX + +#include "sal/config.h" + +namespace test { + +namespace detail { + +// Obtain the value of an argument tunneled in via an "arg-<name>" bootstrap +// variable: +bool getArgument( + rtl::OUString const & name, rtl::OUString * value); + +} + +} + +#endif diff --git a/test/source/cpp/gettestargument.cxx b/test/source/cpp/gettestargument.cxx new file mode 100644 index 000000000000..757faa751d37 --- /dev/null +++ b/test/source/cpp/gettestargument.cxx @@ -0,0 +1,43 @@ +/************************************************************************* +* +* 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 "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "test/gettestargument.hxx" + +#include "getargument.hxx" + +namespace test { + +bool getTestArgument(rtl::OUString const & name, rtl::OUString * value) { + return detail::getArgument( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("testarg.")) + name, value); +} + +} diff --git a/test/source/cpp/makefile.mk b/test/source/cpp/makefile.mk index 9561be25fc1f..4c90dc678959 100644 --- a/test/source/cpp/makefile.mk +++ b/test/source/cpp/makefile.mk @@ -44,6 +44,7 @@ CFLAGSCXX+=-DADAPT_EXT_STL SLOFILES = \ $(SLO)/getargument.obj \ + $(SLO)/gettestargument.obj \ $(SLO)/officeconnection.obj \ $(SLO)/toabsolutefileurl.obj \ $(SLO)/uniquepipename.obj diff --git a/test/source/cpp/officeconnection.cxx b/test/source/cpp/officeconnection.cxx index 85c1b855f88b..ca62a5c93c2b 100644 --- a/test/source/cpp/officeconnection.cxx +++ b/test/source/cpp/officeconnection.cxx @@ -30,8 +30,8 @@ #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 "com/sun/star/uno/XComponentContext.hpp" #include "cppuhelper/bootstrap.hxx" #include <preextstl.h> #include "cppunit/TestAssert.h" @@ -39,11 +39,12 @@ #include "osl/process.h" #include "osl/time.h" #include "sal/types.h" -#include "test/getargument.hxx" #include "test/officeconnection.hxx" #include "test/toabsolutefileurl.hxx" #include "test/uniquepipename.hxx" +#include "getargument.hxx" + namespace { namespace css = com::sun::star; @@ -60,7 +61,7 @@ void OfficeConnection::setUp() { rtl::OUString desc; rtl::OUString argSoffice; CPPUNIT_ASSERT( - getArgument( + detail::getArgument( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("soffice")), &argSoffice)); if (argSoffice.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("path:"))) { @@ -77,7 +78,7 @@ void OfficeConnection::setUp() { rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";urp"))); rtl::OUString argUser; CPPUNIT_ASSERT( - getArgument( + detail::getArgument( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), &argUser)); rtl::OUString userArg( rtl::OUString( @@ -85,15 +86,12 @@ void OfficeConnection::setUp() { 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 }; + acceptArg.pData, userArg.pData, jreArg.pData }; rtl_uString ** envs = 0; rtl::OUString argEnv; - if (getArgument( + if (detail::getArgument( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env")), &argEnv)) { envs = &argEnv.pData; @@ -117,14 +115,14 @@ void OfficeConnection::setUp() { cppu::defaultBootstrap_InitialComponentContext())); for (;;) { try { - factory_ = - css::uno::Reference< css::lang::XMultiServiceFactory >( + context_ = + css::uno::Reference< css::uno::XComponentContext >( resolver->resolve( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("uno:")) + desc + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - ";urp;StarOffice.ServiceManager"))), + ";urp;StarOffice.ComponentContext"))), css::uno::UNO_QUERY_THROW); break; } catch (css::connection::NoConnectException &) {} @@ -138,21 +136,23 @@ void OfficeConnection::setUp() { } 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) { + if (context_.is()) { + css::uno::Reference< css::frame::XDesktop > desktop( + context_->getServiceManager()->createInstanceWithContext( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.frame.Desktop")), + context_), + css::uno::UNO_QUERY_THROW); + context_.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 + } CPPUNIT_ASSERT_EQUAL(osl_Process_E_None, osl_joinProcess(process_)); oslProcessInfo info; info.Size = sizeof info; @@ -164,9 +164,9 @@ void OfficeConnection::tearDown() { } } -css::uno::Reference< css::lang::XMultiServiceFactory > -OfficeConnection::getFactory() const { - return factory_; +css::uno::Reference< css::uno::XComponentContext > +OfficeConnection::getComponentContext() const { + return context_; } } diff --git a/test/source/java/org/openoffice/test/Argument.java b/test/source/java/org/openoffice/test/Argument.java new file mode 100644 index 000000000000..0380375d8519 --- /dev/null +++ b/test/source/java/org/openoffice/test/Argument.java @@ -0,0 +1,36 @@ +/************************************************************************* +* +* 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; + +public final class Argument { + public static String get(String name) { + return System.getProperty("org.openoffice.test.arg." + name); + } + + private Argument() {} +} diff --git a/test/source/java/org/openoffice/test/FileHelper.java b/test/source/java/org/openoffice/test/FileHelper.java new file mode 100644 index 000000000000..722b31124d43 --- /dev/null +++ b/test/source/java/org/openoffice/test/FileHelper.java @@ -0,0 +1,62 @@ +/* + * ************************************************************************ + * + * 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; + +/** + * Helper Functions for File handling + */ +public class FileHelper +{ + public FileHelper() + { + } + /** + * Concat a _sRelativePathToAdd to a _sPath and append a '/' to the _sPath only if need. + * + * @param _sPath + * @param _sRelativePathToAdd + * @return a right concated path + */ + public static String appendPath(String _sPath, String _sRelativePathToAdd) + { + String sNewPath = _sPath; + String fs = System.getProperty("file.separator"); + if (_sPath.startsWith("file:")) + { + fs = "/"; // we use a file URL so only '/' is allowed. + } + if (! (sNewPath.endsWith("/") || sNewPath.endsWith("\\") ) ) + { + sNewPath += fs; + } + sNewPath += _sRelativePathToAdd; + return sNewPath; + } +} diff --git a/test/source/java/OfficeConnection.java b/test/source/java/org/openoffice/test/OfficeConnection.java index 6887c3bfa3cd..60978717a993 100644 --- a/test/source/java/OfficeConnection.java +++ b/test/source/java/org/openoffice/test/OfficeConnection.java @@ -31,8 +31,9 @@ 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.lang.XMultiComponentFactory; import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; @@ -49,17 +50,16 @@ public final class OfficeConnection { /** Start up an OOo instance. */ public void setUp() throws Exception { - String sofficeArg = getArgument("soffice"); + String sofficeArg = Argument.get("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"); + "-env:UserInstallation=" + Argument.get("user"), + "-env:UNO_JAVA_JFW_ENV_JREHOME=true"); + String envArg = Argument.get("env"); if (envArg != null) { Map<String, String> env = pb.environment(); int i = envArg.indexOf("="); @@ -85,11 +85,11 @@ public final class OfficeConnection { Bootstrap.createInitialComponentContext(null)); for (;;) { try { - factory = UnoRuntime.queryInterface( - XMultiServiceFactory.class, + context = UnoRuntime.queryInterface( + XComponentContext.class, resolver.resolve( "uno:" + description + - ";urp;StarOffice.ServiceManager")); + ";urp;StarOffice.ComponentContext")); break; } catch (NoConnectException e) {} if (process != null) { @@ -104,19 +104,24 @@ public final class OfficeConnection { 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(); + if (process != null) { + if (context != null) { + XMultiComponentFactory factory = context.getServiceManager(); + assertNotNull(factory); + XDesktop desktop = UnoRuntime.queryInterface( + XDesktop.class, + factory.createInstanceWithContext( + "com.sun.star.frame.Desktop", context)); + context = 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 { + process.destroy(); + } } int code = 0; if (process != null) { @@ -130,10 +135,10 @@ public final class OfficeConnection { assertTrue(errTerminated); } - /** Obtain the service factory of the running OOo instance. + /** Obtain the component context of the running OOo instance. */ - public XMultiServiceFactory getFactory() { - return factory; + public XComponentContext getComponentContext() { + return context; } //TODO: get rid of this hack for legacy qa/unoapi tests @@ -141,10 +146,6 @@ public final class OfficeConnection { 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 { @@ -217,5 +218,5 @@ public final class OfficeConnection { private Process process = null; private Forward outForward = null; private Forward errForward = null; - private XMultiServiceFactory factory = null; + private XComponentContext context = null; } diff --git a/test/source/java/org/openoffice/test/OfficeFileUrl.java b/test/source/java/org/openoffice/test/OfficeFileUrl.java new file mode 100644 index 000000000000..1ab62e283e6a --- /dev/null +++ b/test/source/java/org/openoffice/test/OfficeFileUrl.java @@ -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. +* +************************************************************************/ + +package org.openoffice.test; + +import java.io.File; + +/** Obtain the office-internal absolute file URL of a given file. + */ +public final class OfficeFileUrl { + public static String getAbsolute(File file) { + return file.getAbsoluteFile().toURI().toString().replaceFirst( + "\\A[Ff][Ii][Ll][Ee]:/(?=[^/]|\\z)", "file:///"); + // file:/path -> file:///path + } + + private OfficeFileUrl() {} +} diff --git a/test/source/java/org/openoffice/test/TestArgument.java b/test/source/java/org/openoffice/test/TestArgument.java new file mode 100644 index 000000000000..1303d09e1ba2 --- /dev/null +++ b/test/source/java/org/openoffice/test/TestArgument.java @@ -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. +* +************************************************************************/ + +package org.openoffice.test; + +/** Obtain the value of a test argument (tunneled in via an + "org.openoffice.test.arg.testarg.<name>" system property). + */ +public final class TestArgument { + public static String get(String name) { + return Argument.get("testarg." + name); + } + + private TestArgument() {} +} diff --git a/test/source/java/makefile.mk b/test/source/java/org/openoffice/test/makefile.mk index a541d532f158..9314ea6a1506 100644 --- a/test/source/java/makefile.mk +++ b/test/source/java/org/openoffice/test/makefile.mk @@ -23,14 +23,19 @@ # for a copy of the LGPLv3 License. #***********************************************************************/ -PRJ = ../.. +PRJ = ../../../../.. PRJNAME = test TARGET = java .IF "$(OOO_JUNIT_JAR)" != "" PACKAGE = org/openoffice/test -JAVAFILES = OfficeConnection.java +JAVAFILES = \ + Argument.java \ + FileHelper.java \ + OfficeConnection.java \ + OfficeFileUrl.java \ + TestArgument.java JARFILES = juh.jar ridl.jar unoil.jar EXTRAJARFILES = $(OOO_JUNIT_JAR) |