diff options
author | Tomas O'Connor <toconnor@openoffice.org> | 2003-03-25 15:55:06 +0000 |
---|---|---|
committer | Tomas O'Connor <toconnor@openoffice.org> | 2003-03-25 15:55:06 +0000 |
commit | 93b11bc7ec94ff0bc3b4a2e1fb974cf1165b6a07 (patch) | |
tree | 7c13b92f20783893f009e157ee9829d633b0b970 /scripting/workben/ifc | |
parent | b658df4194bc54a156dfa7d8224bdae4848f0f84 (diff) |
Add beanshell tests and test of return values from beanshell scripts
Diffstat (limited to 'scripting/workben/ifc')
-rw-r--r-- | scripting/workben/ifc/scripting/_XFunction.java | 61 | ||||
-rw-r--r-- | scripting/workben/ifc/scripting/_XScriptInfoAccess.java | 16 | ||||
-rw-r--r-- | scripting/workben/ifc/scripting/_XScriptSecurity.java | 14 |
3 files changed, 66 insertions, 25 deletions
diff --git a/scripting/workben/ifc/scripting/_XFunction.java b/scripting/workben/ifc/scripting/_XFunction.java index 431127ce7c18..d871ac9bfcc8 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.2 $ + * $Revision: 1.3 $ * - * last change:$Date: 2002-12-10 14:12:05 $ + * last change:$Date: 2003-03-25 16:55:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,7 @@ package ifc.script.framework.provider; import drafts.com.sun.star.script.framework.provider.XFunction; +import drafts.com.sun.star.script.framework.provider.XFunctionProvider; import com.sun.star.uno.UnoRuntime; import com.sun.star.lang.XMultiServiceFactory; @@ -81,10 +82,18 @@ import java.util.Iterator; public class _XFunction extends MultiMethodTest { public XFunction oObj = null; + public XFunctionProvider oProvider = null; + /** * Retrieves object relation. */ public void before() throws StatusException { + log.println("getting provider"); + oProvider = (XFunctionProvider) tEnv.getObjRelation("provider"); + if (oProvider == null) + log.println("it's null"); + else + log.println("it's not null"); } public void _invoke() { @@ -111,8 +120,18 @@ public class _XFunction extends MultiMethodTest { private boolean runInvokeTest(Parameters testdata) { String description = testdata.get("description"); + String logicalname = testdata.get("logicalname"); + + String expreturntype = testdata.get("returntype"); + String expreturnvalue = testdata.get("returnvalue"); + String gotreturntype = "null"; + String gotreturnvalue = "null"; + + String location = testdata.get("location"); + String expected = testdata.get("expected"); String output = ""; + boolean result = true; log.println(testdata.get("description")); @@ -123,7 +142,19 @@ public class _XFunction extends MultiMethodTest { Object[][] aOutParam = new Object[1][]; aOutParam[0] = new Object[0]; - oObj.invoke( aParams, aOutParamIndex, aOutParam ); + XFunction func = oProvider.getFunction(logicalname); + if (func == null) { + log.println("Couldn't get XFunction for:" + logicalname); + return false; + } + + Object ret = func.invoke( aParams, aOutParamIndex, aOutParam ); + + if (ret != null) { + gotreturntype = ret.getClass().getName(); + gotreturnvalue = ret.toString(); + } + output = "success"; } catch (com.sun.star.lang.IllegalArgumentException iae) { @@ -147,10 +178,26 @@ public class _XFunction extends MultiMethodTest { output = "java.lang.Exception"; } + if (expreturntype != null) { + log.println("expected return type: " + expreturntype + + ", got return type: " + gotreturntype); + + if (!gotreturntype.equals(expreturntype)) + result = false; + } + + if (expreturnvalue != null) { + log.println("expected return value: " + expreturnvalue + + ", got return value: " + gotreturnvalue); + + if (!gotreturnvalue.equals(expreturnvalue)) + result = false; + } + log.println("expected: " + expected + ", output: " + output); - if (output.equals(expected)) - return true; - else - return false; + if (!output.equals(expected)) + result = false; + + return result; } } diff --git a/scripting/workben/ifc/scripting/_XScriptInfoAccess.java b/scripting/workben/ifc/scripting/_XScriptInfoAccess.java index a286966c1fcd..e667ed519a4f 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.2 $ + * $Revision: 1.3 $ * - * last change:$Date: 2002-12-10 14:12:05 $ + * last change:$Date: 2003-03-25 16:55:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -119,7 +119,7 @@ public class _XScriptInfoAccess extends MultiMethodTest { log.println(testdata.get("description")); - try { + // try { log.println("In _XScriptInfoAccess.getScriptLogicalNames()"); String[] logicalNames = oObj.getScriptLogicalNames(); @@ -135,11 +135,11 @@ public class _XScriptInfoAccess extends MultiMethodTest { } } } - } - catch (com.sun.star.uno.Exception e) { - log.println("Caught UNO Exception :" + e); - output = "com.sun.star.uno.Exception"; - } + // } + // 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); if (output.equals(expected)) diff --git a/scripting/workben/ifc/scripting/_XScriptSecurity.java b/scripting/workben/ifc/scripting/_XScriptSecurity.java index e28a1e5431be..e5a9a0d44d0d 100644 --- a/scripting/workben/ifc/scripting/_XScriptSecurity.java +++ b/scripting/workben/ifc/scripting/_XScriptSecurity.java @@ -2,9 +2,9 @@ * * $RCSfile: _XScriptSecurity.java,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change:$Date: 2003-03-25 11:26:59 $ + * last change:$Date: 2003-03-25 16:55:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -200,14 +200,8 @@ public class _XScriptSecurity extends MultiMethodTest { try { String uri = util.utils.getFullTestURL(location); - if ( oObj.checkPermission(uri, "execute" ) ) - { - output = "true"; - } - else - { - output = "false"; - } + oObj.checkPermission(uri, "execute" ); + output = "true"; } catch (com.sun.star.security.AccessControlException ace) { log.println("Couldn't invoke script:" + ace); |