summaryrefslogtreecommitdiff
path: root/scripting/workben/ifc/scripting
diff options
context:
space:
mode:
authorTomas O'Connor <toconnor@openoffice.org>2002-12-10 13:12:06 +0000
committerTomas O'Connor <toconnor@openoffice.org>2002-12-10 13:12:06 +0000
commitfa0f14fafc0173b81c414699acbf6820361cb371 (patch)
treef148459bb5bcd4db1237a655456ad80f27bf19ad /scripting/workben/ifc/scripting
parent511b05906b8b4a77d28da432255b24f19b9f5b4b (diff)
Make interface tests generic.
Diffstat (limited to 'scripting/workben/ifc/scripting')
-rw-r--r--scripting/workben/ifc/scripting/_XFunction.java76
-rw-r--r--scripting/workben/ifc/scripting/_XFunctionProvider.java56
-rw-r--r--scripting/workben/ifc/scripting/_XScriptInfo.java324
-rw-r--r--scripting/workben/ifc/scripting/_XScriptInfoAccess.java136
-rw-r--r--scripting/workben/ifc/scripting/_XScriptInvocation.java203
-rw-r--r--scripting/workben/ifc/scripting/_XScriptNameResolver.java202
-rw-r--r--scripting/workben/ifc/scripting/_XScriptStorageManager.java268
-rw-r--r--scripting/workben/ifc/scripting/_XScriptStorageRefresh.java42
8 files changed, 881 insertions, 426 deletions
diff --git a/scripting/workben/ifc/scripting/_XFunction.java b/scripting/workben/ifc/scripting/_XFunction.java
index aa7e89fe41aa..431127ce7c18 100644
--- a/scripting/workben/ifc/scripting/_XFunction.java
+++ b/scripting/workben/ifc/scripting/_XFunction.java
@@ -2,9 +2,9 @@
*
* $RCSfile: _XFunction.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change:$Date: 2002-11-20 14:29:36 $
+ * last change:$Date: 2002-12-10 14:12:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,6 +73,10 @@ import com.sun.star.beans.XPropertySet;
import java.io.PrintWriter;
import lib.MultiMethodTest;
import lib.StatusException;
+import lib.Parameters;
+
+import java.util.Collection;
+import java.util.Iterator;
public class _XFunction extends MultiMethodTest {
@@ -84,41 +88,69 @@ public class _XFunction extends MultiMethodTest {
}
public void _invoke() {
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_invoke");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ result &= runInvokeTest((Parameters)tests.next());
+ }
+ }
+ else {
+ result = false;
+ }
+
+ tRes.tested("invoke()", result);
+ }
+
+ private boolean runInvokeTest(Parameters testdata) {
+ String description = testdata.get("description");
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
try{
- System.out.println("Here we are");
- Object[] aParams = new Object[0];
- short[][] aOutParamIndex = new short[1][];
- aOutParamIndex[0] = new short[0];
- Object[][] aOutParam = new Object[1][];
- aOutParam[0] = new Object[0];
- oObj.invoke( aParams, aOutParamIndex, aOutParam );
- System.out.println("invoke finished");
+ Object[] aParams = new Object[0];
+ short[][] aOutParamIndex = new short[1][];
+ aOutParamIndex[0] = new short[0];
+ Object[][] aOutParam = new Object[1][];
+ aOutParam[0] = new Object[0];
+
+ oObj.invoke( aParams, aOutParamIndex, aOutParam );
+ output = "success";
}
catch (com.sun.star.lang.IllegalArgumentException iae) {
log.println("Couldn't invoke script:" + iae);
- tRes.tested("invoke()", false);
- return;
+ output = "com.sun.star.lang.IllegalArgumentException";
}
catch (com.sun.star.script.CannotConvertException cce) {
log.println("Couldn't invoke script:" + cce);
- tRes.tested("invoke()", false);
- return;
+ output = "com.sun.star.script.CannotConvertException";
}
catch (com.sun.star.reflection.InvocationTargetException ite) {
log.println("Couldn't invoke script:" + ite);
- tRes.tested("invoke()", false);
- return;
+ output = "com.sun.star.reflection.InvocationTargetException";
}
catch (com.sun.star.uno.RuntimeException re) {
log.println("Couldn't invoke script:" + re);
- tRes.tested("invoke()", false);
- return;
+ output = "com.sun.star.uno.RuntimeException";
}
- catch(Exception e){
+ catch(java.lang.Exception e){
log.println("Couldn't invoke script:" + e);
- tRes.tested("invoke()", false);
- return;
+ output = "java.lang.Exception";
}
- tRes.tested("invoke()", true);
+
+ log.println("expected: " + expected + ", output: " + output);
+ if (output.equals(expected))
+ return true;
+ else
+ return false;
}
}
diff --git a/scripting/workben/ifc/scripting/_XFunctionProvider.java b/scripting/workben/ifc/scripting/_XFunctionProvider.java
index 3b813b274b7a..a7d7880aba36 100644
--- a/scripting/workben/ifc/scripting/_XFunctionProvider.java
+++ b/scripting/workben/ifc/scripting/_XFunctionProvider.java
@@ -2,9 +2,9 @@
*
* $RCSfile: _XFunctionProvider.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change:$Date: 2002-11-20 14:29:36 $
+ * last change:$Date: 2002-12-10 14:12:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -74,11 +74,15 @@ import com.sun.star.beans.XPropertySet;
import java.io.PrintWriter;
import lib.MultiMethodTest;
import lib.StatusException;
+import lib.Parameters;
+
+import java.util.Collection;
+import java.util.Iterator;
public class _XFunctionProvider extends MultiMethodTest {
- private String defaultScript = "script://MemoryUtils.MemUsage";
public XFunctionProvider oObj = null;
+
/**
* Retrieves object relation.
*/
@@ -86,12 +90,46 @@ public class _XFunctionProvider extends MultiMethodTest {
}
public void _getFunction() {
- XFunction function = oObj.getFunction( defaultScript );
- if ( function == null ) {
- log.println("Failed:_XFunctionProvider.getFunction(), no function returned.");
- tRes.tested("getScriptLogicalNames()", false);
- return;
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getFunction");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ result &= runGetFunctionTest((Parameters)tests.next());
+ }
+ }
+ else {
+ result = false;
}
- tRes.tested("getFunction()", true);
+
+ tRes.tested("getFunction()", result);
+ }
+
+ private boolean runGetFunctionTest(Parameters testdata) {
+ String description = testdata.get("description");
+ String logicalname = testdata.get("logicalname");
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
+ XFunction function = oObj.getFunction(logicalname);
+
+ if (function == null)
+ output = "null";
+ else
+ output = "XFunction.class";
+
+ log.println("expected: " + expected + ", output: " + output);
+ if (output.equals(expected))
+ return true;
+ else
+ return false;
}
}
diff --git a/scripting/workben/ifc/scripting/_XScriptInfo.java b/scripting/workben/ifc/scripting/_XScriptInfo.java
index 819458c9f283..4d13a28e1b9f 100644
--- a/scripting/workben/ifc/scripting/_XScriptInfo.java
+++ b/scripting/workben/ifc/scripting/_XScriptInfo.java
@@ -2,9 +2,9 @@
*
* $RCSfile: _XScriptInfo.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change:$Date: 2002-11-20 14:29:37 $
+ * last change:$Date: 2002-12-10 14:12:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,7 +72,11 @@ import com.sun.star.ucb.XSimpleFileAccess;
import com.sun.star.uno.Exception;
import com.sun.star.beans.XPropertySet;
+import java.util.Collection;
+import java.util.Iterator;
+
import java.io.PrintWriter;
+import lib.Parameters;
import lib.MultiMethodTest;
import lib.StatusException;
@@ -87,100 +91,274 @@ public class _XScriptInfo extends MultiMethodTest {
}
public void _getLogicalName() {
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getLogicalName");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
- log.println("In _XScriptInfo.getLogicalName()");
- if ( !oObj.getLogicalName().equals( "MemoryUtils.MemUsage" ) ){
- log.println("Expected logical name = MemoryUtils.MemUsage, got " + oObj.getLogicalName() );
- tRes.tested("getImplementations()", false);
- return;
+ output = oObj.getLogicalName();
+
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
+ }
+ }
+ else {
+ result = false;
}
- tRes.tested("getLogicalName()", true);
+ tRes.tested("getLogicalName()", result);
}
+
public void _getParcelURI() {
- log.println("In _XScriptInfo._getParcelUR()");
- if ( oObj.getParcelURI().length() == 0 ){
- log.println( "Expected parcel uri to be set up" );
- tRes.tested( "getParcelURI()", false );
- return;
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getParcelURI");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
+ output = oObj.getParcelURI();
+
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.endsWith(expected);
+ }
+ }
+ else {
+ result = false;
}
- tRes.tested("getParcelURI()", true);
+ tRes.tested("getParcelURI()", result);
}
+
public void _getLanguage() {
- log.println("In _XScriptInfo.getLanguage()");
- if ( !oObj.getLanguage().equals( "Java" ) ){
- log.println("Expected language to be Java, got " +
- oObj.getLanguage().length() );
- tRes.tested("getLanguage()", false);
- return;
- }
- tRes.tested("getLanguage()", true);
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getLanguage");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
+ output = oObj.getLanguage();
+
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
+ }
+ }
+ else {
+ result = false;
+ }
+ tRes.tested("getLanguage()", result);
}
public void _getFunctionName() {
- log.println("In _XScriptInfo.getFunctionName()");
- if ( !oObj.getFunctionName().equals( "MemoryUsage.updateMemoryUsage" ) ) {
- log.println(
- "Expected functionName to be MemoryUsage.updateMemoryUsage, got ->" +
- oObj.getFunctionName() + "<- instead." );
- tRes.tested("getFunctionName()", false);
- return;
- }
- tRes.tested("getFunctionName()", true);
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getFunctionName");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
+ output = oObj.getFunctionName();
+
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
+ }
+ }
+ else {
+ result = false;
+ }
+ tRes.tested("getFunctionName()", result);
}
+
public void _getLanguageProperties() {
- log.println("In _XScriptInfo.getLanguageProperties()");
- XPropertySet langProps = oObj.getLanguageProperties();
- try{
-
- String classPath = (String) langProps.getPropertyValue("classpath"); if ( classPath == null || !classPath.equals( "MemUsage.jar" ) ) {
- log.println(
- "Expected classpath property to be MemUsage.jar, got ->" +
- classPath + "<- instead." );
- tRes.tested("getLanguageProperties()", false);
- return;
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getLanguageProperties");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
+ try {
+ XPropertySet langProps = oObj.getLanguageProperties();
+ output = (String)langProps.getPropertyValue("classpath");
+
+ if (output == null)
+ output = "null";
+ }
+ catch( com.sun.star.uno.Exception e) {
+ log.println("caught UNO Exception:" + e);
+ output = "com.sun.star.uno.Exception";
+ }
+
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
}
}
- catch( com.sun.star.uno.Exception e) {
- log.println("getLanguageProperties: failed:" + e);
- tRes.tested("getLanguageProperties()", false);
- return;
+ else {
+ result = false;
}
tRes.tested("getLanguageProperties()", true);
}
+
public void _getFileSetNames() {
- log.println("In _XScriptInfo.getFileSetNames()");
- String[] fileSets = oObj.getFileSetNames();
- log.println("Got filesets of length " + fileSets.length + " first fileset is called " + fileSets[0] );
- if ( fileSets == null || fileSets.length != 1 ||
- !fileSets[0].equals("delivered") ) {
- log.println(
- "Expected filesets with 1 element with value \"delivered\"");
- tRes.tested("getFileSetNames()", false);
- return;
- }
- tRes.tested("getFileSetNames()", true);
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getFileSetNames");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
+ String[] fileSets = oObj.getFileSetNames();
+
+ if (fileSets == null)
+ output = "null";
+ else if (fileSets.length != 1)
+ output = "WrongNumberOfFileSets";
+ else
+ output = fileSets[0];
+
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
+ }
+ }
+ else {
+ result = false;
+ }
+ tRes.tested("getFileSetNames()", result);
}
+
public void _getFilesInFileSet() {
- log.println("In _XScriptInfo.getFilesInFileSet()");
- String[] filesInFileSet = oObj.getFilesInFileSet( oObj.getFileSetNames()[0] );
- if ( filesInFileSet == null || filesInFileSet.length != 1 ||
- !filesInFileSet[0].equals( "google.jar" ) ) {
- log.println(
- "Expected a list of one file named \"google.jar\" for fileSet named \"delivered\"" );
- tRes.tested("getFilesInFileSet()", false);
- return;
- }
- tRes.tested("getFilesInFileSet()", true);
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getFilesInFileSet");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
+ String[] filesInFileSet =
+ oObj.getFilesInFileSet(oObj.getFileSetNames()[0]);
+
+ if (filesInFileSet == null)
+ output = "null";
+ else if (filesInFileSet.length != 1)
+ output = "WrongNumberOfFilesInFileSet";
+ else
+ output = filesInFileSet[0];
+
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
+ }
+ }
+ else {
+ result = false;
+ }
+ tRes.tested("getFilesInFileSet()", result);
}
+
public void _getDescription() {
- log.println("In _XScriptInfo.getDescription()");
- if ( oObj.getDescription().length() != 0 ){
- log.println("Last test. Expected no description for MemoryUtils.MemUsage" + " got ->" + oObj.getDescription() + "<- instead" );
- tRes.tested("getDescription()", false);
- return;
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getDescription");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
+ output = oObj.getDescription();
+
+ if (output == null)
+ output = "null";
+ else if (output.length() == 0)
+ output = "empty";
+
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
+ }
+ }
+ else {
+ result = false;
}
- tRes.tested("getDescription()", true);
- }
+ tRes.tested("getDescription()", result);
+ }
}
diff --git a/scripting/workben/ifc/scripting/_XScriptInfoAccess.java b/scripting/workben/ifc/scripting/_XScriptInfoAccess.java
index 1d5039a09e1a..a286966c1fcd 100644
--- a/scripting/workben/ifc/scripting/_XScriptInfoAccess.java
+++ b/scripting/workben/ifc/scripting/_XScriptInfoAccess.java
@@ -2,9 +2,9 @@
*
* $RCSfile: _XScriptInfoAccess.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change:$Date: 2002-11-20 14:29:37 $
+ * last change:$Date: 2002-12-10 14:12:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,6 +75,10 @@ import com.sun.star.beans.XPropertySet;
import java.io.PrintWriter;
import lib.MultiMethodTest;
import lib.StatusException;
+import lib.Parameters;
+
+import java.util.Collection;
+import java.util.Iterator;
public class _XScriptInfoAccess extends MultiMethodTest {
@@ -87,59 +91,117 @@ public class _XScriptInfoAccess extends MultiMethodTest {
}
public void _getScriptLogicalNames() {
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getScriptLogicalNames");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ result &= runGetScriptLogicalNamesTest((Parameters)tests.next());
+ }
+ }
+ else {
+ result = false;
+ }
+
+ tRes.tested("getScriptLogicalNames()", result);
+ }
+
+ private boolean runGetScriptLogicalNamesTest(Parameters testdata) {
+ String description = testdata.get("description");
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
try {
log.println("In _XScriptInfoAccess.getScriptLogicalNames()");
String[] logicalNames = oObj.getScriptLogicalNames();
- log.println("Retrieved " + logicalNames.length + " entries from storage" );
- for ( int idx=0; idx < logicalNames.length; idx++ ){
- log.println("logical name [" + idx + "] = " + logicalNames[idx]);
- }
- if ( logicalNames.length == 0 ){
- log.println( "Failed:_XScriptInfoAccess.getScriptLogicalNames(), no logical names returned" );
- tRes.tested( "getScriptLogicalNames()", false );
- }
+ if (logicalNames == null)
+ output = "null";
+ else if (logicalNames.length == 0)
+ output = "empty";
+ else {
+ for (int i = 0; i < logicalNames.length; i++) {
+ if (logicalNames[i].equals(expected)) {
+ output = logicalNames[i];
+ break;
+ }
+ }
+ }
}
catch (com.sun.star.uno.Exception e) {
- log.println("Failed:_XScriptInfoAccess.getScriptLogicalNames() :" + e);
- tRes.tested("getScriptLogicalNames()", false);
- return;
+ log.println("Caught UNO Exception :" + e);
+ output = "com.sun.star.uno.Exception";
}
- tRes.tested("getScriptLogicalNames()", true);
+
+ log.println("expected: " + expected + ", output: " + output);
+ if (output.equals(expected))
+ return true;
+ else
+ return false;
}
public void _getImplementations() {
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getImplementations");
+
+ Iterator tests;
+
+ if (c != null) {
+ tests = c.iterator();
+
+ while (tests.hasNext()) {
+ result &= runGetImplementationsTest((Parameters)tests.next());
+ }
+ }
+ else {
+ result = false;
+ }
+
+ tRes.tested("getImplementations()", result);
+ }
+
+ private boolean runGetImplementationsTest(Parameters testdata) {
+ String description = testdata.get("description");
+ String logicalname = testdata.get("logicalname");
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
// performs a basic check to see if 1 match (XScriptInfo) is returned
// the XScriptInfo object is tested more completely in _XScriptInfo
// which is drive from ScriptInfo
- try {
- log.println("In _XScriptInfoAccess._getImplementations()");
- XScriptInfo[] impls = oObj.getImplementations("script://MemoryUtils.MemUsage?location=document");
- // should only be one match
- log.println("_XScriptInfoAccess._getImplementations() returned " + impls.length + " items ");
- if ( impls.length != 1 ){
- log.println("Expected 1 implementation to be returned, got " +
- impls.length + " instead.");
- tRes.tested("getImplementations()", false);
- return;
- }
- if ( !impls[0].getLogicalName().equals( "MemoryUtils.MemUsage" ) ){
- log.println("Expected logical name = MemoryUtils.MemUsage, got "
- + impls[0].getLogicalName() );
- tRes.tested("getImplementations()", false);
- return;
- }
+ try {
+ XScriptInfo[] impls = oObj.getImplementations(logicalname);
+ // should only be one match
+ if (impls == null)
+ output = "null";
+ else if (impls.length == 0)
+ output = "empty";
+ else
+ output = impls[0].getLogicalName();
}
catch (com.sun.star.uno.Exception e) {
- log.println("getImplementations: failed:" + e);
- tRes.tested("getImplementations()()", false);
- return;
+ log.println("Caught UNO Exception:" + e);
+ output = "com.sun.star.uno.Exception";
}
- log.println("_XScriptInfoAccess._getImplementations() completed sucessfully");
- tRes.tested("getImplementations()", true);
+ log.println("expected: " + expected + ", output: " + output);
+ if (output.equals(expected))
+ return true;
+ else
+ return false;
}
-
}
diff --git a/scripting/workben/ifc/scripting/_XScriptInvocation.java b/scripting/workben/ifc/scripting/_XScriptInvocation.java
index cc9fb8a99014..3df2db8c07a2 100644
--- a/scripting/workben/ifc/scripting/_XScriptInvocation.java
+++ b/scripting/workben/ifc/scripting/_XScriptInvocation.java
@@ -2,9 +2,9 @@
*
* $RCSfile: _XScriptInvocation.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change:$Date: 2002-11-20 14:11:23 $
+ * last change:$Date: 2002-12-10 14:12:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,14 +62,18 @@
package ifc.script.framework;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Collection;
import drafts.com.sun.star.script.framework.XScriptInvocation;
-import drafts.com.sun.star.script.framework.storage.XScriptInfo;
+import drafts.com.sun.star.script.framework.storage.XScriptStorageManager;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.XComponentContext;
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;
@@ -80,88 +84,53 @@ import util.SOfficeFactory;
public class _XScriptInvocation extends MultiMethodTest {
public XScriptInvocation oObj = null;
- private XComponent oDoc = null;
+ private XScriptStorageManager storageManager = 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();
+ Collection c =
+ (Collection) tEnv.getObjRelation("_invoke");
- // result &= testInvokeExceptions();
+ Iterator tests;
- tRes.tested("invoke()", result);
- }
-
- private boolean testUserInvoke() {
- log.println("Try invoking a user level script");
- return testInvoke(ScriptingUtils.USER_LOGICAL_NAME, 1);
- }
+ if (c != null) {
+ tests = c.iterator();
- 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");
+ while (tests.hasNext()) {
+ result &= runInvokeTest((Parameters)tests.next());
+ }
+ }
+ else {
+ result = false;
+ }
- return testInvoke("script://jarscript.jsuite.test", 1);
+ tRes.tested("invoke()", result);
}
- private boolean testDocumentInvoke() {
- log.println("Try invoking a user level script");
-
- String name = util.utils.getFullTestURL(
- ScriptingUtils.XSCRIPTCONTEXT_TEST_DOCUMENT);
+ private boolean runInvokeTest(Parameters testdata) {
+ String description = testdata.get("description");
+ String logicalname = testdata.get("logicalname");
+ String context = testdata.get("context");
+ String location = testdata.get("location");
+ String expected = testdata.get("expected");
+ String output = "";
- int storageId = ScriptingUtils.getDefault().getScriptStorageId(
- tParam.getMSF(), name);
-
- return testInvoke("script://xscriptcontext.jsuite.test", storageId);
- }
+ int storageId = getStorageId(location);
- private boolean testInvoke(String logicalName, int storageId) {
- return testInvoke(logicalName, storageId, null);
- }
+ XModel ctx = null;
+ if (!context.equals("null"))
+ ctx = loadDocument(context);
- 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");
@@ -177,25 +146,119 @@ public class _XScriptInvocation extends MultiMethodTest {
short[][] num = new short[1][0];
num[0] = new short[0];
+ log.println(description + ": " + logicalname);
+
try {
- oObj.invoke(logicalName, params, args, num, result);
+ oObj.invoke(logicalname, params, args, num, result);
+ output = "success";
}
catch (com.sun.star.lang.IllegalArgumentException iae) {
log.println("Couldn't invoke script:" + iae);
- return false;
+ output = "com.sun.star.lang.IllegalArgumentException";
}
catch (com.sun.star.script.CannotConvertException cce) {
log.println("Couldn't invoke script:" + cce);
- return false;
+ output = "com.sun.star.script.CannotConvertException";
}
catch (com.sun.star.reflection.InvocationTargetException ite) {
log.println("Couldn't invoke script:" + ite);
- return false;
+ output = "com.sun.star.reflection.InvocationTargetException";
}
catch (com.sun.star.uno.RuntimeException re) {
log.println("Couldn't invoke script:" + re);
+ output = "com.sun.star.uno.RuntimeException";
+ }
+
+ if (ctx != null)
+ ctx.dispose();
+
+ log.println("expected: " + expected + ", output: " + output);
+ if (output.equals(expected))
+ return true;
+ else
return false;
+ }
+
+ private int getStorageId(String location) {
+
+ if (location.equals("share"))
+ return 0;
+
+ if (location.equals("user"))
+ return 1;
+
+ XSimpleFileAccess access = null;
+ String uri = util.utils.getFullTestURL(location);
+
+ if (storageManager == null) {
+ try {
+ XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, tParam.getMSF());
+
+ 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();
+ if (access == null)
+ return -1;
+
+ int id = storageManager.createScriptStorageWithURI(access, uri);
+
+ return id;
+ }
+
+ private XSimpleFileAccess getXSimpleFileAccess() {
+ XSimpleFileAccess access = null;
+
+ try {
+ Object fa = tParam.getMSF().createInstance(
+ "com.sun.star.ucb.SimpleFileAccess");
+
+ access = (XSimpleFileAccess)
+ UnoRuntime.queryInterface(XSimpleFileAccess.class, fa);
+ }
+ catch (com.sun.star.uno.Exception e) {
+ return null;
}
- return true;
+ return access;
+ }
+
+ private XModel loadDocument(String name) {
+ XModel model = null;
+ SOfficeFactory factory = SOfficeFactory.getFactory(tParam.getMSF());
+
+ String fullname = util.utils.getFullTestURL(name);
+
+ try {
+ Object obj = factory.loadDocument(fullname);
+ model = (XModel) UnoRuntime.queryInterface(XModel.class, obj);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae) {
+ return null;
+ }
+ catch (Exception e) {
+ return null;
+ }
+
+ try {
+ Thread.sleep(5000);
+ }
+ catch (InterruptedException ie) {
+ }
+
+ return model;
}
}
diff --git a/scripting/workben/ifc/scripting/_XScriptNameResolver.java b/scripting/workben/ifc/scripting/_XScriptNameResolver.java
index 117310e222f5..a510400b253d 100644
--- a/scripting/workben/ifc/scripting/_XScriptNameResolver.java
+++ b/scripting/workben/ifc/scripting/_XScriptNameResolver.java
@@ -2,9 +2,9 @@
*
* $RCSfile: _XScriptNameResolver.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change:$Date: 2002-11-20 14:11:23 $
+ * last change:$Date: 2002-12-10 14:12:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,12 +63,17 @@ package ifc.script.framework;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Collection;
import drafts.com.sun.star.script.framework.XScriptNameResolver;
import drafts.com.sun.star.script.framework.storage.XScriptInfo;
+import drafts.com.sun.star.script.framework.storage.XScriptStorageManager;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.XComponentContext;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.Any;
import com.sun.star.uno.XInterface;
import lib.MultiMethodTest;
@@ -78,6 +83,7 @@ import lib.Parameters;
public class _XScriptNameResolver extends MultiMethodTest {
public XScriptNameResolver oObj = null;
+ private XScriptStorageManager storageManager = null;
/**
* Retrieves object relation.
@@ -88,36 +94,36 @@ public class _XScriptNameResolver extends MultiMethodTest {
public void _resolve() {
boolean result = true;
- result &= testValidURIs();
- result &= testInvalidURIs();
- result &= testNonExistentURIs();
+ Collection c =
+ (Collection) tEnv.getObjRelation("_resolve");
- tRes.tested("resolve()", result);
- }
-
- private boolean testValidURIs() {
- boolean result = true;
+ Iterator tests;
- log.println("Try to resolve a valid document script URI");
+ if (c != null) {
+ tests = c.iterator();
- String name = util.utils.getFullTestURL(
- ScriptingUtils.SCRIPT_IN_CLASSFILE_DOC_NAME);
-
- int storageId = ScriptingUtils.getDefault().getScriptStorageId(
- tParam.getMSF(), name);
+ while (tests.hasNext()) {
+ result &= runResolveTest((Parameters)tests.next());
+ }
+ }
+ else {
+ result = false;
+ }
- result &= testValidURI(ScriptingUtils.DOC_LOGICAL_NAME, storageId);
+ tRes.tested("resolve()", result);
+ }
- log.println("Try to resolve a valid user script URI");
- result &= testValidURI(ScriptingUtils.USER_LOGICAL_NAME, 1);
+ private boolean runResolveTest(Parameters data) {
+ String description = data.get("description");
+ String location = data.get("location");
+ String logicalname = data.get("logicalname");
+ String expected = data.get("expected");
+ String output = "";
- log.println("Try to resolve a valid share script URI");
- result &= testValidURI(ScriptingUtils.SHARE_LOGICAL_NAME, 0);
+ int storageId = getStorageId(location);
- return result;
- }
+ log.println(description + ": " + logicalname);
- 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");
@@ -126,105 +132,89 @@ public class _XScriptNameResolver extends MultiMethodTest {
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;
- }
+ XInterface ifc = (XInterface) oObj.resolve(logicalname, args);
+
+ if (ifc == null)
+ output = "null";
+ else if (UnoRuntime.queryInterface(XScriptInfo.class, ifc) == null)
+ output = "null";
+ else
+ output = "XScriptInfo.class";
}
catch (com.sun.star.lang.IllegalArgumentException iae) {
- log.println("Couldn't resolve URI:" + iae);
- return false;
+ log.println("caught IllegalArgumentException: " + iae);
+ output = "com.sun.star.lang.IllegalArgumentException";
}
catch (com.sun.star.script.CannotConvertException cce) {
- log.println("Couldn't resolve URI:" + cce);
- return false;
+ log.println("caught CannotConvertException: " + cce);
+ output = "com.sun.star.script.CannotConvertException";
}
catch (com.sun.star.uno.RuntimeException re) {
- log.println("Couldn't resolve URI:" + re);
- return false;
+ log.println("caught RuntimeException: " + re);
+ output = "com.sun.star.uno.RuntimeException";
}
- return true;
+
+ log.println("expected: " + expected + ", output: " + output);
+ if (output.equals(expected))
+ return true;
+ else
+ return false;
}
- 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");
+ private int getStorageId(String location) {
- Parameters params = new Parameters(map);
- Object[] args = new Object[] {params};
+ if (location.equals("share"))
+ return 0;
- 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;
- }
+ if (location.equals("user"))
+ return 1;
- 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");
+ XSimpleFileAccess access = null;
+ String uri = util.utils.getFullTestURL(location);
+
+ if (storageManager == null) {
+ try {
+ XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, tParam.getMSF());
- Parameters params = new Parameters(map);
- Object[] args = new Object[] {params};
+ XComponentContext xContext = (XComponentContext)
+ UnoRuntime.queryInterface(XComponentContext.class,
+ xProp.getPropertyValue("DefaultContext"));
- XInterface ifc = (XInterface)
- oObj.resolve("script://Non.Existent", args);
+ XInterface ifc = (XInterface)
+ xContext.getValueByName("/singletons/drafts.com.sun.star." +
+ "script.framework.storage.theScriptStorageManager");
- if (ifc != null &&
- UnoRuntime.queryInterface(XScriptInfo.class, ifc) != null)
- {
- log.println("Should not have resolved non-existent URI");
- return false;
+ storageManager = (XScriptStorageManager)
+ UnoRuntime.queryInterface(XScriptStorageManager.class, ifc);
+ }
+ catch( Exception e ) {
+ return -1;
}
}
- 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;
+
+ access = getXSimpleFileAccess();
+ if (access == null)
+ return -1;
+
+ int id = storageManager.createScriptStorageWithURI(access, uri);
+
+ return id;
+ }
+
+ private XSimpleFileAccess getXSimpleFileAccess() {
+ XSimpleFileAccess access = null;
+
+ try {
+ Object fa = tParam.getMSF().createInstance(
+ "com.sun.star.ucb.SimpleFileAccess");
+
+ access = (XSimpleFileAccess)
+ UnoRuntime.queryInterface(XSimpleFileAccess.class, fa);
}
- catch (com.sun.star.uno.RuntimeException re) {
- log.println("Got wrong exception:" + re);
- return false;
+ catch (com.sun.star.uno.Exception e) {
+ return null;
}
- return true;
+ return access;
}
}
diff --git a/scripting/workben/ifc/scripting/_XScriptStorageManager.java b/scripting/workben/ifc/scripting/_XScriptStorageManager.java
index d0a0f548e6bd..01e9cc445306 100644
--- a/scripting/workben/ifc/scripting/_XScriptStorageManager.java
+++ b/scripting/workben/ifc/scripting/_XScriptStorageManager.java
@@ -2,9 +2,9 @@
*
* $RCSfile: _XScriptStorageManager.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change:$Date: 2002-11-20 14:11:23 $
+ * last change:$Date: 2002-12-10 14:12:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,6 +64,9 @@ package ifc.script.framework.storage;
import drafts.com.sun.star.script.framework.storage.XScriptStorageManager;
import drafts.com.sun.star.script.framework.storage.XScriptInfoAccess;
+import java.util.Iterator;
+import java.util.Collection;
+
import com.sun.star.uno.UnoRuntime;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.XInterface;
@@ -73,8 +76,7 @@ import com.sun.star.uno.Exception;
import java.io.PrintWriter;
import lib.MultiMethodTest;
import lib.StatusException;
-
-import ifc.script.framework.ScriptingUtils;
+import lib.Parameters;
public class _XScriptStorageManager extends MultiMethodTest {
@@ -89,55 +91,91 @@ public class _XScriptStorageManager extends MultiMethodTest {
public void _createScriptStorage() {
boolean result = true;
- XSimpleFileAccess access =
- ScriptingUtils.getDefault().getXSimpleFileAccess(tParam.getMSF());
+ Collection c =
+ (Collection) tEnv.getObjRelation("_createScriptStorage");
- if (access == null) {
- result = false;
+ if (c == null) {
+ tRes.tested("createScriptStorage()", false);
+ return;
}
- else {
- try {
- int id = oObj.createScriptStorage(access);
+
+ Iterator tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
+ XSimpleFileAccess access = getXSimpleFileAccess();
+
+ if (access == null) {
+ output = "Couldn't create XSimpleFileAccess";
}
- catch (com.sun.star.uno.RuntimeException re) {
- log.println("Exception from createScriptStorage: " + re);
- result = false;
+ else {
+ try {
+ int id = oObj.createScriptStorage(access);
+ output = "success";
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Exception from createScriptStorage: " + re);
+ output = "com.sun.star.uno.RuntimeException";
+ }
}
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
}
-
tRes.tested("createScriptStorage()", result);
}
public void _createScriptStorageWithURI() {
boolean result = true;
- XSimpleFileAccess access =
- ScriptingUtils.getDefault().getXSimpleFileAccess(tParam.getMSF());
+ Collection c =
+ (Collection) tEnv.getObjRelation("_createScriptStorageWithURI");
- 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:");
+ if (c == null) {
tRes.tested("createScriptStorageWithURI()", false);
+ return;
}
- try {
- String[] names = info.getScriptLogicalNames();
+ Iterator tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String location = testdata.get("location");
+ String output = "";
- if (names == null || names.length == 0) {
- log.println("No logical names found");
- result = false;
+ log.println(testdata.get("description"));
+
+ String uri = util.utils.getFullTestURL(location);
+ XSimpleFileAccess access = getXSimpleFileAccess();
+
+ try {
+ int id = oObj.createScriptStorageWithURI(access, uri);
+
+ XInterface ifc = (XInterface)oObj.getScriptStorage(id);
+
+ if (ifc == null)
+ output = "null";
+ else {
+ Object info = UnoRuntime.queryInterface(
+ XScriptInfoAccess.class, ifc);
+
+ if (info == null)
+ output = "null";
+ else
+ output = "XScriptInfoAccess.class";
+ }
}
- }
- catch (com.sun.star.lang.IllegalArgumentException iae) {
- log.println("Couldn't get logical names:" + iae.getMessage());
- result = false;
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Caught RuntimeException: " + re);
+ output = "com.sun.star.uno.RuntimeException";
+ }
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
}
tRes.tested("createScriptStorageWithURI()", result);
@@ -146,95 +184,117 @@ public class _XScriptStorageManager extends MultiMethodTest {
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);
+ Collection c =
+ (Collection) tEnv.getObjRelation("_getScriptStorage");
- 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;
+ if (c == null) {
+ tRes.tested("getScriptStorage()", false);
+ return;
}
- 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);
+ Iterator tests = c.iterator();
- if (info == null) {
- log.println("Couldn't get XScriptInfoAccess from storage");
- result = false;
- }
- try {
- String[] names = info.getScriptLogicalNames();
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String location = testdata.get("location");
+ String output = "";
- 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;
+ log.println(testdata.get("description"));
+
+ try {
+ int storageid = getStorageId(location);
+
+ XInterface ifc = (XInterface)oObj.getScriptStorage(storageid);
+
+ if (ifc == null)
+ output = "null";
+ else {
+ Object info = UnoRuntime.queryInterface(
+ XScriptInfoAccess.class, ifc);
+
+ if (info == null)
+ output = "null";
+ else
+ output = "XScriptInfoAccess.class";
}
}
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Caught RuntimeException: " + re);
+ output = "com.sun.star.uno.RuntimeException";
+ }
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
}
- 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;
+ Collection c =
+ (Collection) tEnv.getObjRelation("_refreshScriptStorage");
+
+ if (c == null) {
+ tRes.tested("refreshScriptStorage()", false);
+ return;
}
- catch (com.sun.star.uno.RuntimeException re) {
+
+ Iterator tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String location = testdata.get("location");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
+ try {
+ String uri = util.utils.getFullTestURL(location);
+ oObj.refreshScriptStorage(uri);
+ output = "success";
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Caught RuntimeException: " + re);
+ output = "com.sun.star.uno.RuntimeException";
+ }
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
}
+ tRes.tested("refreshScriptStorage()", result);
+ }
- log.println("Try to refresh a valid document URI");
- try {
- XSimpleFileAccess access =
- ScriptingUtils.getDefault().getXSimpleFileAccess(
- tParam.getMSF());
+ private int getStorageId(String location) {
- String name = util.utils.getFullTestURL(
- ScriptingUtils.SCRIPT_IN_CLASSFILE_DOC_NAME);
+ if (location.equals("share"))
+ return 0;
- int id = oObj.createScriptStorageWithURI(access, name);
+ if (location.equals("user"))
+ return 1;
- oObj.refreshScriptStorage(name);
+ String uri = util.utils.getFullTestURL(location);
+
+ XSimpleFileAccess access = getXSimpleFileAccess();
+ if (access == null)
+ return -1;
+
+ return oObj.createScriptStorageWithURI(access, uri);
+ }
+
+ private XSimpleFileAccess getXSimpleFileAccess() {
+ XSimpleFileAccess access = null;
+
+ try {
+ Object fa = tParam.getMSF().createInstance(
+ "com.sun.star.ucb.SimpleFileAccess");
+
+ access = (XSimpleFileAccess)
+ UnoRuntime.queryInterface(XSimpleFileAccess.class, fa);
}
- catch (com.sun.star.uno.RuntimeException re) {
- log.println("Caught unexpected RuntimeException: " + re);
- result = false;
+ catch (com.sun.star.uno.Exception e) {
+ return null;
}
-
- tRes.tested("refreshScriptStorage()", result);
+ return access;
}
}
diff --git a/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java b/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java
index f6aee2cb0495..687fe15c2be6 100644
--- a/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java
+++ b/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java
@@ -2,9 +2,9 @@
*
* $RCSfile: _XScriptStorageRefresh.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change:$Date: 2002-11-20 14:29:37 $
+ * last change:$Date: 2002-12-10 14:12:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,6 +63,9 @@ package ifc.script.framework.storage;
import drafts.com.sun.star.script.framework.storage.XScriptStorageRefresh;
+import java.util.Collection;
+import java.util.Iterator;
+
import com.sun.star.uno.UnoRuntime;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.XInterface;
@@ -73,6 +76,7 @@ import com.sun.star.beans.XPropertySet;
import java.io.PrintWriter;
import lib.MultiMethodTest;
import lib.StatusException;
+import lib.Parameters;
public class _XScriptStorageRefresh extends MultiMethodTest {
@@ -85,8 +89,36 @@ public class _XScriptStorageRefresh extends MultiMethodTest {
}
public void _refresh() {
- log.println("In _XScriptStorageRefresh.getScriptLogicalNames()" );
- oObj.refresh();
- tRes.tested("refresh()", true);
+ boolean result = true;
+
+ Collection c =
+ (Collection) tEnv.getObjRelation("_refresh");
+
+ if (c == null) {
+ tRes.tested("refresh()", false);
+ return;
+ }
+
+ Iterator tests = c.iterator();
+
+ while (tests.hasNext()) {
+ Parameters testdata = (Parameters)tests.next();
+ String expected = testdata.get("expected");
+ String output = "";
+
+ log.println(testdata.get("description"));
+
+ try {
+ oObj.refresh();
+ output = "success";
+ }
+ catch (com.sun.star.uno.RuntimeException re) {
+ log.println("Caught RuntimeException: " + re);
+ output = "com.sun.star.uno.RuntimeException";
+ }
+ log.println("expected: " + expected + ", output: " + output);
+ result &= output.equals(expected);
+ }
+ tRes.tested("refresh()", result);
}
}