Kaydet (Commit) fa0f14fa authored tarafından Tomas O'Connor's avatar Tomas O'Connor

Make interface tests generic.

üst 511b0590
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment