From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- ucb/qa/complex/tdoc/CheckContentProvider.java | 377 +++++++++++++++++++++ .../tdoc/CheckTransientDocumentsContent.java | 156 +++++++++ .../CheckTransientDocumentsContentProvider.java | 163 +++++++++ .../CheckTransientDocumentsDocumentContent.java | 178 ++++++++++ ucb/qa/complex/tdoc/TestDocument.java | 30 ++ ucb/qa/complex/tdoc/_XChild.java | 90 +++++ .../complex/tdoc/_XCommandInfoChangeNotifier.java | 50 +++ ucb/qa/complex/tdoc/_XCommandProcessor.java | 237 +++++++++++++ ucb/qa/complex/tdoc/_XComponent.java | 108 ++++++ ucb/qa/complex/tdoc/_XContent.java | 68 ++++ .../complex/tdoc/_XPropertiesChangeNotifier.java | 53 +++ ucb/qa/complex/tdoc/_XPropertyContainer.java | 89 +++++ .../tdoc/_XPropertySetInfoChangeNotifier.java | 54 +++ ucb/qa/complex/tdoc/_XServiceInfo.java | 88 +++++ ucb/qa/complex/tdoc/_XTypeProvider.java | 84 +++++ ucb/qa/complex/tdoc/interfaces/makefile.mk | 54 +++ ucb/qa/complex/tdoc/makefile.mk | 64 ++++ ucb/qa/complex/tdoc/test_documents/Iterator.sxw | Bin 0 -> 5627 bytes ucb/qa/complex/tdoc/test_documents/chinese.sxw | Bin 0 -> 5757 bytes ucb/qa/complex/tdoc/test_documents/filter.sxw | Bin 0 -> 14359 bytes ucb/qa/complex/ucb/UCB.java | 151 +++++++++ ucb/qa/complex/ucb/makefile.mk | 53 +++ ucb/qa/cppunit/webdav/webdav_local_neon.cxx | 96 ++++++ ucb/qa/cppunit/webdav/webdav_options.cxx | 367 ++++++++++++++++++++ ucb/qa/cppunit/webdav/webdav_propfindcache.cxx | 133 ++++++++ ucb/qa/cppunit/webdav/webdav_resource_access.cxx | 103 ++++++ ucb/qa/unoapi/knownissues.xcl | 19 ++ ucb/qa/unoapi/ucb.sce | 28 ++ 28 files changed, 2893 insertions(+) create mode 100644 ucb/qa/complex/tdoc/CheckContentProvider.java create mode 100644 ucb/qa/complex/tdoc/CheckTransientDocumentsContent.java create mode 100644 ucb/qa/complex/tdoc/CheckTransientDocumentsContentProvider.java create mode 100644 ucb/qa/complex/tdoc/CheckTransientDocumentsDocumentContent.java create mode 100644 ucb/qa/complex/tdoc/TestDocument.java create mode 100644 ucb/qa/complex/tdoc/_XChild.java create mode 100644 ucb/qa/complex/tdoc/_XCommandInfoChangeNotifier.java create mode 100644 ucb/qa/complex/tdoc/_XCommandProcessor.java create mode 100644 ucb/qa/complex/tdoc/_XComponent.java create mode 100644 ucb/qa/complex/tdoc/_XContent.java create mode 100644 ucb/qa/complex/tdoc/_XPropertiesChangeNotifier.java create mode 100644 ucb/qa/complex/tdoc/_XPropertyContainer.java create mode 100644 ucb/qa/complex/tdoc/_XPropertySetInfoChangeNotifier.java create mode 100644 ucb/qa/complex/tdoc/_XServiceInfo.java create mode 100644 ucb/qa/complex/tdoc/_XTypeProvider.java create mode 100644 ucb/qa/complex/tdoc/interfaces/makefile.mk create mode 100644 ucb/qa/complex/tdoc/makefile.mk create mode 100644 ucb/qa/complex/tdoc/test_documents/Iterator.sxw create mode 100644 ucb/qa/complex/tdoc/test_documents/chinese.sxw create mode 100644 ucb/qa/complex/tdoc/test_documents/filter.sxw create mode 100644 ucb/qa/complex/ucb/UCB.java create mode 100644 ucb/qa/complex/ucb/makefile.mk create mode 100644 ucb/qa/cppunit/webdav/webdav_local_neon.cxx create mode 100644 ucb/qa/cppunit/webdav/webdav_options.cxx create mode 100644 ucb/qa/cppunit/webdav/webdav_propfindcache.cxx create mode 100644 ucb/qa/cppunit/webdav/webdav_resource_access.cxx create mode 100644 ucb/qa/unoapi/knownissues.xcl create mode 100644 ucb/qa/unoapi/ucb.sce (limited to 'ucb/qa') diff --git a/ucb/qa/complex/tdoc/CheckContentProvider.java b/ucb/qa/complex/tdoc/CheckContentProvider.java new file mode 100644 index 000000000..56445712e --- /dev/null +++ b/ucb/qa/complex/tdoc/CheckContentProvider.java @@ -0,0 +1,377 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.tdoc; + +import com.sun.star.beans.XPropertiesChangeNotifier; +import com.sun.star.beans.XPropertyContainer; +import com.sun.star.beans.XPropertySetInfoChangeNotifier; +import com.sun.star.container.XChild; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.XTypeProvider; +import com.sun.star.text.XTextDocument; +import com.sun.star.ucb.XCommandInfoChangeNotifier; +import com.sun.star.ucb.XCommandProcessor; +import com.sun.star.ucb.XContent; +import com.sun.star.ucb.XContentIdentifier; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.ucb.XContentProvider; +import com.sun.star.uno.UnoRuntime; + +import util.WriterTools; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; + +import static org.junit.Assert.*; + +/** + * Check the TransientDocumentsContentProvider (TDOC). Three documents are + * loaded. Then every possible TDCP content type is instantiated and its + * interfaces are tested.
+ * Important: opened documents are numbered in the order they are opened and + * numbers are not reused. This test will work only, if you start a new office + * with an accept parameter (writer is initially opened). Otherwise loaded + * documents are not found. + */ +public class CheckContentProvider { + private final String testDocuments[] = new String[]{"filter.sxw", "chinese.sxw", "Iterator.sxw"}; + private final int countDocs = testDocuments.length; + private XMultiServiceFactory xMSF = null; + private XTextDocument[] xTextDoc = null; + private XContent xContent = null; + + + /** + * Open some documents before the test + */ + @Before public void before() { + xMSF = getMSF(); + xTextDoc = new XTextDocument[countDocs]; + System.out.println("Open some new documents."); + for (int i=0; i + *
  • XTypeProvider
  • + *
  • XServiceInfo
  • + *
  • XCommandProcessor
  • + *
  • XChild
  • + *
  • XPropertiesChangeNotifier
  • + *
  • XPropertySetInfoChangeNotifier
  • + *
  • XCommandInfoChangeNotifier
  • + *
  • XContent
  • + *
  • XPropertyContainer
  • + *
  • XComponent
  • + * + * @param hasParent True, if the tested content type does have a parent: + * only the root has not. Used in the XChild interface test. + */ + private void checkInterfaces(boolean hasParent) throws Exception { + // check the XTypeProvider interface + _XTypeProvider xTypeProvider = new _XTypeProvider(); + _XTypeProvider.oObj = UnoRuntime.queryInterface(XTypeProvider.class, xContent); + // xTypeProvider.log = log; + assertNotNull("getImplementationId()", xTypeProvider._getImplementationId()); + assertNotNull("getTypes()", xTypeProvider._getTypes()); + + // check the XServiceInfo interface + _XServiceInfo xServiceInfo = new _XServiceInfo(); + _XServiceInfo.oObj = UnoRuntime.queryInterface(XServiceInfo.class, xContent); + // xServiceInfo.log = log; + assertNotNull("getImplementationName()", xServiceInfo._getImplementationName()); + assertNotNull("getSupportedServiceNames()", xServiceInfo._getSupportedServiceNames()); + assertNotNull("supportsService()", xServiceInfo._supportsService()); + + // check the XCommandProcessor interface + _XCommandProcessor xCommandProcessor = new _XCommandProcessor(); + xCommandProcessor.oObj = UnoRuntime.queryInterface(XCommandProcessor.class, xContent); + // xCommandProcessor.log = log; + xCommandProcessor.before(getMSF()); + assertNotNull("createCommandIdentifier()", xCommandProcessor._createCommandIdentifier()); + assertNotNull("execute()", xCommandProcessor._execute()); + assertNotNull("abort()", xCommandProcessor._abort()); + + // check the XChild interface + _XChild xChild = new _XChild(); + xChild.oObj = UnoRuntime.queryInterface(XChild.class, xContent); + // hasParent determines if this content has a parent + assertNotNull("getParent()", xChild._getParent(hasParent)); + // parameter does determine, if this function is supported: generally not supported with tdcp content + assertNotNull("setParent()", xChild._setParent(false)); + + // check the XPropertyChangeNotifier interface + _XPropertiesChangeNotifier xPropChange = new _XPropertiesChangeNotifier(); + xPropChange.oObj = UnoRuntime.queryInterface(XPropertiesChangeNotifier.class, xContent); + assertNotNull("addPropertiesChangeListener()", xPropChange._addPropertiesChangeListener()); + assertNotNull("removePropertiesChangeListener()", xPropChange._removePropertiesChangeListener()); + + // check the XPropertySetInfoChangeNotifier interface + _XPropertySetInfoChangeNotifier xPropSetInfo = new _XPropertySetInfoChangeNotifier(); + xPropSetInfo.oObj = UnoRuntime.queryInterface(XPropertySetInfoChangeNotifier.class, xContent); + // xPropSetInfo.log = log; + assertNotNull("addPropertiesChangeListener()", xPropSetInfo._addPropertiesChangeListener()); + assertNotNull("removePropertiesChangeListener()", xPropSetInfo._removePropertiesChangeListener()); + + // check the XCommandInfoChangeNotifier interface + _XCommandInfoChangeNotifier xCommandChange = new _XCommandInfoChangeNotifier(); + xCommandChange.oObj = UnoRuntime.queryInterface(XCommandInfoChangeNotifier.class, xContent); + // xCommandChange.log = log; + assertNotNull("addCommandInfoChangeListener()", xCommandChange._addCommandInfoChangeListener()); + assertNotNull("removeCommandInfoChangeListener()", xCommandChange._removeCommandInfoChangeListener()); + + // check the XContent interface + _XContent xCont = new _XContent(); + xCont.oObj = UnoRuntime.queryInterface(XContent.class, xContent); + // xCont.log = log; + assertNotNull("addContentEventListener()", xCont._addContentEventListener()); + assertNotNull("getContentType()", xCont._getContentType()); + assertNotNull("getIdentifier()", xCont._getIdentifier()); + assertNotNull("removeContentEventListener()", xCont._removeContentEventListener()); + + // check the XPropertyContainer interface + _XPropertyContainer xPropCont = new _XPropertyContainer(); + xPropCont.oObj = UnoRuntime.queryInterface(XPropertyContainer.class, xContent); + // xPropCont.log = log; + assertNotNull("addProperty()", xPropCont._addProperty()); + assertNotNull("removeProperty()", xPropCont._removeProperty()); + + // check the XComponent interface + _XComponent xComponent = new _XComponent(); + _XComponent.oObj = UnoRuntime.queryInterface(XComponent.class, xContent); + // xComponent.log = log; + assertNotNull("addEventListener()", xComponent._addEventListener()); + assertNotNull("removeEventListener()", xComponent._removeEventListener()); + } + + + + + private XMultiServiceFactory getMSF() + { + return UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + } + + // setup and close connections + @BeforeClass public static void setUpConnection() throws Exception { + System.out.println("setUpConnection()"); + connection.setUp(); + } + + @AfterClass public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println("tearDownConnection()"); + connection.tearDown(); + } + + private static final OfficeConnection connection = new OfficeConnection(); + +} diff --git a/ucb/qa/complex/tdoc/CheckTransientDocumentsContent.java b/ucb/qa/complex/tdoc/CheckTransientDocumentsContent.java new file mode 100644 index 000000000..a5b2120b2 --- /dev/null +++ b/ucb/qa/complex/tdoc/CheckTransientDocumentsContent.java @@ -0,0 +1,156 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.tdoc; + +import com.sun.star.beans.Property; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.ucb.Command; +import com.sun.star.ucb.XCommandProcessor; +import com.sun.star.ucb.XContent; +import com.sun.star.ucb.XContentIdentifier; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.ucb.XContentProvider; +import com.sun.star.uno.UnoRuntime; +import util.WriterTools; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +/** + * + */ +public class CheckTransientDocumentsContent { + // TODO: document doesn't exists + private final String testDocuments[] = new String[]{"sForm.sxw"};//, "chinese.sxw", "Iterator.sxw"}; + private final int countDocs = testDocuments.length; + private XMultiServiceFactory xMSF = null; + private XTextDocument[] xTextDoc = null; + + public String[] getTestMethodNames() { + return new String[] {"checkTransientDocumentsContent"}; + } + + @Before public void before() { + xMSF = getMSF(); + xTextDoc = new XTextDocument[countDocs]; + System.out.println("Open some documents."); + for (int i=0; i 1) + { + fail("Implementation has been changed. Check this test!"); + } + assertTrue("The service name '" + serviceName + "' is not valid.", !serviceName.equals("com.sun.star.ucb.DynamicContentResultSet")); + + XResultSet xResultSet = xDynamicResultSet.getStaticResultSet(); + XContentAccess xContentAccess = UnoRuntime.queryInterface(XContentAccess.class, xResultSet); + // iterate over the result: three docs were opened, we should have at least three content identifier strings + int countContentIdentifiers = 0; + while(xResultSet.next()) { + countContentIdentifiers++; + String identifier = xContentAccess.queryContentIdentifierString(); + System.out.println("Identifier of row " + xResultSet.getRow() + ": " + identifier); + } + // some feeble test: if the amount >2, we're ok. + // 2do: check better + assertTrue("Did only find " + countContentIdentifiers + " open documents." + + " Should have been at least 3.", countContentIdentifiers>2); + } + catch (com.sun.star.uno.Exception e) { + e.printStackTrace(); + fail("Could not create test objects."); + } + + } + + private XMultiServiceFactory getMSF() + { + return UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + } + + // setup and close connections + @BeforeClass public static void setUpConnection() throws Exception { + System.out.println("setUpConnection()"); + connection.setUp(); + } + + @AfterClass public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println("tearDownConnection()"); + connection.tearDown(); + } + + private static final OfficeConnection connection = new OfficeConnection(); + +} diff --git a/ucb/qa/complex/tdoc/CheckTransientDocumentsDocumentContent.java b/ucb/qa/complex/tdoc/CheckTransientDocumentsDocumentContent.java new file mode 100644 index 000000000..941d68a71 --- /dev/null +++ b/ucb/qa/complex/tdoc/CheckTransientDocumentsDocumentContent.java @@ -0,0 +1,178 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.tdoc; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyValue; +import com.sun.star.document.XDocumentSubStorageSupplier; +import com.sun.star.embed.ElementModes; +import com.sun.star.embed.XStorage; +import com.sun.star.frame.XModel; +import com.sun.star.frame.XTransientDocumentsDocumentContentFactory; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XRow; +import com.sun.star.text.XTextDocument; +import com.sun.star.ucb.Command; +import com.sun.star.ucb.ContentInfo; +import com.sun.star.ucb.OpenCommandArgument2; +import com.sun.star.ucb.OpenMode; +import com.sun.star.ucb.XCommandProcessor; +import com.sun.star.ucb.XContent; +import com.sun.star.ucb.XDynamicResultSet; +import com.sun.star.uno.UnoRuntime; +import util.WriterTools; +import util.utils; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +/** + * + */ +public class CheckTransientDocumentsDocumentContent { + // TODO: document doesn't exists + private static final String testDocuments = "sForm.sxw"; + private static final String folderName = "TestFolder"; + private XMultiServiceFactory xMSF = null; + private XTextDocument xTextDoc = null; + + @Before public void before() { + xMSF = getMSF(); + System.out.println("Open a document."); + String fileName = TestDocument.getUrl(testDocuments); + xTextDoc = WriterTools.loadTextDoc(xMSF, fileName); + assertNotNull(xTextDoc); + } + @After public void after() { + System.out.println("Close all documents."); + xTextDoc.dispose(); + } + + /** + * Check the provider of document content: open some documents + * and look if they are accessible. + */ + @Test public void checkTransientDocumentsDocumentContent() { + try { + // create a content provider + Object o = xMSF.createInstance("com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory"); + + XTransientDocumentsDocumentContentFactory xTransientDocumentsDocumentContentFactory = + UnoRuntime.queryInterface(XTransientDocumentsDocumentContentFactory.class, o); + // get the model from the opened document + XModel xModel = xTextDoc.getCurrentController().getModel(); + + // a little additional check for 114733 + XDocumentSubStorageSupplier xDocumentSubStorageSupplier = UnoRuntime.queryInterface(XDocumentSubStorageSupplier.class, xModel); + String[]names = xDocumentSubStorageSupplier.getDocumentSubStoragesNames(); + for (int i=0; icom.sun.star.container.XChild +* interface methods : +*
      +*
    • getParent()
    • +*
    • setParent()
    • +*
    +* @see com.sun.star.container.XChild +*/ +public class _XChild { + + public XChild oObj = null; + private Object gotten = null; + private final LogWriter log = null; + + + /** + * Test calls the method and checks return value and that + * no exceptions were thrown. Parent returned is stored.

    + * Has OK status if the method returns not null value + * and no exceptions were thrown.

    + */ + public boolean _getParent(boolean hasParent) { + gotten = oObj.getParent(); + if (!hasParent) + return gotten == null; + XNamed the_name = UnoRuntime.queryInterface(XNamed.class,gotten); + if (the_name != null) + log.println("Parent:"+the_name.getName()); + return gotten != null; + } + + /** + * Sets existing parent and checks that + * no exceptions were thrown.

    + * Has OK status if no exceptions were thrown.

    + * The following method tests are to be completed successfully before : + *

      + *
    • getParent() : to get the parent.
    • + *
    + */ + public boolean _setParent(boolean supported) { + String parentComment = null;//String) tEnv.getObjRelation("cannotSwitchParent"); + + if (parentComment != null) { + log.println(parentComment); + return true; + } + + try { + oObj.setParent(gotten); + } + catch (com.sun.star.lang.NoSupportException ex) { + log.println("Exception occurred during setParent() - " + (supported?"FAILED":"OK")); + if (supported) { + ex.printStackTrace((java.io.PrintWriter)log); + return false; + } + } + return true; + } + +} // finish class _XChild + + diff --git a/ucb/qa/complex/tdoc/_XCommandInfoChangeNotifier.java b/ucb/qa/complex/tdoc/_XCommandInfoChangeNotifier.java new file mode 100644 index 000000000..01297c093 --- /dev/null +++ b/ucb/qa/complex/tdoc/_XCommandInfoChangeNotifier.java @@ -0,0 +1,50 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.tdoc; + +import com.sun.star.ucb.XCommandInfoChangeListener; +import com.sun.star.ucb.XCommandInfoChangeNotifier; + +/** + * + */ +public class _XCommandInfoChangeNotifier { + public XCommandInfoChangeNotifier oObj = null; + + private final CommandInfoChangeListener listener = new CommandInfoChangeListener(); + + public boolean _addCommandInfoChangeListener() { + oObj.addCommandInfoChangeListener(listener); + return true; + } + + public boolean _removeCommandInfoChangeListener() { + oObj.removeCommandInfoChangeListener(listener); + return true; + } + + private class CommandInfoChangeListener implements XCommandInfoChangeListener { + + public void commandInfoChange(com.sun.star.ucb.CommandInfoChangeEvent commandInfoChangeEvent) { + } + + public void disposing(com.sun.star.lang.EventObject eventObject) { + } + + } +} diff --git a/ucb/qa/complex/tdoc/_XCommandProcessor.java b/ucb/qa/complex/tdoc/_XCommandProcessor.java new file mode 100644 index 000000000..222a34e2f --- /dev/null +++ b/ucb/qa/complex/tdoc/_XCommandProcessor.java @@ -0,0 +1,237 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.tdoc; + +import com.sun.star.beans.Property; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.Command; +import com.sun.star.ucb.CommandAbortedException; +import com.sun.star.ucb.CommandInfo; +import com.sun.star.ucb.GlobalTransferCommandArgument; +import com.sun.star.ucb.NameClash; +import com.sun.star.ucb.TransferCommandOperation; +import com.sun.star.ucb.XCommandInfo; +import com.sun.star.ucb.XCommandProcessor; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import share.LogWriter; + +/** +* Tests XCommandProcessor. The TestCase can pass (but doesn't have +* to) "XCommandProcessor.AbortCommand" relation, to specify command to abort in +* abort() test. +* +* Testing com.sun.star.ucb.XCommandProcessor +* interface methods : +*
      +*
    • createCommandIdentifier()
    • +*
    • execute()
    • +*
    • abort()
    • +*

    +* This test needs the following object relations : +*

      +*
    • 'XCommandProcessor.AbortCommand' optional +* (of type com.sun.star.ucb.Command): +* specify command to abort in abort() test. +* If the relation is not specified the 'GlobalTransfer' +* command is used.
    • +*

        +* The following predefined files needed to complete the test: +*

          +*
        • poliball.gif : this file is required in case +* if the relation 'XCommandProcessor.AbortCommand' +* is not specified. This file is used by 'GlobalTransfer' +* command as a source file for copying.
        • +*

            +* Test is NOT multithread compliant.

            +* @see com.sun.star.ucb.XCommandProcessor +*/ +public class _XCommandProcessor { + + /** + * Contains the tested object. + */ + public XCommandProcessor oObj; + private final LogWriter log = null; + private XMultiServiceFactory xMSF = null; + + /** + * Contains the command id returned by createCommandIdentifier() + * . It is used in abort() test. + */ + private int cmdId; + + public void before(XMultiServiceFactory _xMSF) { + xMSF = _xMSF; + } + + /** + * Tests createCommandIdentifier(). Calls it for two times + * and checks returned values.

            + * Has OK status if values are unique correct identifiers: not 0. + */ + public boolean _createCommandIdentifier() { + log.println("creating a command line identifier"); + + int testCmdId = oObj.createCommandIdentifier(); + cmdId = oObj.createCommandIdentifier(); + + if (cmdId == 0 || testCmdId == 0) { + log.println("createCommandLineIdentifier() returned 0 - FAILED"); + } + + if (cmdId == testCmdId) { + log.println("the command identifier is not unique"); + } + + return testCmdId != 0 && cmdId != 0 && cmdId != testCmdId; + } + + /** + * First executes 'geCommandInfo' command and examines returned + * command info information. Second tries to execute in proper + * command.

            + * Has OK status if in the first case returned information + * contains info about 'getCommandInfo' command and in the second + * case an exception is thrown.

            + */ + public boolean _execute() throws Exception { + String[]commands = new String[] {"getCommandInfo", "getPropertySetInfo"}; + boolean returnVal = true; + for (int j=0; jabort method + * is called permanently. Then a "long" command (for example, + * "transfer") is started. I case if relation is not + * specified 'GlobalTransfer' command starts to + * copy a file to temporary directory (if the relation is present + * then the its command starts to work).

            + * Has OK status if the command execution is aborted, i.e. + * CommandAbortedException is thrown.

            + * The following method tests are to be completed successfully before : + *

              + *
            • createCommandIdentifier() : to have a unique + * identifier which is used to abort started command.
            • + *
            + */ + public boolean _abort() { + + Command command = new Command("getCommandInfo", -1, null); + + String commandName = "globalTransfer"; + + String srcURL = util.utils.getFullTestURL("solibrary.jar") ; + String tmpURL = util.utils.getOfficeTemp(xMSF) ; + log.println("Copying '" + srcURL + "' to '" + tmpURL) ; + + GlobalTransferCommandArgument arg = new + GlobalTransferCommandArgument( + TransferCommandOperation.COPY, srcURL, + tmpURL, "", NameClash.OVERWRITE); + + command = new Command(commandName, -1, arg); + + Thread aborter = new Thread() { + @Override + public void run() { + for (int i = 0; i < 10; i++) { + log.println("try to abort command"); + oObj.abort(cmdId); + util.utils.pause(10); + } + } + }; + + aborter.start(); + + util.utils.pause(15); + + log.println("executing command"); + try { + oObj.execute(command, cmdId, null); + log.println("Command execution completed"); + log.println("CommandAbortedException is not thrown"); + log.println("This is OK since there is no command implemented "+ + "that can be aborted"); + } catch (CommandAbortedException e) { + return true; + } catch (Exception e) { + log.println("Unexpected exception " + e.getMessage()); + e.printStackTrace((java.io.PrintWriter)log); + return false; + } + + try { + aborter.join(5000); + aborter.interrupt(); + } catch(InterruptedException e) { + } + return true; + } +} diff --git a/ucb/qa/complex/tdoc/_XComponent.java b/ucb/qa/complex/tdoc/_XComponent.java new file mode 100644 index 000000000..1f86128ff --- /dev/null +++ b/ucb/qa/complex/tdoc/_XComponent.java @@ -0,0 +1,108 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.tdoc; + +import com.sun.star.lang.EventObject; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XEventListener; +import share.LogWriter; + +/** +* Testing com.sun.star.lang.XComponent +* interface methods : +*
              +*
            • dispose()
            • +*
            • addEventListener()
            • +*
            • removeEventListener()
            • +*
            +* After this interface test object must be recreated.

            +* Multithreaded test ability not implemented yet. +* @see com.sun.star.lang.XComponent +*/ +public class _XComponent { + + public static XComponent oObj = null; + private final LogWriter log = null; + + private boolean listenerDisposed[] = new boolean[2]; + private String[] Loutput = new String[2]; + + /** + * Listener which added but not removed, and its method must be called + * on dispose call. + */ + private class MyEventListener implements XEventListener { + public void disposing ( EventObject oEvent ) { + Loutput[0] = Thread.currentThread() + " is DISPOSING EV1" + this; + listenerDisposed[0] = true; + } + } + + /** + * Listener which added and then removed, and its method must not + * be called on dispose call. + */ + private class MyEventListener2 implements XEventListener { + public void disposing ( EventObject oEvent ) { + Loutput[0] = Thread.currentThread() + " is DISPOSING EV2" + this; + listenerDisposed[1] = true; + } + } + + private final XEventListener listener1 = new MyEventListener(); + private final XEventListener listener2 = new MyEventListener2(); + + /** + * Adds two listeners.

            + * Has OK status if then the first listener will receive an event + * on dispose method call. + */ + public boolean _addEventListener() { + + listenerDisposed[0] = false; + listenerDisposed[1] = false; + + oObj.addEventListener( listener1 ); + oObj.addEventListener( listener2 ); + + return true; + } // finished _addEventListener() + + /** + * Removes the second of two added listeners.

            + * Method tests to be completed successfully : + *

              + *
            • addEventListener : method must add two listeners.
            • + *

            + * Has OK status if no events will be sent to the second listener on + * dispose method call. + */ + public boolean _removeEventListener() { + if (disposed) return true; + // the second listener should not be called + oObj.removeEventListener( listener2 ); + log.println(Thread.currentThread() + " is removing EL " + listener2); + return true; + } // finished _removeEventListener() + + private boolean disposed = false; + +} // finished class _XComponent + + diff --git a/ucb/qa/complex/tdoc/_XContent.java b/ucb/qa/complex/tdoc/_XContent.java new file mode 100644 index 000000000..327439c85 --- /dev/null +++ b/ucb/qa/complex/tdoc/_XContent.java @@ -0,0 +1,68 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.tdoc; + +import com.sun.star.ucb.XContent; +import com.sun.star.ucb.XContentEventListener; +import com.sun.star.ucb.XContentIdentifier; +import share.LogWriter; + +public class _XContent { + public XContent oObj = null; + private final LogWriter log = null; + private ContentListener listener = null; + + public boolean _addContentEventListener() { + listener = new ContentListener(); + oObj.addContentEventListener(listener); + return true; + } + public boolean _getContentType() { + String type = oObj.getContentType(); + log.println("Type: " + type); + return type != null && type.indexOf("vnd.sun.star.tdoc") != -1; + } + public boolean _getIdentifier() { + XContentIdentifier xIdent = oObj.getIdentifier(); + String id = xIdent.getContentIdentifier(); + String scheme = xIdent.getContentProviderScheme(); + log.println("Id: " + id); + log.println("Scheme: " + scheme); + return id != null && scheme != null && id.indexOf("vnd.sun.star.tdoc") != -1 && scheme.indexOf("vnd.sun.star.tdoc") != -1; + } + public boolean _removeContentEventListener() { + System.out.println("Event: " + (listener.disposed || listener.firedEvent)); + oObj.removeContentEventListener(listener); + return true; + } + + + private class ContentListener implements XContentEventListener { + private boolean disposed = false; + private boolean firedEvent = false; + + public void contentEvent(com.sun.star.ucb.ContentEvent contentEvent) { + firedEvent = true; + } + + public void disposing(com.sun.star.lang.EventObject eventObject) { + disposed = true; + } + + } +} diff --git a/ucb/qa/complex/tdoc/_XPropertiesChangeNotifier.java b/ucb/qa/complex/tdoc/_XPropertiesChangeNotifier.java new file mode 100644 index 000000000..14d9639cd --- /dev/null +++ b/ucb/qa/complex/tdoc/_XPropertiesChangeNotifier.java @@ -0,0 +1,53 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.tdoc; + +import com.sun.star.beans.XPropertiesChangeListener; +import com.sun.star.beans.XPropertiesChangeNotifier; + +/** + * Check the XPropertiesChangeNotifier + */ +public class _XPropertiesChangeNotifier { + public XPropertiesChangeNotifier oObj = null; + + + private final PropertiesChangeListener listener = new PropertiesChangeListener(); + private String[] args; + + + public boolean _addPropertiesChangeListener() { + oObj.addPropertiesChangeListener(args, listener); + return true; + } + + public boolean _removePropertiesChangeListener() { + oObj.removePropertiesChangeListener(args, listener); + return true; + } + + private class PropertiesChangeListener implements XPropertiesChangeListener { + + public void disposing(com.sun.star.lang.EventObject eventObject) { + } + + public void propertiesChange(com.sun.star.beans.PropertyChangeEvent[] propertyChangeEvent) { + } + + } +} diff --git a/ucb/qa/complex/tdoc/_XPropertyContainer.java b/ucb/qa/complex/tdoc/_XPropertyContainer.java new file mode 100644 index 000000000..a5c996b83 --- /dev/null +++ b/ucb/qa/complex/tdoc/_XPropertyContainer.java @@ -0,0 +1,89 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.tdoc; + +import com.sun.star.beans.XPropertyContainer; +import share.LogWriter; + +public class _XPropertyContainer { + public XPropertyContainer oObj = null; + private final LogWriter log = null; + + public boolean _addProperty() { + boolean result = true; + // add illegal property + try { + oObj.addProperty("MyIllegalProperty", (short)0, null); + } + catch(com.sun.star.beans.PropertyExistException e) { + e.printStackTrace((java.io.PrintWriter)log); + result = false; + } + catch(com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace((java.io.PrintWriter)log); + log.println("'IllegalArgument' Unexpected but correct."); + } + catch(com.sun.star.beans.IllegalTypeException e) { + log.println("'IllegalType' Correctly thrown"); + } + // add valid property + try { + oObj.addProperty("MyLegalProperty", (short)0, "Just a value"); + } + catch(com.sun.star.beans.PropertyExistException e) { + e.printStackTrace((java.io.PrintWriter)log); + result = false; + } + catch(com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace((java.io.PrintWriter)log); + result = false; + } + catch(com.sun.star.beans.IllegalTypeException e) { + e.printStackTrace((java.io.PrintWriter)log); + result = false; + } + return result; + } + + public boolean _removeProperty() { + boolean result = true; + try { + oObj.removeProperty("MyIllegalProperty"); + } + catch(com.sun.star.beans.UnknownPropertyException e) { + log.println("'UnknownProperty' Correctly thrown"); + } + catch(com.sun.star.beans.NotRemoveableException e) { + e.printStackTrace((java.io.PrintWriter)log); + result = false; + } + try { + oObj.removeProperty("MyLegalProperty"); + } + catch(com.sun.star.beans.UnknownPropertyException e) { + e.printStackTrace((java.io.PrintWriter)log); + result = false; + } + catch(com.sun.star.beans.NotRemoveableException e) { + e.printStackTrace((java.io.PrintWriter)log); + result = false; + } + return result; + } + +} diff --git a/ucb/qa/complex/tdoc/_XPropertySetInfoChangeNotifier.java b/ucb/qa/complex/tdoc/_XPropertySetInfoChangeNotifier.java new file mode 100644 index 000000000..f69829ce5 --- /dev/null +++ b/ucb/qa/complex/tdoc/_XPropertySetInfoChangeNotifier.java @@ -0,0 +1,54 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.tdoc; + +import com.sun.star.beans.XPropertySetInfoChangeListener; +import com.sun.star.beans.XPropertySetInfoChangeNotifier; + +/** + * + */ +public class _XPropertySetInfoChangeNotifier { + public XPropertySetInfoChangeNotifier oObj = null; + + + private final PropertySetInfoChangeListener listener = new PropertySetInfoChangeListener(); + + + + public boolean _addPropertiesChangeListener() { + oObj.addPropertySetInfoChangeListener(listener); + return true; + } + + public boolean _removePropertiesChangeListener() { + oObj.removePropertySetInfoChangeListener(listener); + return true; + } + + private class PropertySetInfoChangeListener implements XPropertySetInfoChangeListener { + + public void disposing(com.sun.star.lang.EventObject eventObject) { + } + + public void propertySetInfoChange(com.sun.star.beans.PropertySetInfoChangeEvent propertySetInfoChangeEvent) { + } + + } + +} diff --git a/ucb/qa/complex/tdoc/_XServiceInfo.java b/ucb/qa/complex/tdoc/_XServiceInfo.java new file mode 100644 index 000000000..7104e0ee2 --- /dev/null +++ b/ucb/qa/complex/tdoc/_XServiceInfo.java @@ -0,0 +1,88 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.tdoc; + +import com.sun.star.lang.XServiceInfo; +import share.LogWriter; + +/** +* Testing com.sun.star.lang.XServiceInfo +* interface methods : +*

              +*
            • getImplementationName()
            • +*
            • supportsService()
            • +*
            • getSupportedServiceNames()
            • +*

            +* Test is multithread compliant.

            +* @see com.sun.star.lang.XServiceInfo +*/ +public class _XServiceInfo { + public static XServiceInfo oObj = null; + private static String[] names = null; + private final LogWriter log = null; + + /** + * Just calls the method.

            + * Has OK status if no runtime exceptions occurred. + */ + public boolean _getImplementationName() { + boolean result = true; + log.println("testing getImplementationName() ... "); + + log.println("The ImplementationName is "+oObj.getImplementationName()); + result=true; + + return result; + + } // end getImplementationName() + + + /** + * Just calls the method.

            + * Has OK status if no runtime exceptions occurred. + */ + public boolean _getSupportedServiceNames() { + boolean result = true; + log.println("getting supported Services..."); + names = oObj.getSupportedServiceNames(); + for (int i=0;igetSupportedServiceNames method and + * calls the supportsService method with this + * name.

            + * Has OK status if true value is + * returned. + */ + public boolean _supportsService() { + log.println("testing supportsService"); + names = oObj.getSupportedServiceNames(); + return oObj.supportsService(names[0]); + } // end supportsService() +} + diff --git a/ucb/qa/complex/tdoc/_XTypeProvider.java b/ucb/qa/complex/tdoc/_XTypeProvider.java new file mode 100644 index 000000000..3d45ae798 --- /dev/null +++ b/ucb/qa/complex/tdoc/_XTypeProvider.java @@ -0,0 +1,84 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.tdoc; + +import com.sun.star.lang.XTypeProvider; +import com.sun.star.uno.Type; +import share.LogWriter; + +/** +* Testing com.sun.star.lang.XTypeProvider +* interface methods : +*

              +*
            • getTypes()
            • +*
            • getImplementationId()
            • +*

            +* Test is NOT multithread compliant.

            +* @see com.sun.star.lang.XTypeProvider +*/ +public class _XTypeProvider { + + public static XTypeProvider oObj = null; + private static Type[] types = null; + private final LogWriter log = null; + + /** + * Just calls the method.

            + * Has OK status if no runtime exceptions occurred. + */ + public boolean _getImplementationId() { + boolean result = true; + log.println("testing getImplementationId() ... "); + + log.println("The ImplementationId is "+oObj.getImplementationId()); + result = true; + + return result; + + } // end getImplementationId() + + + /** + * Calls the method and checks the return value.

            + * Has OK status if one of the return value equals to the + * type com.sun.star.lang.XTypeProvider. + */ + public boolean _getTypes() { + boolean result = false; + log.println("getting Types..."); + types = oObj.getTypes(); + for (int i=0;i"); + } + + return result; + + } // end getTypes() + +} + diff --git a/ucb/qa/complex/tdoc/interfaces/makefile.mk b/ucb/qa/complex/tdoc/interfaces/makefile.mk new file mode 100644 index 000000000..5af099835 --- /dev/null +++ b/ucb/qa/complex/tdoc/interfaces/makefile.mk @@ -0,0 +1,54 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +PRJ = ../../../.. +TARGET = TransientDocument +PRJNAME = $(TARGET) +PACKAGE = complex/tdoc/interfaces + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + + +#----- compile .java files ----------------------------------------- + +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JAVAFILES = _XChild.java \ + _XCommandInfoChangeNotifier.java \ + _XCommandProcessor.java \ + _XComponent.java \ + _XContent.java \ + _XPropertiesChangeNotifier.java \ + _XPropertyContainer.java \ + _XPropertySetInfoChangeNotifier.java \ + _XServiceInfo.java \ + _XTypeProvider.java + +#----- make a jar from compiled files ------------------------------ + +MAXLINELENGTH = 100000 + +JARCLASSDIRS = $(PACKAGE) +JARTARGET = $(TARGET).jar +JARCOMPRESS = TRUE + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + diff --git a/ucb/qa/complex/tdoc/makefile.mk b/ucb/qa/complex/tdoc/makefile.mk new file mode 100644 index 000000000..dd9da4996 --- /dev/null +++ b/ucb/qa/complex/tdoc/makefile.mk @@ -0,0 +1,64 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ = ../../.. +PRJNAME = sc +TARGET = qa_complex_tdoc + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/tdoc + +JAVATESTFILES = \ + CheckContentProvider.java \ + CheckTransientDocumentsContent.java \ + CheckTransientDocumentsContentProvider.java \ + CheckTransientDocumentsDocumentContent.java + +JAVAFILES = $(JAVATESTFILES) \ + TestDocument.java \ + _XChild.java \ + _XCommandInfoChangeNotifier.java \ + _XCommandProcessor.java \ + _XComponent.java \ + _XContent.java \ + _XPropertiesChangeNotifier.java \ + _XPropertyContainer.java \ + _XPropertySetInfoChangeNotifier.java \ + _XServiceInfo.java \ + _XTypeProvider.java + +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) + +# Sample how to debug +# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y + +.END + +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk + +ALLTAR : javatest + +.END + diff --git a/ucb/qa/complex/tdoc/test_documents/Iterator.sxw b/ucb/qa/complex/tdoc/test_documents/Iterator.sxw new file mode 100644 index 000000000..9a7f8961b Binary files /dev/null and b/ucb/qa/complex/tdoc/test_documents/Iterator.sxw differ diff --git a/ucb/qa/complex/tdoc/test_documents/chinese.sxw b/ucb/qa/complex/tdoc/test_documents/chinese.sxw new file mode 100644 index 000000000..53b242a29 Binary files /dev/null and b/ucb/qa/complex/tdoc/test_documents/chinese.sxw differ diff --git a/ucb/qa/complex/tdoc/test_documents/filter.sxw b/ucb/qa/complex/tdoc/test_documents/filter.sxw new file mode 100644 index 000000000..e4b077c65 Binary files /dev/null and b/ucb/qa/complex/tdoc/test_documents/filter.sxw differ diff --git a/ucb/qa/complex/ucb/UCB.java b/ucb/qa/complex/ucb/UCB.java new file mode 100644 index 000000000..16ee67080 --- /dev/null +++ b/ucb/qa/complex/ucb/UCB.java @@ -0,0 +1,151 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.ucb; + +import com.sun.star.beans.Property; +import com.sun.star.sdbc.XRow; +import com.sun.star.ucb.*; +import com.sun.star.uno.UnoRuntime; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + +/** + * This class is used to copy the content of a folder to + * another folder. + * There is an inconsistency with argument order. + * It should be always: dir,filename. + */ +public class UCB { + private XUniversalContentBroker ucb; + + public void init() throws Exception { + ucb = UniversalContentBroker.create(connection.getComponentContext()); + } + + public void delete(String filename) throws Exception { + executeCommand(getContent(filename), "delete", Boolean.TRUE); + } + + /** + * target name can be "", in which case the name stays lige the source name + */ + public Object executeCommand( + Object xContent, + String aCommandName, + Object aArgument) + throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception { + XCommandProcessor xCmdProcessor = + UnoRuntime.queryInterface(XCommandProcessor.class, xContent); + Command aCommand = new Command(); + aCommand.Name = aCommandName; + aCommand.Handle = -1; // not available + aCommand.Argument = aArgument; + return xCmdProcessor.execute(aCommand, 0, null); + } + + public Object getContentProperty( + Object content, + String propName, + Class type) + throws Exception { + Property[] pv = new Property[1]; + pv[0] = new Property(); + pv[0].Name = propName; + pv[0].Handle = -1; + + Object row = executeCommand(content, "getPropertyValues", pv); + XRow xrow = UnoRuntime.queryInterface(XRow.class, row); + if (type.equals(String.class)) + { + return xrow.getString(1); + } + else if (type.equals(Boolean.class)) + { + return xrow.getBoolean(1) ? Boolean.TRUE : Boolean.FALSE; + } + else if (type.equals(Integer.class)) + { + return Integer.valueOf(xrow.getInt(1)); + } + else if (type.equals(Short.class)) + { + return Short.valueOf(xrow.getShort(1)); + } + else + { + return null; + } + + } + + public Object getContent(String path) throws Exception + { + XContentIdentifier id = ucb.createContentIdentifier(path); + return ucb.queryContent(id); + } + + @Test public void checkWrongFtpConnection() { + try { + String acountUrl = "ftp://noname:nopasswd@*nohost.invalid"; + System.out.println(acountUrl); + init(); + Object content = getContent(acountUrl); + + OpenCommandArgument2 aArg = new OpenCommandArgument2(); + aArg.Mode = OpenMode.ALL; // FOLDER, DOCUMENTS -> simple filter + aArg.Priority = 32768; // Ignored by most implementations + + System.out.println("now executing open"); + executeCommand(content, "open", aArg); + fail("Expected exception 'IllegalArgumentException' or 'IllegalIdentifierException' was not thrown."); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + // correct + } catch (com.sun.star.ucb.IllegalIdentifierException ex) { + // correct + } catch(com.sun.star.ucb.InteractiveNetworkException ex) { + System.out.println("This Exception is correctly thrown when no Proxy in StarOffice is used."); + System.out.println("To reproduce the bug behaviour, use a Proxy and try again."); + } catch (Exception ex) { + ex.printStackTrace(); + String exceptionName = ex.toString(); + System.out.println("ExName: '"+exceptionName+"'"); + fail("Wrong exception thrown: " + exceptionName); + } + } + + // setup and close connections + @BeforeClass public static void setUpConnection() throws Exception { + System.out.println("setUpConnection()"); + connection.setUp(); + } + + @AfterClass public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println("tearDownConnection()"); + connection.tearDown(); + } + + private static final OfficeConnection connection = new OfficeConnection(); + +} diff --git a/ucb/qa/complex/ucb/makefile.mk b/ucb/qa/complex/ucb/makefile.mk new file mode 100644 index 000000000..401576c9c --- /dev/null +++ b/ucb/qa/complex/ucb/makefile.mk @@ -0,0 +1,53 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ = ../../.. +PRJNAME = UCB +TARGET = qa_complex_ucb + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/ucb +JAVATESTFILES = \ + UCB.java + +JAVAFILES = $(JAVATESTFILES) + +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar jurt.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) + +# Sample how to debug +# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y +.END + +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk + +ALLTAR : javatest + +.END + + + + + + diff --git a/ucb/qa/cppunit/webdav/webdav_local_neon.cxx b/ucb/qa/cppunit/webdav/webdav_local_neon.cxx new file mode 100644 index 000000000..bde7652b9 --- /dev/null +++ b/ucb/qa/cppunit/webdav/webdav_local_neon.cxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include + +using namespace http_dav_ucp; + +namespace +{ + + class webdav_local_test: public CppUnit::TestFixture + { + + public: + void WebdavUriTest(); + void WebdavUriTest2(); + + // Change the following lines only, if you add, remove or rename + // member functions of the current class, + // because these macros are need by auto register mechanism. + + CPPUNIT_TEST_SUITE( webdav_local_test ); + CPPUNIT_TEST( WebdavUriTest ); + CPPUNIT_TEST( WebdavUriTest2 ); + CPPUNIT_TEST_SUITE_END(); + }; // class webdav_local_test + + void webdav_local_test::WebdavUriTest() + { + //try URL decomposition + CurlUri aURI(u"http://user%40anothername@server.biz:8040/aService/asegment/nextsegment/check.this?test=true&link=http://anotherserver.com/%3Fcheck=theapplication%26os=linuxintel%26lang=en-US%26version=5.2.0" ); + CPPUNIT_ASSERT_EQUAL( OUString( "http" ), aURI.GetScheme() ); + CPPUNIT_ASSERT_EQUAL( OUString( "server.biz" ), aURI.GetHost() ); + CPPUNIT_ASSERT_EQUAL( OUString( "user%40anothername" ), aURI.GetUser() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 8040 ), aURI.GetPort() ); + CPPUNIT_ASSERT_EQUAL( OUString( "/aService/asegment/nextsegment/check.this?test=true&link=http://anotherserver.com/%3Fcheck=theapplication%26os=linuxintel%26lang=en-US%26version=5.2.0" ), aURI.GetRelativeReference() ); + + CurlUri uri2(aURI.CloneWithRelativeRefPathAbsolute(u"/foo/bar")); + CPPUNIT_ASSERT_EQUAL( OUString("http"), uri2.GetScheme() ); + CPPUNIT_ASSERT_EQUAL( OUString("server.biz"), uri2.GetHost() ); + CPPUNIT_ASSERT_EQUAL( OUString("user%40anothername"), uri2.GetUser() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16(8040), uri2.GetPort() ); + CPPUNIT_ASSERT_EQUAL( OUString("/foo/bar"), uri2.GetRelativeReference() ); + CPPUNIT_ASSERT_EQUAL( OUString("http://user%40anothername@server.biz:8040/foo/bar"), uri2.GetURI() ); + + CurlUri uri3(aURI.CloneWithRelativeRefPathAbsolute(u"?query#fragment")); + CPPUNIT_ASSERT_EQUAL( OUString("http"), uri3.GetScheme() ); + CPPUNIT_ASSERT_EQUAL( OUString("server.biz"), uri3.GetHost() ); + CPPUNIT_ASSERT_EQUAL( OUString("user%40anothername"), uri3.GetUser() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16(8040), uri3.GetPort() ); + CPPUNIT_ASSERT_EQUAL( OUString("?query#fragment"), uri3.GetRelativeReference() ); + CPPUNIT_ASSERT_EQUAL( OUString("http://user%40anothername@server.biz:8040/?query#fragment"), uri3.GetURI() ); + } + + void webdav_local_test::WebdavUriTest2() + { + CurlUri aURI(u"https://foo:bar@server.biz:8040/aService#aaa" ); + CPPUNIT_ASSERT_EQUAL( OUString("https"), aURI.GetScheme() ); + CPPUNIT_ASSERT_EQUAL( OUString("server.biz"), aURI.GetHost() ); + CPPUNIT_ASSERT_EQUAL( OUString("foo"), aURI.GetUser() ); + CPPUNIT_ASSERT_EQUAL( OUString("bar"), aURI.GetPassword() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 8040 ), aURI.GetPort() ); + CPPUNIT_ASSERT_EQUAL( OUString( "/aService#aaa" ), aURI.GetRelativeReference() ); + + CurlUri uri2(aURI.CloneWithRelativeRefPathAbsolute(u"/foo/bar")); + CPPUNIT_ASSERT_EQUAL( OUString("https"), uri2.GetScheme() ); + CPPUNIT_ASSERT_EQUAL( OUString("server.biz"), uri2.GetHost() ); + CPPUNIT_ASSERT_EQUAL( OUString("foo"), uri2.GetUser() ); + CPPUNIT_ASSERT_EQUAL( OUString("bar"), uri2.GetPassword() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 8040 ), uri2.GetPort() ); + CPPUNIT_ASSERT_EQUAL( OUString("/foo/bar"), uri2.GetRelativeReference() ); + CPPUNIT_ASSERT_EQUAL( OUString("https://foo:bar@server.biz:8040/foo/bar"), uri2.GetURI() ); + + CurlUri uri3(aURI.CloneWithRelativeRefPathAbsolute(u"?query")); + CPPUNIT_ASSERT_EQUAL( OUString("https"), uri3.GetScheme() ); + CPPUNIT_ASSERT_EQUAL( OUString("server.biz"), uri3.GetHost() ); + CPPUNIT_ASSERT_EQUAL( OUString("foo"), uri3.GetUser() ); + CPPUNIT_ASSERT_EQUAL( OUString("bar"), uri3.GetPassword() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16(8040), uri3.GetPort() ); + CPPUNIT_ASSERT_EQUAL( OUString("?query"), uri3.GetRelativeReference() ); + CPPUNIT_ASSERT_EQUAL( OUString("https://foo:bar@server.biz:8040/?query"), uri3.GetURI() ); + } + + CPPUNIT_TEST_SUITE_REGISTRATION( webdav_local_test ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/qa/cppunit/webdav/webdav_options.cxx b/ucb/qa/cppunit/webdav/webdav_options.cxx new file mode 100644 index 000000000..d8e3d0946 --- /dev/null +++ b/ucb/qa/cppunit/webdav/webdav_options.cxx @@ -0,0 +1,367 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include + +using namespace http_dav_ucp; + +namespace +{ + + class webdav_opts_test: public test::BootstrapFixture + { + + public: + webdav_opts_test() : BootstrapFixture( true, true ) {} + + // initialise your test code values here. + void setUp( ) override; + + void tearDown( ) override; + + void DAVTypesCheckInit( DAVOptions const & aDavType ); + void DAVTypesTest(); + + void DAVOptsCacheTests(); + + // Change the following lines only, if you add, remove or rename + // member functions of the current class, + // because these macros are need by auto register mechanism. + + CPPUNIT_TEST_SUITE( webdav_opts_test ); + CPPUNIT_TEST( DAVTypesTest ); + CPPUNIT_TEST( DAVOptsCacheTests ); + CPPUNIT_TEST_SUITE_END(); + }; // class webdav_local_test + + // initialise your test code values here. + void webdav_opts_test::setUp() + { + } + + void webdav_opts_test::tearDown() + { + } + + void webdav_opts_test::DAVTypesCheckInit( DAVOptions const & aDavType ) + { + // check if the class is at reset state + // using accessors + CPPUNIT_ASSERT_EQUAL( false, aDavType.isClass1() ); + CPPUNIT_ASSERT_EQUAL( false, aDavType.isClass2() ); + CPPUNIT_ASSERT_EQUAL( false, aDavType.isClass3() ); + CPPUNIT_ASSERT_EQUAL( false, aDavType.isLocked() ); + CPPUNIT_ASSERT_EQUAL( true, aDavType.isHeadAllowed() ); + CPPUNIT_ASSERT_EQUAL( true, aDavType.getAllowedMethods().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( false, aDavType.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( true, aDavType.getURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( true, aDavType.getRedirectedURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavType.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavType.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavType.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( true, aDavType.getHttpResponseStatusText().isEmpty() ); + } + + void webdav_opts_test::DAVTypesTest() + { + //our DAVOptions + DAVOptions aDavOpt; + DAVTypesCheckInit( aDavOpt ); + + aDavOpt.setClass1(); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isClass1() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() ); + + aDavOpt.setClass1( false ); + aDavOpt.setClass2(); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isClass2() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() ); + + aDavOpt.setClass2( false ); + aDavOpt.setClass3(); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isClass3() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() ); + + aDavOpt.setClass3( false ); + + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() ); + + DAVTypesCheckInit( aDavOpt ); + //example of allowed method for a Web resource + OUString aAllowedMethods = "POST,OPTIONS,GET,HEAD,TRACE"; + aDavOpt.setAllowedMethods( aAllowedMethods ); + // now check... + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( aAllowedMethods, aDavOpt.getAllowedMethods() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() ); + + //example of allowed method for a WebDAV resource supporting LOCK + aAllowedMethods = "OPTIONS,GET,HEAD,POST,DELETE,TRACE,PROPFIND,PROPPATCH,COPY,MOVE,PUT,LOCK,UNLOCK"; + aDavOpt.setAllowedMethods( aAllowedMethods ); + // now check... + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( aAllowedMethods, aDavOpt.getAllowedMethods() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() ); + + aAllowedMethods.clear(); + aDavOpt.setAllowedMethods( aAllowedMethods ); + aDavOpt.setStaleTime( 12345678 ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 12345678 ), aDavOpt.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() ); + + aDavOpt.setStaleTime( 0 ); + + aDavOpt.setRequestedTimeLife( 300 ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 300 ), aDavOpt.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() ); + + aDavOpt.setRequestedTimeLife( 0 ); + + OUString aHTTPResponseStatusText = "522 Origin Connection Time-out"; + aDavOpt.setHttpResponseStatusCode( 522 ); + aDavOpt.setHttpResponseStatusText( aHTTPResponseStatusText ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt.getURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 522 ), aDavOpt.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( aHTTPResponseStatusText, aDavOpt.getHttpResponseStatusText() ); + + aDavOpt.setHttpResponseStatusCode( 0 ); + aHTTPResponseStatusText.clear(); + aDavOpt.setHttpResponseStatusText( aHTTPResponseStatusText ); + + OUString aURL = "http://my.server.org/a%20fake%20url/to%20test"; + aDavOpt.setURL( aURL ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( aURL, aDavOpt.getURL() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() ); + + aURL.clear(); + aDavOpt.setURL( aURL ); + aURL = "http://my.server.org/a%20fake%20url/to%20test/another-url"; + aDavOpt.setRedirectedURL( aURL ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() ); + CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() ); + CPPUNIT_ASSERT_EQUAL( aURL, aDavOpt.getRedirectedURL() ); + CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() ); + CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() ); + + //check the init() function + aAllowedMethods = "OPTIONS,GET,HEAD,POST,DELETE,TRACE,PROPFIND,PROPPATCH,COPY,MOVE,PUT,LOCK,UNLOCK"; + aURL = "http://my.server.org/a%20fake%20url/to%20test/another-url"; + aHTTPResponseStatusText = "404 Not Found"; + aDavOpt.setClass1(); + aDavOpt.setClass2(); + aDavOpt.setClass3(); + aDavOpt.setHeadAllowed( false ); + aDavOpt.setLocked(); + aDavOpt.setAllowedMethods( aAllowedMethods ); + aDavOpt.setStaleTime( 1234567 ); + aDavOpt.setRequestedTimeLife( 300 ); + aDavOpt.setURL( aURL ); + aDavOpt.setRedirectedURL( aURL ); + aDavOpt.setHttpResponseStatusCode( 404 ); + aDavOpt.setHttpResponseStatusText( aHTTPResponseStatusText ); + + aDavOpt.init(); + DAVTypesCheckInit( aDavOpt ); + // equality check + DAVOptions aDavOptTarget; + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + aDavOpt.setClass1(); + CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget ); + aDavOpt.setClass1( false ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + aDavOpt.setClass2(); + CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget ); + aDavOpt.setClass2( false ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + aDavOpt.setClass3(); + CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget ); + aDavOpt.setClass3( false ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + aDavOpt.setHeadAllowed( false ); + CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget ); + aDavOpt.setHeadAllowed(); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + aDavOpt.setLocked(); + CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget ); + aDavOpt.setLocked( false ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + aDavOpt.setStaleTime( 1234567 ); + CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget ); + aDavOpt.setStaleTime( 0 ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + aDavOpt.setRequestedTimeLife( 1234567 ); + CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget ); + aDavOpt.setRequestedTimeLife( 0 ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + aDavOpt.setHttpResponseStatusCode( 404 ); + CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget ); + aDavOpt.setHttpResponseStatusCode( 0 ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + aDavOpt.setAllowedMethods( aAllowedMethods ); + CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget ); + aAllowedMethods.clear(); + aDavOpt.setAllowedMethods( aAllowedMethods ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + aDavOpt.setURL( aURL ); + CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget ); + aURL.clear(); + aDavOpt.setURL( aURL ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + aDavOpt.setHttpResponseStatusText( aHTTPResponseStatusText ); + CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget ); + aHTTPResponseStatusText.clear(); + aDavOpt.setHttpResponseStatusText( aHTTPResponseStatusText ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget ); + + } + + void webdav_opts_test::DAVOptsCacheTests() + { + // define a local cache to test + DAVOptionsCache aDAVOptsCache; + // the value to cache + DAVOptions aDavOpt; + // the returned value to test + DAVOptions aDavOptCached; + // init the values + OUString aURL = "http://my.server.org/a%20fake%20url/to%20test/another-url"; + aDavOpt.setURL( aURL ); + aDavOpt.setRedirectedURL( "http://my.server.org/a%20fake%20url/to%20test/another-url/redirected" ); + aDavOpt.setClass1(); + aDavOpt.setClass2(); + aDavOpt.setClass3(); + aDavOpt.setHeadAllowed( false ); + aDavOpt.setAllowedMethods( "OPTIONS,GET,HEAD,POST,DELETE,TRACE,PROPFIND,PROPPATCH,COPY,MOVE,PUT,LOCK,UNLOCK" ); + // add to cache + aDAVOptsCache.addDAVOptions( aDavOpt, 30000 ); + CPPUNIT_ASSERT_EQUAL( true ,aDAVOptsCache.getDAVOptions( aURL, aDavOptCached ) ); + CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptCached ); + } + + CPPUNIT_TEST_SUITE_REGISTRATION( webdav_opts_test ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/qa/cppunit/webdav/webdav_propfindcache.cxx b/ucb/qa/cppunit/webdav/webdav_propfindcache.cxx new file mode 100644 index 000000000..da790442e --- /dev/null +++ b/ucb/qa/cppunit/webdav/webdav_propfindcache.cxx @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include + +using namespace http_dav_ucp; + +namespace +{ + + class webdav_propcache_test: public test::BootstrapFixture + { + + public: + webdav_propcache_test() : BootstrapFixture( true, true ) {} + + // initialise your test code values here. + void setUp( ) override; + + void tearDown( ) override; + + void PropfindCacheElemTests(); + void PropfindCacheTests(); + + // Change the following lines only, if you add, remove or rename + // member functions of the current class, + // because these macros are need by auto register mechanism. + + CPPUNIT_TEST_SUITE( webdav_propcache_test ); + CPPUNIT_TEST( PropfindCacheElemTests ); + CPPUNIT_TEST( PropfindCacheTests ); + CPPUNIT_TEST_SUITE_END(); + }; // class webdav_local_test + + // initialise your test code values here. + void webdav_propcache_test::setUp() + { + } + + void webdav_propcache_test::tearDown() + { + } + + void webdav_propcache_test::PropfindCacheElemTests( ) + { + OUString aTheURL( "http:://server/path/filename.odt" ); + PropertyNames aPropsNames( aTheURL ); + + CPPUNIT_ASSERT_EQUAL( aTheURL, aPropsNames.getURL() ); + CPPUNIT_ASSERT_EQUAL( static_cast< sal_uInt32 >(0), aPropsNames.getStaleTime() ); + + sal_uInt32 maxTime = static_cast< sal_uInt32 >(std::pow(2,32)-1); + + aPropsNames.setStaleTime( maxTime ); + CPPUNIT_ASSERT_EQUAL( maxTime, aPropsNames.getStaleTime() ); + + std::vector < OUString > properties { + "DAV:lockdiscovery", + "DAV:supportedlock", + "DAV:resourcetype", + "DAV:displayname", + "DAV:getlastmodified", + "DAV:getcontentlength", + "DAV:creationdate", + "DAV:getetag", + "DAV:authticket", + }; + + DAVResourceInfo aSingleInfo { properties }; + std::vector< DAVResourceInfo > aProps { aSingleInfo }; + std::vector< DAVResourceInfo > aRetProp; + + aPropsNames.setPropertiesNames( std::vector(aProps) ); + aRetProp = aPropsNames.getPropertiesNames(); + CPPUNIT_ASSERT_EQUAL( true, ( aProps == aRetProp ) ); + + aProps[0].properties.emplace_back("DAV:getlastmodified" ); + aRetProp = aPropsNames.getPropertiesNames(); + CPPUNIT_ASSERT_EQUAL( false, ( aProps == aRetProp ) ); + } + + void webdav_propcache_test::PropfindCacheTests( ) + { + PropertyNamesCache PropCache; + OUString aTheURL( "http:://server/path/filename.odt" ); + PropertyNames aPropsNames( aTheURL ); + + // check cache emptiness + CPPUNIT_ASSERT_EQUAL( false, PropCache.getCachedPropertyNames( aTheURL, aPropsNames ) ); + + std::vector < OUString > properties { + "DAV:lockdiscovery", + "DAV:supportedlock", + "DAV:resourcetype", + "DAV:displayname", + "DAV:getlastmodified", + "DAV:getcontentlength", + "DAV:creationdate", + "DAV:getetag", + "DAV:authticket", + }; + + DAVResourceInfo aSingleInfo { properties }; + std::vector< DAVResourceInfo > aProps { aSingleInfo }; + + // add the cache an element + aPropsNames.setPropertiesNames( std::vector(aProps) ); + PropCache.addCachePropertyNames( aPropsNames, 10 ); + + PropertyNames aRetPropsNames; + //test existence + CPPUNIT_ASSERT_EQUAL( true, PropCache.getCachedPropertyNames( aTheURL, aRetPropsNames ) ); + //check equality + std::vector< DAVResourceInfo > aRetProp = aRetPropsNames.getPropertiesNames(); + CPPUNIT_ASSERT_EQUAL( true, ( aProps == aRetProp ) ); + //remove from cache + PropCache.removeCachedPropertyNames( aTheURL ); + //check absence + CPPUNIT_ASSERT_EQUAL( false, PropCache.getCachedPropertyNames( aTheURL, aPropsNames ) ); + } + + CPPUNIT_TEST_SUITE_REGISTRATION( webdav_propcache_test ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/qa/cppunit/webdav/webdav_resource_access.cxx b/ucb/qa/cppunit/webdav/webdav_resource_access.cxx new file mode 100644 index 000000000..2379139c0 --- /dev/null +++ b/ucb/qa/cppunit/webdav/webdav_resource_access.cxx @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include + +using namespace http_dav_ucp; + +namespace +{ + + class webdav_resource_access_test: public test::BootstrapFixture + { + + public: + webdav_resource_access_test() : BootstrapFixture( true, true ) {} + + // initialise your test code values here. + void setUp() override; + + void tearDown() override; + + void DAVCheckRetries(); + + // Change the following lines only, if you add, remove or rename + // member functions of the current class, + // because these macros are need by auto register mechanism. + + CPPUNIT_TEST_SUITE( webdav_resource_access_test ); + CPPUNIT_TEST( DAVCheckRetries ); + CPPUNIT_TEST_SUITE_END(); + }; // class webdav_local_test + + // initialise your test code values here. + void webdav_resource_access_test::setUp() + { + } + + void webdav_resource_access_test::tearDown() + { + } + + // test when http connection should retry + void webdav_resource_access_test::DAVCheckRetries() + { + // instantiate a resource access class + DAVResourceAccess ResourceAccess(nullptr, nullptr, "http://url"); + // first check: all http errors from 100 to 399 should return true, to force a retry + for (auto i = SC_CONTINUE; i < SC_BAD_REQUEST; i++) + { + const DAVException aTheException(DAVException::DAV_HTTP_ERROR, "http error code", i ); + CPPUNIT_ASSERT_EQUAL( true , ResourceAccess.handleException( aTheException, 1 ) ); + } + // http error code from 400 to 499 should NOT force a retry + for (auto i = SC_BAD_REQUEST; i < SC_INTERNAL_SERVER_ERROR; i++) + { + const DAVException aTheException(DAVException::DAV_HTTP_ERROR, "http error code", i ); + CPPUNIT_ASSERT_EQUAL( false , ResourceAccess.handleException( aTheException, 1 ) ); + } + + // http error code from 500 (SC_INTERNAL_SERVER_ERROR) up should force a retry + // except in special value + // 1999 as high limit is just a current (2016-09-25) choice. + // RFC poses no limit to the max value of response status code + for (auto i = SC_INTERNAL_SERVER_ERROR; i < 2000; i++) + { + const DAVException aTheException(DAVException::DAV_HTTP_ERROR, "http error code", i ); + switch ( i ) + { + // the HTTP response status codes that can be retried + case SC_BAD_GATEWAY: + case SC_GATEWAY_TIMEOUT: + case SC_SERVICE_UNAVAILABLE: + case SC_INSUFFICIENT_STORAGE: + CPPUNIT_ASSERT_EQUAL( true , ResourceAccess.handleException( aTheException, 1 ) ); + break; + // default is NOT retry + default: + CPPUNIT_ASSERT_EQUAL( false , ResourceAccess.handleException( aTheException, 1 ) ); + } + } + + // check the retry request + { + const DAVException aTheException(DAVException::DAV_HTTP_RETRY, "the-host-name", 8080 ); + CPPUNIT_ASSERT_EQUAL( true , ResourceAccess.handleException( aTheException, 1 ) ); + } + } + + CPPUNIT_TEST_SUITE_REGISTRATION( webdav_resource_access_test ); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/qa/unoapi/knownissues.xcl b/ucb/qa/unoapi/knownissues.xcl new file mode 100644 index 000000000..8f0de81ea --- /dev/null +++ b/ucb/qa/unoapi/knownissues.xcl @@ -0,0 +1,19 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# +### i86626 ### +ucb.UniversalContentBroker::com::sun::star::ucb::XCommandProcessor diff --git a/ucb/qa/unoapi/ucb.sce b/ucb/qa/unoapi/ucb.sce new file mode 100644 index 000000000..0c798cfde --- /dev/null +++ b/ucb/qa/unoapi/ucb.sce @@ -0,0 +1,28 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# +-o ucb.UcbContentProviderProxyFactory +-o ucb.UcbPropertiesManager +-o ucb.UcbStore +-o ucb.UniversalContentBroker +-o ucpchelp.CHelpContentProvider +-o ucpdav.WebDAVContentProvider +-o ucpfile.FileProvider +-o ucpftp.FTPContentProvider +-o ucphier.HierarchyContentProvider +-o ucphier.HierarchyDataSource +-o ucppkg.PackageContentProvider -- cgit v1.2.3