summaryrefslogtreecommitdiff
path: root/test/source/java
diff options
context:
space:
mode:
Diffstat (limited to 'test/source/java')
-rw-r--r--test/source/java/org/openoffice/test/Argument.java36
-rw-r--r--test/source/java/org/openoffice/test/FileHelper.java62
-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.java42
-rw-r--r--test/source/java/org/openoffice/test/TestArgument.java39
-rw-r--r--test/source/java/org/openoffice/test/makefile.mk (renamed from test/source/java/makefile.mk)9
6 files changed, 217 insertions, 32 deletions
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)