diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-03-16 16:37:50 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-03-16 16:39:50 +0100 |
commit | 81cdce299342254c2c272a07d807cffd6c88b0bf (patch) | |
tree | 60e50d0caee42c5289ce87fb51e0caf529f27714 /qadevOOo/runner | |
parent | 804d0a896731629397c5328c13c04a45bc55f459 (diff) |
Removed unused qadevOOo BASIC test code
Diffstat (limited to 'qadevOOo/runner')
-rw-r--r-- | qadevOOo/runner/base/basic_fat.java | 457 | ||||
-rw-r--r-- | qadevOOo/runner/basicrunner/BasicException.java | 42 | ||||
-rw-r--r-- | qadevOOo/runner/basicrunner/BasicHandler.java | 612 | ||||
-rw-r--r-- | qadevOOo/runner/basicrunner/BasicHandlerProvider.java | 153 | ||||
-rw-r--r-- | qadevOOo/runner/basicrunner/BasicIfcTest.java | 169 | ||||
-rw-r--r-- | qadevOOo/runner/basicrunner/BasicTestCase.java | 178 | ||||
-rw-r--r-- | qadevOOo/runner/basicrunner/basichelper/AttributeList.java | 138 | ||||
-rw-r--r-- | qadevOOo/runner/basicrunner/basichelper/Connector.java | 272 | ||||
-rw-r--r-- | qadevOOo/runner/basicrunner/basichelper/DispatchProviderInterceptor.java | 194 | ||||
-rw-r--r-- | qadevOOo/runner/basicrunner/basichelper/DocumentHandler.java | 344 | ||||
-rw-r--r-- | qadevOOo/runner/basicrunner/basichelper/Filter.java | 269 | ||||
-rw-r--r-- | qadevOOo/runner/basicrunner/basichelper/ThreadRunner.java | 254 |
12 files changed, 0 insertions, 3082 deletions
diff --git a/qadevOOo/runner/base/basic_fat.java b/qadevOOo/runner/base/basic_fat.java deleted file mode 100644 index 74a6708cf801..000000000000 --- a/qadevOOo/runner/base/basic_fat.java +++ /dev/null @@ -1,457 +0,0 @@ -/************************************************************************* - * - * 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 base; - - -import basicrunner.BasicIfcTest; -import basicrunner.BasicTestCase; - -import com.sun.star.lang.XMultiServiceFactory; - -import helper.APIDescGetter; -import helper.AppProvider; -import helper.OfficeProvider; -import helper.OfficeWatcher; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.PrintWriter; - -import java.util.Vector; - -import lib.TestCase; -import lib.TestEnvironment; -import lib.TestParameters; - -import share.DescEntry; -import share.DescGetter; -import share.LogWriter; - -import stats.OutProducerFactory; -import stats.Summarizer; - -import util.DynamicClassLoader; - -/** - * The testbase for executing basic tests. - * @see lib.TestBase - */ -public class basic_fat implements TestBase -{ - - public static boolean debug = false; - - /** - * Execute a test. - * @param param The test parameters. - * @return True, if the test was executed. - */ - public boolean executeTest(TestParameters param) - { - DescGetter dg = new APIDescGetter(); - String job = (String) param.get("TestJob"); - OfficeProvider office = null; - debug = param.getBool("DebugIsActive"); - - - //get Job-Descriptions - System.out.print("Getting Descriptions for Job: " + job + " from "); - - DescEntry[] entries = dg.getDescriptionFor(job, - (String) param.get( - "DescriptionPath"), - debug); - - if (entries == null) - { - System.out.println("Couldn't get Description for Job"); - - return false; - } - - String ExclusionFile = (String) param.get("ExclusionList"); - Vector exclusions = null; - - if (ExclusionFile != null) - { - exclusions = getExclusionList(ExclusionFile, debug); - } - - String conStr = (String) param.get("ConnectionString"); - System.out.println(""); - System.out.print("> Connecting the Office "); - System.out.println("With " + conStr); - - for (int l = 0; l < entries.length; l++) - { - if (entries[l].hasErrorMsg) - { - System.out.println(entries[l].ErrorMsg); - - continue; - } - - office = new OfficeProvider(); - - XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager( - param); - - if (msf == null) - { - return false; - } - - param.put("ServiceFactory", msf); - - DescEntry entry = entries[l]; - - //get some helper classes - Summarizer sumIt = new Summarizer(); - DynamicClassLoader dcl = new DynamicClassLoader(); - - TestCase tCase = null; - - tCase = (TestCase) new BasicTestCase(entry); - - if (tCase == null) - { - sumIt.summarizeDown(entry, entry.ErrorMsg); - - LogWriter sumObj = OutProducerFactory.createOutProducer(param); - sumObj.initialize(entry, true); - sumObj.summary(entry); - - continue; - } - - System.out.println("Creating: " + tCase.getObjectName()); - - LogWriter log = (LogWriter) dcl.getInstance( - (String) param.get("LogWriter")); - log.initialize(entry, true); - entry.UserDefinedParams = param; - tCase.setLogWriter((PrintWriter) log); - - try - { - tCase.initializeTestCase(param); - } - catch (RuntimeException e) - { - helper.ProcessHandler ph = (helper.ProcessHandler) param.get( - "AppProvider"); - - if (ph != null) - { - OfficeWatcher ow = (OfficeWatcher) param.get("Watcher"); - - if ((ow != null) && ow.isAlive()) - { - ow.finish = true; - } - - ph.kill(); - shortWait(5000); - } - - continue; - } - - TestEnvironment tEnv = tCase.getTestEnvironment(param); - - if (tEnv == null) - { - sumIt.summarizeDown(entry, "Unable to create testcase"); - - LogWriter sumObj = OutProducerFactory.createOutProducer(param); - sumObj.initialize(entry, true); - sumObj.summary(entry); - - helper.ProcessHandler ph = (helper.ProcessHandler) param.get( - "AppProvider"); - - if (ph != null) - { - OfficeWatcher ow = (OfficeWatcher) param.get("Watcher"); - - if ((ow != null) && ow.isAlive()) - { - ow.finish = true; - } - - ph.kill(); - shortWait(5000); - } - - continue; - } - - System.out.println("created " + tCase.getObjectName()); - - for (int j = 0; j < entry.SubEntryCount; j++) - { - if (!entry.SubEntries[j].isToTest) - { - Summarizer.summarizeDown(entry.SubEntries[j], - "not part of the job"); - - continue; - } - - if ((exclusions != null) && - (exclusions.contains(entry.SubEntries[j].longName))) - { - Summarizer.summarizeDown(entry.SubEntries[j], - "known issue"); - - continue; - } - - System.out.println("running: " + - entry.SubEntries[j].entryName); - - LogWriter ifclog = (LogWriter) dcl.getInstance( - (String) param.get("LogWriter")); - ifclog.initialize(entry.SubEntries[j], true); - entry.SubEntries[j].UserDefinedParams = param; - entry.SubEntries[j].Logger = ifclog; - - if ((tEnv == null) || tEnv.isDisposed()) - { - helper.ProcessHandler ph = (helper.ProcessHandler) param.get( - "AppProvider"); - - if (ph != null) - { - office.closeExistingOffice(param, true); - shortWait(5000); - } - - tEnv = getEnv(entry, param); - } - - BasicIfcTest ifc = null; - lib.TestResult res = null; - ifc = new BasicIfcTest(entry.SubEntries[j].longName); - res = ifc.run(entry.SubEntries[j], tEnv, param); - - sumIt.summarizeUp(entry.SubEntries[j]); - - LogWriter sumIfc = OutProducerFactory.createOutProducer(param); - - sumIfc.initialize(entry.SubEntries[j], true); - sumIfc.summary(entry.SubEntries[j]); - } - - try - { - tCase.cleanupTestCase(param); - } - catch (Exception e) - { - log.println("TestCase already gone"); - - helper.ProcessHandler ph = (helper.ProcessHandler) param.get( - "AppProvider"); - - if (ph != null) - { - office.closeExistingOffice(param, true); - shortWait(5000); - } - } - - sumIt.summarizeUp(entry); - - LogWriter sumObj = OutProducerFactory.createOutProducer(param); - sumObj.initialize(entry, true); - sumObj.summary(entry); - } - - if (entries.length > 1) - { - System.out.println(); - - int counter = 0; - System.out.println( - "Failures that appeared during scenario execution:"); - - for (int i = 0; i < entries.length; i++) - { - if (!entries[i].State.endsWith("OK")) - { - System.out.println("\t " + entries[i].longName); - counter++; - } - } - - System.out.println(counter + " of " + entries.length + - " tests failed"); - } - - helper.ProcessHandler ph = (helper.ProcessHandler) param.get( - "AppProvider"); - - if (ph != null) - { - office.closeExistingOffice(param, true); - } - - return true; - } - - protected TestEnvironment getEnv(DescEntry entry, TestParameters param) - { - DynamicClassLoader dcl = new DynamicClassLoader(); - String officeProviderName = (String) param.get("OfficeProvider"); - AppProvider office = (AppProvider) dcl.getInstance(officeProviderName); - - if (office == null) - { - System.out.println("ERROR: Wrong parameter 'OfficeProvider', " + - " it cannot be instantiated."); - System.exit(-1); - } - - XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager( - param); - - if (msf == null) - { - return null; - } - - param.put("ServiceFactory", msf); - - TestCase tCase = (TestCase) new BasicTestCase(entry); - - System.out.println("Creating: " + tCase.getObjectName()); - - LogWriter log = (LogWriter) dcl.getInstance( - (String) param.get("LogWriter")); - log.initialize(entry, true); - entry.UserDefinedParams = param; - tCase.setLogWriter((PrintWriter) log); - - TestEnvironment tEnv = null; - - try - { - tCase.initializeTestCase(param); - tEnv = tCase.getTestEnvironment(param); - } - catch (java.lang.RuntimeException e) - { - System.out.println(e.getMessage()); - - helper.ProcessHandler ph = (helper.ProcessHandler) param.get( - "AppProvider"); - - if (ph != null) - { - office.closeExistingOffice(param, true); - shortWait(5000); - } - - entry.ErrorMsg = e.getMessage(); - entry.hasErrorMsg = true; - } - - return tEnv; - } - - protected void shortWait(int millis) - { - try - { - Thread.sleep(millis); - } - catch (java.lang.InterruptedException ie) - { - } - } - - protected Vector getExclusionList(String url, boolean debug) - { - Vector entryList = new Vector(); - String line = "#"; - BufferedReader exclusion = null; - - try - { - exclusion = new BufferedReader(new FileReader(url)); - } - catch (java.io.FileNotFoundException fnfe) - { - if (debug) - { - System.out.println("Couldn't find file " + url); - } - - return entryList; - } - - while (line != null) - { - try - { - if (!line.startsWith("#")) - { - entryList.add(line); - } - - line = exclusion.readLine(); - } - catch (java.io.IOException ioe) - { - if (debug) - { - System.out.println( - "Exception while reading exclusion list"); - } - - return entryList; - } - } - - try - { - exclusion.close(); - } - catch (java.io.IOException ioe) - { - if (debug) - { - System.out.println("Couldn't close file " + url); - } - - return entryList; - } - - return entryList; - } -} diff --git a/qadevOOo/runner/basicrunner/BasicException.java b/qadevOOo/runner/basicrunner/BasicException.java deleted file mode 100644 index 419e26461916..000000000000 --- a/qadevOOo/runner/basicrunner/BasicException.java +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************************* - * - * 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 basicrunner; - -/** An exception while executing a Basic test. - */ -public class BasicException extends Throwable { - /** Detailed information about the exception. - */ - public String info; - - /** Constructor with detailed information. - * @param info Information about the exception. - */ - public BasicException(String info) { - this.info = info; - } -}
\ No newline at end of file diff --git a/qadevOOo/runner/basicrunner/BasicHandler.java b/qadevOOo/runner/basicrunner/BasicHandler.java deleted file mode 100644 index a0f5f5e405fc..000000000000 --- a/qadevOOo/runner/basicrunner/BasicHandler.java +++ /dev/null @@ -1,612 +0,0 @@ -/************************************************************************* - * - * 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 basicrunner; - - -import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; -import com.sun.star.connection.ConnectionSetupException; -import com.sun.star.container.ContainerEvent; -import com.sun.star.container.XContainer; -import com.sun.star.container.XContainerListener; -import com.sun.star.container.XNameContainer; -import com.sun.star.frame.XComponentLoader; -import com.sun.star.frame.XDesktop; -import com.sun.star.lang.WrappedTargetException; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.lang.XTypeProvider; -import com.sun.star.uno.Type; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.util.XChangesBatch; -import java.util.Hashtable; -import lib.TestParameters; - -import share.LogWriter; - - -/** - * This class is a java-part of BASIC-java interaction "driver" - * It is used to call Star-Basic's function from java using - * basic's part of "driver" where listeners are implemented. - * The instance of the BasicHandler should be added to the MSF that will be - * used for loading BASIC's part of "driver".<br> - * After opening basic's document it creates an instance of the - * HandlerContainer using BasicHandler. HandlerContainer is a UNO - * XContainer and XNameContainer. - * Only one instance of BasicHandler can be used at the moment. - * @see com.sun.star.lang.XServiceInfo - * @see com.sun.star.lang.XSingleServiceFactory - */ -public class BasicHandler implements XServiceInfo, XSingleServiceFactory { - /** - * serviceName is the name of service that can be created in BASIC. - */ - static final String serviceName = - "com.sun.star.jsuite.basicrunner.BasicHandler"; - - /** - * <code>container</code> is a SHARED variable (between BASIC and Java). - * It is used for interacting. - */ - static private HandlerContainer container = null; - - /** - * Contains a writer to log an information about the interface testing, to - * allows for tests to access it. - */ - static private LogWriter log; - - /** - * <code>oHandlerDoc</code> is a referrence to BASIC's document. - */ - static private XComponent oHandlerDoc = null; - - /** - * <code>xMSF</code> is a MultiServiceFactory currently used by - * BasicHandler. - */ - static private XMultiServiceFactory xMSF = null; - - /** - * Interface being tested now. - */ - static private BasicIfcTest TestedInterface = null; - - /** - * Ab enhanced scheme of timeouts can be used with BASIC tests. - * A small timeout can be used zo wait for changes in the test status. - * <code>respFlag</code> is set to <code>true</code> when a BASIC test - * writes any log information. - */ - static private boolean respFlag = false; - - /** - * <code>iBasicTimeout</code> is the amount of milliseconds that - * the BasicHandler will wait for a response from tests - * (finish to execute a method or add log information) - * before it decides that SOffice is dead. - */ - static private int iBasicTimeout = 10000; - - - - /** - * Creates an instance of a HandlerContainer. This instance is used from - * BASIC. - * @param tParam The test parameters. - */ - public BasicHandler(TestParameters tParam) { - if (tParam.get("soapi.test.basic.debugFile") != null) { - iBasicTimeout = 0; // Debug mode. - } - container = new HandlerContainer(this); - } - - /** - * Set the tested interface and a log writer. - * @param ifc The test of an interface - * @param log A log writer. - */ - public void setTestedInterface(BasicIfcTest ifc, LogWriter log) { - this.log = log; - TestedInterface = ifc; - } - - /** - * Is called when BASIC signals that it has performed the test of a method. - * @param methodName The name of the method. - * @bResult The result of the test. - */ - synchronized void methodTested(String methodName, boolean bResult) { - respFlag = true; - TestedInterface.methodTested(methodName, bResult); - notify() ; - } - - /** - * Is called when BASIC sends a signal to write some log information. - * @param info The string to write. - */ - synchronized public void Log(String info) { - respFlag = true; - log.println(info); - notify() ; - } - - /** - * Is called by BasicIfcTest to find out if this BasicHandler uses the - * correct MultiServiceFactory. - * @param xMSF The MultiServiceFactory - * @see com.sun.star.lang.XMultiServiceFactory - * @return True, if xMSF is equal to the MultiServiceFactory of this class. - */ - public boolean isUptodate(XMultiServiceFactory xMSF) { - return xMSF.equals(this.xMSF); - } - - - /** - * Establishes a connection between BASIC and Java. - * If required, hte BASIC part of the "driver" is loaded. - * @param sBasicBridgeURL The URL of the basic bridge document - * (BasicBridge.sxw) - * @param tParam The test parameters. - * @param xMSF The MultiServiceFactory - * @param log The log writer. - * @see com.sun.star.lang.XMultiServiceFactory - * @throws ConnectionSetupException Exception is thrown, if no connection could be made. - */ - public synchronized void Connect(String sBasicBridgeURL, - TestParameters tParam, XMultiServiceFactory xMSF, - LogWriter log) throws ConnectionSetupException { - this.log = log; - try { - this.xMSF = xMSF; - Object oInterface = xMSF.createInstance( - "com.sun.star.frame.Desktop"); - XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface( - XDesktop.class, oInterface); - XComponentLoader oCLoader = (XComponentLoader) - UnoRuntime.queryInterface( - XComponentLoader.class, oDesktop); - - // load BasicBridge with MarcoEceutionMode = Always-no warn - //PropertyValue[] DocArgs = null; - PropertyValue[] DocArgs = new PropertyValue[1]; - PropertyValue DocArg = new PropertyValue(); - DocArg.Name = "MacroExecutionMode"; - DocArg.Value = new Short( - com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN); - DocArgs[0] = DocArg; - - // configure Office to allow to execute macos - PropertyValue [] ProvArgs = new PropertyValue [1]; - PropertyValue Arg = new PropertyValue(); - Arg.Name = "nodepath"; - Arg.Value = "/org.openoffice.Office.Common/Security"; - ProvArgs[0] = Arg; - - Object oProvider = xMSF.createInstance( - "com.sun.star.configuration.ConfigurationProvider"); - - XMultiServiceFactory oProviderMSF = (XMultiServiceFactory) - UnoRuntime.queryInterface( - XMultiServiceFactory.class, oProvider); - - Object oSecure = oProviderMSF.createInstanceWithArguments( - "com.sun.star.configuration.ConfigurationUpdateAccess", - ProvArgs); - - XPropertySet oSecureProps = (XPropertySet) - UnoRuntime.queryInterface(XPropertySet.class, oSecure); - - Object oScripting = oSecureProps.getPropertyValue("Scripting"); - XPropertySet oScriptingSettings = (XPropertySet) - UnoRuntime.queryInterface(XPropertySet.class, oScripting); - - oScriptingSettings.setPropertyValue("Warning", Boolean.FALSE); - oScriptingSettings.setPropertyValue("OfficeBasic", new Integer(2)); - - XChangesBatch oSecureChange = (XChangesBatch) - UnoRuntime.queryInterface(XChangesBatch.class, oSecure); - oSecureChange.commitChanges(); - - // As we want to have some information about a debugFile - // BEFORE connection is established - // we pass the information about it in frame name. - String sFrameName = (String)tParam.get( - "soapi.test.basic.debugFile"); - if (sFrameName == null) sFrameName = "BasicRunner"; - - oHandlerDoc = oCLoader.loadComponentFromURL(sBasicBridgeURL, - sFrameName, 40, DocArgs); - - do { - respFlag = false ; - wait(10000); // waiting for basic response for 10 seconds. - } while (respFlag && !container.hasByName("BASIC_Done")) ; - - if (!container.hasByName("BASIC_Done")) { - throw new ConnectionSetupException("Connection timed out."); - } - } catch (Exception e) { - System.out.println("Exception: " + e.toString()); - throw new ConnectionSetupException(); - } - - log.println("Java-BASIC connection established!"); - } - - /** - * Overloads perform(Strin fName, Object params) for convenience. - * @return A proprty value as result. - * - public synchronized PropertyValue perform(String fName) - throws BasicException { - return perform(fName, ""); - } -*/ - /** - * Perform a test of a method. - * @param fName The name of the method to test. - * @param params The test parameters. - * @return A proprty value as result of the test. - * @throws BasicException The method could not be executed. - */ - public synchronized PropertyValue perform(String fName, Object params) - throws BasicException { - try { - container.callBasicFunction(fName, params); - - do { - respFlag = false; - // waiting for basic response for iBasicTimeout milliseconds. - wait(iBasicTimeout); - } while(respFlag && !container.hasByName("BASIC_Done")); - - } catch (InterruptedException e) { - System.out.println("The operation " + fName + " was interrupted."); - } catch (com.sun.star.lang.DisposedException de) { - System.out.println("## Office is disposed"); - } - - if (!container.hasByName("BASIC_Done")) { - System.out.println("Operation timed out."); - throw new BasicException( - "Operation timed out."); - } - - Object res = container.getByName("BASIC_Done") ; - container.removeByName("BASIC_Done"); - - if (!(res instanceof PropertyValue)) { - if (res == null) { - System.out.println( - "BasicBridge returns null"); - throw new BasicException( - "BasicBridge returns null"); - } else { - System.out.println( - "BasicBridge returns wrong type: " + res.getClass()); - throw new BasicException( - "BasicBridge returns wrong type: " + res.getClass()); - } - } - - PropertyValue result = (PropertyValue) res ; - - if ((result.Value instanceof String) && (((String)result.Value)).startsWith("Exception")) { - throw new BasicException((String)result.Value); - } - - return result; - } - - /** - * Returns true, if name is a supported service of this class. - * @param name The service name. - * @return True, if the service is supported. - */ - public boolean supportsService(String name) { - return serviceName.equals(name); - } - - /** - * Return all supported service names. - * @return All supported services. - */ - public String[] getSupportedServiceNames() { - return new String[] {serviceName}; - } - - /** - * Get the implementation name. - * @return Implementation name. - */ - public String getImplementationName() { - return getClass().getName(); - } - - /** - * Create an instance of HandlerContainer. - * Arguments are not supported here, so they will be ignored. - * @param args The arguments. - * @return The instance. - */ - public Object createInstanceWithArguments(Object[] args) { - return container; - } - - /** - * Create an instance of HandlerContainer. - * @return The instance. - */ - public Object createInstance() { - return createInstanceWithArguments(null); - } - - /** - * Dispose the BASIC document. - */ - public synchronized void dispose() { - try { - if (oHandlerDoc != null) { - //oHandlerDoc.dispose(); - util.DesktopTools.closeDoc(oHandlerDoc); - wait(1000); - } - } catch (Exception e) { - System.out.println("Exception: " + e.toString()); - } - } -} - - -/** - * This class handles the communication between Java and BASIC. - * @see com.sun.star.container.XContainer - * @see com.sun.star.container.XNameContainer - * @see com.sun.star.lang.XTypeProvider - */ -class HandlerContainer implements XContainer, XNameContainer, XTypeProvider{ - - /** Container for parameters. - **/ - Hashtable container = new Hashtable(20); - /** - * An array of listeners for container events. - * @see com.sun.star.container.XContainerListener - */ - static XContainerListener[] listener = null; - - /** The BasicHandler belonging to this handler. **/ - BasicHandler parent = null; - - /** - * Constructor with the parent BasicHandler. - * @param par The BasicHandler. - */ - public HandlerContainer(BasicHandler par) { - parent = par; - } - - /** - * Call a BASIC function, meaning a test method. - * @param fName The method name. - * @param args Arguments for the method. - */ - public void callBasicFunction(String fName, Object args) { - // BASIC's listener should be called ONLY in this case. - if (container.containsKey(fName)) { - container.remove(fName); - } - container.put(fName, args); - if (listener != null) { - ContainerEvent event = new ContainerEvent(); - event.Element = fName; - for (int i=0; i<listener.length; i++){ - if (listener[i] != null) { - listener[i].elementInserted(event); - } - } - } - } - - /** - * Insert an object into the container. - * @param name The key for the object. - * @param object The object to insert. - * @throws IllegalArgumentException Throws this exception when trying to insert null. - */ - public void insertByName(String name, Object object) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.ElementExistException, com.sun.star.lang.WrappedTargetException { - - // BASIC and Java can insert into the container. - if (container.containsKey(name)) { - container.remove(name); - } - container.put(name, object); - - PropertyValue result = null ; - - if (object instanceof PropertyValue) { - result = (PropertyValue)object; - if (name.equals("BASIC_Done")) { - synchronized (parent) { - parent.notify(); - } - } else if (name.equals("BASIC_MethodTested")) { - parent.methodTested(result.Name, - ((Boolean)result.Value).booleanValue()); - } - } else if (name.equals("BASIC_Log")) { - parent.Log(object.toString()); - } - } - - /** - * Remove the object with this name from the container. - * @param name The key. - */ - public void removeByName(String name) { - container.remove(name) ; - } - - /** - * Unsupported method. - * @param name The name of the key. - * @param value The value. - * @throws WrappedTargetException Throws this exception when called falsely. - */ - public void replaceByName(String name, Object value) - throws WrappedTargetException { - throw new WrappedTargetException("Unsupported"); - } - - /** - * Has a value for this key. - * @param name The name of a key. - * @return True, if name exists as key in the container. - */ - public boolean hasByName(String name) { - return container.containsKey(name); - } - - /** - * Get an object by its key. - * @param name The name of the key. - * @return The object of this key. - */ - public Object getByName(String name) { - return container.get(name); - } - - /** - * Get all key names. - * @return All names of keys. - */ - public String[] getElementNames() { - String[] res = new String[container.size()]; - return (String[])container.keySet().toArray(res); - } - - /** - * Is the xcontainer empty? - * @return True, if the container has elements. - */ - public boolean hasElements() { - return !container.isEmpty(); - } - - /** - * Get the type of this class. - * @return The type of this class. - */ - public Type getElementType() { - try { - return new Type(String.class); - } catch (Exception e) { - return null; - } - } - - /** - * Get the implementation id of this class. - * @return A unique id for this class - * @see com.sun.star.lang.XTypeProvider - */ - public byte[] getImplementationId() { - return toString().getBytes(); - } - - /** - * Get all types of this class. - * @return All implemented UNO types. - */ - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - Type types[] = new Type[interfaces.length]; - for(int i = 0; i < interfaces.length; ++ i) { - types[i] = new Type(interfaces[i]); - } - return types; - } - - /** - * Add a listener - * @param xListener The listener. - */ - public void addContainerListener(XContainerListener xListener){ - int length = 0; - if (listener != null) - length = listener.length; - - XContainerListener[] mListener = - new XContainerListener[length+1]; - for (int i=0; i<length-1; i++) { - mListener[i] = listener[i]; - // listener already added - if (((Object)xListener).equals(listener[i])) - return; - } - mListener[length] = xListener; - listener = mListener; - } - - /** - * Remove a listener - * @param xListener The listener. - */ - public void removeContainerListener(XContainerListener xListener){ - if (listener != null && listener.length != 0) { - int length = listener.length; - XContainerListener[] mListener = - new XContainerListener[length-1]; - boolean found = false; - int j=0; - for (int i=0; i<length-1; i++) { - if (!((Object)xListener).equals(listener[j])) { - mListener[i] = listener[j]; - } - else { - j++; - found = true; - } - j++; - } - if (!found) { - if (((Object)xListener).equals(listener[length-1])) - listener = mListener; - } - else - listener = mListener; - - } - } -} diff --git a/qadevOOo/runner/basicrunner/BasicHandlerProvider.java b/qadevOOo/runner/basicrunner/BasicHandlerProvider.java deleted file mode 100644 index 9a6479d50f1d..000000000000 --- a/qadevOOo/runner/basicrunner/BasicHandlerProvider.java +++ /dev/null @@ -1,153 +0,0 @@ -/************************************************************************* - * - * 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 basicrunner; - -import com.sun.star.uno.UnoRuntime; -import com.sun.star.container.XSet; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.container.ElementExistException; -import com.sun.star.lang.IllegalArgumentException; -import com.sun.star.connection.ConnectionSetupException; -import lib.TestParameters; -import share.LogWriter; -import basicrunner.basichelper.Connector; -import basicrunner.basichelper.DocumentHandler; -import basicrunner.basichelper.ThreadRunner; -import basicrunner.basichelper.AttributeList; -import basicrunner.basichelper.Filter; -import basicrunner.basichelper.DispatchProviderInterceptor; - -/** - * This class provides a BasicHandler. All classes for the communication with - * and handling of the BASIC tests are instantiated and inserted int the - * MultiServiceFactory of StarOffice. - */ -public class BasicHandlerProvider { - - /** The BassicHandler **/ - static BasicHandler oHandler = null; - /** The Connector **/ - static Connector oConnector = null; - /** The DocumentHandler **/ - static DocumentHandler oDocumentHandler = null; - /** The Thread Runner **/ - static ThreadRunner oThreadRunner = null; - /** The AttributeList **/ - static AttributeList oAttributeList = null; - /** The Filter **/ - static Filter oFilter = null; - /** The DispatchProviderInterceptor **/ - static DispatchProviderInterceptor oCeptor = null ; - /** The MultiServiceFactory from StarOffice **/ - static XMultiServiceFactory MSF = null; - /** IS this a new connection or an existing one? **/ - static boolean bIsNewConnection = true; - - /** - * Get a BasicHandler - * @param tParam Test parameters. - * @param log A log writer - * @return An instance of BasicHandler - */ - static public BasicHandler getHandler(TestParameters tParam, LogWriter log) { - - XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF(); - - if (!xMSF.equals(MSF)) { - MSF = xMSF; - oHandler = new BasicHandler(tParam); - oConnector = new Connector(); - oFilter = new Filter(); - oDocumentHandler = new DocumentHandler(); - oThreadRunner = new ThreadRunner(xMSF); - oCeptor = new DispatchProviderInterceptor() ; - oAttributeList = new AttributeList(); - XSet xMSFSet = (XSet)UnoRuntime.queryInterface(XSet.class, xMSF); - - try { - xMSFSet.insert(oHandler); - xMSFSet.insert(oConnector); - xMSFSet.insert(oFilter); - xMSFSet.insert(oDocumentHandler); - xMSFSet.insert(oThreadRunner); - xMSFSet.insert(oCeptor); - xMSFSet.insert(oAttributeList); - } catch (ElementExistException e) { - System.out.println(e.toString()); - } catch (IllegalArgumentException e) { - System.out.println(e.toString()); - } - - try { - oHandler.Connect(util.utils.getFullURL((String)tParam.get("BASICBRIDGE")), - tParam, xMSF, log); - } catch (ConnectionSetupException e) { - System.out.println("Can't connect to BASIC !"); - } - - bIsNewConnection = true; - } else { - bIsNewConnection = false; - } - - return oHandler; - } - - /** - * Is this a new connection? - * @return True, if the connection did not exist before. - */ - static public boolean isNewConnection() { - return bIsNewConnection; - } - - /** - * Dispose the BasicHandler - */ - static public void disposeHandler() { - - try { - if (oHandler != null) { - oHandler.dispose(); - } - if (MSF != null) { - XSet xMSFSet = (XSet)UnoRuntime.queryInterface(XSet.class, MSF); - xMSFSet.remove(oHandler); - xMSFSet.remove(oFilter); - xMSFSet.remove(oConnector); - xMSFSet.remove(oDocumentHandler); - xMSFSet.remove(oThreadRunner); - xMSFSet.remove(oAttributeList); - } - } catch (Exception e){ - System.out.println(e.toString()); - } - - MSF = null; - oHandler = null; - } -} diff --git a/qadevOOo/runner/basicrunner/BasicIfcTest.java b/qadevOOo/runner/basicrunner/BasicIfcTest.java deleted file mode 100644 index 8c75f8ff94f0..000000000000 --- a/qadevOOo/runner/basicrunner/BasicIfcTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/************************************************************************* - * - * 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 basicrunner; - -import lib.TestResult; -import lib.TestEnvironment; -import lib.TestParameters; -import share.DescEntry; -import share.LogWriter; - -import com.sun.star.lang.XMultiServiceFactory; - -import com.sun.star.beans.PropertyValue; - - -/** - * The BASIC interface test - */ -public class BasicIfcTest { - /** The BasicHandler **/ - static BasicHandler oBasicHandler = null; - /** The result orf the test **/ - protected TestResult tRes; - /** the name of the test **/ - protected String testName; - - /** Constructor with test name. - * @param name The name of the test. - */ - public BasicIfcTest(String name) { - testName = name; - } - - /** - * Let the test run. - * @param xTestedEntry Informaton about the interface to test. - * @param tEnv The environment of the test. - * @param tParam The test parameters. - * @return A result of the test. - */ - public TestResult run(DescEntry xTestedEntry, TestEnvironment tEnv, - TestParameters tParam) { - - String sResult = ""; - - this.tRes = new TestResult(); - LogWriter log = xTestedEntry.Logger; - - // Get Handler, that was created during object creation. - try { - oBasicHandler = (BasicHandler)tEnv.getObjRelation("BasicHandler"); - } catch (java.lang.NullPointerException e) { - log.println("No Component created"); - return null; - } - - if (!oBasicHandler.isUptodate((XMultiServiceFactory)tParam.getMSF())) { - // If Handler uses old MSF (in case of Office's GPF) then don't test - // interface. - return null; - } - - boolean objectWasCreated = ((Boolean)tEnv.getObjRelation("objectCreated")).booleanValue(); - - if (objectWasCreated) { - oBasicHandler.setTestedInterface(this, log); - - DescEntry methods[] = xTestedEntry.SubEntries; - - String names[] = new String[methods.length + 1]; - boolean isOpt[] = new boolean[methods.length + 1]; - String other[] = new String[1]; - - String aName = xTestedEntry.longName; - aName = aName.substring(aName.indexOf("::")+2); - int oldIndex = 0; - int index = aName.indexOf("::"); - names[0] = ""; - while(index!=-1) { - names[0] += aName.substring(oldIndex,index) + "."; - oldIndex=index+2; - index=aName.indexOf("::", oldIndex); - } - names[0] += aName.substring(oldIndex); - isOpt[0] = xTestedEntry.isOptional; - - for (int i = 1; i < names.length; i++) { - names[i] = methods[i - 1].entryName; - isOpt[i] = methods[i - 1].isOptional; - } - - // for reasons of compatibility with JSuite we change the first - // character of EntryType to upper case. - String eType = xTestedEntry.EntryType; - other[0] = eType.toUpperCase().charAt(0)+eType.substring(1); - - Object params[] = {names, isOpt, other}; - - try { - PropertyValue Res = oBasicHandler.perform("testInterface", params); - sResult = (String)Res.Value; - } catch (BasicException e) { - log.println(e.info); - sResult = "SKIPPED.FAILED"; - } - } else { // if object was not created... - sResult = "SKIPPED.FAILED"; - } - - // now tRes has all substates: collect them - DescEntry[] subs = xTestedEntry.SubEntries; - for (int i = 0; i < subs.length ; i++) { - if (sResult.equals("SKIPPED.FAILED")) - subs[i].State = "SKIPPED.FAILED"; - else if (sResult.equals("SKIPPED.OK")) - subs[i].State = "SKIPPED.OK"; - else - if (tRes.getStatusFor(subs[i].entryName) == null) { - subs[i].State = "SKIPPED.FAILED"; - } else { - subs[i].State = tRes.getStatusFor( - subs[i].entryName).toString(); - } - } - - xTestedEntry.State = sResult; - return null; - } - - /** - * Set the result of the method that is tested. - * @param methodName The name of the method. - * @param bResult The result of the test. - */ - public void methodTested(String methodName, boolean bResult) { - tRes.tested(methodName, bResult); - } - - /** - * @return The name of the interface or the service tested. - */ - String getTestedClassName() { - return testName; - } -} diff --git a/qadevOOo/runner/basicrunner/BasicTestCase.java b/qadevOOo/runner/basicrunner/BasicTestCase.java deleted file mode 100644 index 1356badc12d7..000000000000 --- a/qadevOOo/runner/basicrunner/BasicTestCase.java +++ /dev/null @@ -1,178 +0,0 @@ -/************************************************************************* - * - * 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 basicrunner; - -import lib.TestCase; -import lib.TestParameters; -import lib.TestEnvironment; -import share.DescEntry; -import share.LogWriter; - -import com.sun.star.uno.XInterface; - -import java.io.PrintWriter; - -import com.sun.star.beans.PropertyValue; - - -/** - * The basic test case. - */ -public class BasicTestCase extends TestCase { - - /** - * Specifies the PrintWriter to log information. - */ - public PrintWriter oLog; - - /** The name of the test object **/ - protected String objName; - /** The implementation name of the test object **/ - protected String implName; - /** A BasicHandler **/ - static BasicHandler oBasicHandler = null; - - /** - * Constructor with the entry which is to test. - * @param entry The description entry. - */ - public BasicTestCase(DescEntry entry) { - this.objName = entry.entryName; - this.implName = entry.longName; - } - - - /** - * Initialize the test case. - * The BasicHandler is talken from the test parameters and several - * parameters are initialized. - * @param tParam The test parameters. - * @param pLog A log writer. - */ - protected void initialize(TestParameters tParam, PrintWriter pLog) { - // Create Handler ONLY here. If SOffice crashes, - // no new Handler will be created until new object's initialization. - this.oLog = pLog; - LogWriter log = (LogWriter)pLog; - oBasicHandler = BasicHandlerProvider.getHandler(tParam, log); - try { - oBasicHandler.perform("setValue", - "cBASPath = \"" + tParam.get("BASICRESPTH") + "/\""); - oBasicHandler.perform("setValue", - "cTestDocsDir = \"" + tParam.get("DOCPTH") + "/\""); - oBasicHandler.perform("setValue", - "CNCSTR = \"" + tParam.get("CNCSTR") + "\""); - if (tParam.get("soapi.test.hidewindows") != null) { - oBasicHandler.perform("setValue", - "soapi_test_hidewindows = true"); - } else { - oBasicHandler.perform("setValue", - "soapi_test_hidewindows = false"); - } - //this parameters are used by testcases of db-driver components - oBasicHandler.perform("setValue", "dbaseUrl = \"sdbc:dbase:" + - tParam.get("dbase.url") + "\""); - oBasicHandler.perform("setValue", "flatUrl = \"sdbc:flat:" + - tParam.get("flat.url") + "\""); - oBasicHandler.perform("setValue", "calcUrl = \"sdbc:calc:" + - tParam.get("calc.url") + "\""); - oBasicHandler.perform("setValue", "odbcUrl = \"sdbc:odbc:" + - tParam.get("odbc.url") + "\""); - oBasicHandler.perform("setValue", "jdbcUrl = \"jdbc:" + - tParam.get("jdbc.url") + "\""); - oBasicHandler.perform("setValue", "jdbcUser = \"" + - tParam.get("jdbc.user") + "\""); - oBasicHandler.perform("setValue", "jdbcPassword = \"" + - tParam.get("jdbc.password") + "\""); - oBasicHandler.perform("setValue", "adabasUrl = \"sdbc:adabas:" + - tParam.get("adabas.url") + "\""); - oBasicHandler.perform("setValue", "adabasUser = \"" + - tParam.get("adabas.user") + "\""); - oBasicHandler.perform("setValue", "adabasPassword = \"" + - tParam.get("adabas.password") + "\""); - oBasicHandler.perform("setValue", "adoUrl = \"sdbc:ado:" + - tParam.get("ado.url") + "\""); - oBasicHandler.perform("setValue", "mozabUrl = \"sdbc:address:" + - tParam.get("mozab.url") + "\""); - } catch (BasicException e) { - log.println(e.info); - throw new RuntimeException(e.info); - } - } - - /** - * Create the environment for the test. This is done by BASIC. - * @param tParam The test parameters. - * @param log A log writer. - * @return The test environment - */ - protected TestEnvironment createTestEnvironment(TestParameters tParam, - PrintWriter log) { - - PropertyValue Res; - boolean bObjectWasCreated = false; - - try { - oBasicHandler.perform("setValue", - "cObjectImplementationName = \"" + implName + "\""); - Res = oBasicHandler.perform("createObject", objName); - bObjectWasCreated = ((Boolean)Res.Value).booleanValue(); - - if (!bObjectWasCreated) { - log.println("Couldn't create object"); - throw new RuntimeException("Couldn't create object"); - } - - } catch (BasicException e) { - log.println(e.info); - bObjectWasCreated = false; - throw new RuntimeException(e.info); - } - - TestEnvironment tEnv = new TestEnvironment(new XInterface(){}); - tEnv.addObjRelation("objectCreated", new Boolean(bObjectWasCreated)); - tEnv.addObjRelation("BasicHandler", oBasicHandler); - return tEnv; - } - - /** - * BASIC is told to dispose the test object. - * @param tParam The test parameters. - */ - - public void cleanupTestCase(TestParameters tParam) { - PropertyValue Res; - oLog.println("Cleaning up testcase"); - try { - Res = oBasicHandler.perform("disposeObject", objName); - } catch (BasicException e) { - oLog.println(e.info); - throw new RuntimeException(e.info); - } - } - -} diff --git a/qadevOOo/runner/basicrunner/basichelper/AttributeList.java b/qadevOOo/runner/basicrunner/basichelper/AttributeList.java deleted file mode 100644 index cdcba0f6f956..000000000000 --- a/qadevOOo/runner/basicrunner/basichelper/AttributeList.java +++ /dev/null @@ -1,138 +0,0 @@ -/************************************************************************* - * - * 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 basicrunner.basichelper; - -import com.sun.star.lang.XInitialization; -import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.uno.Type; -import com.sun.star.lang.XTypeProvider; -import util.XMLTools; - -/** -* The class provides an implementation of the service -* <code>com.sun.star.xml.sax.XAttributeList</code>. -* @see com.sun.star.xml.sax.XAttributeList -* @see com.sun.star.lang.XServiceInfo -* @see com.sun.star.lang.XSingleServiceFactory -*/ -public class AttributeList implements XServiceInfo, XSingleServiceFactory { - /** The service name of this class **/ - static final String __serviceName = "basichelper.AttributeList"; - - /** - * Returns True, of the service is supported. - * @param name The service name. - * @return True, if the service is supported. - */ - public boolean supportsService(String name) { - return __serviceName.equals(name); - } - - /** - * Get all supported services. - * @return The supported services. - */ - public String[] getSupportedServiceNames() { - return new String[] {__serviceName}; - } - - /** - * Ask for the implementation name. - * @return The implementation name. - */ - public String getImplementationName() { - return getClass().getName(); - } - - /** - * Create an instance of the actual implementation of the AttributeList. - * Arguments are not supported, so they will bge ignored. - * @param args The arguments. - * @return A new instance of this class. - */ - public Object createInstanceWithArguments(Object[] args) { - return new AttributeListImpl(); - } - - /** - * Create an instance of this class. - * @return A new instance of this class. - */ - public Object createInstance() { - return createInstanceWithArguments(null); - } -} - -/** - * The actual implementation of the service - * <code>com.sun.star.xml.sax.XAttributeList</code>. - * Extends the class util.XMLTools.AttributeList. - * @see util.XMLTools.AttributeList - * @see com.sun.star.xml.sax.XAttributeList - * @see com.sun.star.lang.XTypeProvider - * @see com.sun.star.lang.XInitialization - */ -class AttributeListImpl extends XMLTools.AttributeList - implements XTypeProvider, XInitialization { - - /** - * Initialize this class. - * @param p0 An array of XML attributes that are added to the list. - * @throws Exception Initialize failed. - */ - public void initialize(Object[] p0) throws com.sun.star.uno.Exception { - for(int i = 0; i + 2 < p0.length; i += 3) { - add((String)p0[i], (String)p0[i + 1], (String)p0[i + 2]); - } - } - - /** - * Return all implemented types of this class. - * @return All UNO types of this class. - */ - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - Class superInterfaces[] = getClass().getSuperclass().getInterfaces(); - - Type types[] = new Type[interfaces.length + superInterfaces.length]; - int i = 0; - for(; i < interfaces.length; ++ i) - types[i] = new Type(interfaces[i]); - for(; i < interfaces.length + superInterfaces.length; ++ i) - types[i] = new Type(superInterfaces[i - interfaces.length]); - return types; - } - - /** - * Get a unique id for this class - * @return The id. - */ - public byte[] getImplementationId() { - return toString().getBytes(); - } -} diff --git a/qadevOOo/runner/basicrunner/basichelper/Connector.java b/qadevOOo/runner/basicrunner/basichelper/Connector.java deleted file mode 100644 index cc219ac9f416..000000000000 --- a/qadevOOo/runner/basicrunner/basichelper/Connector.java +++ /dev/null @@ -1,272 +0,0 @@ -/************************************************************************* - * - * 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 basicrunner.basichelper; - -import com.sun.star.lang.XInitialization; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.lang.XTypeProvider; -import com.sun.star.uno.Type; -import com.sun.star.connection.XConnector; -import com.sun.star.connection.XConnection; -import com.sun.star.connection.ConnectionSetupException; -import com.sun.star.connection.NoConnectException; -import com.sun.star.container.XNameAccess; -import com.sun.star.container.NoSuchElementException; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.XSingleServiceFactory; - -/** - * This is a special service that is used in testing Acceptor - * component in BASIC. This componennt creates a separate thread - * that tries to connect to BASIC's acceptor. After successfull - * connection it writes a connectionString to XConnection. - */ - public class Connector implements XServiceInfo, XSingleServiceFactory { - /** The service name of this class **/ - static final String __serviceName = "basichelper.Connector"; - /** The Connector implementation **/ - static ConnectorImpl oConnector = null; - - /** Create a connector. - */ - public Connector() { - oConnector = new ConnectorImpl(); - } - - /** - * Returns an instance of the connector. - * Arguments are not supported here and will be ignored. - * @param args The arguments. - * @return The connector. - */ - public Object createInstanceWithArguments(Object[] args) { - return oConnector; - } - - /** - * Returns an instance of the connector. - * @return The connector. - */ - public Object createInstance() { - return createInstanceWithArguments(null); - } - - /** - * Get a unique id for this implementation. - * @return The id. - */ - public byte[] getImplementationId() { - return toString().getBytes(); - } - - /** - * Return all implemented types of this class. - * @return The implemented UNO types. - */ - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - - Type types[] = new Type[interfaces.length]; - for(int i = 0; i < interfaces.length; ++ i) - types[i] = new Type(interfaces[i]); - - return types; - } - - /** Is this servioce supported? - * @param name The service name. - * @return True, if the service is supported. - */ - public boolean supportsService(String name) { - return __serviceName.equals(name); - } - - /** - * Get all supported service names. - * @return All supported servcices. - */ - public String[] getSupportedServiceNames() { - return new String[] {__serviceName}; - } - - /** - * Get the implementation name of this class. - * @return The implementation name. - */ - public String getImplementationName() { - return getClass().getName(); - } -} - -/** - * The actual implementation of the connector - * @see com.sun.star.lang.XInitialization - * @see com.sun.star.lang.XTypeProvider - * @see com.sun.star.container.XNameAccess - */ -class ConnectorImpl implements XInitialization, XTypeProvider, XNameAccess { - static String aState; - static Integer iTimeout; - - /** - * Construct a new connector. - */ - public ConnectorImpl() { - aState = "just created"; - iTimeout = new Integer(3000); - } - - /** - * Method initialize() creates a new thread that will try to connect to - * Acceptor for a few seconds. One should pass as parameters an array, - * where element 0 is an instance of Connector and element 1 is a - * connection string (the same as in Acceptor) - * @param parm1 An instance of XConnector. - * @see com.sun.star.connection.XConnector - * @throws Exception Is thrown, when initialize fails. - */ - public void initialize(Object[] parm1) throws com.sun.star.uno.Exception { - aState = "just initialized"; - XConnector cntr = (XConnector)UnoRuntime.queryInterface( - XConnector.class, parm1[0]); - ConnThread aThread = new ConnThread(cntr, (String)parm1[1]); - aThread.start(); - } - - /** - * Get the element names - * @return All element names. - */ - public String[] getElementNames() { - return new String[]{"State", "Timeout"}; - } - - /** - * Does this element exist? - * @param name The element name. - * @return True, if the name exists. - */ - public boolean hasByName(String name) { - return (name.equals("State") || name.equals("Timeout")); - } - - /** - * Get an element by its name. - * @param name The name of the element. - * @return The value of the element. - * @throws NoSuchElementException The element does not exist. - */ - public Object getByName(String name) throws NoSuchElementException{ - if (name.equals("State")) - return aState; - else if (name.equals("Timeout")) - return iTimeout; - else - throw new NoSuchElementException(); - } - - /** - * Are there elements - * @return Always true. - */ - public boolean hasElements() { - return true; - } - - /** - * Get element type. - * @return null. - */ - public Type getElementType() { - return null; - } - - /** - * Get a unique id for this implementation. - * @return The id. - */ - public byte[] getImplementationId() { - return toString().getBytes(); - } - - /** - * Return all implemented types of this class. - * @return The implemented UNO types. - */ - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - - Type types[] = new Type[interfaces.length]; - for(int i = 0; i < interfaces.length; ++ i) - types[i] = new Type(interfaces[i]); - - return types; - } -} - -/** - * A connector thread - */ -class ConnThread extends Thread { - String connStr; - XConnector oConnector; - - /**Construct the thread. - * @param oCntr A connector. - * @param cStr The conection string. - */ - public ConnThread(XConnector oCntr, String cStr){ - connStr = cStr; - oConnector = oCntr; - } - - /** - * Run the thread. - */ - public void run(){ - try { - Thread.sleep(ConnectorImpl.iTimeout.intValue()); - ConnectorImpl.aState = "before connection"; - XConnection oConnection = oConnector.connect(connStr); - if (oConnection != null) { - ConnectorImpl.aState = "connected"; - oConnection.write(connStr.getBytes()); - oConnection.write(new byte[]{0}); - } else - ConnectorImpl.aState = "XConnection is null"; - } catch (ConnectionSetupException e) { - ConnectorImpl.aState = "ConnectionSetupException"; - throw new RuntimeException(e.toString()); - } catch (NoConnectException e) { - ConnectorImpl.aState = "NoConnectException"; - throw new RuntimeException(e.toString()); - } catch (Exception e) { - ConnectorImpl.aState = "error"; - throw new RuntimeException("Can't sleep exception"); - } - } -} diff --git a/qadevOOo/runner/basicrunner/basichelper/DispatchProviderInterceptor.java b/qadevOOo/runner/basicrunner/basichelper/DispatchProviderInterceptor.java deleted file mode 100644 index f50a7d2eb470..000000000000 --- a/qadevOOo/runner/basicrunner/basichelper/DispatchProviderInterceptor.java +++ /dev/null @@ -1,194 +0,0 @@ -/************************************************************************* - * - * 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 basicrunner.basichelper; - -import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.lang.XTypeProvider; -import com.sun.star.uno.Type; -import com.sun.star.frame.XDispatchProviderInterceptor; -import com.sun.star.frame.XDispatchProvider; -import com.sun.star.frame.XDispatch; -import com.sun.star.frame.DispatchDescriptor; -import com.sun.star.util.URL; - -/** - * This implementation provides an implementation of an interceptor. - * @see com.sun.star.lang.XSingleServiceFactory - * @see com.sun.star.lang.XServiceInfo - */ -public class DispatchProviderInterceptor implements XServiceInfo, - XSingleServiceFactory { - /** The service name **/ - static final String __serviceName = - "basichelper.DispatchProviderInterceptor"; - - /** Create an instance of the interceptor - * Arguments are not supported here, so they will be ignored. - * @param args The arguments. - * @return A new instance of the interceptor. - **/ - public Object createInstanceWithArguments(Object[] args) { - return new InterceptorImpl(); - } - - /** Create an instance of the interceptor - * @return A new instance of the interceptor. - **/ - public Object createInstance() { - return createInstanceWithArguments(null); - } - - /** Get the unique id for this implementation - * @return The id. - */ - public byte[] getImplementationId() { - return toString().getBytes(); - } - - /** Get all implemented types. - * @return The implemented UNO types. - */ - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - - Type types[] = new Type[interfaces.length]; - for(int i = 0; i < interfaces.length; ++ i) - types[i] = new Type(interfaces[i]); - - return types; - } - - /** - * Is this service supported? - * @param name The name of a service. - * @return True, if the service is supported. - */ - public boolean supportsService(String name) { - return __serviceName.equals(name); - } - - /** - * Get all supported service names. - * @return All service names. - */ - public String[] getSupportedServiceNames() { - return new String[] {__serviceName}; - } - - /** - * Get the implementation name of this class. - * @return The name. - */ - public String getImplementationName() { - return getClass().getName(); - } -} - -/** - * The actual implementation of the interceptor. - * @see com.sun.star.lang.XTypeProvider - * @see com.sun.star.frame.XDispatchProviderInterceptor - * @see com.sun.star.frame.XDispatchProvider - */ -class InterceptorImpl implements XDispatchProvider, - XDispatchProviderInterceptor, XTypeProvider { - - /** A master dispatch provider **/ - public XDispatchProvider master = null; - /** A slave dispatch provider **/ - public XDispatchProvider slave = null; - - /** Get the slave dispatch provider - * @return The slave. - */ - public XDispatchProvider getSlaveDispatchProvider() { - return slave; - } - /** Get the master dispatch provider - * @return The master. - */ - public XDispatchProvider getMasterDispatchProvider() { - return master; - } - - /** Set the slave dispatch provider - * @param prov The new slave. - */ - public void setSlaveDispatchProvider(XDispatchProvider prov) { - slave = prov ; - } - - /** Set the master dispatch provider - * @param prov The new master. - */ - public void setMasterDispatchProvider(XDispatchProvider prov) { - master = prov ; - } - - /** Searches for an <type>XDispatch</type> for the specified URL within - * the specified target frame. - * @param url The URL. - * @param frame The target frame - * @param flags Optional search flags. - * @return The dispatch object which provides the queried functionality - * or null if no dispatch object is available. - * @see com.sun.star.frame.XDispatch - */ - public XDispatch queryDispatch(URL url, String frame, int flags) { - return master.queryDispatch(url, frame, flags) ; - } - - /** - * Query for an array of <type>XDispatch</type>. - * @param desc A list of dipatch requests. - * @return A list of dispatch objects. - */ - public XDispatch[] queryDispatches(DispatchDescriptor[] desc) { - return master.queryDispatches(desc) ; - } - - /** Get the unique id for this implementation - * @return The id. - */ - public byte[] getImplementationId() { - return toString().getBytes(); - } - - /** Get all implemented types. - * @return The implemented UNO types. - */ - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - - Type types[] = new Type[interfaces.length]; - for(int i = 0; i < interfaces.length; ++ i) - types[i] = new Type(interfaces[i]); - - return types; - } -} diff --git a/qadevOOo/runner/basicrunner/basichelper/DocumentHandler.java b/qadevOOo/runner/basicrunner/basichelper/DocumentHandler.java deleted file mode 100644 index 62909f16dd4f..000000000000 --- a/qadevOOo/runner/basicrunner/basichelper/DocumentHandler.java +++ /dev/null @@ -1,344 +0,0 @@ -/************************************************************************* - * - * 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 basicrunner.basichelper; - -import com.sun.star.lang.XInitialization; -import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.lang.XTypeProvider; -import com.sun.star.uno.Type; -import com.sun.star.xml.sax.XDocumentHandler; -import com.sun.star.container.XNameAccess; -import com.sun.star.container.NoSuchElementException; -import java.util.Vector; -import util.XMLTools.Tag; -import util.XMLTools; -import java.io.StringWriter; -import java.io.PrintWriter; - -/** - * This class provides a handler of the BASIC test document. - * @see com.sun.star.lang.XSingleServiceFactory - * @see com.sun.star.lang.XServiceInfo - */ -public class DocumentHandler implements XServiceInfo, XSingleServiceFactory { - /** The service name of this class **/ - static final String __serviceName = "basichelper.DocumentHandler"; - /** The actual handler of the document **/ - static DocumentHandlerImpl oDocumentHandler = null; - /** A string writer **/ - private StringWriter writer; - /** The log writer (just a wrapper around <code>writer</code>) **/ - private PrintWriter log; - - /** - * Create an instance of the document handler. - * @param args A boolean value as <codde>args[0]</code> determines, - * if checked XML data is printed to the log. - * Default is false. - * @return The document handler - */ - public Object createInstanceWithArguments(Object[] args) { - boolean printXML = false; - if (args != null && args.length!=0 && args[0] instanceof Boolean) - printXML = ((Boolean)args[0]).booleanValue(); - writer = new StringWriter(); - log = new PrintWriter(writer); - oDocumentHandler = new DocumentHandlerImpl(log, printXML, writer); - return oDocumentHandler; - } - - /** - * Create an instance of the document handler. - * @return The document handler - */ - public Object createInstance() { - return createInstanceWithArguments(null); - } - - /** Get the unique id for this implementation - * @return The id. - */ - public byte[] getImplementationId() { - return toString().getBytes(); - } - - /** Get all implemented types. - * @return The implemented UNO types. - */ - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - Type types[] = new Type[interfaces.length]; - for(int i = 0; i < interfaces.length; ++ i) - types[i] = new Type(interfaces[i]); - return types; - } - - /** Is this servioce supported? - * @param name The service name. - * @return True, if the service is supported. - */ - public boolean supportsService(String name) { - return __serviceName.equals(name); - } - - /** - * Get all supported service names. - * @return All supported servcices. - */ - public String[] getSupportedServiceNames() { - return new String[] {__serviceName}; - } - - /** - * Get the implementation name of this class. - * @return The implementation name. - */ - public String getImplementationName() { - return getClass().getName(); - } -} - -/** - * The actual implementation of the document handler - * @see util.XMLTools.XMLChecker - * @see com.sun.star.lang.XInitialization - * @see com.sun.star.xml.sax.XDocumentHandler - * @see com.sun.star.container.XNameAccess - * @see com.sun.star.lang.XTypeProvider - */ -class DocumentHandlerImpl extends XMLTools.XMLChecker - implements XInitialization, XDocumentHandler, - XNameAccess, XTypeProvider { - /** A string writer **/ - private StringWriter writer; - - /** - * Constructor - * @param log_ A log writer. - * @param printXML Should XML data be printed to the log? - * @param logWriter A wrapper around <code>log_</code> for convenience. - */ - public DocumentHandlerImpl(PrintWriter log_, - boolean printXML, StringWriter logWriter) { - super(log_, printXML); - writer = logWriter; - } - - /** - * Initialize this class with rules. - * @param parm1 An array of filter rules: - * <code>processAction()</code> is called for every rule. - * @throws com.sun.star.uno.Exception for an incorrect rule. - */ - public void initialize(Object[] parm1) throws com.sun.star.uno.Exception { - if (!(parm1[0] instanceof Object[])) return; - for (int i=0; i<parm1.length; i++) { - processActionForXMLChecker((Object[])parm1[i]); - } - } - - /** - * Method processes all filters received from basic tests. - * Called by initialize(). - * @param filterRule An array building one filter rule. - * @throws com.sun.star.uno.Exception for an incorrect rule. - */ - private void processActionForXMLChecker(Object[] filterRule) - throws com.sun.star.uno.Exception { - int arrLen = filterRule.length; - String oTagName; - Object[] oTags; - Object[] oTag; - int tagsNum = arrLen-1; - Vector allTags = new Vector(); - String CDATA = ""; - String action = ""; - - // First element of rule is RuleName and should be String - if (!(filterRule[0] instanceof String)) { - throw new com.sun.star.uno.Exception("Error: incorrect filter rule "+ - "received from basic test! Rule name must be a String."); - } else { - action = (String) filterRule[0]; - } - - // Searching for character data and defining amount of tags received. - for (int j=1; j<arrLen; j++) { - if ( (filterRule[j] instanceof String) && (j != 1) ) { - CDATA = (String) filterRule[j]; - tagsNum--; - } - } - - // Adding received tags to internal array. - oTags = new Object[tagsNum]; - for (int j=1; j<=tagsNum; j++) { - if (filterRule[j] instanceof Object[]) { - oTags[j-1] = (Object[]) filterRule[j]; - } - } - - // Process all received tags for a given filter rule - for (int i=0; i<oTags.length; i++) { - if (oTags[i] instanceof Object[]) { - oTag = (Object[]) oTags[i]; - oTagName = (String) oTag[0]; - } else if (oTags[i] instanceof Object) { - oTag = new Object[1]; - oTag[0] = (Object) oTags[i]; - oTagName = (String) oTag[0]; - } else { - throw new com.sun.star.uno.Exception("Error: invalid tag "+ - "received from basic test! Check tag " - +i+" in rule '"+action+"'."); - } - - // Action for constructor Tag(TagName, attrName, attrValue) - if (oTag.length == 3) { - if ((oTag[1] instanceof String)&&(oTag[2] instanceof String)) { - allTags.add(new Tag(oTagName, - (String) oTag[1], (String) oTag[2])); - } else { - throw new com.sun.star.uno.Exception("Error: invalid tag '"+ - oTagName+"' received from basic test!"); - } - - // Action for constructors: - // Tag(TagName, String[][] attrValues ) - // Tag(TagName, String[] attrNames) - // Tag(TagName, String attrName) - // - } else if (oTag.length == 2) { - if (oTag[1] instanceof String[][]) { - allTags.add(new Tag(oTagName, (String[][]) oTag[1])); - } else if (oTag[1] instanceof String[]) { - allTags.add(new Tag(oTagName, (String[]) oTag[1])); - } else if (oTag[1] instanceof String) { - allTags.add(new Tag(oTagName, (String) oTag[1])); - } else { - throw new com.sun.star.uno.Exception("Error: invalid tag '"+ - oTagName+"' received from basic test!"); - } - - // Action for constructor Tag(TagName) - } else if (oTag.length == 1) { - if (oTag[0] instanceof String) { - allTags.add(new Tag(oTagName)); - } else { - throw new com.sun.star.uno.Exception("Error: invalid tag '"+ - oTagName+"' received from basic test!"); - } - } else { - throw new com.sun.star.uno.Exception("Error: invalid tag '"+ - oTagName+"' received from basic test!"); - } - } - - // Adding tags to XMLChecker - if ( action.equals((String)"TagExists") ) { - for (int i=0; i<allTags.size(); i++) { - addTag((Tag)allTags.get(i)); - } - } else if (action.equals((String)"TagEnclosed")) { - addTagEnclosed((Tag) allTags.get(0), (Tag) allTags.get(1)); - } else if (action.equals((String)"CharsEnclosed")) { - addCharactersEnclosed(CDATA, (Tag) allTags.get(0)); - } else { - throw new com.sun.star.uno.Exception("Error: incorrect rule name '"+ - action+"' received from basic test!"); - } - } - - /** - * Get the names of the elements. - * @return element names. - */ - public String[] getElementNames() { - return new String[]{"XMLCode", "XMLIsCorrect"}; - } - - /** - * Is this an element? - * @param name Element name. - * @return true, if <code>name>/code> is the name of an element. - */ - public boolean hasByName(String name) { - return (name.equals("XMLCode") || name.equals("XMLIsCorrect")); - } - - /** - * Get an element by its name. - * @param name The element name. - * @return The element with the specified <code>name</code>. - * @throws NoSuchElementException Is thrown, if name does not exist. - */ - public Object getByName(String name) throws NoSuchElementException{ - if (name.equals("XMLIsCorrect")) - return new Boolean(this.check()); - else if (name.equals("XMLCode")) { - return writer.getBuffer().toString(); - } else - throw new NoSuchElementException(); - } - - /** - * Are there any elements? - * @return Always true. - */ - public boolean hasElements() { - return true; - } - - /** - * Get the element type. - * @return The type. - */ - public Type getElementType() { - return new Type(Object.class); - } - - /** - * Get a unique id for this implementation. - * @return The id. - */ - public byte[] getImplementationId() { - return toString().getBytes(); - } - - /** - * Return all implemented types of this class. - * @return The implemented UNO types. - */ - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - Type types[] = new Type[interfaces.length]; - for(int i = 0; i < interfaces.length; ++ i) - types[i] = new Type(interfaces[i]); - return types; - } -} diff --git a/qadevOOo/runner/basicrunner/basichelper/Filter.java b/qadevOOo/runner/basicrunner/basichelper/Filter.java deleted file mode 100644 index d9616d30e5b2..000000000000 --- a/qadevOOo/runner/basicrunner/basichelper/Filter.java +++ /dev/null @@ -1,269 +0,0 @@ -/************************************************************************* - * - * 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 basicrunner.basichelper; - -import com.sun.star.lang.XInitialization; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.lang.XTypeProvider; -import com.sun.star.uno.Type; -import com.sun.star.container.XNameAccess; -import com.sun.star.container.NoSuchElementException; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.document.XFilter; -import com.sun.star.beans.PropertyValue; - - -/** - * Provides an implementation of XFilter. - * @see com.sun.star.document.XFilter - * @see com.sun.star.lang.XServiceInfo - * @see com.sun.star.lang.XSingleServiceFactory - */ -public class Filter implements XServiceInfo, XSingleServiceFactory { - /** The service name of this class **/ - static final String __serviceName = "basichelper.Filter"; - /** The actual filter **/ - static FilterImpl oFilter = null; - - /** - * Construct a new filter - */ - public Filter() { - oFilter = new FilterImpl(); - } - - /** - * Returns an instance of the filter. - * Arguments are not supported here and will be ignored. - * @param args The arguments. - * @return The filter. - */ - public Object createInstanceWithArguments(Object[] args) { - return oFilter; - } - - /** - * Returns an instance of the filter. - * @return The filter. - */ - public Object createInstance() { - return createInstanceWithArguments(null); - } - - /** - * Get a unique id for this implementation. - * @return The id. - */ - public byte[] getImplementationId() { - return toString().getBytes(); - } - - /** - * Return all implemented types of this class. - * @return The implemented UNO types. - */ - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - - Type types[] = new Type[interfaces.length]; - for(int i = 0; i < interfaces.length; ++ i) - types[i] = new Type(interfaces[i]); - - return types; - } - - /** Is this servioce supported? - * @param name The service name. - * @return True, if the service is supported. - */ - public boolean supportsService(String name) { - return __serviceName.equals(name); - } - - /** - * Get all supported service names. - * @return All supported servcices. - */ - public String[] getSupportedServiceNames() { - return new String[] {__serviceName}; - } - - /** - * Get the implementation name of this class. - * @return The implementation name. - */ - public String getImplementationName() { - return getClass().getName(); - } -} - -/** - * The actual filter implementation - * @see com.sun.star.lang.XInitialization; - * @see com.sun.star.lang.XTypeProvider; - * @see com.sun.star.container.XNameAccess; - */ -class FilterImpl implements XInitialization, XTypeProvider, XNameAccess { - /** A state **/ - static String aState; - /** A result **/ - static boolean bResult; - - /** - * Constructs a new filter. - */ - public FilterImpl() { - aState = "just created"; - bResult = false; - } - - /** - * Get the element names - * @return All element names. - */ - public String[] getElementNames() { - return new String[]{"State", "Result"}; - } - - /** - * Does this element exist? - * @param name The element name. - * @return True, if the name exists. - */ - public boolean hasByName(String name) { - return (name.equals("State") || name.equals("Result")); - } - - /** - * Get an element by its name. - * @param name The name of the element. - * @return The value of the element. - * @throws NoSuchElementException The element does not exist. - */ - public Object getByName(String name) throws NoSuchElementException{ - if (name.equals("State")) - return aState; - else if (name.equals("Result")) - return new Boolean(bResult); - else - throw new NoSuchElementException(); - } - - /** - * Are there elements - * @return Always true. - */ - public boolean hasElements() { - return true; - } - - /** - * Get element type. - * @return null. - */ - public Type getElementType() { - return null; - } - - /** - * Get a unique id for this implementation. - * @return The id. - */ - public byte[] getImplementationId() { - return toString().getBytes(); - } - - /** - * Return all implemented types of this class. - * @return The implemented UNO types. - */ - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - - Type types[] = new Type[interfaces.length]; - for(int i = 0; i < interfaces.length; ++ i) - types[i] = new Type(interfaces[i]); - - return types; - } - - - /** - * Method initialize() creates a new thread that will try to start - * filtering - * @param parm1 An instance of XFilter - * @see com.sun.star.document.XFilter - * @throws Exception Is thrown, when initialize fails. - */ - public void initialize(Object[] parm1) throws com.sun.star.uno.Exception { - XFilter oFilter = (XFilter)UnoRuntime.queryInterface( - XFilter.class, parm1[0]); -//? PropertyValue[] FilterDesc = (PropertyValue[])AnyConverter.toArray(parm1[1]); - PropertyValue[] FilterDesc = (PropertyValue[])UnoRuntime.queryInterface(PropertyValue[].class, parm1[1]); - aState = "just initialized"; - FilterThread aThread = new FilterThread(oFilter, FilterDesc); - aThread.start(); - } -} - -/** - * A thread for filtering. - */ -class FilterThread extends Thread { - /** The filter that is used **/ - XFilter oFilter = null; - /** Filter descriptions **/ - PropertyValue[] FilterDesc = null; - - /** - * Construct the thread. - * @param oObj The filter. - * @param Desc The descriptions. - */ - public FilterThread(XFilter oObj, PropertyValue[] Desc){ - oFilter = oObj; - FilterDesc = Desc; - } - - /** - * Let the thread run - */ - public void run(){ - boolean bOK; - try { - FilterImpl.aState = "before filtering"; - bOK = oFilter.filter(FilterDesc); - FilterImpl.aState = "filtering finished"; - FilterImpl.bResult = bOK; - } catch (Exception e) { - ConnectorImpl.aState = "error"; - throw new RuntimeException("Can't filtering exception" - + e.toString()); - } - } -} diff --git a/qadevOOo/runner/basicrunner/basichelper/ThreadRunner.java b/qadevOOo/runner/basicrunner/basichelper/ThreadRunner.java deleted file mode 100644 index ec8957e01a6f..000000000000 --- a/qadevOOo/runner/basicrunner/basichelper/ThreadRunner.java +++ /dev/null @@ -1,254 +0,0 @@ -/************************************************************************* - * - * 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 basicrunner.basichelper; - -import com.sun.star.beans.PropertyValue; -import com.sun.star.lang.XInitialization; -import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.lang.XTypeProvider; -import com.sun.star.uno.Type; -import com.sun.star.frame.XDispatch; -import com.sun.star.frame.XDispatchProvider; -import com.sun.star.frame.XModel; -import com.sun.star.util.XURLTransformer; -import com.sun.star.frame.XController; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.util.URL; -import com.sun.star.lang.XMultiServiceFactory; -import util.utils; -import com.sun.star.lang.XComponent; -import lib.StatusException; -import lib.Status; -import util.SOfficeFactory; -import com.sun.star.ui.dialogs.XExecutableDialog; - - -public class ThreadRunner implements XServiceInfo, XSingleServiceFactory { - static final String __serviceName = "basichelper.ThreadRunner"; - static ThreadRunnerImpl oThreadRunner = null; - - public ThreadRunner(XMultiServiceFactory xMSF) { - oThreadRunner = new ThreadRunnerImpl(xMSF); - } - - public Object createInstanceWithArguments(Object[] args) { - return oThreadRunner; - } - - public Object createInstance() { - return createInstanceWithArguments(null); - } - - public byte[] getImplementationId() { - return toString().getBytes(); - } - - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - Type types[] = new Type[interfaces.length]; - for(int i = 0; i < interfaces.length; ++ i) - types[i] = new Type(interfaces[i]); - return types; - } - - public boolean supportsService(String name) { - return __serviceName.equals(name); - } - - public String[] getSupportedServiceNames() { - return new String[] {__serviceName}; - } - - public String getImplementationName() { - return getClass().getName(); - } -} - - -class ThreadRunnerImpl implements XInitialization, XTypeProvider { - Object oDoc = null; - String actionType = null; - String actionParm = null; - XMultiServiceFactory oMSF = null; - - public ThreadRunnerImpl(XMultiServiceFactory MSF) { - oMSF = MSF; - } - - public void initialize(Object[] params) throws com.sun.star.uno.Exception { - boolean parmsOK = false; - - if (!(params[0] instanceof String)) { - throw new StatusException(Status.failed( - "Wrong first parameter for ThreadRunner, allowed values:" + - "'OpenToolkitDialog', 'OpenDialogFromFile', 'ExecuteDialog'")); - } - - actionType = (String) params[0]; - - if (actionType.equals("OpenToolkitDialog")) { - if (params.length != 3 || !(params[2] instanceof Object) || - !(params[1] instanceof String) ) { - throw new StatusException(Status.failed("Expected the " + - "following type of parameters for 'OpenToolkitDialog': " + - "String, Object")); - } - actionParm = (String)params[1]; - oDoc = (Object)params[2]; - ToolkitDialogThread aThread = - new ToolkitDialogThread(oMSF, oDoc, actionParm); - aThread.start(); - } else if (actionType.equals("OpenDialogFromFile")) { - if (params.length != 2 || !(params[1] instanceof String) ) { - throw new StatusException(Status.failed("Expected the " + - "following type of parameters for 'OpenDialogFromFile': " + - "String")); - } - actionParm = (String)params[1]; - DialogFromFileThread bThread = - new DialogFromFileThread(oMSF, actionParm); - bThread.start(); - } else if ( actionType.equals("ExecuteDialog")) { - if (params.length != 2 || !(params[1] instanceof String)) { - throw new StatusException(Status.failed("Expected the " + - "following type of parameters for 'ExecuteDialog': " + - "String")); - } - ExecuteDialogThread cThread = - new ExecuteDialogThread(oMSF, (String)params[1]); - cThread.start(); - } else { - System.out.println("Error! ThreadRunnerImpl.initialize(): " + - "Incorrect parameters!"); - } - } - - public byte[] getImplementationId() { - return toString().getBytes(); - } - - public Type[] getTypes() { - Class interfaces[] = getClass().getInterfaces(); - Type types[] = new Type[interfaces.length]; - for(int i = 0; i < interfaces.length; ++ i) - types[i] = new Type(interfaces[i]); - return types; - } -} - - -class ToolkitDialogThread extends Thread { - Object oDoc = null; - String url = null; - XMultiServiceFactory msf = null; - - public ToolkitDialogThread(XMultiServiceFactory xMSF, Object doc, String sUrl) { - oDoc = doc; - url = sUrl; - msf = xMSF; - } - - public void run() { - XModel aModel = (XModel) UnoRuntime.queryInterface(XModel.class, oDoc); - XController xController = aModel.getCurrentController(); - try { - XDispatchProvider xDispProv = (XDispatchProvider) - UnoRuntime.queryInterface( XDispatchProvider.class, xController ); - XURLTransformer xParser = (com.sun.star.util.XURLTransformer) - UnoRuntime.queryInterface(XURLTransformer.class, - msf.createInstance("com.sun.star.util.URLTransformer")); - URL[] aParseURL = new URL[1]; - aParseURL[0] = new URL(); - aParseURL[0].Complete = url; - xParser.parseStrict(aParseURL); - URL aURL = aParseURL[0]; - XDispatch xDispatcher = xDispProv.queryDispatch( aURL,"",0); - if( xDispatcher != null ) - xDispatcher.dispatch( aURL, null ); - } catch (com.sun.star.uno.Exception e) { - System.out.println("Couldn't open dialog!!!"); - throw new StatusException( "Couldn't open dialog!!!", e ); - } - } -} - - -class DialogFromFileThread extends Thread { - String url = null; - SOfficeFactory SOF = null; - XMultiServiceFactory myMSF = null; - - public DialogFromFileThread(XMultiServiceFactory xMSF, String sUrl) { - url = sUrl; - SOF = SOfficeFactory.getFactory(xMSF); - myMSF = xMSF; - } - - public void run() { - try { - PropertyValue[] args = new PropertyValue[1]; - args[0] = new PropertyValue(); - args[0].Name = "InteractionHandler"; - args[0].Value = myMSF.createInstance( - "com.sun.star.comp.uui.UUIInteractionHandler"); - - String testUrl= utils.getFullTestURL(url); - System.out.println("loading "+testUrl); - XComponent xDoc = SOF.loadDocument(testUrl, args); - } catch (com.sun.star.uno.Exception e) { - System.out.println("Couldn't create document!!!"); - throw new StatusException( "Couldn't create document!!!", e ); - } - } - -} - -class ExecuteDialogThread extends Thread { - XMultiServiceFactory xMSF = null; - String serviceName = null; - - public ExecuteDialogThread(XMultiServiceFactory xMSF, String serviceName) { - this.xMSF = xMSF; - this.serviceName = serviceName; - } - - public void run() { - Object dlg = null; - try { - dlg = xMSF.createInstance(serviceName); - } catch(com.sun.star.uno.Exception e) { - throw new StatusException(Status.failed("Couldn't create service")); - } - XExecutableDialog execDlg = (XExecutableDialog)UnoRuntime.queryInterface - (XExecutableDialog.class, dlg); - execDlg.execute(); - } -} - - |