summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas O'Connor <toconnor@openoffice.org>2002-11-20 13:11:25 +0000
committerTomas O'Connor <toconnor@openoffice.org>2002-11-20 13:11:25 +0000
commit6c4dc427b0b35e15ff2d8384b1063966532174f8 (patch)
tree31af91d79dbf25958662504afea1b17e738443d4
parent89d12ee72bfef031eedb6764093860e797a7ba25 (diff)
Add some jsuite tests for the Scripting Framework
-rw-r--r--scripting/workben/data/share_scripts.zipbin0 -> 2248 bytes
-rw-r--r--scripting/workben/data/user_scripts.zipbin0 -> 6890 bytes
-rw-r--r--scripting/workben/ifc/scripting/ScriptingUtils.java168
-rw-r--r--scripting/workben/ifc/scripting/_XScriptInvocation.java201
-rw-r--r--scripting/workben/ifc/scripting/_XScriptNameResolver.java230
-rw-r--r--scripting/workben/ifc/scripting/_XScriptStorageManager.java240
-rw-r--r--scripting/workben/ifc/scripting/makefile.mk75
-rw-r--r--scripting/workben/mod/_scripting/ScriptRuntimeManager.java100
-rw-r--r--scripting/workben/mod/_scripting/ScriptStorageManager.java115
-rw-r--r--scripting/workben/mod/_scripting/makefile.mk75
10 files changed, 1204 insertions, 0 deletions
diff --git a/scripting/workben/data/share_scripts.zip b/scripting/workben/data/share_scripts.zip
new file mode 100644
index 000000000000..7c7fec622930
--- /dev/null
+++ b/scripting/workben/data/share_scripts.zip
Binary files differ
diff --git a/scripting/workben/data/user_scripts.zip b/scripting/workben/data/user_scripts.zip
new file mode 100644
index 000000000000..f5eed7657365
--- /dev/null
+++ b/scripting/workben/data/user_scripts.zip
Binary files differ
diff --git a/scripting/workben/ifc/scripting/ScriptingUtils.java b/scripting/workben/ifc/scripting/ScriptingUtils.java
new file mode 100644
index 000000000000..81104d66cbc8
--- /dev/null
+++ b/scripting/workben/ifc/scripting/ScriptingUtils.java
@@ -0,0 +1,168 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptingUtils.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change:$Date: 2002-11-20 14:11:22 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package ifc.script.framework;
+
+import java.io.File;
+import drafts.com.sun.star.script.framework.storage.XScriptStorageManager;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.XComponentContext;
+
+public class ScriptingUtils {
+ private XScriptStorageManager storageManager;
+ private static ScriptingUtils utils;
+
+ public static final String USER_LOGICAL_NAME =
+ "script://user.jsuite.test";
+ public static final String SHARE_LOGICAL_NAME =
+ "script://share.jsuite.test";
+ public static final String DOC_LOGICAL_NAME =
+ "script://doc.jsuite.testMethod";
+
+ public static final String SCRIPT_IN_CLASSFILE_DOC_NAME =
+ "script_in_class_file.sxw";
+
+ public static final String SCRIPT_IN_JARFILE_DOC_NAME =
+ "script_in_jar_file.sxw";
+
+ public static final String DOC_WITH_ONE_SCRIPT =
+ "doc_with_one_script.sxw";
+
+ public static final String DOC_WITH_TWO_SCRIPTS =
+ "doc_with_two_scripts.sxw";
+
+ public static final String XSCRIPTCONTEXT_TEST_DOCUMENT =
+ "xscriptcontext_test_document.sxw";
+
+ private ScriptingUtils() {
+ }
+
+ public static ScriptingUtils getDefault() {
+ if (utils == null) {
+ synchronized (ScriptingUtils.class) {
+ if (utils == null)
+ utils = new ScriptingUtils();
+ }
+ }
+ return utils;
+ }
+
+ public static void cleanUserDir() {
+ }
+
+ public static void cleanShareDir() {
+ }
+
+ public int getScriptStorageId(XMultiServiceFactory xMSF, String uri) {
+
+ XSimpleFileAccess access = null;
+
+ if (storageManager == null) {
+ try {
+ XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xMSF);
+
+ XComponentContext xContext = (XComponentContext)
+ UnoRuntime.queryInterface(XComponentContext.class,
+ xProp.getPropertyValue("DefaultContext"));
+
+ XInterface ifc = (XInterface)
+ xContext.getValueByName("/singletons/drafts.com.sun.star." +
+ "script.framework.storage.theScriptStorageManager");
+
+ storageManager = (XScriptStorageManager)
+ UnoRuntime.queryInterface(XScriptStorageManager.class, ifc);
+ }
+ catch( Exception e ) {
+ return -1;
+ }
+ }
+
+ access = getXSimpleFileAccess(xMSF);
+ if (access == null)
+ return -1;
+
+ int id = storageManager.createScriptStorageWithURI(access, uri);
+
+ return id;
+ }
+
+ public XSimpleFileAccess getXSimpleFileAccess(XMultiServiceFactory xMSF) {
+ XSimpleFileAccess access = null;
+
+ try {
+ Object fa =
+ xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+
+ access = (XSimpleFileAccess)
+ UnoRuntime.queryInterface(XSimpleFileAccess.class, fa);
+ }
+ catch (com.sun.star.uno.Exception e) {
+ return null;
+ }
+ return access;
+ }
+}
diff --git a/scripting/workben/ifc/scripting/_XScriptInvocation.java b/scripting/workben/ifc/scripting/_XScriptInvocation.java
new file mode 100644
index 000000000000..cc9fb8a99014
--- /dev/null
+++ b/scripting/workben/ifc/scripting/_XScriptInvocation.java
@@ -0,0 +1,201 @@
+/*************************************************************************
+ *
+ * $RCSfile: _XScriptInvocation.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change:$Date: 2002-11-20 14:11:23 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package ifc.script.framework;
+
+import java.util.HashMap;
+
+import drafts.com.sun.star.script.framework.XScriptInvocation;
+import drafts.com.sun.star.script.framework.storage.XScriptInfo;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XComponent;
+import com.sun.star.frame.XModel;
+
+import lib.MultiMethodTest;
+import lib.StatusException;
+import lib.Parameters;
+import util.SOfficeFactory;
+
+public class _XScriptInvocation extends MultiMethodTest {
+
+ public XScriptInvocation oObj = null;
+ private XComponent oDoc = null;
+
+ /**
+ * Retrieves object relation.
+ */
+ public void before() throws StatusException {
+ SOfficeFactory factory = SOfficeFactory.getFactory(tParam.getMSF());
+
+ String name = util.utils.getFullTestURL(
+ "xscriptcontext_test_document.sxw");
+
+ try {
+ oDoc = factory.loadDocument(name);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae) {
+ log.println("Exception while preloading document: " + iae);
+ }
+ catch (Exception e) {
+ log.println("Exception while preloading document: " + e);
+ }
+
+ try {
+ Thread.sleep(5000);
+ }
+ catch (InterruptedException ie) {
+ }
+ }
+
+ public void after() throws StatusException {
+ if (oDoc != null)
+ oDoc.dispose();
+ }
+
+ public void _invoke() {
+ boolean result = true;
+
+ result &= testUserInvoke();
+ result &= testUserInvokeWithContext();
+ result &= testUserInvokeScriptInJar();
+ // if (oDoc != null)
+ // result &= testDocumentInvoke();
+
+ // result &= testInvokeExceptions();
+
+ tRes.tested("invoke()", result);
+ }
+
+ private boolean testUserInvoke() {
+ log.println("Try invoking a user level script");
+ return testInvoke(ScriptingUtils.USER_LOGICAL_NAME, 1);
+ }
+
+ private boolean testUserInvokeWithContext() {
+ log.println("Try invoking a user level script with an XScriptContext");
+
+ XModel model = (XModel) UnoRuntime.queryInterface(XModel.class, oDoc);
+ return testInvoke("script://xscriptcontext.jsuite.test", 1, model);
+ }
+
+ private boolean testUserInvokeScriptInJar() {
+ log.println("Try invoking a user level script in a Jar file");
+
+ return testInvoke("script://jarscript.jsuite.test", 1);
+ }
+
+ private boolean testDocumentInvoke() {
+ log.println("Try invoking a user level script");
+
+ String name = util.utils.getFullTestURL(
+ ScriptingUtils.XSCRIPTCONTEXT_TEST_DOCUMENT);
+
+ int storageId = ScriptingUtils.getDefault().getScriptStorageId(
+ tParam.getMSF(), name);
+
+ return testInvoke("script://xscriptcontext.jsuite.test", storageId);
+ }
+
+ private boolean testInvoke(String logicalName, int storageId) {
+ return testInvoke(logicalName, storageId, null);
+ }
+
+ private boolean testInvoke(String logicalName, int storageId, XModel ctx) {
+ HashMap map = new HashMap();
+ map.put("SCRIPTING_DOC_STORAGE_ID", new Integer(storageId));
+ map.put("SCRIPTING_DOC_URI", "hahaha");
+ if (ctx != null)
+ map.put("SCRIPTING_DOC_REF", ctx);
+
+ Parameters params = new Parameters(map);
+ Object[] args = new Object[0];
+
+ Object[][] result = new Object[1][0];
+ result[0] = new Object[0];
+
+ short[][] num = new short[1][0];
+ num[0] = new short[0];
+
+ try {
+ oObj.invoke(logicalName, params, args, num, result);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae) {
+ log.println("Couldn't invoke script:" + iae);
+ return false;
+ }
+ catch (com.sun.star.script.CannotConvertException cce) {
+ log.println("Couldn't invoke script:" + cce);
+ return false;
+ }
+ catch (com.sun.star.reflection.InvocationTargetException ite) {
+ log.println("Couldn't invoke script:" + ite);
+ return false;
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Couldn't invoke script:" + re);
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/scripting/workben/ifc/scripting/_XScriptNameResolver.java b/scripting/workben/ifc/scripting/_XScriptNameResolver.java
new file mode 100644
index 000000000000..117310e222f5
--- /dev/null
+++ b/scripting/workben/ifc/scripting/_XScriptNameResolver.java
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * $RCSfile: _XScriptNameResolver.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change:$Date: 2002-11-20 14:11:23 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package ifc.script.framework;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import drafts.com.sun.star.script.framework.XScriptNameResolver;
+import drafts.com.sun.star.script.framework.storage.XScriptInfo;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.XInterface;
+
+import lib.MultiMethodTest;
+import lib.StatusException;
+import lib.Parameters;
+
+public class _XScriptNameResolver extends MultiMethodTest {
+
+ public XScriptNameResolver oObj = null;
+
+ /**
+ * Retrieves object relation.
+ */
+ public void before() throws StatusException {
+ }
+
+ public void _resolve() {
+ boolean result = true;
+
+ result &= testValidURIs();
+ result &= testInvalidURIs();
+ result &= testNonExistentURIs();
+
+ tRes.tested("resolve()", result);
+ }
+
+ private boolean testValidURIs() {
+ boolean result = true;
+
+ log.println("Try to resolve a valid document script URI");
+
+ String name = util.utils.getFullTestURL(
+ ScriptingUtils.SCRIPT_IN_CLASSFILE_DOC_NAME);
+
+ int storageId = ScriptingUtils.getDefault().getScriptStorageId(
+ tParam.getMSF(), name);
+
+ result &= testValidURI(ScriptingUtils.DOC_LOGICAL_NAME, storageId);
+
+ log.println("Try to resolve a valid user script URI");
+ result &= testValidURI(ScriptingUtils.USER_LOGICAL_NAME, 1);
+
+ log.println("Try to resolve a valid share script URI");
+ result &= testValidURI(ScriptingUtils.SHARE_LOGICAL_NAME, 0);
+
+ return result;
+ }
+
+ private boolean testValidURI(String logicalName, int storageId) {
+ HashMap map = new HashMap();
+ map.put("SCRIPTING_DOC_STORAGE_ID", new Integer(storageId));
+ map.put("SCRIPTING_DOC_URI", "hahaha");
+
+ Parameters params = new Parameters(map);
+ Object[] args = new Object[] {params};
+
+ try {
+ XInterface ifc = (XInterface)
+ oObj.resolve(logicalName, args);
+
+ Integer resolvedId = (Integer)
+ params.getPropertyValue("SCRIPTING_RESOLVED_STORAGE_ID");
+
+ if (resolvedId == null) {
+ log.println("SCRIPTING_RESOLVED_STORAGE_ID not in return args");
+ return false;
+ }
+
+ if (resolvedId.intValue() != storageId) {
+ log.println("Wrong SCRIPTING_RESOLVED_STORAGE_ID returned");
+ return false;
+ }
+
+ if (ifc == null ||
+ UnoRuntime.queryInterface(XScriptInfo.class, ifc) == null)
+ {
+ log.println("Can't get XScriptInfo from resolved interface");
+ return false;
+ }
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae) {
+ log.println("Couldn't resolve URI:" + iae);
+ return false;
+ }
+ catch (com.sun.star.script.CannotConvertException cce) {
+ log.println("Couldn't resolve URI:" + cce);
+ return false;
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Couldn't resolve URI:" + re);
+ return false;
+ }
+ return true;
+ }
+
+ private boolean testInvalidURIs() {
+ log.println("Try an invalid URI, should throw IllegalArgumentException");
+ try {
+ HashMap map = new HashMap();
+ map.put("SCRIPTING_DOC_STORAGE_ID", new Integer(0));
+ map.put("SCRIPTING_DOC_URI", "hahaha");
+
+ Parameters params = new Parameters(map);
+ Object[] args = new Object[] {params};
+
+ XInterface ifc = (XInterface)
+ oObj.resolve("scrpit://HighlightText.showForm", args);
+ log.println("Should not have resolved invalid URI");
+ return false;
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae) {
+ log.println("Correctly got exception:" + iae);
+ }
+ catch (com.sun.star.script.CannotConvertException cce) {
+ log.println("Got wrong exception" + cce);
+ return false;
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Got wrong exception:" + re);
+ return false;
+ }
+ return true;
+ }
+
+ private boolean testNonExistentURIs() {
+ log.println("Try a valid but non-existent URI");
+ try {
+ HashMap map = new HashMap();
+ map.put("SCRIPTING_DOC_STORAGE_ID", new Integer(0));
+ map.put("SCRIPTING_DOC_URI", "hahaha");
+
+ Parameters params = new Parameters(map);
+ Object[] args = new Object[] {params};
+
+ XInterface ifc = (XInterface)
+ oObj.resolve("script://Non.Existent", args);
+
+ if (ifc != null &&
+ UnoRuntime.queryInterface(XScriptInfo.class, ifc) != null)
+ {
+ log.println("Should not have resolved non-existent URI");
+ return false;
+ }
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae) {
+ log.println("Couldn't resolve name:" + iae);
+ return false;
+ }
+ catch (com.sun.star.script.CannotConvertException cce) {
+ log.println("Couldn't resolve name:" + cce);
+ return false;
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Got wrong exception:" + re);
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/scripting/workben/ifc/scripting/_XScriptStorageManager.java b/scripting/workben/ifc/scripting/_XScriptStorageManager.java
new file mode 100644
index 000000000000..d0a0f548e6bd
--- /dev/null
+++ b/scripting/workben/ifc/scripting/_XScriptStorageManager.java
@@ -0,0 +1,240 @@
+/*************************************************************************
+ *
+ * $RCSfile: _XScriptStorageManager.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change:$Date: 2002-11-20 14:11:23 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package ifc.script.framework.storage;
+
+import drafts.com.sun.star.script.framework.storage.XScriptStorageManager;
+import drafts.com.sun.star.script.framework.storage.XScriptInfoAccess;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.uno.Exception;
+
+import java.io.PrintWriter;
+import lib.MultiMethodTest;
+import lib.StatusException;
+
+import ifc.script.framework.ScriptingUtils;
+
+public class _XScriptStorageManager extends MultiMethodTest {
+
+ public XScriptStorageManager oObj = null;
+
+ /**
+ * Retrieves object relation.
+ */
+ public void before() throws StatusException {
+ }
+
+ public void _createScriptStorage() {
+ boolean result = true;
+
+ XSimpleFileAccess access =
+ ScriptingUtils.getDefault().getXSimpleFileAccess(tParam.getMSF());
+
+ if (access == null) {
+ result = false;
+ }
+ else {
+ try {
+ int id = oObj.createScriptStorage(access);
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Exception from createScriptStorage: " + re);
+ result = false;
+ }
+ }
+
+ tRes.tested("createScriptStorage()", result);
+ }
+
+ public void _createScriptStorageWithURI() {
+ boolean result = true;
+
+ XSimpleFileAccess access =
+ ScriptingUtils.getDefault().getXSimpleFileAccess(tParam.getMSF());
+
+ String name = util.utils.getFullTestURL(
+ ScriptingUtils.SCRIPT_IN_CLASSFILE_DOC_NAME);
+ int id = oObj.createScriptStorageWithURI(access, name);
+
+ XInterface ifc = (XInterface)oObj.getScriptStorage(id);
+ XScriptInfoAccess info = (XScriptInfoAccess)
+ UnoRuntime.queryInterface(XScriptInfoAccess.class, ifc);
+
+ if (info == null) {
+ log.println("Couldn't get XScriptInfoAccess:");
+ tRes.tested("createScriptStorageWithURI()", false);
+ }
+
+ try {
+ String[] names = info.getScriptLogicalNames();
+
+ if (names == null || names.length == 0) {
+ log.println("No logical names found");
+ result = false;
+ }
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae) {
+ log.println("Couldn't get logical names:" + iae.getMessage());
+ result = false;
+ }
+
+ tRes.tested("createScriptStorageWithURI()", result);
+ }
+
+ public void _getScriptStorage() {
+ boolean result = true;
+
+ log.println("Try getScriptStorage for share");
+ try {
+ XInterface ifc = (XInterface)oObj.getScriptStorage(0);
+
+ if (ifc == null) {
+ log.println("getScriptStorage returned null");
+ result = false;
+ }
+ else {
+ XScriptInfoAccess info = (XScriptInfoAccess)
+ UnoRuntime.queryInterface(XScriptInfoAccess.class, ifc);
+
+ if (info == null) {
+ log.println("Couldn't get XScriptInfoAccess from storage");
+ result = false;
+ }
+ }
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Caught unexpected RuntimeException: " + re);
+ result = false;
+ }
+
+ log.println("Try getScriptStorage for user");
+ try {
+ XInterface ifc = (XInterface)oObj.getScriptStorage(1);
+ if (ifc == null) {
+ log.println("getScriptStorage returned null");
+ result = false;
+ }
+ else {
+ XScriptInfoAccess info = (XScriptInfoAccess)
+ UnoRuntime.queryInterface(XScriptInfoAccess.class, ifc);
+
+ if (info == null) {
+ log.println("Couldn't get XScriptInfoAccess from storage");
+ result = false;
+ }
+ try {
+ String[] names = info.getScriptLogicalNames();
+
+ if (names == null) {
+ log.println("No logical names found");
+ result = false;
+ }
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae) {
+ log.println("Error get logical names:" + iae.getMessage());
+ result = false;
+ }
+ }
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Caught unexpected RuntimeException: " + re);
+ result = false;
+ }
+
+ tRes.tested("getScriptStorage()", result);
+ }
+
+ public void _refreshScriptStorage() {
+ boolean result = true;
+
+ log.println("Try to refresh a URI for non-existent script storage");
+ try {
+ oObj.refreshScriptStorage("file:///does/not/exist");
+ result = false;
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ }
+
+ log.println("Try to refresh a valid document URI");
+ try {
+ XSimpleFileAccess access =
+ ScriptingUtils.getDefault().getXSimpleFileAccess(
+ tParam.getMSF());
+
+ String name = util.utils.getFullTestURL(
+ ScriptingUtils.SCRIPT_IN_CLASSFILE_DOC_NAME);
+
+ int id = oObj.createScriptStorageWithURI(access, name);
+
+ oObj.refreshScriptStorage(name);
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Caught unexpected RuntimeException: " + re);
+ result = false;
+ }
+
+ tRes.tested("refreshScriptStorage()", result);
+ }
+}
diff --git a/scripting/workben/ifc/scripting/makefile.mk b/scripting/workben/ifc/scripting/makefile.mk
new file mode 100644
index 000000000000..93d385f1e604
--- /dev/null
+++ b/scripting/workben/ifc/scripting/makefile.mk
@@ -0,0 +1,75 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: toconnor $ $Date: 2002-11-20 14:11:24 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..
+PRJNAME = testcase
+TARGET = testcase
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+JARFILES = sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar $(CLASSPATH)$
+JAVAFILES = $(foreach,j,$(shell ls | grep java) $j)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/scripting/workben/mod/_scripting/ScriptRuntimeManager.java b/scripting/workben/mod/_scripting/ScriptRuntimeManager.java
new file mode 100644
index 000000000000..abe3ae709e01
--- /dev/null
+++ b/scripting/workben/mod/_scripting/ScriptRuntimeManager.java
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptRuntimeManager.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change:$Date: 2002-11-20 14:11:25 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package mod._scripting;
+
+import com.sun.star.uno.XInterface;
+import java.io.PrintWriter;
+import lib.StatusException;
+import lib.TestCase;
+import lib.TestEnvironment;
+import lib.TestParameters;
+
+public class ScriptRuntimeManager extends TestCase {
+
+ public void initialize( TestParameters tParam, PrintWriter log ) {
+ }
+
+ public synchronized TestEnvironment createTestEnvironment(
+ TestParameters Param, PrintWriter log ) throws StatusException {
+
+ log.println("creating test environment");
+
+ XInterface oObj = null;
+
+ try {
+ oObj = (XInterface) Param.getMSF().createInstance
+ ("drafts.com.sun.star.script.framework.ScriptRuntimeManager");
+ } catch (com.sun.star.uno.Exception e) {
+ throw new StatusException("Can't create object environment", e) ;
+ }
+
+ TestEnvironment tEnv = new TestEnvironment(oObj) ;
+
+ return tEnv ;
+ }
+
+ public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+ TestParameters tParam) {
+ }
+}
+
+
diff --git a/scripting/workben/mod/_scripting/ScriptStorageManager.java b/scripting/workben/mod/_scripting/ScriptStorageManager.java
new file mode 100644
index 000000000000..523c2d5c9ae9
--- /dev/null
+++ b/scripting/workben/mod/_scripting/ScriptStorageManager.java
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptStorageManager.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change:$Date: 2002-11-20 14:11:25 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package mod._scripting;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import java.io.PrintWriter;
+import lib.StatusException;
+import lib.TestCase;
+import lib.TestEnvironment;
+import lib.TestParameters;
+import util.utils;
+
+public class ScriptStorageManager extends TestCase {
+
+ public void initialize( TestParameters tParam, PrintWriter log ) {
+ }
+
+ public synchronized TestEnvironment createTestEnvironment(
+ TestParameters Param, PrintWriter log ) throws StatusException {
+
+ XInterface oObj = null;
+ Object oInterface = null;
+
+ try {
+ XMultiServiceFactory xMSF = Param.getMSF();
+ XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xMSF);
+ // get context
+ XComponentContext xContext = (XComponentContext)
+ UnoRuntime.queryInterface(XComponentContext.class,
+ xProp.getPropertyValue("DefaultContext"));
+ // get the script storage manager from context
+ oInterface = xContext.getValueByName("/singletons/" +
+ "drafts.com.sun.star.script.framework.storage.theScriptStorageManager");
+ }
+ catch( Exception e ) {
+ log.println("ScriptStorageManager singleton service not available" );
+ e.printStackTrace();
+ }
+ oObj = (XInterface) oInterface;
+
+ TestEnvironment tEnv = new TestEnvironment(oObj) ;
+
+ return tEnv ;
+ }
+
+ public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+ TestParameters tParam) {
+ }
+}
+
+
diff --git a/scripting/workben/mod/_scripting/makefile.mk b/scripting/workben/mod/_scripting/makefile.mk
new file mode 100644
index 000000000000..70789a34fb0b
--- /dev/null
+++ b/scripting/workben/mod/_scripting/makefile.mk
@@ -0,0 +1,75 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: toconnor $ $Date: 2002-11-20 14:11:25 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..
+PRJNAME = testcase
+TARGET = testcase
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+JARFILES = sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar $(CLASSPATH)
+JAVAFILES = $(foreach,j,$(shell ls | grep java) $j)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk