summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qadevOOo/prj/build.lst4
-rw-r--r--qadevOOo/qa/complex/junitskeleton/Skeleton.java194
-rw-r--r--qadevOOo/qa/complex/junitskeleton/TestDocument.java41
-rw-r--r--qadevOOo/qa/complex/junitskeleton/helper/justatest.java38
-rw-r--r--qadevOOo/qa/complex/junitskeleton/helper/makefile.mk48
-rw-r--r--qadevOOo/qa/complex/junitskeleton/makefile.mk65
-rw-r--r--qadevOOo/qa/complex/junitskeleton/test_documents/README.txt1
-rw-r--r--qadevOOo/runner/helper/ProcessHandler.java25
-rw-r--r--smoketestoo_native/makefile.mk3
-rw-r--r--smoketestoo_native/smoketest.cxx16
-rw-r--r--test/inc/test/gettestargument.hxx46
-rw-r--r--test/inc/test/officeconnection.hxx12
-rw-r--r--test/prj/build.lst2
-rw-r--r--test/prj/d.lst2
-rw-r--r--test/source/cpp/getargument.cxx7
-rw-r--r--test/source/cpp/getargument.hxx (renamed from test/inc/test/getargument.hxx)14
-rw-r--r--test/source/cpp/gettestargument.cxx43
-rw-r--r--test/source/cpp/makefile.mk1
-rw-r--r--test/source/cpp/officeconnection.cxx37
-rw-r--r--test/source/java/org/openoffice/test/Argument.java36
-rw-r--r--test/source/java/org/openoffice/test/OfficeConnection.java (renamed from test/source/java/OfficeConnection.java)36
-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)8
24 files changed, 689 insertions, 71 deletions
diff --git a/qadevOOo/prj/build.lst b/qadevOOo/prj/build.lst
index 1594d5c59f57..3a62f3775104 100644
--- a/qadevOOo/prj/build.lst
+++ b/qadevOOo/prj/build.lst
@@ -2,4 +2,6 @@ qa qadevOOo : javaunohelper jurt ridljar unoil NULL
qa qadevOOo usr1 - all qa_mkout NULL
qa qadevOOo nmake - all qa_runner_ant_build NULL
qa qadevOOo\runner nmake - all qa_make_package qa_runner_ant_build NULL
-qa qadevOOo\qa\unoapi nmake - all qa_qa_unoapi NULL
+
+qa qadevOOo\qa\unoapi nmake - all qa_qa_unoapi qa_make_package NULL
+qa qadevOOo\qa\complex\junitskeleton nmake - all qa_complex qa_make_package NULL
diff --git a/qadevOOo/qa/complex/junitskeleton/Skeleton.java b/qadevOOo/qa/complex/junitskeleton/Skeleton.java
new file mode 100644
index 000000000000..f00d93f81b03
--- /dev/null
+++ b/qadevOOo/qa/complex/junitskeleton/Skeleton.java
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * 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 complex.junitskeleton;
+
+import com.sun.star.io.IOException;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XCloseable;
+import java.io.File;
+import java.io.RandomAccessFile;
+
+import lib.TestParameters;
+
+import util.SOfficeFactory;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+public class Skeleton
+{
+ /**
+ * The test parameters
+ */
+ private static TestParameters param = null;
+
+ @Test public void check() {
+ assertTrue("Couldn't open document", open());
+ System.out.println("check");
+ assertTrue("Couldn't close document", close());
+ String tempDirURL = util.utils.getOfficeTemp/*Dir*/(getMSF());
+ System.out.println("temp dir URL is: " + tempDirURL);
+ String tempDir = graphical.FileHelper.getSystemPathFromFileURL(tempDirURL);
+ assertTrue("Temp directory doesn't exist.", new File(tempDir).exists());
+ }
+
+ private boolean open()
+ {
+ System.out.println("open()");
+ // get multiservicefactory -----------------------------------------
+ final XMultiServiceFactory xMsf = getMSF();
+
+ SOfficeFactory SOF = SOfficeFactory.getFactory(xMsf);
+
+ // some Tests need the qadevOOo TestParameters, it is like a Hashmap for Properties.
+ param = new TestParameters();
+ param.put("ServiceFactory", xMsf); // some qadevOOo functions need the ServiceFactory
+
+ return true;
+ }
+
+ private boolean close()
+ {
+ System.out.println("close()");
+ return true;
+ }
+
+ // marked as test
+ @Test public void checkDocument()
+ {
+ System.out.println("checkDocument()");
+ final String sREADME = TestDocument.getUrl("README.txt");
+ System.out.println("README is in:" + sREADME);
+ File aFile = new File(sREADME);
+ if (! aFile.exists())
+ {
+ // It is a little bit stupid that office urls not compatible to java file urls
+ System.out.println("java.io.File can't access Office file urls.");
+ String sREADMESystemPath = graphical.FileHelper.getSystemPathFromFileURL(sREADME);
+ aFile = new File(sREADMESystemPath);
+ assertTrue("File '" + sREADMESystemPath + "' doesn't exists.", aFile.exists());
+ }
+
+ try
+ {
+ RandomAccessFile aAccess = new RandomAccessFile(aFile, "r");
+ long nLength = aAccess.length();
+ System.out.println("File length: " + nLength);
+ assertTrue("File length wrong", nLength > 0);
+ String sLine = aAccess.readLine();
+ assertTrue("Line must not be empty", sLine.length() > 0);
+ System.out.println(" Line: '" + sLine + "'");
+ System.out.println(" length: " + sLine.length());
+ assertTrue("File length not near equal to string length", sLine.length() + 2 >= nLength);
+ aAccess.close();
+ }
+ catch (java.io.FileNotFoundException e)
+ {
+ fail("Can't find file: " + sREADME + " - " + e.getMessage());
+ }
+ catch (java.io.IOException e)
+ {
+ fail("IO Exception: " + e.getMessage());
+ }
+
+ }
+
+ @Test public void checkOpenDocumentWithOffice()
+ {
+ // SOfficeFactory aFactory = new SOfficeFactory(getMSF());
+ SOfficeFactory SOF = SOfficeFactory.getFactory(getMSF());
+ final String sREADME = TestDocument.getUrl("README.txt");
+ try
+ {
+ XComponent aDocument = SOF.loadDocument(sREADME);
+ complex.junitskeleton.helper.justatest.shortWait();
+ XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, aDocument);
+ xClose.close(true);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException ex)
+ {
+ fail("Illegal argument exception caught: " + ex.getMessage());
+ }
+ catch (com.sun.star.io.IOException ex)
+ {
+ fail("IOException caught: " + ex.getMessage());
+ }
+ catch (com.sun.star.uno.Exception ex)
+ {
+ fail("Exception caught: " + ex.getMessage());
+ }
+ }
+
+ // marked as prepare for test, will call before every test
+ @Before public void before()
+ {
+ System.out.println("before()");
+ System.setProperty("THIS IS A TEST", "Hallo");
+ }
+
+
+ // marked as post for test, will call after every test
+ @After public void after()
+ {
+ System.out.println("after()");
+ String sValue = System.getProperty("THIS IS A TEST");
+ assertEquals(sValue, "Hallo");
+ }
+
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass public static void setUpConnection() throws Exception {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+
+ private static final OfficeConnection connection = new OfficeConnection();
+
+}
diff --git a/qadevOOo/qa/complex/junitskeleton/TestDocument.java b/qadevOOo/qa/complex/junitskeleton/TestDocument.java
new file mode 100644
index 000000000000..ff140a9991f6
--- /dev/null
+++ b/qadevOOo/qa/complex/junitskeleton/TestDocument.java
@@ -0,0 +1,41 @@
+/*************************************************************************
+*
+* 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 complex.junitskeleton;
+
+import java.io.File;
+import org.openoffice.test.OfficeFileUrl;
+
+final class TestDocument
+{
+ public static String getUrl(String name)
+ {
+ return OfficeFileUrl.getAbsolute(new File("test_documents", name));
+ }
+
+ private TestDocument() {}
+}
diff --git a/qadevOOo/qa/complex/junitskeleton/helper/justatest.java b/qadevOOo/qa/complex/junitskeleton/helper/justatest.java
new file mode 100644
index 000000000000..a277e011c9ba
--- /dev/null
+++ b/qadevOOo/qa/complex/junitskeleton/helper/justatest.java
@@ -0,0 +1,38 @@
+/**
+ * @author: ll93751
+ * @copyright: Sun Microsystems Inc. 2010
+ */
+
+package complex.junitskeleton.helper;
+
+public class justatest /* extends *//* implements */ {
+ //public static void main( String[] argv ) {
+ //
+ // }
+ public void justatest()
+ {
+ System.out.println("justatest CTor.");
+ }
+
+ public void testfkt()
+ {
+ System.out.println("Test called.");
+ }
+
+ /**
+ * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
+ * reset</code> call.
+ */
+ public static void shortWait()
+ {
+ try
+ {
+ Thread.sleep(500) ;
+ }
+ catch (InterruptedException e)
+ {
+ System.out.println("While waiting :" + e) ;
+ }
+ }
+
+}
diff --git a/qadevOOo/qa/complex/junitskeleton/helper/makefile.mk b/qadevOOo/qa/complex/junitskeleton/helper/makefile.mk
new file mode 100644
index 000000000000..1ed0a1a82b03
--- /dev/null
+++ b/qadevOOo/qa/complex/junitskeleton/helper/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ = ../../../..
+TARGET = helper
+PRJNAME = $(TARGET)
+PACKAGE = complex/junitskeleton/helper
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES = \
+ justatest.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)/$(PACKAGE)/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/qadevOOo/qa/complex/junitskeleton/makefile.mk b/qadevOOo/qa/complex/junitskeleton/makefile.mk
new file mode 100644
index 000000000000..675d3096f5b5
--- /dev/null
+++ b/qadevOOo/qa/complex/junitskeleton/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+ @echo "OOO_SUBSEQUENT_TESTS not set, do nothing."
+.ELSE
+
+PRJ = ../../..
+PRJNAME = sc
+TARGET = qa_complex_junitskeleton
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/junitskeleton
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ Skeleton.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES) \
+ TestDocument.java
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# subdirectories
+SUBDIRS = helper
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
diff --git a/qadevOOo/qa/complex/junitskeleton/test_documents/README.txt b/qadevOOo/qa/complex/junitskeleton/test_documents/README.txt
new file mode 100644
index 000000000000..775f01c4924d
--- /dev/null
+++ b/qadevOOo/qa/complex/junitskeleton/test_documents/README.txt
@@ -0,0 +1 @@
+Here you can store documents.
diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java
index c414accd44ac..519c7473a50f 100644
--- a/qadevOOo/runner/helper/ProcessHandler.java
+++ b/qadevOOo/runner/helper/ProcessHandler.java
@@ -33,10 +33,12 @@ import java.io.PrintStream;
import java.io.LineNumberReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import lib.TestParameters;
+import share.LogWriter;
import util.PropertyName;
import util.utils;
@@ -58,6 +60,7 @@ class Pump extends Thread
private String pref;
private StringBuffer buf = new StringBuffer(256);
private PrintWriter log;
+ private boolean bOutput;
/**
* Creates Pump for specified <code>InputStream</code>.
@@ -70,11 +73,12 @@ class Pump extends Thread
* @param outPrefix A prefix which is printed at the
* beginning of each output line.
*/
- public Pump(InputStream is, PrintWriter log, String outPrefix)
+ public Pump(InputStream is, PrintWriter log, String outPrefix, boolean _bOutput)
{
this.pref = (outPrefix == null) ? "" : outPrefix;
reader = new LineNumberReader(new InputStreamReader(is));
this.log = log;
+ this.bOutput = _bOutput;
start();
}
@@ -85,8 +89,11 @@ class Pump extends Thread
String line = reader.readLine();
while (line != null)
{
- log.println(pref + line);
- log.flush();
+ if (bOutput)
+ {
+ log.println(pref + line);
+ log.flush();
+ }
buf.append(line).append('\n');
line = reader.readLine();
}
@@ -134,6 +141,8 @@ public class ProcessHandler
private TestParameters param = null;
private boolean debug = false;
+ private boolean bUseOutput = true;
+
/**
* Creates instance with specified external command.
* Debug info and output
@@ -566,8 +575,8 @@ public class ProcessHandler
return;
}
dbg("execute: pump io-streams");
- stdout = new Pump(m_aProcess.getInputStream(), log, "out > ");
- stderr = new Pump(m_aProcess.getErrorStream(), log, "err > ");
+ stdout = new Pump(m_aProcess.getInputStream(), log, "out > ", bUseOutput);
+ stderr = new Pump(m_aProcess.getErrorStream(), log, "err > ", bUseOutput);
stdIn = new PrintStream(m_aProcess.getOutputStream());
// int nExitValue = m_aProcess.exitValue();
@@ -821,4 +830,10 @@ public class ProcessHandler
log.println(utils.getDateTime() + "PH." + message);
}
}
+
+ public void noOutput()
+ {
+ bUseOutput = false;
+ }
+
}
diff --git a/smoketestoo_native/makefile.mk b/smoketestoo_native/makefile.mk
index 0337c748d914..ec0d6be313c8 100644
--- a/smoketestoo_native/makefile.mk
+++ b/smoketestoo_native/makefile.mk
@@ -49,7 +49,8 @@ ALLTAR : cpptest
cpptest : $(SHL1TARGETN) $(BIN)/smoketestdoc.sxw
-OOO_CPPTEST_ARGS = $(SHL1TARGETN) -env:arg-doc=$(BIN)/smoketestdoc.sxw
+TEST_ARGUMENTS = smoketest.doc=$(BIN)/smoketestdoc.sxw
+CPPTEST_LIBRARY = $(SHL1TARGETN)
$(BIN)/smoketestdoc.sxw: data/smoketestdoc.sxw
$(COPY) $< $@
diff --git a/smoketestoo_native/smoketest.cxx b/smoketestoo_native/smoketest.cxx
index e2cb51127f47..0d7e636f142b 100644
--- a/smoketestoo_native/smoketest.cxx
+++ b/smoketestoo_native/smoketest.cxx
@@ -53,7 +53,7 @@
#include "osl/diagnose.h"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
-#include "test/getargument.hxx"
+#include "test/gettestargument.hxx"
#include "test/officeconnection.hxx"
#include "test/oustringostreaminserter.hxx"
#include "test/toabsolutefileurl.hxx"
@@ -121,8 +121,8 @@ void Test::tearDown() {
void Test::test() {
rtl::OUString doc;
CPPUNIT_ASSERT(
- test::getArgument(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("doc")), &doc));
+ test::getTestArgument(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("smoketest.doc")), &doc));
css::uno::Sequence< css::beans::PropertyValue > args(1);
args[0].Name = rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode"));
@@ -141,10 +141,12 @@ void Test::test() {
css::uno::Reference< css::frame::XController >(
css::uno::Reference< css::frame::XModel >(
css::uno::Reference< css::frame::XComponentLoader >(
- connection_.getFactory()->createInstance(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.frame.Desktop"))),
+ (connection_.getComponentContext()->
+ getServiceManager()->createInstanceWithContext(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.frame.Desktop")),
+ connection_.getComponentContext())),
css::uno::UNO_QUERY_THROW)->loadComponentFromURL(
test::toAbsoluteFileUrl(doc),
rtl::OUString(
diff --git a/test/inc/test/gettestargument.hxx b/test/inc/test/gettestargument.hxx
new file mode 100644
index 000000000000..21b9df7a097e
--- /dev/null
+++ b/test/inc/test/gettestargument.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+*
+* 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_GETTESTARGUMENT_HXX
+#define INCLUDED_TEST_GETTESTARGUMENT_HXX
+
+#include "sal/config.h"
+
+#include "test/detail/testdllapi.hxx"
+
+namespace rtl { class OUString; }
+
+namespace test {
+
+// Obtain the value of a test argument (tunneled in via an "arg-testarg.<name>"
+// bootstrap variable):
+OOO_DLLPUBLIC_TEST bool getTestArgument(
+ rtl::OUString const & name, rtl::OUString * value);
+
+}
+
+#endif
diff --git a/test/inc/test/officeconnection.hxx b/test/inc/test/officeconnection.hxx
index 99a319d51a7e..45c0a370d3c4 100644
--- a/test/inc/test/officeconnection.hxx
+++ b/test/inc/test/officeconnection.hxx
@@ -33,8 +33,8 @@
#include "osl/process.h"
#include "test/detail/testdllapi.hxx"
-namespace com { namespace sun { namespace star { namespace lang {
- class XMultiServiceFactory;
+namespace com { namespace sun { namespace star { namespace uno {
+ class XComponentContext;
} } } }
namespace test {
@@ -51,13 +51,13 @@ public:
void tearDown();
- com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
- getFactory() const;
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+ getComponentContext() const;
private:
oslProcess process_;
- com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
- factory_;
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+ context_;
};
}
diff --git a/test/prj/build.lst b/test/prj/build.lst
index 1bf76d664a7a..5ef6353a1dc3 100644
--- a/test/prj/build.lst
+++ b/test/prj/build.lst
@@ -1,4 +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
+te test\source\java\org\openoffice\test nmake - all source_java NULL
diff --git a/test/prj/d.lst b/test/prj/d.lst
index bcea8bee46fe..34218f54e974 100644
--- a/test/prj/d.lst
+++ b/test/prj/d.lst
@@ -5,7 +5,7 @@ mkdir: %_DEST%\inc%_EXT%\test\detail
..\%__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\gettestargument.hxx %_DEST%\inc%_EXT%\test\gettestargument.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
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/inc/test/getargument.hxx b/test/source/cpp/getargument.hxx
index 1b4df29d2115..4ba7e0f47827 100644
--- a/test/inc/test/getargument.hxx
+++ b/test/source/cpp/getargument.hxx
@@ -23,22 +23,22 @@
* for a copy of the LGPLv3 License.
************************************************************************/
-#ifndef INCLUDED_TEST_GETARGUMENT_HXX
-#define INCLUDED_TEST_GETARGUMENT_HXX
+#ifndef INCLUDED_TEST_SOURCE_CPP_GETARGUMENT_HXX
+#define INCLUDED_TEST_SOURCE_CPP_GETARGUMENT_HXX
#include "sal/config.h"
-#include "test/detail/testdllapi.hxx"
-
-namespace rtl { class OUString; }
-
namespace test {
+namespace detail {
+
// Obtain the value of an argument tunneled in via an "arg-<name>" bootstrap
// variable:
-OOO_DLLPUBLIC_TEST bool getArgument(
+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 8494bd4aaa05..1c2d5a8ca2ff 100644
--- a/test/source/cpp/makefile.mk
+++ b/test/source/cpp/makefile.mk
@@ -37,6 +37,7 @@ CFLAGSCXX += $(CPPUNIT_CFLAGS)
SLOFILES = \
$(SLO)/getargument.obj \
+ $(SLO)/gettestargument.obj \
$(SLO)/officeconnection.obj \
$(SLO)/toabsolutefileurl.obj
diff --git a/test/source/cpp/officeconnection.cxx b/test/source/cpp/officeconnection.cxx
index ccfd2cd0a069..d18f266ecb7d 100644
--- a/test/source/cpp/officeconnection.cxx
+++ b/test/source/cpp/officeconnection.cxx
@@ -30,17 +30,18 @@
#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 "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"
+#include "getargument.hxx"
+
namespace {
namespace css = com::sun::star;
@@ -57,7 +58,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:"))) {
@@ -78,7 +79,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(
@@ -86,15 +87,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;
@@ -118,14 +116,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 &) {}
@@ -139,13 +137,14 @@ void OfficeConnection::setUp() {
}
void OfficeConnection::tearDown() {
- if (factory_.is()) {
+ if (context_.is()) {
css::uno::Reference< css::frame::XDesktop > desktop(
- factory_->createInstance(
+ context_->getServiceManager()->createInstanceWithContext(
rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))),
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")),
+ context_),
css::uno::UNO_QUERY_THROW);
- factory_.clear();
+ context_.clear();
try {
CPPUNIT_ASSERT(desktop->terminate());
desktop.clear();
@@ -165,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..83c3f2417416
--- /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;
+
+final public class Argument {
+ public static String get(String name) {
+ return System.getProperty("org.openoffice.test.arg." + name);
+ }
+
+ private Argument() {}
+}
diff --git a/test/source/java/OfficeConnection.java b/test/source/java/org/openoffice/test/OfficeConnection.java
index 6887c3bfa3cd..f87947137167 100644
--- a/test/source/java/OfficeConnection.java
+++ b/test/source/java/org/openoffice/test/OfficeConnection.java
@@ -31,8 +31,8 @@ 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 com.sun.star.uno.XComponentContext;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
@@ -49,17 +49,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 +84,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,11 +103,12 @@ public final class OfficeConnection {
throws InterruptedException, com.sun.star.uno.Exception
{
boolean desktopTerminated = true;
- if (factory != null) {
+ if (context != null) {
XDesktop desktop = UnoRuntime.queryInterface(
XDesktop.class,
- factory.createInstance("com.sun.star.frame.Desktop"));
- factory = null;
+ context.getServiceManager().createInstanceWithContext(
+ "com.sun.star.frame.Desktop", context));
+ context = null;
try {
desktopTerminated = desktop.terminate();
} catch (DisposedException e) {}
@@ -130,10 +130,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 +141,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 +213,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..94b629a69ed0 100644
--- a/test/source/java/makefile.mk
+++ b/test/source/java/org/openoffice/test/makefile.mk
@@ -23,14 +23,18 @@
# 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 \
+ OfficeConnection.java \
+ OfficeFileUrl.java \
+ TestArgument.java
JARFILES = juh.jar ridl.jar unoil.jar
EXTRAJARFILES = $(OOO_JUNIT_JAR)