diff options
Diffstat (limited to 'sfx2/qa')
25 files changed, 3393 insertions, 0 deletions
diff --git a/sfx2/qa/complex/CheckGlobalEventBroadcaster_writer1.java b/sfx2/qa/complex/CheckGlobalEventBroadcaster_writer1.java new file mode 100644 index 000000000000..d5dc17e183eb --- /dev/null +++ b/sfx2/qa/complex/CheckGlobalEventBroadcaster_writer1.java @@ -0,0 +1,243 @@ +/************************************************************************* + * + * 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.framework; + +import com.sun.star.awt.XWindow; +import com.sun.star.document.XEventBroadcaster; +import com.sun.star.document.XEventListener; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import complex.framework.DocHelper.WriterHelper; +import complexlib.ComplexTestCase; +import java.util.ArrayList; +import com.sun.star.task.XJobExecutor; +import com.sun.star.util.URL; +import util.UITools; + +/** + * This testcase checks the GlobalEventBroadcaster + * it will add an XEventListener and verify the Events + * raised when opening/changing and closing Office Documents + */ +public class CheckGlobalEventBroadcaster_writer1 extends ComplexTestCase { + XMultiServiceFactory m_xMSF = null; + XEventBroadcaster m_xEventBroadcaster = null; + ArrayList notifyEvents = new ArrayList(); + XTextDocument xTextDoc; + XSpreadsheetDocument xSheetDoc; + XEventListener m_xEventListener = new EventListenerImpl(); + + public String[] getTestMethodNames() { + return new String[] { + "initialize", "checkWriter", "cleanup" + }; + } + + public void initialize() { + m_xMSF = (XMultiServiceFactory) param.getMSF(); + log.println("check wether there is a valid MultiServiceFactory"); + + if (m_xMSF == null) { + assure("## Couldn't get MultiServiceFactory make sure your Office is started", + true); + } + + log.println("... done"); + + log.println( + "Create an instance of com.sun.star.frame.GlobalEventBroadcaster"); + + Object GlobalEventBroadcaster = null; + Object dispatcher = null; + + try { + GlobalEventBroadcaster = m_xMSF.createInstance( + "com.sun.star.frame.GlobalEventBroadcaster"); + } catch (com.sun.star.uno.Exception e) { + assure("## Exception while creating instance", false); + } + + log.println("... done"); + + log.println("check wether the created instance is valid"); + + if (GlobalEventBroadcaster == null) { + assure("couldn't create service", false); + } + + log.println("... done"); + + log.println( + "try to query the XEventBroadcaster from the gained Object"); + m_xEventBroadcaster = (XEventBroadcaster) UnoRuntime.queryInterface( + XEventBroadcaster.class, + GlobalEventBroadcaster); + + if (util.utils.isVoid(m_xEventBroadcaster)) { + assure("couldn't get XEventBroadcaster", false); + } + + log.println("... done"); + + log.println("adding Listener"); + m_xEventBroadcaster.addEventListener(m_xEventListener); + log.println("... done"); + } + + public void checkWriter() { + log.println("-- Checking Writer --"); + + WriterHelper wHelper = new WriterHelper(m_xMSF); + String[] expected; + boolean locRes = true; + log.println("opening an empty writer doc"); + notifyEvents.clear(); + xTextDoc = wHelper.openEmptyDoc(); + shortWait(); + expected = new String[] { "OnUnfocus", "OnCreate", "OnViewCreated", "OnFocus" }; + + assure("Wrong events fired when opening empty doc", + proveExpectation(expected)); + log.println("... done"); + + log.println("changing the writer doc"); + notifyEvents.clear(); + xTextDoc.getText().setString("GlobalEventBroadcaster"); + shortWait(); + expected = new String[] { "OnModifyChanged" }; + + assure("Wrong events fired when changing doc", + proveExpectation(expected)); + log.println("... done"); + + log.println("closing the empty writer doc"); + notifyEvents.clear(); + wHelper.closeDoc(xTextDoc); + shortWait(); + expected = new String[] { "OnUnfocus", "OnFocus", "OnViewClosed", "OnUnload" }; + + assure("Wrong events fired when closing empty doc", + proveExpectation(expected)); + log.println("... done"); + + log.println("opening an writer doc via Window-New Window"); + notifyEvents.clear(); + xTextDoc = wHelper.openFromDialog(".uno:NewWindow", "", false); + shortWait(); + expected = new String[] { "OnUnfocus", "OnCreate", "OnViewCreated", "OnFocus", "OnUnfocus", "OnViewCreated", "OnFocus", }; + + assure("Wrong events fired when opening an writer doc via Window-New Window", + proveExpectation(expected)); + log.println("... done"); + + log.println("closing the created writer doc"); + notifyEvents.clear(); + + wHelper.closeDoc(xTextDoc); + shortWait(); + expected = new String[] { "OnViewClosed", "OnUnfocus", "OnFocus", "OnViewClosed", "OnUnload" }; + + assure("Wrong events fired when closing Window-New Window", + proveExpectation(expected)); + + log.println("... done"); + + log.println("Opening document with label wizard"); + xTextDoc = wHelper.openFromDialog("private:factory/swriter?slot=21051", "", false); + shortWait(); + XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, wHelper.getToolkit ().getActiveTopWindow ()); + UITools ut = new UITools(m_xMSF,xWindow); + notifyEvents.clear(); + log.println("pressing button 'New Document'"); + try{ + ut.clickButton ("New Document"); + } catch (Exception e) { + log.println("Couldn't press Button"); + } + log.println("... done"); + shortWait(); + shortWait(); + shortWait(); + expected = new String[] { "OnViewClosed", "OnCreate", "OnFocus", "OnModifyChanged" }; + + assure("Wrong events fired when starting labels wizard", + proveExpectation(expected)); + + log.println("-- Done Writer --"); + } + + public void cleanup() { + log.println("removing Listener"); + m_xEventBroadcaster.removeEventListener(m_xEventListener); + log.println("... done"); + } + + /** + * Sleeps for 0.5 sec. to allow StarOffice to react on <code> + * reset</code> call. + */ + private void shortWait() { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + log.println("While waiting :" + e); + } + } + + private boolean proveExpectation(String[] expected) { + boolean locRes = true; + boolean failure = false; + + log.println("Fired Events:"); + for (int k=0;k<notifyEvents.size();k++) { + System.out.println("\t- "+notifyEvents.get(k)); + } + + for (int i = 0; i < expected.length; i++) { + locRes = notifyEvents.contains(expected[i]); + + if (!locRes) { + log.println("The event " + expected[i] + " isn't fired"); + failure = true; + } + } + + return !failure; + } + + public class EventListenerImpl implements XEventListener { + public void disposing(com.sun.star.lang.EventObject eventObject) { + log.println("disposing: " + eventObject.Source.toString()); + } + + public void notifyEvent(com.sun.star.document.EventObject eventObject) { + notifyEvents.add(eventObject.EventName); + } + } +} diff --git a/sfx2/qa/complex/DocHelper/DialogThread.java b/sfx2/qa/complex/DocHelper/DialogThread.java new file mode 100644 index 000000000000..7151ccbb292d --- /dev/null +++ b/sfx2/qa/complex/DocHelper/DialogThread.java @@ -0,0 +1,95 @@ +/************************************************************************* + * + * 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.framework.DocHelper; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +import java.lang.Thread; + + +/** + * This class opens a given dialog in a separate Thread by dispatching an url + * + */ +public class DialogThread extends Thread { + public XComponent m_xDoc = null; + public XMultiServiceFactory m_xMSF = null; + public String m_url = ""; + + public DialogThread(XComponent xDoc, XMultiServiceFactory msf, String url) { + this.m_xDoc = xDoc; + this.m_xMSF = msf; + this.m_url = url; + } + + public void run() { + XModel aModel = (XModel) UnoRuntime.queryInterface(XModel.class, + m_xDoc); + + XController xController = aModel.getCurrentController(); + + //Opening Dialog + try { + XDispatchProvider xDispProv = (XDispatchProvider) UnoRuntime.queryInterface( + XDispatchProvider.class, + xController.getFrame()); + XURLTransformer xParser = (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface( + XURLTransformer.class, + m_xMSF.createInstance( + "com.sun.star.util.URLTransformer")); + + // Because it's an in/out parameter + // we must use an array of URL objects. + URL[] aParseURL = new URL[1]; + aParseURL[0] = new URL(); + aParseURL[0].Complete = m_url; + xParser.parseStrict(aParseURL); + + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", com.sun.star.frame.FrameSearchFlag.SELF | + com.sun.star.frame.FrameSearchFlag.CHILDREN); + PropertyValue[] dispatchArguments = new PropertyValue[0]; + + if (xDispatcher != null) { + xDispatcher.dispatch(aURL, dispatchArguments); + } else { + System.out.println("xDispatcher is null"); + } + } catch (com.sun.star.uno.Exception e) { + System.out.println("Couldn't open dialog"); + } + } +}
\ No newline at end of file diff --git a/sfx2/qa/complex/DocHelper/WriterHelper.java b/sfx2/qa/complex/DocHelper/WriterHelper.java new file mode 100644 index 000000000000..b65e8e915423 --- /dev/null +++ b/sfx2/qa/complex/DocHelper/WriterHelper.java @@ -0,0 +1,296 @@ +/************************************************************************* + * + * 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.framework.DocHelper; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XDesktop; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XCloseable; + +import complex.framework.DocHelper.DialogThread; +import java.io.PrintWriter; + +import util.AccessibilityTools; +import util.WriterTools; + + +/** + * Methods to open Writer docs + * + */ +public class WriterHelper { + XMultiServiceFactory m_xMSF = null; + + /** Creates a new instance of WriterHelper + * @param m_xMSF The MultiServiceFactory gained from the office + */ + public WriterHelper(XMultiServiceFactory m_xMSF) { + this.m_xMSF = m_xMSF; + } + + /** Opens an empty document + * @return a reference to the opened document is returned + */ + public XTextDocument openEmptyDoc() { + return WriterTools.createTextDoc(m_xMSF); + } + + /** Closes a given XTextDocument + * @param xTextDoc the text document to be closed + * @return if an error occurs the errormessage is returned and an empty String if not + */ + public String closeDoc(XTextDocument xTextDoc) { + XCloseable closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + String err = ""; + + try { + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + err = "couldn't close document " + e; + } + + return err; + } + + /** a TextDocument is opened by pressing a button in a dialog given by uno-URL + * @param url the uno-URL of the dialog to be opened + * @param createButton the language dependend label of the button to be pressed + * @param destroyLocal if true the document that has been opened to dispatch the dialog is closed before the method returns, + * otherwise this document remains open + * @return returns the created Textdocument + */ + public XTextDocument openFromDialog(String url, String createButton, + boolean destroyLocal) { + XTextDocument xLocalDoc = WriterTools.createTextDoc(m_xMSF); + XComponent comp = (XComponent) UnoRuntime.queryInterface( + XComponent.class, xLocalDoc); + DialogThread diagThread = new DialogThread(comp, m_xMSF, url); + diagThread.start(); + shortWait(); + + if (createButton.length() > 1) { + XExtendedToolkit tk = getToolkit(); + AccessibilityTools at = new AccessibilityTools(); + Object atw = tk.getActiveTopWindow(); + + XWindow xWindow = (XWindow) UnoRuntime.queryInterface( + XWindow.class, atw); + + XAccessible xRoot = at.getAccessibleObject(xWindow); + XAccessibleContext buttonContext = at.getAccessibleObjectForRole( + xRoot, + AccessibleRole.PUSH_BUTTON, + createButton); + + XAccessibleAction buttonAction = (XAccessibleAction) UnoRuntime.queryInterface( + XAccessibleAction.class, + buttonContext); + + try { + System.out.println("Name: " + + buttonContext.getAccessibleName()); + buttonAction.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Couldn't press button"); + } + + shortWait(); + } + + XDesktop xDesktop = getDesktop(); + + XTextDocument returnDoc = (XTextDocument) UnoRuntime.queryInterface( + XTextDocument.class, + xDesktop.getCurrentComponent()); + + if (destroyLocal) { + closeDoc(xLocalDoc); + } + + return returnDoc; + } + + public XTextDocument DocByAutopilot(XMultiServiceFactory msf, + int[] indexes, boolean destroyLocal, + String bName) { + XTextDocument xLocalDoc = WriterTools.createTextDoc(m_xMSF); + Object toolkit = null; + + try { + toolkit = msf.createInstance("com.sun.star.awt.Toolkit"); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(); + } + + XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface( + XExtendedToolkit.class, toolkit); + + shortWait(); + + AccessibilityTools at = new AccessibilityTools(); + + Object atw = tk.getActiveTopWindow(); + + XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, + atw); + + XAccessible xRoot = at.getAccessibleObject(xWindow); + + XAccessibleContext ARoot = at.getAccessibleObjectForRole(xRoot, + AccessibleRole.MENU_BAR); + XAccessibleSelection sel = (XAccessibleSelection) UnoRuntime.queryInterface( + XAccessibleSelection.class, ARoot); + + for (int k = 0; k < indexes.length; k++) { + try { + sel.selectAccessibleChild(indexes[k]); + shortWait(); + ARoot = ARoot.getAccessibleChild(indexes[k]) + .getAccessibleContext(); + sel = (XAccessibleSelection) UnoRuntime.queryInterface( + XAccessibleSelection.class, ARoot); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + } + + shortWait(); + + atw = tk.getActiveTopWindow(); + + xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, atw); + + xRoot = at.getAccessibleObject(xWindow); + + //at.printAccessibleTree(new PrintWriter(System.out),xRoot); + + XAccessibleAction action = (XAccessibleAction) UnoRuntime.queryInterface( + XAccessibleAction.class, + at.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON, + bName)); + + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + + shortWait(); + + atw = tk.getActiveTopWindow(); + + xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, atw); + + xRoot = at.getAccessibleObject(xWindow); + + at.printAccessibleTree(new PrintWriter(System.out),xRoot); + + action = (XAccessibleAction) UnoRuntime.queryInterface( + XAccessibleAction.class, + at.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON, + "Yes")); + + try { + if (action != null) action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + + shortWait(); + + XDesktop xDesktop = getDesktop(); + + XTextDocument returnDoc = (XTextDocument) UnoRuntime.queryInterface( + XTextDocument.class, + xDesktop.getCurrentComponent()); + + if (destroyLocal) { + closeDoc(xLocalDoc); + } + + return returnDoc; + } + + /** + * Sleeps for 2 sec. to allow StarOffice to react + */ + private void shortWait() { + try { + Thread.sleep(4000); + } catch (InterruptedException e) { + System.out.println("While waiting :" + e); + } + } + + /** creates an instance of com.sun.star.awt.Toolkit to query the XExtendedToolkit + * interface + * @return returns the gained XExtendedToolkit Interface + */ + public XExtendedToolkit getToolkit() { + Object toolkit = null; + + try { + toolkit = m_xMSF.createInstance("com.sun.star.awt.Toolkit"); + } catch (com.sun.star.uno.Exception e) { + System.out.println("Couldn't get toolkit"); + e.printStackTrace(); + } + + XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface( + XExtendedToolkit.class, toolkit); + + return tk; + } + + /** creates an instance of com.sun.star.frame.Desktop to query the XDesktop interface + * @return returns the gained XDesktop interface + */ + protected XDesktop getDesktop() { + Object desk = null; + + try { + desk = m_xMSF.createInstance("com.sun.star.frame.Desktop"); + } catch (com.sun.star.uno.Exception e) { + System.out.println("Couldn't get desktop"); + e.printStackTrace(); + } + + XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface( + XDesktop.class, desk); + + return xDesktop; + } +}
\ No newline at end of file diff --git a/sfx2/qa/complex/DocHelper/makefile.mk b/sfx2/qa/complex/DocHelper/makefile.mk new file mode 100644 index 000000000000..6b6ac9191cdb --- /dev/null +++ b/sfx2/qa/complex/DocHelper/makefile.mk @@ -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. +# +#************************************************************************* + +PRJ = ..$/..$/.. +TARGET = DocHelper +PRJNAME = $(TARGET) +PACKAGE = complex$/framework$/dochelper + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + + +#----- compile .java files ----------------------------------------- + +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JAVAFILES = DialogThread.java WriterHelper.java +JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/sfx2/qa/complex/DocumentMetaData.java b/sfx2/qa/complex/DocumentMetaData.java new file mode 100644 index 000000000000..ae7970227c75 --- /dev/null +++ b/sfx2/qa/complex/DocumentMetaData.java @@ -0,0 +1,546 @@ +/************************************************************************* + * + * 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.framework; + +import complexlib.ComplexTestCase; +import helper.StreamSimulator; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.Any; +import com.sun.star.lang.XInitialization; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.Locale; +import com.sun.star.lang.EventObject; +import com.sun.star.util.Date; +import com.sun.star.util.DateTime; +import com.sun.star.util.Time; +import com.sun.star.util.Duration; +import com.sun.star.util.XModifyListener; +import com.sun.star.util.XModifyBroadcaster; +import com.sun.star.beans.XPropertyContainer; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.IllegalTypeException; +import com.sun.star.embed.XStorage; +import com.sun.star.io.XInputStream; +import com.sun.star.document.XDocumentProperties; + + +/** + * Test case for the service com.sun.star.document.DocumentProperties. + * Currently, this service is implemented in + * sfx2/source/doc/SfxDocumentMetaData.cxx. + * + * @author mst + */ +public class DocumentMetaData extends ComplexTestCase +{ + public String[] getTestMethodNames () { + return new String[] { "check", "cleanup" }; + } + + public void cleanup() { + // nothing to do + } + + // for testing modifications + class Listener implements XModifyListener { + private boolean m_Called; + + public Listener() { + m_Called = false; + } + + public boolean reset() { + boolean oldCalled = m_Called; + m_Called = false; + return oldCalled; + } + + public void modified(EventObject e) { + m_Called = true; + } + + public void disposing(EventObject e) { + } + } + + public void check() { + try { + XMultiServiceFactory xMSF = (XMultiServiceFactory) param.getMSF(); + assure("could not create MultiServiceFactory.", xMSF != null); + XPropertySet xPropertySet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xMSF); + Object defaultCtx = xPropertySet.getPropertyValue("DefaultContext"); + XComponentContext xContext = (XComponentContext) + UnoRuntime.queryInterface(XComponentContext.class, defaultCtx); + assure("could not get component context.", xContext != null); + + String temp = util.utils.getOfficeTemp/*Dir*/(xMSF); + log.println("tempdir: " + temp); + + PropertyValue[] noArgs = { }; + PropertyValue mimetype = new PropertyValue(); + mimetype.Name = "MediaType"; + mimetype.Value = "application/vnd.oasis.opendocument.text"; + PropertyValue[] mimeArgs = { mimetype }; +// new Any("application/vnd.oasis.opendocument.text")) }; + PropertyValue cfile = new PropertyValue(); + cfile.Name = "URL"; + cfile.Value = temp + "EMPTY.odt"; + PropertyValue[] mimeEmptyArgs = { mimetype, cfile }; + + log.println("Creating service DocumentProperties..."); + + Object oDP = +// xMSF.createInstanceWithContext( +// "com.sun.star.document.DocumentProperties", xContext); + xMSF.createInstance("com.sun.star.document.DocumentProperties"); + XDocumentProperties xDP = (XDocumentProperties) + UnoRuntime.queryInterface(XDocumentProperties.class, oDP); + + log.println("...done"); + + + log.println("Checking initialize ..."); + + XDocumentProperties xDP2 = (XDocumentProperties) + UnoRuntime.queryInterface(XDocumentProperties.class, + xMSF.createInstance( + "com.sun.star.document.DocumentProperties")); + XInitialization xInit = (XInitialization) + UnoRuntime.queryInterface(XInitialization.class, xDP2); + xInit.initialize(new Object[] { }); + + log.println("...done"); + + log.println("Checking storing default-initialized meta data ..."); + +// xDP2.storeToMedium(temp + "EMPTY.odt", mimeArgs); + xDP2.storeToMedium("", mimeEmptyArgs); + + log.println("...done"); + + log.println("Checking loading default-initialized meta data ..."); + +// xDP2.loadFromMedium(temp + "EMPTY.odt", noArgs); + xDP2.loadFromMedium("", mimeEmptyArgs); + assure ("Author", "".equals(xDP2.getAuthor())); + + log.println("...done"); + + log.println("(Not) Checking preservation of custom meta data ..."); + + xDP2.loadFromMedium(util.utils.getFullTestURL("CUSTOM.odt"), + noArgs); + assure ("Author", "".equals(xDP2.getAuthor())); + xDP2.storeToMedium(temp + "CUSTOM.odt", mimeArgs); + + //FIXME: now what? comparing for binary equality seems useless + // we could unzip the written file and grep for the custom stuff + // but would that work on windows... + + log.println("...done"); + + log.println("Checking loading from test document..."); + + String file = util.utils.getFullTestURL("TEST.odt"); + xDP.loadFromMedium(file, noArgs); +/* XInputStream xStream = + new StreamSimulator("./testdocuments/TEST.odt", true, param); + Object oSF = + xMSF.createInstance("com.sun.star.embed.StorageFactory"); + XSingleServiceFactory xSF = (XSingleServiceFactory) + UnoRuntime.queryInterface(XSingleServiceFactory.class, oSF); + Object oStor = xSF.createInstanceWithArguments( + new Object[] { xStream }); + XStorage xStor = (XStorage) UnoRuntime.queryInterface( + XStorage.class, oStor); + xDP.loadFromStorage(xStor);*/ + + log.println("...done"); + + log.println("Checking meta-data import..."); + + assure ("Author", "Karl-Heinz Mustermann".equals(xDP.getAuthor())); + assure ("Generator", + "StarOffice/8$Solaris_x86 OpenOffice.org_project/680m232$Build-9227" + .equals(xDP.getGenerator())); + assure ("CreationDate", 2007 == xDP.getCreationDate().Year); + assure ("Title", "Urgent Memo".equals(xDP.getTitle())); + assure ("Subject", "Wichtige Mitteilung".equals(xDP.getSubject())); + assure ("Description", + "Modern internal company memorandum in full-blocked style" + .equals(xDP.getDescription())); +// assure ("Language", "".equals(xDP.getLanguage())); + assure ("ModifiedBy", + "Karl-Heinz Mustermann".equals(xDP.getModifiedBy())); + assure ("ModificationDate", 10 == xDP.getModificationDate().Month); + assure ("PrintedBy", + "Karl-Heinz Mustermann".equals(xDP.getPrintedBy())); + assure ("PrintDate", 29 == xDP.getPrintDate().Day); + assure ("TemplateName", + "Modern Memo".equals(xDP.getTemplateName())); + assure ("TemplateURL", + xDP.getTemplateURL().endsWith("memmodern.ott")); + assure ("TemplateDate", 17 == xDP.getTemplateDate().Hours); + assure ("AutoloadURL", "../TEST.odt".equals(xDP.getAutoloadURL())); + assure ("AutoloadSecs", 0 == xDP.getAutoloadSecs()); + assure ("DefaultTarget", "_blank".equals(xDP.getDefaultTarget())); + assure ("EditingCycles", 3 == xDP.getEditingCycles()); + assure ("EditingDuration", 320 == xDP.getEditingDuration()); + + String[] kws = xDP.getKeywords(); + assure ("Keywords", fromArray(kws).containsAll( + fromArray(new Object[] { "Asien", "Memo", "Reis" }))); + + NamedValue[] ds = xDP.getDocumentStatistics(); +/* for (int i = 0; i < ds.length; ++i) { + log.println("nv: " + ds[i].Name + " " + ds[i].Value); + } + NamedValue nv1 = new NamedValue("WordCount", new Integer(23)); + NamedValue nv2 = new NamedValue("WordCount", new Integer(23)); + log.println("eq: " + nv1.equals(nv2)); // grrr, this is false... +*/ + assure ("DocumentStatistics:WordCount", containsNV(ds, + new NamedValue("WordCount", new Integer(23)))); + assure ("DocumentStatistics:PageCount", containsNV(ds, + new NamedValue("PageCount", new Integer(1)))); + + XPropertyContainer udpc = xDP.getUserDefinedProperties(); + XPropertySet udps = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, udpc); + assure ("UserDefined 1", "Dies ist ein wichtiger Hinweis" + .equals(udps.getPropertyValue("Hinweis"))); + assure ("UserDefined 2", ("Kann Spuren von N" + + new String(new byte[] { (byte) 0xc3, (byte) 0xbc }, "UTF-8") + + "ssen enthalten") + .equals(udps.getPropertyValue("Warnung"))); + + log.println("...done"); + + log.println("Checking meta-data updates..."); + + String str; + DateTime dt = new DateTime(); + Locale l = new Locale(); + int i; + + str = "me"; + xDP.setAuthor(str); + assure ("setAuthor", str.equals(xDP.getAuthor())); + str = "the computa"; + xDP.setGenerator(str); + assure ("setGenerator", str.equals(xDP.getGenerator())); + dt.Year = 2038; + dt.Month = 1; + dt.Day = 1; + xDP.setCreationDate(dt); + assure ("setCreationDate", dt.Year == xDP.getCreationDate().Year); + str = "El t'itulo"; + xDP.setTitle(str); + assure ("setTitle", str.equals(xDP.getTitle())); + str = "Ein verkommenes Subjekt"; + xDP.setSubject(str); + assure ("setSubject", str.equals(xDP.getSubject())); + str = "Este descripci'on no es importante"; + xDP.setDescription(str); + assure ("setDescription", str.equals(xDP.getDescription())); + l.Language = "en"; + l.Country = "GB"; + xDP.setLanguage(l); + Locale l2 = xDP.getLanguage(); + assure ("setLanguage Lang", l.Language.equals(l2.Language)); + assure ("setLanguage Cty", l.Country.equals(l2.Country)); + str = "myself"; + xDP.setModifiedBy(str); + assure ("setModifiedBy", str.equals(xDP.getModifiedBy())); + dt.Year = 2042; + xDP.setModificationDate(dt); + assure ("setModificationDate", + dt.Year == xDP.getModificationDate().Year); + str = "i didnt do it"; + xDP.setPrintedBy(str); + assure ("setPrintedBy", str.equals(xDP.getPrintedBy())); + dt.Year = 2024; + xDP.setPrintDate(dt); + assure ("setPrintDate", dt.Year == xDP.getPrintDate().Year); + str = "blah"; + xDP.setTemplateName(str); + assure ("setTemplateName", str.equals(xDP.getTemplateName())); + str = "gopher://some-hole-in-the-ground/"; + xDP.setTemplateURL(str); + assure ("setTemplateURL", str.equals(xDP.getTemplateURL())); + dt.Year = 2043; + xDP.setTemplateDate(dt); + assure ("setTemplateDate", dt.Year == xDP.getTemplateDate().Year); + str = "http://nowhere/"; + xDP.setAutoloadURL(str); + assure ("setAutoloadURL", str.equals(xDP.getAutoloadURL())); + i = 3661; // this might not work (due to conversion via double...) + xDP.setAutoloadSecs(i); +// log.println("set: " + i + " get: " + xDP.getAutoloadSecs()); + assure ("setAutoloadSecs", i == xDP.getAutoloadSecs()); + str = "_blank"; + xDP.setDefaultTarget(str); + assure ("setDefaultTarget", str.equals(xDP.getDefaultTarget())); + i = 42; + xDP.setEditingCycles((short) i); + assure ("setEditingCycles", i == xDP.getEditingCycles()); + i = 84; + xDP.setEditingDuration(i); + assure ("setEditingDuration", i == xDP.getEditingDuration()); + str = ""; + + String[] kws2 = new String[] { + "keywordly", "keywordlike", "keywordalicious" }; + xDP.setKeywords(kws2); + kws = xDP.getKeywords(); + assure ("setKeywords", fromArray(kws).containsAll(fromArray(kws2))); + + NamedValue[] ds2 = new NamedValue[] { + new NamedValue("SyllableCount", new Integer(9)), + new NamedValue("FrameCount", new Integer(2)), + new NamedValue("SentenceCount", new Integer(7)) }; + xDP.setDocumentStatistics(ds2); + ds = xDP.getDocumentStatistics(); + assure ("setDocumentStatistics:SyllableCount", containsNV(ds, + new NamedValue("SyllableCount", new Integer(9)))); + assure ("setDocumentStatistics:FrameCount", containsNV(ds, + new NamedValue("FrameCount", new Integer(2)))); + assure ("setDocumentStatistics:SentenceCount", containsNV(ds, + new NamedValue("SentenceCount", new Integer(7)))); + + log.println("...done"); + + log.println("Checking user-defined meta-data updates..."); + + // actually, this tests the PropertyBag service + // but maybe the DocumentProperties service will be implemented + // differently some day... + boolean b = true; + double d = 3.1415; + // note that Time is only supported for backward compatibilty! + Time t = new Time(); + t.Hours = 1; + t.Minutes = 16; + Date date = new Date(); + date.Year = 2071; + date.Month = 2; + date.Day = 3; + dt.Year = 2065; + Duration dur = new Duration(); + dur.Negative = true; + dur.Years = 1001; + dur.Months = 999; + dur.Days = 888; + dur.Hours = 777; + dur.Minutes = 666; + dur.Seconds = 555; + dur.MilliSeconds = 444; + + udpc.addProperty("Frobnicate", PropertyAttribute.REMOVEABLE, + new Boolean(b)); + udpc.addProperty("FrobDuration", PropertyAttribute.REMOVEABLE, dur); + udpc.addProperty("FrobDuration2", PropertyAttribute.REMOVEABLE, t); + udpc.addProperty("FrobEndDate", PropertyAttribute.REMOVEABLE, date); + udpc.addProperty("FrobStartTime", PropertyAttribute.REMOVEABLE, dt); + udpc.addProperty("Pi", PropertyAttribute.REMOVEABLE, new Double(d)); + udpc.addProperty("Foo", PropertyAttribute.REMOVEABLE, "bar"); + udpc.addProperty("Removed", PropertyAttribute.REMOVEABLE, "bar"); + // #i94175#: empty property name is valid ODF 1.1 + udpc.addProperty("", PropertyAttribute.REMOVEABLE, "eeeeek"); + try { + udpc.removeProperty("Info 1"); + udpc.removeProperty("Removed"); + } catch (UnknownPropertyException e) { + assure("removeProperty failed", false); + } + + try { + udpc.addProperty("Forbidden", PropertyAttribute.REMOVEABLE, + new String[] { "foo", "bar" }); + assure("inserting value of non-supported type did not fail", + false); + } catch (IllegalTypeException e) { + // ignore + } + + assure ("UserDefined bool", new Boolean(b).equals( + udps.getPropertyValue("Frobnicate"))); + assure ("UserDefined duration", eqDuration(dur, (Duration) + udps.getPropertyValue("FrobDuration"))); + assure ("UserDefined time", eqTime(t, (Time) + udps.getPropertyValue("FrobDuration2"))); + assure ("UserDefined date", eqDate(date, (Date) + udps.getPropertyValue("FrobEndDate"))); + assure ("UserDefined datetime", eqDateTime(dt, (DateTime) + udps.getPropertyValue("FrobStartTime"))); + assure ("UserDefined float", new Double(d).equals( + udps.getPropertyValue("Pi"))); + assure ("UserDefined string", "bar".equals( + udps.getPropertyValue("Foo"))); + assure ("UserDefined empty name", "eeeeek".equals( + udps.getPropertyValue(""))); + + try { + udps.getPropertyValue("Removed"); + assure("UserDefined remove didn't", false); + } catch (UnknownPropertyException e) { + // ok + } + + log.println("...done"); + + log.println("Checking storing meta-data to file..."); + + xDP.storeToMedium(temp + "TEST.odt", mimeArgs); + + log.println("...done"); + + log.println("Checking loading meta-data from stored file..."); + + xDP.loadFromMedium(temp + "TEST.odt", noArgs); + + log.println("...done"); + + log.println("Checking user-defined meta-data from stored file..."); + + udpc = xDP.getUserDefinedProperties(); + udps = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, udpc); + + assure ("UserDefined bool", new Boolean(b).equals( + udps.getPropertyValue("Frobnicate"))); + assure ("UserDefined duration", eqDuration(dur, (Duration) + udps.getPropertyValue("FrobDuration"))); + // this is now a Duration! + Duration t_dur = new Duration(false, (short)0, (short)0, (short)0, + t.Hours, t.Minutes, t.Seconds, + (short)(10 * t.HundredthSeconds)); + assure ("UserDefined time", eqDuration(t_dur, (Duration) + udps.getPropertyValue("FrobDuration2"))); + assure ("UserDefined date", eqDate(date, (Date) + udps.getPropertyValue("FrobEndDate"))); + assure ("UserDefined datetime", eqDateTime(dt, (DateTime) + udps.getPropertyValue("FrobStartTime"))); + assure ("UserDefined float", new Double(d).equals( + udps.getPropertyValue("Pi"))); + assure ("UserDefined string", "bar".equals( + udps.getPropertyValue("Foo"))); + + try { + udps.getPropertyValue("Removed"); + assure("UserDefined remove didn't", false); + } catch (UnknownPropertyException e) { + // ok + } + + log.println("...done"); + + log.println("Checking notification listener interface..."); + + Listener listener = new Listener(); + XModifyBroadcaster xMB = (XModifyBroadcaster) + UnoRuntime.queryInterface(XModifyBroadcaster.class, xDP); + xMB.addModifyListener(listener); + xDP.setAuthor("not me"); + assure ("Listener Author", listener.reset()); + udpc.addProperty("Listener", PropertyAttribute.REMOVEABLE, "foo"); + assure ("Listener UserDefined Add", listener.reset()); + udps.setPropertyValue("Listener", "bar"); + assure ("Listener UserDefined Set", listener.reset()); + udpc.removeProperty("Listener"); + assure ("Listener UserDefined Remove", listener.reset()); + xMB.removeModifyListener(listener); + udpc.addProperty("Listener2", PropertyAttribute.REMOVEABLE, "foo"); + assure ("Removed Listener UserDefined Add", !listener.reset()); + + log.println("...done"); + + } catch (Exception e) { + report(e); + } + } + + // grrr... + boolean eqDateTime(DateTime a, DateTime b) { + return a.Year == b.Year && a.Month == b.Month && a.Day == b.Day + && a.Hours == b.Hours && a.Minutes == b.Minutes + && a.Seconds == b.Seconds + && a.HundredthSeconds == b.HundredthSeconds; + } + + boolean eqDate(Date a, Date b) { + return a.Year == b.Year && a.Month == b.Month && a.Day == b.Day; + } + + boolean eqTime(Time a, Time b) { + return a.Hours == b.Hours && a.Minutes == b.Minutes + && a.Seconds == b.Seconds + && a.HundredthSeconds == b.HundredthSeconds; + } + + boolean eqDuration(Duration a, Duration b) { + return a.Years == b.Years && a.Months == b.Months && a.Days == b.Days + && a.Hours == b.Hours && a.Minutes == b.Minutes + && a.Seconds == b.Seconds + && a.MilliSeconds == b.MilliSeconds + && a.Negative == b.Negative; + } + + java.util.Collection fromArray(Object[] os) { + java.util.Collection ret = new java.util.HashSet(); + for (int i = 0; i < os.length; ++i) { + ret.add(os[i]); + } + return ret; + } + + // bah, structs do not have proper equals(), and uno.Type is not comparable + public static boolean containsNV (NamedValue[] nvs, NamedValue nv) { + for (int i = 0; i < nvs.length; ++i) { + if (nvs[i].Name.equals(nv.Name) && nvs[i].Value.equals(nv.Value)) { + return true; + } + } + return false; + } + + public void report(Exception e) { + log.println("Exception occurred:"); + e.printStackTrace((java.io.PrintWriter) log); + failed(); + } +} + diff --git a/sfx2/qa/complex/DocumentMetadataAccessTest.java b/sfx2/qa/complex/DocumentMetadataAccessTest.java new file mode 100644 index 000000000000..a61280c45fe5 --- /dev/null +++ b/sfx2/qa/complex/DocumentMetadataAccessTest.java @@ -0,0 +1,1275 @@ +/************************************************************************* + * + * 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.framework; + +import complexlib.ComplexTestCase; +import helper.StreamSimulator; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.Any; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XInitialization; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.WrappedTargetRuntimeException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.Pair; +import com.sun.star.beans.StringPair; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.ElementExistException; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.util.XCloseable; +import com.sun.star.frame.XStorable; +import com.sun.star.frame.XLoadable; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRange; +import com.sun.star.text.XText; +import com.sun.star.rdf.*; + +/** + * Test case for interface com.sun.star.rdf.XDocumentMetadataAccess + * Currently, this service is implemented in + * sfx2/source/doc/DocumentMetadataAccess.cxx + * + * Actually, this is not a service, so we need to create a document and + * go from there... + * + * @author mst + */ +public class DocumentMetadataAccessTest extends ComplexTestCase +{ + XMultiServiceFactory xMSF; + XComponentContext xContext; + String tempDir; + + String nsRDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; + String nsRDFS = "http://www.w3.org/2000/01/rdf-schema#"; + String nsPkg="http://docs.oasis-open.org/opendocument/meta/package/common#"; + String nsODF ="http://docs.oasis-open.org/opendocument/meta/package/odf#"; + + XURI foo; + XURI bar; + XURI baz; + + static XURI rdf_type; + static XURI rdfs_label; + static XURI pkg_Document; + static XURI pkg_hasPart; + static XURI pkg_MetadataFile; + static XURI odf_ContentFile; + static XURI odf_StylesFile; + static XURI odf_Element; + static XBlankNode blank1; + static XBlankNode blank2; + static XBlankNode blank3; + static XBlankNode blank4; + static String manifestPath = "manifest.rdf"; + static String contentPath = "content.xml"; + static String stylesPath = "styles.xml"; + static String fooPath = "foo.rdf"; + static String fooBarPath = "meta/foo/bar.rdf"; + + XRepository xRep; + XRepositorySupplier xRS; + XDocumentMetadataAccess xDMA; + + public String[] getTestMethodNames () + { + return new String[] { "check", "checkRDFa" }; + } + + public void before() + { + try { + + xMSF = (XMultiServiceFactory) param.getMSF(); + assure("could not create MultiServiceFactory.", xMSF != null); + XPropertySet xPropertySet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xMSF); + Object defaultCtx = xPropertySet.getPropertyValue("DefaultContext"); + xContext = (XComponentContext) + UnoRuntime.queryInterface(XComponentContext.class, defaultCtx); + assure("could not get component context.", xContext != null); + + tempDir = util.utils.getOfficeTemp/*Dir*/(xMSF); + log.println("tempdir: " + tempDir); + + foo = URI.create(xContext, "uri:foo"); + assure("foo", null != foo); + bar = URI.create(xContext, "uri:bar"); + assure("bar", null != bar); + baz = URI.create(xContext, "uri:baz"); + assure("baz", null != baz); + + blank1 = BlankNode.create(xContext, "_:1"); + assure("blank1", null != blank1); + blank2 = BlankNode.create(xContext, "_:2"); + assure("blank2", null != blank2); + blank3 = BlankNode.create(xContext, "_:3"); + assure("blank3", null != blank3); + blank4 = BlankNode.create(xContext, "_:4"); + assure("blank4", null != blank4); + rdf_type = URI.createKnown(xContext, URIs.RDF_TYPE); + assure("rdf_type", null != rdf_type); + rdfs_label = URI.createKnown(xContext, URIs.RDFS_LABEL); + assure("rdfs_label", null != rdfs_label); + pkg_Document = URI.createKnown(xContext, URIs.PKG_DOCUMENT); + assure("pkg_Document", null != pkg_Document); + pkg_hasPart = URI.createKnown(xContext, URIs.PKG_HASPART); + assure("pkg_hasPart", null != pkg_hasPart); + pkg_MetadataFile = URI.createKnown(xContext, URIs.PKG_METADATAFILE); + assure("pkg_MetadataFile", null != pkg_MetadataFile); + odf_ContentFile = URI.createKnown(xContext, URIs.ODF_CONTENTFILE); + assure("odf_ContentFile", null != odf_ContentFile); + odf_StylesFile = URI.createKnown(xContext, URIs.ODF_STYLESFILE); + assure("odf_StylesFile", null != odf_StylesFile); + odf_Element = URI.createKnown(xContext, URIs.ODF_ELEMENT); + assure("odf_Element", null != odf_Element); + + } catch (Exception e) { + report(e); + } + } + + public void after() + { + xRep = null; + xRS = null; + xDMA = null; + } + + public void check() + { + XComponent xComp = null; + XComponent xComp2 = null; + try { + XEnumeration xStmtsEnum; + XNamedGraph xManifest; + + log.println("Creating document with Repository..."); + + // we cannot create a XDMA directly, we must create + // a document and get it from there :( + // create document + PropertyValue[] loadProps = new PropertyValue[1]; + loadProps[0] = new PropertyValue(); + loadProps[0].Name = "Hidden"; + loadProps[0].Value = new Boolean(true); + xComp = util.DesktopTools.openNewDoc(xMSF, "swriter", loadProps); + XTextDocument xText = (XTextDocument) UnoRuntime.queryInterface( + XTextDocument.class, xComp); + + XRepositorySupplier xRS = (XRepositorySupplier) + UnoRuntime.queryInterface(XRepositorySupplier.class, xComp); + assure("xRS null", null != xRS); + XDocumentMetadataAccess xDMA = (XDocumentMetadataAccess) + UnoRuntime.queryInterface(XDocumentMetadataAccess.class, xRS); + assure("xDMA null", null != xDMA); + xRep = xRS.getRDFRepository(); + assure("xRep null", null != xRep); + + log.println("...done"); + + log.println("Checking that new repository is initialized..."); + + XURI xBaseURI = (XURI) xDMA; + String baseURI = xBaseURI.getStringValue(); + assure("new: baseURI", + null != xBaseURI && !xBaseURI.getStringValue().equals("")); + + assure("new: # graphs", 1 == xRep.getGraphNames().length); + XURI manifest = URI.createNS(xContext, xBaseURI.getStringValue(), + manifestPath); + xManifest = xRep.getGraph(manifest); + assure("new: manifest graph", null != xManifest); + + Statement[] manifestStmts = getManifestStmts(xBaseURI); + xStmtsEnum = xRep.getStatements(null, null, null); + assure("new: manifest graph", eq(xStmtsEnum, manifestStmts)); + + log.println("...done"); + + log.println("Checking some invalid args..."); + + String content = "behold, for i am the content."; + XTextRange xTR = new TestRange(content); + XMetadatable xM = (XMetadatable) xTR; + + try { + xDMA.getElementByURI(null); + assure("getElementByURI: null allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.getMetadataGraphsWithType(null); + assure("getMetadataGraphsWithType: null URI allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addMetadataFile("", new XURI[0]); + assure("addMetadataFile: empty filename allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addMetadataFile("/foo", new XURI[0]); + assure("addMetadataFile: absolute filename allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addMetadataFile("fo\"o", new XURI[0]); + assure("addMetadataFile: invalid filename allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addMetadataFile("../foo", new XURI[0]); + assure("addMetadataFile: filename with .. allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addMetadataFile("foo/../../bar", new XURI[0]); + assure("addMetadataFile: filename with nest .. allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addMetadataFile("foo/././bar", new XURI[0]); + assure("addMetadataFile: filename with nest . allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addMetadataFile("content.xml", new XURI[0]); + assure("addMetadataFile: content.xml allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addMetadataFile("styles.xml", new XURI[0]); + assure("addMetadataFile: styles.xml allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addMetadataFile("meta.xml", new XURI[0]); + assure("addMetadataFile: meta.xml allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addMetadataFile("settings.xml", new XURI[0]); + assure("addMetadataFile: settings.xml allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.importMetadataFile(FileFormat.RDF_XML, null, "foo", + foo, new XURI[0]); + assure("importMetadataFile: null stream allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + XInputStream xFooIn = + new StreamSimulator(tempDir + "empty.rdf", true, param); + xDMA.importMetadataFile(FileFormat.RDF_XML, xFooIn, "", + foo, new XURI[0]); + assure("importMetadataFile: empty filename allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + XInputStream xFooIn = + new StreamSimulator(tempDir + "empty.rdf", true, param); + xDMA.importMetadataFile(FileFormat.RDF_XML, xFooIn, "meta.xml", + foo, new XURI[0]); + assure("importMetadataFile: meta.xml filename allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + XInputStream xFooIn = + new StreamSimulator(tempDir + "empty.rdf", true, param); + xDMA.importMetadataFile(FileFormat.RDF_XML, + xFooIn, "foo", null, new XURI[0]); + assure("importMetadataFile: null base URI allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + XInputStream xFooIn = + new StreamSimulator(tempDir + "empty.rdf", true, param); + xDMA.importMetadataFile(FileFormat.RDF_XML, + xFooIn, "foo", rdf_type, new XURI[0]); + assure("importMetadataFile: non-absolute base URI allowed", + false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.removeMetadataFile(null); + assure("removeMetadataFile: null URI allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addContentOrStylesFile(""); + assure("addContentOrStylesFile: empty filename allowed", + false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addContentOrStylesFile("/content.xml"); + assure("addContentOrStylesFile: absolute filename allowed", + false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.addContentOrStylesFile("foo.rdf"); + assure("addContentOrStylesFile: invalid filename allowed", + false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.removeContentOrStylesFile(""); + assure("removeContentOrStylesFile: empty filename allowed", + false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.loadMetadataFromStorage(null, foo, null); + assure("loadMetadataFromStorage: null storage allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.storeMetadataToStorage(null/*, base*/); + assure("storeMetadataToStorage: null storage allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.loadMetadataFromMedium(new PropertyValue[0]); + assure("loadMetadataFromMedium: empty medium allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + try { + xDMA.storeMetadataToMedium(new PropertyValue[0]); + assure("storeMetadataToMedium: empty medium allowed", false); + } catch (IllegalArgumentException e) { + // ignore + } + + log.println("...done"); + + log.println("Checking file addition/removal..."); + + xDMA.removeContentOrStylesFile(contentPath); + xStmtsEnum = xManifest.getStatements(null, null, null); + assure("removeContentOrStylesFile (content)", + eq(xStmtsEnum, new Statement[] { + manifestStmts[0], manifestStmts[2], manifestStmts[4] + })); + + xDMA.addContentOrStylesFile(contentPath); + xStmtsEnum = xManifest.getStatements(null, null, null); + assure("addContentOrStylesFile (content)", + eq(xStmtsEnum, manifestStmts)); + + xDMA.removeContentOrStylesFile(stylesPath); + xStmtsEnum = xManifest.getStatements(null, null, null); + assure("removeContentOrStylesFile (styles)", + eq(xStmtsEnum, new Statement[] { + manifestStmts[0], manifestStmts[1], manifestStmts[3] + })); + + xDMA.addContentOrStylesFile(stylesPath); + xStmtsEnum = xManifest.getStatements(null, null, null); + assure("addContentOrStylesFile (styles)", + eq(xStmtsEnum, manifestStmts)); + + XURI xFoo = URI.createNS(xContext, xBaseURI.getStringValue(), + fooPath); + Statement xM_BaseHaspartFoo = + new Statement(xBaseURI, pkg_hasPart, xFoo, manifest); + Statement xM_FooTypeMetadata = + new Statement(xFoo, rdf_type, pkg_MetadataFile, manifest); + Statement xM_FooTypeBar = + new Statement(xFoo, rdf_type, bar, manifest); + xDMA.addMetadataFile(fooPath, new XURI[] { bar }); + xStmtsEnum = xManifest.getStatements(null, null, null); + assure("addMetadataFile", + eq(xStmtsEnum, merge(manifestStmts, new Statement[] { + xM_BaseHaspartFoo, xM_FooTypeMetadata, xM_FooTypeBar + }))); + + XURI[] graphsBar = xDMA.getMetadataGraphsWithType(bar); + assure("getMetadataGraphsWithType", + graphsBar.length == 1 && eq(graphsBar[0], xFoo)); + + + xDMA.removeMetadataFile(xFoo); + xStmtsEnum = xManifest.getStatements(null, null, null); + assure("removeMetadataFile", + eq(xStmtsEnum, manifestStmts)); + + log.println("...done"); + + log.println("Checking mapping..."); + + XEnumerationAccess xTextEnum = (XEnumerationAccess) + UnoRuntime.queryInterface(XEnumerationAccess.class, + xText.getText()); + Object o = xTextEnum.createEnumeration().nextElement(); + XMetadatable xMeta1 = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, o); + + XURI uri; + XMetadatable xMeta; + xMeta = xDMA.getElementByURI(xMeta1); + assure("getElementByURI: null", null != xMeta); + String XmlId = xMeta.getMetadataReference().Second; + String XmlId1 = xMeta1.getMetadataReference().Second; + assure("getElementByURI: no xml id", !XmlId.equals("")); + assure("getElementByURI: different xml id", XmlId.equals(XmlId1)); + + log.println("...done"); + + log.println("Checking storing and loading..."); + + XURI xFoobar = URI.createNS(xContext, xBaseURI.getStringValue(), + fooBarPath); + Statement[] metadataStmts = getMetadataFileStmts(xBaseURI, + fooBarPath); + xDMA.addMetadataFile(fooBarPath, new XURI[0]); + xStmtsEnum = xRep.getStatements(null, null, null); + assure("addMetadataFile", + eq(xStmtsEnum, merge(manifestStmts, metadataStmts ))); + + Statement xFoobar_FooBarFoo = + new Statement(foo, bar, foo, xFoobar); + xRep.getGraph(xFoobar).addStatement(foo, bar, foo); + xStmtsEnum = xRep.getStatements(null, null, null); + assure("addStatement", + eq(xStmtsEnum, merge(manifestStmts, merge(metadataStmts, + new Statement[] { xFoobar_FooBarFoo })))); + + PropertyValue noMDNoContentFile = new PropertyValue(); + noMDNoContentFile.Name = "URL"; + noMDNoContentFile.Value = util.utils.getFullTestURL("CUSTOM.odt"); + PropertyValue noMDFile = new PropertyValue(); + noMDFile.Name = "URL"; + noMDFile.Value = util.utils.getFullTestURL("TEST.odt"); + PropertyValue file = new PropertyValue(); + file.Name = "URL"; + file.Value = tempDir + "TESTDMA.odt"; + /* + PropertyValue baseURL = new PropertyValue(); + baseURL.Name = "DocumentBaseURL"; + baseURL.Value = tempDir + "TMP.odt"; + */ + PropertyValue mimetype = new PropertyValue(); + mimetype.Name = "MediaType"; + mimetype.Value = "application/vnd.oasis.opendocument.text"; + PropertyValue[] argsEmptyNoContent = { mimetype, noMDNoContentFile}; + PropertyValue[] argsEmpty = { mimetype, noMDFile }; + PropertyValue[] args = { mimetype, file }; + + xStmtsEnum = xRep.getStatements(null, null, null); + XURI[] graphs = xRep.getGraphNames(); + + xDMA.storeMetadataToMedium(args); + + // this should re-init + xDMA.loadMetadataFromMedium(argsEmptyNoContent); + xRep = xRS.getRDFRepository(); + assure("xRep null", null != xRep); + assure("baseURI still tdoc?", + !baseURI.equals(xDMA.getStringValue())); + Statement[] manifestStmts2 = getManifestStmts((XURI) xDMA); + xStmtsEnum = xRep.getStatements(null, null, null); + // there is no content or styles file in here, so we have just + // the package stmt + assure("loadMetadataFromMedium (no metadata, no content)", + eq(xStmtsEnum, new Statement[] { manifestStmts2[0] })); + + // this should re-init + xDMA.loadMetadataFromMedium(argsEmpty); + xRep = xRS.getRDFRepository(); + assure("xRep null", null != xRep); + assure("baseURI still tdoc?", + !baseURI.equals(xDMA.getStringValue())); + Statement[] manifestStmts3 = getManifestStmts((XURI) xDMA); + + xStmtsEnum = xRep.getStatements(null, null, null); + assure("loadMetadataFromMedium (no metadata)", + eq(xStmtsEnum, manifestStmts3)); + + xDMA.loadMetadataFromMedium(args); + xRep = xRS.getRDFRepository(); + assure("xRep null", null != xRep); + Statement[] manifestStmts4 = getManifestStmts((XURI) xDMA); + Statement[] metadataStmts4 = getMetadataFileStmts((XURI) xDMA, + fooBarPath); + + xStmtsEnum = xRep.getStatements(null, null, null); + assure("some graph(s) not reloaded", + graphs.length == xRep.getGraphNames().length); + + XURI xFoobar4 = URI.createNS(xContext, xDMA.getStringValue(), + fooBarPath); + Statement xFoobar_FooBarFoo4 = + new Statement(foo, bar, foo, xFoobar4); + assure("loadMetadataFromMedium (re-load)", + eq(xStmtsEnum, merge(manifestStmts4, merge(metadataStmts4, + new Statement[] { xFoobar_FooBarFoo4 })))); + + log.println("...done"); + + log.println("Checking storing and loading via model..."); + + String f = tempDir + "TESTPARA.odt"; + + XStorable xStor = (XStorable) UnoRuntime.queryInterface( + XStorable.class, xRS); + + xStor.storeToURL(f, new PropertyValue[0]); + + xComp2 = util.DesktopTools.loadDoc(xMSF, f, loadProps); + + XDocumentMetadataAccess xDMA2 = (XDocumentMetadataAccess) + UnoRuntime.queryInterface(XDocumentMetadataAccess.class, + xComp2); + assure("xDMA2 null", null != xDMA2); + + XRepositorySupplier xRS2 = (XRepositorySupplier) + UnoRuntime.queryInterface(XRepositorySupplier.class, xComp2); + assure("xRS2 null", null != xRS2); + + XRepository xRep2 = xRS2.getRDFRepository(); + assure("xRep2 null", null != xRep2); + + Statement[] manifestStmts5 = getManifestStmts((XURI) xDMA2); + Statement[] metadataStmts5 = getMetadataFileStmts((XURI) xDMA2, + fooBarPath); + XURI xFoobar5 = URI.createNS(xContext, xDMA2.getStringValue(), + fooBarPath); + Statement xFoobar_FooBarFoo5 = + new Statement(foo, bar, foo, xFoobar5); + xStmtsEnum = xRep.getStatements(null, null, null); + XEnumeration xStmtsEnum2 = xRep2.getStatements(null, null, null); + assure("load: repository differs", + eq(xStmtsEnum2, merge(manifestStmts5, merge(metadataStmts5, + new Statement[] { xFoobar_FooBarFoo5 })))); + + log.println("...done"); + + } catch (Exception e) { + report(e); + } finally { + close(xComp); + close(xComp2); + } + } + + public void checkRDFa() + { + XComponent xComp = null; + String file; + try { + file = util.utils.getFullTestURL("TESTRDFA.odt"); + xComp = loadRDFa(file); + if (xComp != null) + { + file = tempDir + "TESTRDFA.odt"; + storeRDFa(xComp, file); + close(xComp); + xComp = loadRDFa(file); + } + } finally { + close(xComp); + } + } + + public void storeRDFa(XComponent xComp, String file) + { + try { + + log.println("Storing test document..."); + + XStorable xStor = (XStorable) UnoRuntime.queryInterface( + XStorable.class, xComp); + + xStor.storeToURL(file, new PropertyValue[0]); + + log.println("...done"); + + } catch (Exception e) { + report(e); + } + } + + public XComponent loadRDFa(String file) + { + XComponent xComp = null; + try { + + log.println("Loading test document..."); + + PropertyValue[] loadProps = new PropertyValue[1]; + loadProps[0] = new PropertyValue(); + loadProps[0].Name = "Hidden"; + loadProps[0].Value = new Boolean(true); + + + + xComp = util.DesktopTools.loadDoc(xMSF, file, loadProps); + + XRepositorySupplier xRS = (XRepositorySupplier) + UnoRuntime.queryInterface(XRepositorySupplier.class, xComp); + assure("xRS null", null != xRS); + + XDocumentRepository xRep = (XDocumentRepository) + UnoRuntime.queryInterface(XDocumentRepository.class, + xRS.getRDFRepository()); + assure("xRep null", null != xRep); + + XTextDocument xTextDoc = (XTextDocument) + UnoRuntime.queryInterface(XTextDocument.class, xComp); + + XText xText = xTextDoc.getText(); + + XEnumerationAccess xEA = (XEnumerationAccess) + UnoRuntime.queryInterface(XEnumerationAccess.class, xText); + XEnumeration xEnum = xEA.createEnumeration(); + + log.println("...done"); + + log.println("Checking RDFa in loaded test document..."); + + XMetadatable xPara; + Pair<Statement[], Boolean> result; + + Statement x_FooBarLit1 = new Statement(foo, bar, mkLit("1"), null); + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 1", + !result.Second && + eq(result.First, new Statement[] { + x_FooBarLit1 + })); + + Statement x_FooBarLit2 = new Statement(foo, bar, mkLit("2"), null); + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 2", + !result.Second && + eq(result.First, new Statement[] { + x_FooBarLit2 + })); + + Statement x_BlankBarLit3 = + new Statement(blank1, bar, mkLit("3"), null); + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 3", + !result.Second && + eq(result.First, new Statement[] { + x_BlankBarLit3 + })); + XBlankNode b3 = (XBlankNode) UnoRuntime.queryInterface( + XBlankNode.class, result.First[0].Subject); + + Statement x_BlankBarLit4 = + new Statement(blank2, bar, mkLit("4"), null); + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 4", + !result.Second && + eq(result.First, new Statement[] { + x_BlankBarLit4 + })); + XBlankNode b4 = (XBlankNode) UnoRuntime.queryInterface( + XBlankNode.class, result.First[0].Subject); + + Statement x_BlankBarLit5 = + new Statement(blank1, bar, mkLit("5"), null); + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 5", + !result.Second && + eq(result.First, new Statement[] { + x_BlankBarLit5 + })); + XBlankNode b5 = (XBlankNode) UnoRuntime.queryInterface( + XBlankNode.class, result.First[0].Subject); + + assure("RDFa: 3 != 4", + !b3.getStringValue().equals(b4.getStringValue())); + assure("RDFa: 3 == 5", + b3.getStringValue().equals(b5.getStringValue())); + + Statement x_FooBarLit6 = new Statement(foo, bar, mkLit("6"), null); + Statement x_FooBazLit6 = new Statement(foo, baz, mkLit("6"), null); + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 6", + !result.Second && + eq(result.First, new Statement[] { + x_FooBarLit6, x_FooBazLit6 + })); + + Statement x_FooBarLit7 = new Statement(foo, bar, mkLit("7"), null); + Statement x_FooBazLit7 = new Statement(foo, baz, mkLit("7"), null); + Statement x_FooFooLit7 = new Statement(foo, foo, mkLit("7"), null); + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 7", + !result.Second && + eq(result.First, new Statement[] { + x_FooBarLit7, x_FooBazLit7, x_FooFooLit7 + })); + + XNode lit = mkLit("a fooish bar"); + XNode lit_type= mkLit("a fooish bar", bar); + Statement x_FooBarLit = new Statement(foo, bar, lit, null); + Statement x_FooBarLittype = new Statement(foo, bar, lit_type, null); + + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 8", + result.Second && + eq(result.First, new Statement[] { + x_FooBarLit + })); + + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 9", + result.Second && + eq(result.First, new Statement[] { + x_FooBarLit + })); + + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 10", + result.Second && + eq(result.First, new Statement[] { + x_FooBarLittype + })); + + Statement x_FooBarLit11 + = new Statement(foo, bar, mkLit("11", bar), null); + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 11", + !result.Second && + eq(result.First, new Statement[] { + x_FooBarLit11 + })); + + XURI xFile = URI.createNS(xContext, file, "/" + contentPath); + Statement x_FileBarLit12 = + new Statement(xFile, bar, mkLit("12"), null); + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 12", + !result.Second && + eq(result.First, new Statement[] { + x_FileBarLit12 + })); + + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 13", + result.Second && + eq(result.First, new Statement[] { + x_FooBarLit + })); + + Statement x_FooLabelLit14 = + new Statement(foo, rdfs_label, mkLit("14"), null); + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 14", + result.Second && + eq(result.First, new Statement[] { + x_FooBarLit + })); + + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 15", eq(result.First, new Statement[] { } )); + + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 16", eq(result.First, new Statement[] { } )); + + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 17", eq(result.First, new Statement[] { } )); + + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 18", eq(result.First, new Statement[] { } )); + + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 19", eq(result.First, new Statement[] { } )); + + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 20", eq(result.First, new Statement[] { } )); + + xPara = (XMetadatable) UnoRuntime.queryInterface( + XMetadatable.class, xEnum.nextElement()); + result = xRep.getStatementRDFa(xPara); + assure("RDFa: 21", eq(result.First, new Statement[] { } )); + + log.println("...done"); + + } catch (Exception e) { + report(e); + close(xComp); + } + return xComp; + } + + +// utilities ------------------------------------------------------------- + + public void report2(Exception e) + { + if (e instanceof WrappedTargetException) + { + log.println("Cause:"); + Exception cause = (Exception) + (((WrappedTargetException)e).TargetException); + log.println(cause.toString()); + report2(cause); + } else if (e instanceof WrappedTargetRuntimeException) { + log.println("Cause:"); + Exception cause = (Exception) + (((WrappedTargetRuntimeException)e).TargetException); + log.println(cause.toString()); + report2(cause); + } + } + + public void report(Exception e) { + log.println("Exception occurred:"); + e.printStackTrace((java.io.PrintWriter) log); + report2(e); + failed(); + } + + static void close(XComponent i_comp) + { + try { + XCloseable xClos = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, i_comp); + if (xClos != null) xClos.close(true); + } catch (Exception e) { + } + } + + XLiteral mkLit(String i_content) + { + return Literal.create(xContext, i_content); + } + + XLiteral mkLit(String i_content, XURI i_uri) + { + return Literal.createWithType(xContext, i_content, i_uri); + } + + static Statement[] merge(Statement[] i_A1, Statement[] i_A2) + { + // bah, java sucks... + Statement[] ret = new Statement[i_A1.length + i_A2.length]; + for (int i = 0; i < i_A1.length; ++i) { + ret[i] = i_A1[i]; + } + for (int i = 0; i < i_A2.length; ++i) { + ret[i+i_A1.length] = i_A2[i]; + } + return ret; + } + + public static String toS(XNode n) { + if (null == n) return "< null >"; + return n.getStringValue(); + } + + static boolean isBlank(XNode i_node) + { + XBlankNode blank = (XBlankNode) UnoRuntime.queryInterface( + XBlankNode.class, i_node); + return blank != null; + } + +/* + static class Statement implements XStatement + { + XResource m_Subject; + XResource m_Predicate; + XNode m_Object; + XURI m_Graph; + + Statement(XResource i_Subject, XResource i_Predicate, XNode i_Object, + XURI i_Graph) + { + m_Subject = i_Subject; + m_Predicate = i_Predicate; + m_Object = i_Object; + m_Graph = i_Graph; + } + + public XResource getSubject() { return m_Subject; } + public XResource getPredicate() { return m_Predicate; } + public XNode getObject() { return m_Object; } + public XURI getGraph() { return m_Graph; } + } +*/ + + static Statement[] toSeq(XEnumeration i_Enum) throws Exception + { + java.util.Collection c = new java.util.Vector(); + while (i_Enum.hasMoreElements()) { + Statement s = (Statement) i_Enum.nextElement(); +//log.println("toSeq: " + s.getSubject().getStringValue() + " " + s.getPredicate().getStringValue() + " " + s.getObject().getStringValue() + "."); + c.add(s); + } +// return (Statement[]) c.toArray(); + // java sucks + Object[] arr = c.toArray(); + Statement[] ret = new Statement[arr.length]; + for (int i = 0; i < arr.length; ++i) { + ret[i] = (Statement) arr[i]; + } + return ret; + } + + static XNode[][] toSeqs(XEnumeration i_Enum) throws Exception + { + java.util.Collection c = new java.util.Vector(); + while (i_Enum.hasMoreElements()) { + XNode[] s = (XNode[]) i_Enum.nextElement(); + c.add(s); + } +// return (XNode[][]) c.toArray(); + Object[] arr = c.toArray(); + XNode[][] ret = new XNode[arr.length][]; + for (int i = 0; i < arr.length; ++i) { + ret[i] = (XNode[]) arr[i]; + } + return ret; + } + + static class BindingComp implements java.util.Comparator + { + public int compare(Object i_Left, Object i_Right) + { + XNode[] left = (XNode[]) i_Left; + XNode[] right = (XNode[]) i_Right; + if (left.length != right.length) throw new RuntimeException(); + for (int i = 0; i < left.length; ++i) { + int eq = (left[i].getStringValue().compareTo( + right[i].getStringValue())); + if (eq != 0) return eq; + } + return 0; + } + } + + static class StmtComp implements java.util.Comparator + { + public int compare(Object i_Left, Object i_Right) + { + int eq; + Statement left = (Statement) i_Left; + Statement right = (Statement) i_Right; + if ((eq = cmp(left.Graph, right.Graph )) != 0) return eq; + if ((eq = cmp(left.Subject, right.Subject )) != 0) return eq; + if ((eq = cmp(left.Predicate, right.Predicate)) != 0) return eq; + if ((eq = cmp(left.Object, right.Object )) != 0) return eq; + return 0; + } + + public int cmp(XNode i_Left, XNode i_Right) + { + if (isBlank(i_Left)) { + return isBlank(i_Right) ? 0 : 1; + } else { + if (isBlank(i_Right)) { + return -1; + } else { + return toS(i_Left).compareTo(toS(i_Right)); + } + } + } + } + + static boolean eq(Statement i_Left, Statement i_Right) + { + XURI lG = i_Left.Graph; + XURI rG = i_Right.Graph; + if (!eq(lG, rG)) { + log.println("Graphs differ: " + toS(lG) + " != " + toS(rG)); + return false; + } + if (!eq(i_Left.Subject, i_Right.Subject)) { + log.println("Subjects differ: " + + i_Left.Subject.getStringValue() + " != " + + i_Right.Subject.getStringValue()); + return false; + } + if (!eq(i_Left.Predicate, i_Right.Predicate)) { + log.println("Predicates differ: " + + i_Left.Predicate.getStringValue() + " != " + + i_Right.Predicate.getStringValue()); + return false; + } + if (!eq(i_Left.Object, i_Right.Object)) { + log.println("Objects differ: " + + i_Left.Object.getStringValue() + " != " + + i_Right.Object.getStringValue()); + return false; + } + return true; + } + + static boolean eq(Statement[] i_Result, Statement[] i_Expected) + { + if (i_Result.length != i_Expected.length) { + log.println("eq: different lengths: " + i_Result.length + " " + + i_Expected.length); + return false; + } + Statement[] expected = (Statement[]) + java.util.Arrays.asList(i_Expected).toArray(); + java.util.Arrays.sort(i_Result, new StmtComp()); + java.util.Arrays.sort(expected, new StmtComp()); + for (int i = 0; i < expected.length; ++i) { + if (!eq(i_Result[i], expected[i])) return false; + } + return true; + } + + static boolean eq(XEnumeration i_Enum, Statement[] i_Expected) + throws Exception + { + Statement[] current = toSeq(i_Enum); + return eq(current, i_Expected); + } + + static boolean eq(XNode i_Left, XNode i_Right) + { + if (i_Left == null) { + return (i_Right == null); + } else { + return (i_Right != null) && + (i_Left.getStringValue().equals(i_Right.getStringValue()) + // FIXME: hack: blank nodes considered equal + || (isBlank(i_Left) && isBlank(i_Right))); + } + } + + static boolean eq(XQuerySelectResult i_Result, + String[] i_Vars, XNode[][] i_Bindings) throws Exception + { + String[] vars = (String[]) i_Result.getBindingNames(); + XEnumeration iter = (XEnumeration) i_Result; + XNode[][] bindings = toSeqs(iter); + if (vars.length != i_Vars.length) { + log.println("var lengths differ"); + return false; + } + if (bindings.length != i_Bindings.length) { + log.println("binding lengths differ: " + i_Bindings.length + + " vs " + bindings.length ); + return false; + } + java.util.Arrays.sort(bindings, new BindingComp()); + java.util.Arrays.sort(i_Bindings, new BindingComp()); + for (int i = 0; i < i_Bindings.length; ++i) { + if (i_Bindings[i].length != i_Vars.length) { + log.println("TEST ERROR!"); + throw new Exception(); + } + if (bindings[i].length != i_Vars.length) { + log.println("binding length and var length differ"); + return false; + } + for (int j = 0; j < i_Vars.length; ++j) { + if (!eq(bindings[i][j], i_Bindings[i][j])) { + log.println("bindings differ: " + + toS(bindings[i][j]) + " != " + toS(i_Bindings[i][j])); + return false; + } + } + } + for (int i = 0; i < i_Vars.length; ++i) { + if (!vars[i].equals(i_Vars[i])) { + log.println("variable names differ: " + + vars[i] + " != " + i_Vars[i]); + return false; + } + } + return true; + } + + static boolean eq(StringPair i_Left, StringPair i_Right) + { + return ((i_Left.First).equals(i_Right.First)) && + ((i_Left.Second).equals(i_Right.Second)); + } + + static String mkNamespace(String i_prefix, String i_namespace) + { + return "PREFIX " + i_prefix + ": <" + i_namespace + ">\n"; + } + + static String mkNss() + { + String namespaces = mkNamespace("rdf", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); + namespaces += mkNamespace("pkg", + "http://docs.oasis-open.org/opendocument/meta/package/common#"); + namespaces += mkNamespace("odf", + "http://docs.oasis-open.org/opendocument/meta/package/odf#"); + return namespaces; + } + + Statement[] getManifestStmts(XURI xBaseURI) throws Exception + { + XURI xManifest = URI.createNS(xContext, xBaseURI.getStringValue(), + manifestPath); + XURI xContent = URI.createNS(xContext, xBaseURI.getStringValue(), + contentPath); + XURI xStyles = URI.createNS(xContext, xBaseURI.getStringValue(), + stylesPath); + Statement xM_BaseTypeDoc = + new Statement(xBaseURI, rdf_type, pkg_Document, xManifest); + Statement xM_BaseHaspartContent = + new Statement(xBaseURI, pkg_hasPart, xContent, xManifest); + Statement xM_BaseHaspartStyles = + new Statement(xBaseURI, pkg_hasPart, xStyles, xManifest); + Statement xM_ContentTypeContent = + new Statement(xContent, rdf_type, odf_ContentFile, xManifest); + Statement xM_StylesTypeStyles = + new Statement(xStyles, rdf_type, odf_StylesFile, xManifest); + return new Statement[] { + xM_BaseTypeDoc, xM_BaseHaspartContent, xM_BaseHaspartStyles, + xM_ContentTypeContent, xM_StylesTypeStyles + }; + } + + Statement[] getMetadataFileStmts(XURI xBaseURI, String Path) + throws Exception + { + XURI xManifest = URI.createNS(xContext, xBaseURI.getStringValue(), + manifestPath); + XURI xGraph = URI.createNS(xContext, xBaseURI.getStringValue(), Path); + Statement xM_BaseHaspartGraph = + new Statement(xBaseURI, pkg_hasPart, xGraph, xManifest); + Statement xM_GraphTypeMetadata = + new Statement(xGraph, rdf_type, pkg_MetadataFile, xManifest); + return new Statement[] { xM_BaseHaspartGraph, xM_GraphTypeMetadata }; + } + + class TestRange implements XTextRange, XMetadatable, XServiceInfo + { + String m_Stream; + String m_XmlId; + String m_Text; + TestRange(String i_Str) { m_Text = i_Str; } + + public String getStringValue() { return ""; } + public String getNamespace() { return ""; } + public String getLocalName() { return ""; } + + public StringPair getMetadataReference() + { return new StringPair(m_Stream, m_XmlId); } + public void setMetadataReference(StringPair i_Ref) + throws IllegalArgumentException + { m_Stream = (String)i_Ref.First; m_XmlId = (String)i_Ref.Second; } + public void ensureMetadataReference() + { m_Stream = "content.xml"; m_XmlId = "42"; } + + public String getImplementationName() { return null; } + public String[] getSupportedServiceNames() { return null; } + public boolean supportsService(String i_Svc) + { return i_Svc.equals("com.sun.star.text.Paragraph"); } + + public XText getText() { return null; } + public XTextRange getStart() { return null; } + public XTextRange getEnd() { return null; } + public String getString() { return m_Text; } + public void setString(String i_Str) { m_Text = i_Str; } + } +} + diff --git a/sfx2/qa/complex/docinfo/DocumentProperties.java b/sfx2/qa/complex/docinfo/DocumentProperties.java new file mode 100644 index 000000000000..cff1dd341d48 --- /dev/null +++ b/sfx2/qa/complex/docinfo/DocumentProperties.java @@ -0,0 +1,269 @@ +/************************************************************************* + * + * 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.docinfo; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertyContainer; +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XDocumentInfo; +import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.frame.XStorable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.Date; + +import complexlib.ComplexTestCase; + +import util.DesktopTools; +import util.WriterTools; + + +public class DocumentProperties extends ComplexTestCase { + XMultiServiceFactory m_xMSF = null; + XTextDocument xTextDoc = null; + + public String[] getTestMethodNames() { + return new String[] {"checkDocInfo", "cleanup"}; + } + + public void checkDocInfo() { + m_xMSF = (XMultiServiceFactory) param.getMSF(); + + log.println( + "check wether there is a valid MultiServiceFactory"); + + if (m_xMSF == null) { + assure("## Couldn't get MultiServiceFactory make sure your Office is started", + true); + } + + log.println("... done"); + + log.println("Opening a Writer document"); + xTextDoc = WriterTools.createTextDoc(m_xMSF); + log.println("... done"); + + XDocumentInfoSupplier xDocInfoSup = + (XDocumentInfoSupplier) UnoRuntime.queryInterface(XDocumentInfoSupplier.class, + xTextDoc); + XDocumentInfo xDocInfo = xDocInfoSup.getDocumentInfo(); + XPropertyContainer xPropContainer = + (XPropertyContainer) UnoRuntime.queryInterface(XPropertyContainer.class, + xDocInfo); + + log.println("Trying to add a existing property"); + + boolean worked = + addProperty(xPropContainer, "Author", (short) 0, ""); + assure("Could set an existing property", !worked); + log.println("...done"); + + log.println("Trying to add a integer property"); + worked = + addProperty(xPropContainer, "intValue", com.sun.star.beans.PropertyAttribute.READONLY, + new Integer(17)); + assure("Couldn't set an integer property", worked); + log.println("...done"); + + log.println("Trying to add a double property"); + worked = + addProperty(xPropContainer, "doubleValue", com.sun.star.beans.PropertyAttribute.REMOVEABLE , + new Double(17.7)); + assure("Couldn't set an double property", worked); + log.println("...done"); + + log.println("Trying to add a boolean property"); + worked = + addProperty(xPropContainer, "booleanValue", com.sun.star.beans.PropertyAttribute.REMOVEABLE, + Boolean.TRUE); + assure("Couldn't set an boolean property", worked); + log.println("...done"); + + log.println("Trying to add a date property"); + worked = + addProperty(xPropContainer, "dateValue", com.sun.star.beans.PropertyAttribute.REMOVEABLE, + new Date()); + assure("Couldn't set an date property", worked); + log.println("...done"); + + log.println("trying to remove a read only Property"); + try { + xPropContainer.removeProperty ("intValue"); + assure("Could remove read only property", false); + } catch (Exception e) { + log.println("\tException was thrown "+e); + log.println("\t...OK"); + } + log.println("...done"); + + + String tempdir = System.getProperty("java.io.tmpdir"); + String fs = System.getProperty("file.separator"); + + if (!tempdir.endsWith(fs)) { + tempdir += fs; + } + + tempdir = util.utils.getFullURL(tempdir); + + log.println("Storing the document"); + + try { + XStorable store = + (XStorable) UnoRuntime.queryInterface(XStorable.class, + xTextDoc); + store.storeToURL(tempdir + "DocInfo.oot", + new PropertyValue[] {}); + DesktopTools.closeDoc(xTextDoc); + } catch (Exception e) { + assure("Couldn't store document", false); + } + + log.println("...done"); + + log.println("loading the document"); + + try { + XComponentLoader xCL = + (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, + m_xMSF.createInstance( + "com.sun.star.frame.Desktop")); + XComponent xComp = + xCL.loadComponentFromURL(tempdir + "DocInfo.oot", + "_blank", 0, new PropertyValue[] {}); + xTextDoc = + (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, + xComp); + } catch (Exception e) { + assure("Couldn't load document", false); + } + + log.println("...done"); + + xDocInfoSup = + (XDocumentInfoSupplier) UnoRuntime.queryInterface(XDocumentInfoSupplier.class, + xTextDoc); + xDocInfo = xDocInfoSup.getDocumentInfo(); + + XPropertySet xProps = + (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, + xDocInfo); + + assure("Integer doesn't work", + checkType(xProps, "intValue", "java.lang.Integer")); + assure("Double doesn't work", + checkType(xProps, "doubleValue", "java.lang.Double")); + assure("Boolean doesn't work", + checkType(xProps, "booleanValue", "java.lang.Boolean")); + assure("Date doesn't work", + checkType(xProps, "dateValue", + "com.sun.star.util.DateTime")); + + xPropContainer = + (XPropertyContainer) UnoRuntime.queryInterface(XPropertyContainer.class, + xDocInfo); + + log.println("trying to remove a not user defined Property"); + try { + xPropContainer.removeProperty ("Author"); + assure("Could remove non user defined property", false); + } catch (Exception e) { + log.println("\tException was thrown "+e); + log.println("\t...OK"); + } + log.println("...done"); + + log.println("Trying to remove a user defined property"); + try { + xPropContainer.removeProperty ("dateValue"); + log.println("\t...OK"); + } catch (Exception e) { + log.println("\tException was thrown "+e); + log.println("\t...FAILED"); + assure("Could not remove user defined property", false); + } + log.println("...done"); + + } + + public void cleanup() { + DesktopTools.closeDoc(xTextDoc); + } + + private boolean checkType(XPropertySet xProps, String aName, + String expected) { + boolean ret = true; + log.println("Checking " + expected); + + String getting = + getPropertyByName(xProps, aName).getClass().getName(); + + if (!getting.equals(expected)) { + log.println("\t Expected: " + expected); + log.println("\t Detting: " + getting); + ret = false; + } + + if (ret) { + log.println("...OK"); + } + + return ret; + } + + private Object getPropertyByName(XPropertySet xProps, String aName) { + Object ret = null; + + try { + ret = xProps.getPropertyValue(aName); + } catch (Exception e) { + log.println("\tCouldn't get Property " + aName); + log.println("\tMessage " + e); + } + + return ret; + } + + private boolean addProperty(XPropertyContainer xPropContainer, + String aName, short attr, Object defaults) { + boolean ret = true; + + try { + xPropContainer.addProperty(aName, attr, defaults); + } catch (Exception e) { + ret = false; + log.println("\tCouldn't get Property " + aName); + log.println("\tMessage " + e); + } + + return ret; + } +} diff --git a/sfx2/qa/complex/docinfo/makefile.mk b/sfx2/qa/complex/docinfo/makefile.mk new file mode 100644 index 000000000000..8c3525541062 --- /dev/null +++ b/sfx2/qa/complex/docinfo/makefile.mk @@ -0,0 +1,56 @@ +#************************************************************************* +# +# 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 = DocumentProperties +PRJNAME = sfx2 +PACKAGE = complex$/docinfo + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + + +#----- compile .java files ----------------------------------------- + +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JAVAFILES = DocumentProperties.java + +#----- make a jar from compiled files ------------------------------ + +MAXLINELENGTH = 100000 + +JARCLASSDIRS = $(PACKAGE) +JARTARGET = $(TARGET).jar +JARCOMPRESS = TRUE + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + +run: + $(JAVAI) $(JAVAIFLAGS) -cp $(CLASSPATH) org.openoffice.Runner -TestBase java_complex -o $(PACKAGE:s#$/#.#).$(JAVAFILES:b) diff --git a/sfx2/qa/complex/makefile.mk b/sfx2/qa/complex/makefile.mk new file mode 100644 index 000000000000..b8bc897fccf7 --- /dev/null +++ b/sfx2/qa/complex/makefile.mk @@ -0,0 +1,61 @@ +#************************************************************************* +# +# 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 = CheckGlobalEventBroadcaster_writer1 +PRJNAME = $(TARGET) +PACKAGE = complex$/framework + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + + +#----- compile .java files ----------------------------------------- + +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JAVAFILES = CheckGlobalEventBroadcaster_writer1.java \ + DocumentMetaData.java \ + DocumentMetadataAccessTest.java + +JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) + +SUBDIRS = DocHelper +#----- make a jar from compiled files ------------------------------ + +MAXLINELENGTH = 100000 + +JARCLASSDIRS = $(PACKAGE) +JARTARGET = $(TARGET).jar +JARCOMPRESS = TRUE + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + +run: + +java -cp $(CLASSPATH) org.openoffice.Runner -TestBase java_complex -sce tests.sce -tdoc $(PWD)$/testdocuments diff --git a/sfx2/qa/complex/standalonedocumentinfo/StandaloneDocumentInfoTest.java b/sfx2/qa/complex/standalonedocumentinfo/StandaloneDocumentInfoTest.java new file mode 100644 index 000000000000..f5512bf9723b --- /dev/null +++ b/sfx2/qa/complex/standalonedocumentinfo/StandaloneDocumentInfoTest.java @@ -0,0 +1,31 @@ +/************************************************************************* + * + * 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.standalonedocumentinfo; + +public interface StandaloneDocumentInfoTest { + boolean test(); +} diff --git a/sfx2/qa/complex/standalonedocumentinfo/StandaloneDocumentInfoUnitTest.java b/sfx2/qa/complex/standalonedocumentinfo/StandaloneDocumentInfoUnitTest.java new file mode 100644 index 000000000000..0136f8941df5 --- /dev/null +++ b/sfx2/qa/complex/standalonedocumentinfo/StandaloneDocumentInfoUnitTest.java @@ -0,0 +1,69 @@ +/************************************************************************* + * + * 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.standalonedocumentinfo; + +import complexlib.ComplexTestCase; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; + +/* Document here +*/ + +public class StandaloneDocumentInfoUnitTest extends ComplexTestCase { + private XMultiServiceFactory m_xMSF = null; + + public String[] getTestMethodNames() { + return new String[] { + "ExecuteTest01"}; + } + + public String[] getTestObjectNames() { + return new String[] {"StandaloneDocumentInfoUnitTest"}; + } + + public void before() { + try { + m_xMSF = (XMultiServiceFactory)param.getMSF(); + } catch(Exception e) { + failed( "Failed to create service factory!" ); + } + if( m_xMSF ==null ) { + failed( "Failed to create service factory!" ); + } + } + + public void after() { + m_xMSF = null; + } + + public void ExecuteTest01() { + StandaloneDocumentInfoTest aTest = new Test01 (m_xMSF, log); + assure( "Test01 failed!", aTest.test() ); + } +} + + diff --git a/sfx2/qa/complex/standalonedocumentinfo/Test01.java b/sfx2/qa/complex/standalonedocumentinfo/Test01.java new file mode 100644 index 000000000000..92c59d81e1c4 --- /dev/null +++ b/sfx2/qa/complex/standalonedocumentinfo/Test01.java @@ -0,0 +1,161 @@ +/************************************************************************* + * + * 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.standalonedocumentinfo; + +import com.sun.star.beans.Property; +import com.sun.star.beans.XProperty; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.io.IOException; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import complexlib.ComplexTestCase; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.document.XStandaloneDocumentInfo; +import com.sun.star.io.XTempFile; +import com.sun.star.frame.XLoadable; +import com.sun.star.frame.XStorable; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.AnyConverter; +import com.sun.star.task.ErrorCodeIOException; +import java.util.Properties; + +import java.util.Random; +import share.LogWriter; + +public class Test01 implements StandaloneDocumentInfoTest { + XMultiServiceFactory m_xMSF = null; + TestHelper m_aTestHelper = null; + + public Test01 ( XMultiServiceFactory xMSF, LogWriter aLogWriter ) { + m_xMSF = xMSF; + m_aTestHelper = new TestHelper( aLogWriter, "Test01: " ); + } + + public boolean test() { + try { + final String sDocTitle [] = new String [] { + "ODF_Doc", "OOo6_Doc", "old_binary_Doc" }; + final String sFilterName [] = new String [] { + "writer8", "StarOffice XML (Writer)", "StarWriter 5.0" }; + + for (int i = 0; i < 3; ++i ) { + m_aTestHelper.Message ( "==============================" ); + m_aTestHelper.Message ( sFilterName[i] ); + m_aTestHelper.Message ( "==============================" ); + //create a new temporary file + Object oTempFile = m_xMSF.createInstance ( "com.sun.star.io.TempFile" ); + XTempFile xTempFile = (XTempFile) UnoRuntime.queryInterface ( + XTempFile.class, oTempFile ); + + //create a text document and initiallize it + Object oTextDocument = m_xMSF.createInstance ( "com.sun.star.text.TextDocument" ); + XLoadable xLoadable = (XLoadable) UnoRuntime.queryInterface ( + XLoadable.class, oTextDocument ); + xLoadable.initNew(); + m_aTestHelper.Message ( "New document initialized." ); + + //store the instance to the temporary file URL + XStorable xStorable = (XStorable) UnoRuntime.queryInterface ( + XStorable.class, oTextDocument ); + String sURL = AnyConverter.toString ( xTempFile.getUri () ); + PropertyValue aProps[] = new PropertyValue[2]; + aProps[0] = new PropertyValue(); + aProps[0].Name = "DocumentTitle"; + aProps[0].Value = sDocTitle[i]; + aProps[1] = new PropertyValue(); + aProps[1].Name = "FilterName"; + aProps[1].Value = sFilterName[i]; + m_aTestHelper.Message ( "Set title: " + + sDocTitle[i] ); + xStorable.storeToURL ( sURL, aProps ); + m_aTestHelper.Message ( "Document stored." ); + + //create StandaloneDocumentInfo object and load it from the file + Object oStandaloneDocInfo = m_xMSF.createInstance ( + "com.sun.star.document.StandaloneDocumentInfo" ); + XStandaloneDocumentInfo xStandaloneDocInfo = + (XStandaloneDocumentInfo) UnoRuntime.queryInterface ( + XStandaloneDocumentInfo.class, oStandaloneDocInfo ); + xStandaloneDocInfo.loadFromURL ( sURL ); + m_aTestHelper.Message ( "StandaloneDocumentInfo loaded." ); + + //get the title from the object and check it + XPropertySet xPropSet = + (XPropertySet)UnoRuntime.queryInterface ( + XPropertySet.class, oStandaloneDocInfo ); + String sTitle = xPropSet.getPropertyValue ( "Title" ).toString (); + m_aTestHelper.Message ( "Get title: " + sTitle ); + if ( sTitle.compareTo ( sDocTitle[i] ) != 0 ) { + m_aTestHelper.Error ( "Title not match. Expected \"" + + sDocTitle[i] + + "\"" ); + return false; + } else { + m_aTestHelper.Message ( "Title matched." ); + } + + //set a new title to the object + sTitle += "_new"; + xPropSet.setPropertyValue ( "Title", sTitle ); + m_aTestHelper.Message ( "Set new title: " + sTitle ); + + //store the object to the same file + xStandaloneDocInfo.storeIntoURL ( sURL ); + m_aTestHelper.Message ( "Document info stored." ); + + //create a new StandaloneDocumentInfo object and load it from the file + Object oStandaloneDocInfo_ = m_xMSF.createInstance ( + "com.sun.star.document.StandaloneDocumentInfo" ); + XStandaloneDocumentInfo xStandaloneDocInfo_ = + (XStandaloneDocumentInfo)UnoRuntime.queryInterface ( + XStandaloneDocumentInfo.class, oStandaloneDocInfo_ ); + xStandaloneDocInfo_.loadFromURL ( sURL ); + m_aTestHelper.Message ( "New StandaloneDocumentInfo loaded." ); + + //get the title and check it + XPropertySet xPropSet_ = (XPropertySet)UnoRuntime.queryInterface ( + XPropertySet.class, oStandaloneDocInfo_ ); + String sTitle_ = xPropSet_.getPropertyValue ( "Title" ).toString (); + m_aTestHelper.Message ( "Get new title: " + sTitle_ ); + if ( sTitle_.compareTo ( sTitle ) != 0 ) { + m_aTestHelper.Error ( "New title not matched. Expected: \"" + sTitle + + "\"." ); + return false; + } else { + m_aTestHelper.Message ( "New title matched." ); + } + } + } catch ( Exception e ) { + m_aTestHelper.Error( "Exception: " + e ); + return false; + } + return true; + } +} diff --git a/sfx2/qa/complex/standalonedocumentinfo/TestHelper.java b/sfx2/qa/complex/standalonedocumentinfo/TestHelper.java new file mode 100644 index 000000000000..f319fe412227 --- /dev/null +++ b/sfx2/qa/complex/standalonedocumentinfo/TestHelper.java @@ -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. + * + ************************************************************************/ +package complex.standalonedocumentinfo; + +import share.LogWriter; + +public class TestHelper { + LogWriter m_aLogWriter; + String m_sTestPrefix; + + /** Creates a new instance of TestHelper */ + public TestHelper ( LogWriter aLogWriter, String sTestPrefix ) { + m_aLogWriter = aLogWriter; + m_sTestPrefix = sTestPrefix; + } + + public void Error ( String sError ) { + m_aLogWriter.println ( m_sTestPrefix + "Error: " + sError ); + } + + public void Message ( String sMessage ) { + m_aLogWriter.println ( m_sTestPrefix + sMessage ); + } +} diff --git a/sfx2/qa/complex/standalonedocumentinfo/makefile.mk b/sfx2/qa/complex/standalonedocumentinfo/makefile.mk new file mode 100644 index 000000000000..c65556aeb763 --- /dev/null +++ b/sfx2/qa/complex/standalonedocumentinfo/makefile.mk @@ -0,0 +1,85 @@ +#************************************************************************* +# +# 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 = StandaloneDocumentInfoUnitTest +PRJNAME = binfilter +PACKAGE = complex$/standalonedocumentinfo + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + + +#----- compile .java files ----------------------------------------- + +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar + +JAVAFILES =\ + StandaloneDocumentInfoUnitTest.java\ + StandaloneDocumentInfoTest.java\ + Test01.java\ + TestHelper.java\ + +JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) + +#----- make a jar from compiled files ------------------------------ + +MAXLINELENGTH = 100000 + +JARCLASSDIRS = $(PACKAGE) +JARTARGET = $(TARGET).jar +JARCOMPRESS = TRUE + +# --- Parameters for the test -------------------------------------- + +# start an office if the parameter is set for the makefile +.IF "$(OFFICE)" == "" +CT_APPEXECCOMMAND = +.ELSE +CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;" +.ENDIF + +# test base is java complex +CT_TESTBASE = -TestBase java_complex + +# test looks something like the.full.package.TestName +CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b) + +# start the runner application +CT_APP = org.openoffice.Runner + +# --- Targets ------------------------------------------------------ + +.INCLUDE: target.mk + +RUN: run + +run: + +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST) + + + diff --git a/sfx2/qa/complex/testdocuments/CUSTOM.odt b/sfx2/qa/complex/testdocuments/CUSTOM.odt Binary files differnew file mode 100644 index 000000000000..831a8f451dfd --- /dev/null +++ b/sfx2/qa/complex/testdocuments/CUSTOM.odt diff --git a/sfx2/qa/complex/testdocuments/TEST.odt b/sfx2/qa/complex/testdocuments/TEST.odt Binary files differnew file mode 100644 index 000000000000..7c6f0b60f7b0 --- /dev/null +++ b/sfx2/qa/complex/testdocuments/TEST.odt diff --git a/sfx2/qa/complex/testdocuments/TESTRDFA.odt b/sfx2/qa/complex/testdocuments/TESTRDFA.odt Binary files differnew file mode 100644 index 000000000000..d59739142df6 --- /dev/null +++ b/sfx2/qa/complex/testdocuments/TESTRDFA.odt diff --git a/sfx2/qa/complex/tests.sce b/sfx2/qa/complex/tests.sce new file mode 100644 index 000000000000..c38852927ede --- /dev/null +++ b/sfx2/qa/complex/tests.sce @@ -0,0 +1,3 @@ +-o complex.framework.DocumentMetaData +-o complex.framework.DocumentMetadataAccessTest +#-o complex.framework.CheckGlobalEventBroadcaster_writer1 diff --git a/sfx2/qa/unoapi/Test.java b/sfx2/qa/unoapi/Test.java new file mode 100644 index 000000000000..4263985c133f --- /dev/null +++ b/sfx2/qa/unoapi/Test.java @@ -0,0 +1,51 @@ +/************************************************************************* +* 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.sfx2.qa.unoapi; + +import org.openoffice.Runner; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + +public final class Test { + @org.junit.Before public void setUp() throws Exception { + connection.setUp(); + } + + @org.junit.After public void tearDown() + throws InterruptedException, com.sun.star.uno.Exception + { + connection.tearDown(); + } + + @org.junit.Test public void test() { + assertTrue( + Runner.run( + "-sce", "sfx.sce", "-xcl", "knownissues.xcl", "-tdoc", + "testdocuments", "-cs", connection.getDescription())); + } + + private final OfficeConnection connection = new OfficeConnection(); +} diff --git a/sfx2/qa/unoapi/knownissues.xcl b/sfx2/qa/unoapi/knownissues.xcl new file mode 100644 index 000000000000..1d87f84c96d2 --- /dev/null +++ b/sfx2/qa/unoapi/knownissues.xcl @@ -0,0 +1,5 @@ +### i23244 ### +sfx.FrameLoader::com::sun::star::frame::XSynchronousFrameLoader + +### i79149 ### +sfx.StandaloneDocumentInfo::com::sun::star::document::DocumentInfo diff --git a/sfx2/qa/unoapi/makefile.mk b/sfx2/qa/unoapi/makefile.mk new file mode 100644 index 000000000000..ea91ba4d1c44 --- /dev/null +++ b/sfx2/qa/unoapi/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. +#***********************************************************************/ + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ = ../.. +PRJNAME = sfx2 +TARGET = qa_unoapi + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = org/openoffice/sfx2/qa/unoapi +JAVATESTFILES = Test.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END + +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk + +ALLTAR : javatest + +.END diff --git a/sfx2/qa/unoapi/sfx.sce b/sfx2/qa/unoapi/sfx.sce new file mode 100644 index 000000000000..2aaf12c25950 --- /dev/null +++ b/sfx2/qa/unoapi/sfx.sce @@ -0,0 +1,5 @@ +-o sfx.AppDispatchProvider +-o sfx.DocumentTemplates +-o sfx.FrameLoader +-o sfx.SfxMacroLoader +-o sfx.StandaloneDocumentInfo diff --git a/sfx2/qa/unoapi/testdocuments/SfxStandaloneDocInfoObject.sdw b/sfx2/qa/unoapi/testdocuments/SfxStandaloneDocInfoObject.sdw Binary files differnew file mode 100644 index 000000000000..c4b5672f9624 --- /dev/null +++ b/sfx2/qa/unoapi/testdocuments/SfxStandaloneDocInfoObject.sdw diff --git a/sfx2/qa/unoapi/testdocuments/report.stw b/sfx2/qa/unoapi/testdocuments/report.stw Binary files differnew file mode 100644 index 000000000000..5b8efafa159b --- /dev/null +++ b/sfx2/qa/unoapi/testdocuments/report.stw diff --git a/sfx2/qa/unoapi/testdocuments/report2.stw b/sfx2/qa/unoapi/testdocuments/report2.stw Binary files differnew file mode 100644 index 000000000000..9ee0a7ee0ee0 --- /dev/null +++ b/sfx2/qa/unoapi/testdocuments/report2.stw |