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

Make interface tests generic.

üst 511b0590
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: _XFunction.java,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -73,6 +73,10 @@ import com.sun.star.beans.XPropertySet; ...@@ -73,6 +73,10 @@ import com.sun.star.beans.XPropertySet;
import java.io.PrintWriter; import java.io.PrintWriter;
import lib.MultiMethodTest; import lib.MultiMethodTest;
import lib.StatusException; import lib.StatusException;
import lib.Parameters;
import java.util.Collection;
import java.util.Iterator;
public class _XFunction extends MultiMethodTest { public class _XFunction extends MultiMethodTest {
...@@ -84,41 +88,69 @@ public class _XFunction extends MultiMethodTest { ...@@ -84,41 +88,69 @@ public class _XFunction extends MultiMethodTest {
} }
public void _invoke() { 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{ try{
System.out.println("Here we are");
Object[] aParams = new Object[0]; Object[] aParams = new Object[0];
short[][] aOutParamIndex = new short[1][]; short[][] aOutParamIndex = new short[1][];
aOutParamIndex[0] = new short[0]; aOutParamIndex[0] = new short[0];
Object[][] aOutParam = new Object[1][]; Object[][] aOutParam = new Object[1][];
aOutParam[0] = new Object[0]; aOutParam[0] = new Object[0];
oObj.invoke( aParams, aOutParamIndex, aOutParam ); oObj.invoke( aParams, aOutParamIndex, aOutParam );
System.out.println("invoke finished"); output = "success";
} }
catch (com.sun.star.lang.IllegalArgumentException iae) { catch (com.sun.star.lang.IllegalArgumentException iae) {
log.println("Couldn't invoke script:" + iae); log.println("Couldn't invoke script:" + iae);
tRes.tested("invoke()", false); output = "com.sun.star.lang.IllegalArgumentException";
return;
} }
catch (com.sun.star.script.CannotConvertException cce) { catch (com.sun.star.script.CannotConvertException cce) {
log.println("Couldn't invoke script:" + cce); log.println("Couldn't invoke script:" + cce);
tRes.tested("invoke()", false); output = "com.sun.star.script.CannotConvertException";
return;
} }
catch (com.sun.star.reflection.InvocationTargetException ite) { catch (com.sun.star.reflection.InvocationTargetException ite) {
log.println("Couldn't invoke script:" + ite); log.println("Couldn't invoke script:" + ite);
tRes.tested("invoke()", false); output = "com.sun.star.reflection.InvocationTargetException";
return;
} }
catch (com.sun.star.uno.RuntimeException re) { catch (com.sun.star.uno.RuntimeException re) {
log.println("Couldn't invoke script:" + re); log.println("Couldn't invoke script:" + re);
tRes.tested("invoke()", false); output = "com.sun.star.uno.RuntimeException";
return;
} }
catch(Exception e){ catch(java.lang.Exception e){
log.println("Couldn't invoke script:" + e); log.println("Couldn't invoke script:" + e);
tRes.tested("invoke()", false); output = "java.lang.Exception";
return;
} }
tRes.tested("invoke()", true);
log.println("expected: " + expected + ", output: " + output);
if (output.equals(expected))
return true;
else
return false;
} }
} }
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: _XFunctionProvider.java,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -74,11 +74,15 @@ import com.sun.star.beans.XPropertySet; ...@@ -74,11 +74,15 @@ import com.sun.star.beans.XPropertySet;
import java.io.PrintWriter; import java.io.PrintWriter;
import lib.MultiMethodTest; import lib.MultiMethodTest;
import lib.StatusException; import lib.StatusException;
import lib.Parameters;
import java.util.Collection;
import java.util.Iterator;
public class _XFunctionProvider extends MultiMethodTest { public class _XFunctionProvider extends MultiMethodTest {
private String defaultScript = "script://MemoryUtils.MemUsage";
public XFunctionProvider oObj = null; public XFunctionProvider oObj = null;
/** /**
* Retrieves object relation. * Retrieves object relation.
*/ */
...@@ -86,12 +90,46 @@ public class _XFunctionProvider extends MultiMethodTest { ...@@ -86,12 +90,46 @@ public class _XFunctionProvider extends MultiMethodTest {
} }
public void _getFunction() { public void _getFunction() {
XFunction function = oObj.getFunction( defaultScript ); boolean result = true;
if ( function == null ) {
log.println("Failed:_XFunctionProvider.getFunction(), no function returned."); Collection c =
tRes.tested("getScriptLogicalNames()", false); (Collection) tEnv.getObjRelation("_getFunction");
return;
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 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: _XScriptInfo.java,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -72,7 +72,11 @@ import com.sun.star.ucb.XSimpleFileAccess; ...@@ -72,7 +72,11 @@ import com.sun.star.ucb.XSimpleFileAccess;
import com.sun.star.uno.Exception; import com.sun.star.uno.Exception;
import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySet;
import java.util.Collection;
import java.util.Iterator;
import java.io.PrintWriter; import java.io.PrintWriter;
import lib.Parameters;
import lib.MultiMethodTest; import lib.MultiMethodTest;
import lib.StatusException; import lib.StatusException;
...@@ -87,100 +91,274 @@ public class _XScriptInfo extends MultiMethodTest { ...@@ -87,100 +91,274 @@ public class _XScriptInfo extends MultiMethodTest {
} }
public void _getLogicalName() { 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()"); output = oObj.getLogicalName();
if ( !oObj.getLogicalName().equals( "MemoryUtils.MemUsage" ) ){
log.println("Expected logical name = MemoryUtils.MemUsage, got " + oObj.getLogicalName() ); log.println("expected: " + expected + ", output: " + output);
tRes.tested("getImplementations()", false); result &= output.equals(expected);
return; }
}
else {
result = false;
} }
tRes.tested("getLogicalName()", true); tRes.tested("getLogicalName()", result);
} }
public void _getParcelURI() { public void _getParcelURI() {
log.println("In _XScriptInfo._getParcelUR()"); boolean result = true;
if ( oObj.getParcelURI().length() == 0 ){
log.println( "Expected parcel uri to be set up" ); Collection c =
tRes.tested( "getParcelURI()", false ); (Collection) tEnv.getObjRelation("_getParcelURI");
return;
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() { public void _getLanguage() {
log.println("In _XScriptInfo.getLanguage()"); boolean result = true;
if ( !oObj.getLanguage().equals( "Java" ) ){
log.println("Expected language to be Java, got " + Collection c =
oObj.getLanguage().length() ); (Collection) tEnv.getObjRelation("_getLanguage");
tRes.tested("getLanguage()", false);
return; 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);
} }
tRes.tested("getLanguage()", true); }
else {
result = false;
}
tRes.tested("getLanguage()", result);
} }
public void _getFunctionName() { public void _getFunctionName() {
log.println("In _XScriptInfo.getFunctionName()"); boolean result = true;
if ( !oObj.getFunctionName().equals( "MemoryUsage.updateMemoryUsage" ) ) {
log.println( Collection c =
"Expected functionName to be MemoryUsage.updateMemoryUsage, got ->" + (Collection) tEnv.getObjRelation("_getFunctionName");
oObj.getFunctionName() + "<- instead." );
tRes.tested("getFunctionName()", false); Iterator tests;
return;
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);
}
} }
tRes.tested("getFunctionName()", true); else {
result = false;
} }
tRes.tested("getFunctionName()", result);
}
public void _getLanguageProperties() { public void _getLanguageProperties() {
log.println("In _XScriptInfo.getLanguageProperties()"); 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(); XPropertySet langProps = oObj.getLanguageProperties();
try{ output = (String)langProps.getPropertyValue("classpath");
String classPath = (String) langProps.getPropertyValue("classpath"); if ( classPath == null || !classPath.equals( "MemUsage.jar" ) ) { if (output == null)
log.println( output = "null";
"Expected classpath property to be MemUsage.jar, got ->" +
classPath + "<- instead." );
tRes.tested("getLanguageProperties()", false);
return;
}
} }
catch( com.sun.star.uno.Exception e) { catch( com.sun.star.uno.Exception e) {
log.println("getLanguageProperties: failed:" + e); log.println("caught UNO Exception:" + e);
tRes.tested("getLanguageProperties()", false); output = "com.sun.star.uno.Exception";
return; }
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
}
else {
result = false;
} }
tRes.tested("getLanguageProperties()", true); tRes.tested("getLanguageProperties()", true);
} }
public void _getFileSetNames() { public void _getFileSetNames() {
log.println("In _XScriptInfo.getFileSetNames()"); 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(); String[] fileSets = oObj.getFileSetNames();
log.println("Got filesets of length " + fileSets.length + " first fileset is called " + fileSets[0] );
if ( fileSets == null || fileSets.length != 1 || if (fileSets == null)
!fileSets[0].equals("delivered") ) { output = "null";
log.println( else if (fileSets.length != 1)
"Expected filesets with 1 element with value \"delivered\""); output = "WrongNumberOfFileSets";
tRes.tested("getFileSetNames()", false); else
return; output = fileSets[0];
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
}
else {
result = false;
} }
tRes.tested("getFileSetNames()", true); tRes.tested("getFileSetNames()", result);
} }
public void _getFilesInFileSet() { public void _getFilesInFileSet() {
log.println("In _XScriptInfo.getFilesInFileSet()"); boolean result = true;
String[] filesInFileSet = oObj.getFilesInFileSet( oObj.getFileSetNames()[0] );
if ( filesInFileSet == null || filesInFileSet.length != 1 || Collection c =
!filesInFileSet[0].equals( "google.jar" ) ) { (Collection) tEnv.getObjRelation("_getFilesInFileSet");
log.println(
"Expected a list of one file named \"google.jar\" for fileSet named \"delivered\"" ); Iterator tests;
tRes.tested("getFilesInFileSet()", false);
return; 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);
}
} }
tRes.tested("getFilesInFileSet()", true); else {
result = false;
} }
tRes.tested("getFilesInFileSet()", result);
}
public void _getDescription() { public void _getDescription() {
log.println("In _XScriptInfo.getDescription()"); boolean result = true;
if ( oObj.getDescription().length() != 0 ){
log.println("Last test. Expected no description for MemoryUtils.MemUsage" + " got ->" + oObj.getDescription() + "<- instead" ); Collection c =
tRes.tested("getDescription()", false); (Collection) tEnv.getObjRelation("_getDescription");
return;
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);
} }
tRes.tested("getDescription()", true); }
else {
result = false;
} }
tRes.tested("getDescription()", result);
}
} }
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: _XScriptInfoAccess.java,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -75,6 +75,10 @@ import com.sun.star.beans.XPropertySet; ...@@ -75,6 +75,10 @@ import com.sun.star.beans.XPropertySet;
import java.io.PrintWriter; import java.io.PrintWriter;
import lib.MultiMethodTest; import lib.MultiMethodTest;
import lib.StatusException; import lib.StatusException;
import lib.Parameters;
import java.util.Collection;
import java.util.Iterator;
public class _XScriptInfoAccess extends MultiMethodTest { public class _XScriptInfoAccess extends MultiMethodTest {
...@@ -87,59 +91,117 @@ public class _XScriptInfoAccess extends MultiMethodTest { ...@@ -87,59 +91,117 @@ public class _XScriptInfoAccess extends MultiMethodTest {
} }
public void _getScriptLogicalNames() { 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 { try {
log.println("In _XScriptInfoAccess.getScriptLogicalNames()"); log.println("In _XScriptInfoAccess.getScriptLogicalNames()");
String[] logicalNames = oObj.getScriptLogicalNames(); String[] logicalNames = oObj.getScriptLogicalNames();
log.println("Retrieved " + logicalNames.length + " entries from storage" );
for ( int idx=0; idx < logicalNames.length; idx++ ){ if (logicalNames == null)
log.println("logical name [" + idx + "] = " + logicalNames[idx]); 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;
}
} }
if ( logicalNames.length == 0 ){
log.println( "Failed:_XScriptInfoAccess.getScriptLogicalNames(), no logical names returned" );
tRes.tested( "getScriptLogicalNames()", false );
} }
} }
catch (com.sun.star.uno.Exception e) { catch (com.sun.star.uno.Exception e) {
log.println("Failed:_XScriptInfoAccess.getScriptLogicalNames() :" + e); log.println("Caught UNO Exception :" + e);
tRes.tested("getScriptLogicalNames()", false); output = "com.sun.star.uno.Exception";
return;
} }
tRes.tested("getScriptLogicalNames()", true);
log.println("expected: " + expected + ", output: " + output);
if (output.equals(expected))
return true;
else
return false;
} }
public void _getImplementations() { 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 // performs a basic check to see if 1 match (XScriptInfo) is returned
// the XScriptInfo object is tested more completely in _XScriptInfo // the XScriptInfo object is tested more completely in _XScriptInfo
// which is drive from ScriptInfo // 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" ) ){ try {
log.println("Expected logical name = MemoryUtils.MemUsage, got " XScriptInfo[] impls = oObj.getImplementations(logicalname);
+ impls[0].getLogicalName() );
tRes.tested("getImplementations()", false);
return;
}
// 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) { catch (com.sun.star.uno.Exception e) {
log.println("getImplementations: failed:" + e); log.println("Caught UNO Exception:" + e);
tRes.tested("getImplementations()()", false); output = "com.sun.star.uno.Exception";
return;
} }
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 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: _XScriptInvocation.java,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -62,14 +62,18 @@ ...@@ -62,14 +62,18 @@
package ifc.script.framework; package ifc.script.framework;
import java.util.HashMap; 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.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.UnoRuntime;
import com.sun.star.uno.Any;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
import com.sun.star.lang.XComponent;
import com.sun.star.frame.XModel; import com.sun.star.frame.XModel;
import lib.MultiMethodTest; import lib.MultiMethodTest;
...@@ -80,88 +84,53 @@ import util.SOfficeFactory; ...@@ -80,88 +84,53 @@ import util.SOfficeFactory;
public class _XScriptInvocation extends MultiMethodTest { public class _XScriptInvocation extends MultiMethodTest {
public XScriptInvocation oObj = null; public XScriptInvocation oObj = null;
private XComponent oDoc = null; private XScriptStorageManager storageManager = null;
/** /**
* Retrieves object relation. * Retrieves object relation.
*/ */
public void before() throws StatusException { 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 { public void after() throws StatusException {
if (oDoc != null)
oDoc.dispose();
} }
public void _invoke() { public void _invoke() {
boolean result = true; boolean result = true;
result &= testUserInvoke(); Collection c =
result &= testUserInvokeWithContext(); (Collection) tEnv.getObjRelation("_invoke");
result &= testUserInvokeScriptInJar();
// if (oDoc != null)
// result &= testDocumentInvoke();
// result &= testInvokeExceptions(); Iterator tests;
tRes.tested("invoke()", result); if (c != null) {
} tests = c.iterator();
private boolean testUserInvoke() { while (tests.hasNext()) {
log.println("Try invoking a user level script"); result &= runInvokeTest((Parameters)tests.next());
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);
} }
else {
private boolean testUserInvokeScriptInJar() { result = false;
log.println("Try invoking a user level script in a Jar file");
return testInvoke("script://jarscript.jsuite.test", 1);
} }
private boolean testDocumentInvoke() { tRes.tested("invoke()", result);
log.println("Try invoking a user level script"); }
String name = util.utils.getFullTestURL(
ScriptingUtils.XSCRIPTCONTEXT_TEST_DOCUMENT);
int storageId = ScriptingUtils.getDefault().getScriptStorageId( private boolean runInvokeTest(Parameters testdata) {
tParam.getMSF(), name); 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 = "";
return testInvoke("script://xscriptcontext.jsuite.test", storageId); int storageId = getStorageId(location);
}
private boolean testInvoke(String logicalName, int storageId) { XModel ctx = null;
return testInvoke(logicalName, storageId, null); if (!context.equals("null"))
} ctx = loadDocument(context);
private boolean testInvoke(String logicalName, int storageId, XModel ctx) {
HashMap map = new HashMap(); HashMap map = new HashMap();
map.put("SCRIPTING_DOC_STORAGE_ID", new Integer(storageId)); map.put("SCRIPTING_DOC_STORAGE_ID", new Integer(storageId));
map.put("SCRIPTING_DOC_URI", "hahaha"); map.put("SCRIPTING_DOC_URI", "hahaha");
...@@ -177,25 +146,119 @@ public class _XScriptInvocation extends MultiMethodTest { ...@@ -177,25 +146,119 @@ public class _XScriptInvocation extends MultiMethodTest {
short[][] num = new short[1][0]; short[][] num = new short[1][0];
num[0] = new short[0]; num[0] = new short[0];
log.println(description + ": " + logicalname);
try { try {
oObj.invoke(logicalName, params, args, num, result); oObj.invoke(logicalname, params, args, num, result);
output = "success";
} }
catch (com.sun.star.lang.IllegalArgumentException iae) { catch (com.sun.star.lang.IllegalArgumentException iae) {
log.println("Couldn't invoke script:" + iae); log.println("Couldn't invoke script:" + iae);
return false; output = "com.sun.star.lang.IllegalArgumentException";
} }
catch (com.sun.star.script.CannotConvertException cce) { catch (com.sun.star.script.CannotConvertException cce) {
log.println("Couldn't invoke script:" + cce); log.println("Couldn't invoke script:" + cce);
return false; output = "com.sun.star.script.CannotConvertException";
} }
catch (com.sun.star.reflection.InvocationTargetException ite) { catch (com.sun.star.reflection.InvocationTargetException ite) {
log.println("Couldn't invoke script:" + ite); log.println("Couldn't invoke script:" + ite);
return false; output = "com.sun.star.reflection.InvocationTargetException";
} }
catch (com.sun.star.uno.RuntimeException re) { catch (com.sun.star.uno.RuntimeException re) {
log.println("Couldn't invoke script:" + re); log.println("Couldn't invoke script:" + re);
return false; output = "com.sun.star.uno.RuntimeException";
} }
if (ctx != null)
ctx.dispose();
log.println("expected: " + expected + ", output: " + output);
if (output.equals(expected))
return true; 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 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 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: _XScriptNameResolver.java,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -63,12 +63,17 @@ package ifc.script.framework; ...@@ -63,12 +63,17 @@ package ifc.script.framework;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Collection;
import drafts.com.sun.star.script.framework.XScriptNameResolver; 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.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.UnoRuntime;
import com.sun.star.uno.Any;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
import lib.MultiMethodTest; import lib.MultiMethodTest;
...@@ -78,6 +83,7 @@ import lib.Parameters; ...@@ -78,6 +83,7 @@ import lib.Parameters;
public class _XScriptNameResolver extends MultiMethodTest { public class _XScriptNameResolver extends MultiMethodTest {
public XScriptNameResolver oObj = null; public XScriptNameResolver oObj = null;
private XScriptStorageManager storageManager = null;
/** /**
* Retrieves object relation. * Retrieves object relation.
...@@ -88,36 +94,36 @@ public class _XScriptNameResolver extends MultiMethodTest { ...@@ -88,36 +94,36 @@ public class _XScriptNameResolver extends MultiMethodTest {
public void _resolve() { public void _resolve() {
boolean result = true; boolean result = true;
result &= testValidURIs(); Collection c =
result &= testInvalidURIs(); (Collection) tEnv.getObjRelation("_resolve");
result &= testNonExistentURIs();
tRes.tested("resolve()", result); Iterator tests;
}
private boolean testValidURIs() {
boolean result = true;
log.println("Try to resolve a valid document script URI");
String name = util.utils.getFullTestURL( if (c != null) {
ScriptingUtils.SCRIPT_IN_CLASSFILE_DOC_NAME); tests = c.iterator();
int storageId = ScriptingUtils.getDefault().getScriptStorageId( while (tests.hasNext()) {
tParam.getMSF(), name); 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"); private boolean runResolveTest(Parameters data) {
result &= testValidURI(ScriptingUtils.USER_LOGICAL_NAME, 1); 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"); int storageId = getStorageId(location);
result &= testValidURI(ScriptingUtils.SHARE_LOGICAL_NAME, 0);
return result; log.println(description + ": " + logicalname);
}
private boolean testValidURI(String logicalName, int storageId) {
HashMap map = new HashMap(); HashMap map = new HashMap();
map.put("SCRIPTING_DOC_STORAGE_ID", new Integer(storageId)); map.put("SCRIPTING_DOC_STORAGE_ID", new Integer(storageId));
map.put("SCRIPTING_DOC_URI", "hahaha"); map.put("SCRIPTING_DOC_URI", "hahaha");
...@@ -126,105 +132,89 @@ public class _XScriptNameResolver extends MultiMethodTest { ...@@ -126,105 +132,89 @@ public class _XScriptNameResolver extends MultiMethodTest {
Object[] args = new Object[] {params}; Object[] args = new Object[] {params};
try { try {
XInterface ifc = (XInterface) XInterface ifc = (XInterface) oObj.resolve(logicalname, args);
oObj.resolve(logicalName, args);
Integer resolvedId = (Integer)
params.getPropertyValue("SCRIPTING_RESOLVED_STORAGE_ID");
if (resolvedId == null) { if (ifc == null)
log.println("SCRIPTING_RESOLVED_STORAGE_ID not in return args"); output = "null";
return false; else if (UnoRuntime.queryInterface(XScriptInfo.class, ifc) == null)
} output = "null";
else
if (resolvedId.intValue() != storageId) { output = "XScriptInfo.class";
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) { catch (com.sun.star.lang.IllegalArgumentException iae) {
log.println("Couldn't resolve URI:" + iae); log.println("caught IllegalArgumentException: " + iae);
return false; output = "com.sun.star.lang.IllegalArgumentException";
} }
catch (com.sun.star.script.CannotConvertException cce) { catch (com.sun.star.script.CannotConvertException cce) {
log.println("Couldn't resolve URI:" + cce); log.println("caught CannotConvertException: " + cce);
return false; output = "com.sun.star.script.CannotConvertException";
} }
catch (com.sun.star.uno.RuntimeException re) { catch (com.sun.star.uno.RuntimeException re) {
log.println("Couldn't resolve URI:" + re); log.println("caught RuntimeException: " + re);
return false; output = "com.sun.star.uno.RuntimeException";
} }
log.println("expected: " + expected + ", output: " + output);
if (output.equals(expected))
return true; return true;
else
return false;
} }
private boolean testInvalidURIs() { private int getStorageId(String location) {
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); if (location.equals("share"))
Object[] args = new Object[] {params}; return 0;
XInterface ifc = (XInterface) if (location.equals("user"))
oObj.resolve("scrpit://HighlightText.showForm", args); return 1;
log.println("Should not have resolved invalid URI");
return false; XSimpleFileAccess access = null;
} String uri = util.utils.getFullTestURL(location);
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() { if (storageManager == null) {
log.println("Try a valid but non-existent URI");
try { try {
HashMap map = new HashMap(); XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(
map.put("SCRIPTING_DOC_STORAGE_ID", new Integer(0)); XPropertySet.class, tParam.getMSF());
map.put("SCRIPTING_DOC_URI", "hahaha");
Parameters params = new Parameters(map); XComponentContext xContext = (XComponentContext)
Object[] args = new Object[] {params}; UnoRuntime.queryInterface(XComponentContext.class,
xProp.getPropertyValue("DefaultContext"));
XInterface ifc = (XInterface) XInterface ifc = (XInterface)
oObj.resolve("script://Non.Existent", args); xContext.getValueByName("/singletons/drafts.com.sun.star." +
"script.framework.storage.theScriptStorageManager");
if (ifc != null && storageManager = (XScriptStorageManager)
UnoRuntime.queryInterface(XScriptInfo.class, ifc) != null) UnoRuntime.queryInterface(XScriptStorageManager.class, ifc);
{
log.println("Should not have resolved non-existent URI");
return false;
} }
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); access = getXSimpleFileAccess();
return false; if (access == null)
return -1;
int id = storageManager.createScriptStorageWithURI(access, uri);
return id;
} }
catch (com.sun.star.uno.RuntimeException re) {
log.println("Got wrong exception:" + re); private XSimpleFileAccess getXSimpleFileAccess() {
return false; XSimpleFileAccess access = null;
try {
Object fa = tParam.getMSF().createInstance(
"com.sun.star.ucb.SimpleFileAccess");
access = (XSimpleFileAccess)
UnoRuntime.queryInterface(XSimpleFileAccess.class, fa);
} }
return true; catch (com.sun.star.uno.Exception e) {
return null;
}
return access;
} }
} }
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: _XScriptStorageManager.java,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -64,6 +64,9 @@ package ifc.script.framework.storage; ...@@ -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.XScriptStorageManager;
import drafts.com.sun.star.script.framework.storage.XScriptInfoAccess; 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.uno.UnoRuntime;
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
...@@ -73,8 +76,7 @@ import com.sun.star.uno.Exception; ...@@ -73,8 +76,7 @@ import com.sun.star.uno.Exception;
import java.io.PrintWriter; import java.io.PrintWriter;
import lib.MultiMethodTest; import lib.MultiMethodTest;
import lib.StatusException; import lib.StatusException;
import lib.Parameters;
import ifc.script.framework.ScriptingUtils;
public class _XScriptStorageManager extends MultiMethodTest { public class _XScriptStorageManager extends MultiMethodTest {
...@@ -89,55 +91,91 @@ public class _XScriptStorageManager extends MultiMethodTest { ...@@ -89,55 +91,91 @@ public class _XScriptStorageManager extends MultiMethodTest {
public void _createScriptStorage() { public void _createScriptStorage() {
boolean result = true; boolean result = true;
XSimpleFileAccess access = Collection c =
ScriptingUtils.getDefault().getXSimpleFileAccess(tParam.getMSF()); (Collection) tEnv.getObjRelation("_createScriptStorage");
if (c == null) {
tRes.tested("createScriptStorage()", 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"));
XSimpleFileAccess access = getXSimpleFileAccess();
if (access == null) { if (access == null) {
result = false; output = "Couldn't create XSimpleFileAccess";
} }
else { else {
try { try {
int id = oObj.createScriptStorage(access); int id = oObj.createScriptStorage(access);
output = "success";
} }
catch (com.sun.star.uno.RuntimeException re) { catch (com.sun.star.uno.RuntimeException re) {
log.println("Exception from createScriptStorage: " + re); log.println("Exception from createScriptStorage: " + re);
result = false; output = "com.sun.star.uno.RuntimeException";
} }
} }
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
tRes.tested("createScriptStorage()", result); tRes.tested("createScriptStorage()", result);
} }
public void _createScriptStorageWithURI() { public void _createScriptStorageWithURI() {
boolean result = true; boolean result = true;
XSimpleFileAccess access = Collection c =
ScriptingUtils.getDefault().getXSimpleFileAccess(tParam.getMSF()); (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) { if (c == null) {
log.println("Couldn't get XScriptInfoAccess:");
tRes.tested("createScriptStorageWithURI()", false); tRes.tested("createScriptStorageWithURI()", false);
return;
} }
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"));
String uri = util.utils.getFullTestURL(location);
XSimpleFileAccess access = getXSimpleFileAccess();
try { try {
String[] names = info.getScriptLogicalNames(); 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 (names == null || names.length == 0) { if (info == null)
log.println("No logical names found"); output = "null";
result = false; else
output = "XScriptInfoAccess.class";
}
} }
catch (com.sun.star.uno.RuntimeException re) {
log.println("Caught RuntimeException: " + re);
output = "com.sun.star.uno.RuntimeException";
} }
catch (com.sun.star.lang.IllegalArgumentException iae) { log.println("expected: " + expected + ", output: " + output);
log.println("Couldn't get logical names:" + iae.getMessage()); result &= output.equals(expected);
result = false;
} }
tRes.tested("createScriptStorageWithURI()", result); tRes.tested("createScriptStorageWithURI()", result);
...@@ -146,95 +184,117 @@ public class _XScriptStorageManager extends MultiMethodTest { ...@@ -146,95 +184,117 @@ public class _XScriptStorageManager extends MultiMethodTest {
public void _getScriptStorage() { public void _getScriptStorage() {
boolean result = true; boolean result = true;
log.println("Try getScriptStorage for share"); Collection c =
try { (Collection) tEnv.getObjRelation("_getScriptStorage");
XInterface ifc = (XInterface)oObj.getScriptStorage(0);
if (ifc == null) { if (c == null) {
log.println("getScriptStorage returned null"); tRes.tested("getScriptStorage()", false);
result = false; return;
} }
else {
XScriptInfoAccess info = (XScriptInfoAccess)
UnoRuntime.queryInterface(XScriptInfoAccess.class, ifc);
if (info == null) { Iterator tests = c.iterator();
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"); while (tests.hasNext()) {
try { Parameters testdata = (Parameters)tests.next();
XInterface ifc = (XInterface)oObj.getScriptStorage(1); String expected = testdata.get("expected");
if (ifc == null) { String location = testdata.get("location");
log.println("getScriptStorage returned null"); String output = "";
result = false;
} log.println(testdata.get("description"));
else {
XScriptInfoAccess info = (XScriptInfoAccess)
UnoRuntime.queryInterface(XScriptInfoAccess.class, ifc);
if (info == null) {
log.println("Couldn't get XScriptInfoAccess from storage");
result = false;
}
try { try {
String[] names = info.getScriptLogicalNames(); int storageid = getStorageId(location);
if (names == null) { XInterface ifc = (XInterface)oObj.getScriptStorage(storageid);
log.println("No logical names found");
result = false; if (ifc == null)
} output = "null";
} else {
catch (com.sun.star.lang.IllegalArgumentException iae) { Object info = UnoRuntime.queryInterface(
log.println("Error get logical names:" + iae.getMessage()); XScriptInfoAccess.class, ifc);
result = false;
} if (info == null)
output = "null";
else
output = "XScriptInfoAccess.class";
} }
} }
catch (com.sun.star.uno.RuntimeException re) { catch (com.sun.star.uno.RuntimeException re) {
log.println("Caught unexpected RuntimeException: " + re); log.println("Caught RuntimeException: " + re);
result = false; output = "com.sun.star.uno.RuntimeException";
}
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
} }
tRes.tested("getScriptStorage()", result); tRes.tested("getScriptStorage()", result);
} }
public void _refreshScriptStorage() { public void _refreshScriptStorage() {
boolean result = true; boolean result = true;
log.println("Try to refresh a URI for non-existent script storage"); Collection c =
(Collection) tEnv.getObjRelation("_refreshScriptStorage");
if (c == null) {
tRes.tested("refreshScriptStorage()", false);
return;
}
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 { try {
oObj.refreshScriptStorage("file:///does/not/exist"); String uri = util.utils.getFullTestURL(location);
result = false; oObj.refreshScriptStorage(uri);
output = "success";
} }
catch (com.sun.star.uno.RuntimeException re) { 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"); private int getStorageId(String location) {
try {
XSimpleFileAccess access =
ScriptingUtils.getDefault().getXSimpleFileAccess(
tParam.getMSF());
String name = util.utils.getFullTestURL( if (location.equals("share"))
ScriptingUtils.SCRIPT_IN_CLASSFILE_DOC_NAME); return 0;
int id = oObj.createScriptStorageWithURI(access, name); if (location.equals("user"))
return 1;
oObj.refreshScriptStorage(name); String uri = util.utils.getFullTestURL(location);
}
catch (com.sun.star.uno.RuntimeException re) { XSimpleFileAccess access = getXSimpleFileAccess();
log.println("Caught unexpected RuntimeException: " + re); if (access == null)
result = false; return -1;
return oObj.createScriptStorageWithURI(access, uri);
} }
tRes.tested("refreshScriptStorage()", result); 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 access;
} }
} }
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: _XScriptStorageRefresh.java,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -63,6 +63,9 @@ package ifc.script.framework.storage; ...@@ -63,6 +63,9 @@ package ifc.script.framework.storage;
import drafts.com.sun.star.script.framework.storage.XScriptStorageRefresh; 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.uno.UnoRuntime;
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
...@@ -73,6 +76,7 @@ import com.sun.star.beans.XPropertySet; ...@@ -73,6 +76,7 @@ import com.sun.star.beans.XPropertySet;
import java.io.PrintWriter; import java.io.PrintWriter;
import lib.MultiMethodTest; import lib.MultiMethodTest;
import lib.StatusException; import lib.StatusException;
import lib.Parameters;
public class _XScriptStorageRefresh extends MultiMethodTest { public class _XScriptStorageRefresh extends MultiMethodTest {
...@@ -85,8 +89,36 @@ public class _XScriptStorageRefresh extends MultiMethodTest { ...@@ -85,8 +89,36 @@ public class _XScriptStorageRefresh extends MultiMethodTest {
} }
public void _refresh() { public void _refresh() {
log.println("In _XScriptStorageRefresh.getScriptLogicalNames()" ); 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(); oObj.refresh();
tRes.tested("refresh()", true); 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